Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

0
votes
0answers
7 views

How to modify or override a core function (wp_star_rating)

I'm looking for the way to modify a core function, in this case the wp_star_rating() function, declared in wp-admin/includes/template.php Actually what I want is to change the $title variable, cause I ...
0
votes
1answer
6 views

Add Featured image column into wordpress admin on pages AND posts

I have created a column in my functions.php file to add in a column to see the featured image on posts. However i would like to do this for pages as well, but if i repeat the code replacing posts with ...
0
votes
0answers
6 views

How to allow only auto indentation on TinyMCE

I want that Wordpress (or TinyMCE or any plugin) could auto indent my HTML (as switching from Text to Visual does), because I have lots of old posts that I need to edit and they are kind of minified. ...
1
vote
1answer
10 views

WordPress menu link doesn't work properly

I am developing custom site. The header links work on home-page but when I go inside shop then the home-link becomes siteurl/shop how to solve this? <div id="content" class="site-content"> &...
0
votes
1answer
28 views

How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?

My website is a daily deals and offers site. I promote many online stores with affiliate links. I have created a php script to detect any merchant's link (ex- Amazon) and convert it to my affiliate ...
0
votes
0answers
12 views

Classic TinyMCE messing up only Contributor's HTML

I use a plugin that loads pre-defined HTML for my posts. I don't need the Visual editor, so I've disable it for everybody. Also, I want TinyMCE not to mess with my code. Nothing, no auto formatting ...
0
votes
1answer
17 views

Wordpress upload_mimes not working for front-end uploads of 3D files

So, after the new WP updates my form will not allow certain files to upload. I have a Gravity form with an upload field to submit 3D print files. I can get one type of file to work, but not the others....
0
votes
0answers
23 views

Cleaner 'for each' loop for registering scripts in functions.php

I'm looking for a elegant way to register a ton of scripts I have sitting in a js directory on my server without having to sit and type them all out. I found this question here but it is 3 years ...
0
votes
1answer
8 views

Automated mark posts as featured every day

Hello Wordpress Community, I want to build myself a "recipe of the day" functionality. I'm looking for a way to mark 3 Custom Post Types per day as "Featured Posts" by a plugin or Cronjob. The ...
0
votes
0answers
15 views

Bifurcate woocommerce cart plugin in two parts

[woocommerce_cart] The above shortcode renders the woocommerce cart page, which will have these looks: What if we want just to generate just Part 1 or Part 2 as shown in the figure. Is that ...
0
votes
0answers
6 views

Keep Page hierarchical order on Control Panel when I use 'remove_cap' 'edit_others_pages'

I'm admin user and just created several editor users who are 'NOT' allowed to edit other pages. Let me call them 'master editor','editor A' and 'editor B'. 'master editor' can edit top level parent ...
0
votes
0answers
7 views

Custom Customizer Image Sanitize fails to update image

I use this custom sanitizer to get the appropriate image size so that anyone using my themes can't mess up and put an 8k image in the website. The code works, but the problem I have is that once the ...
0
votes
1answer
16 views

Is it possible to use array_walk() to append terms to an array of posts?

I'm creating a masonry post grid of animals. I plan to filter the the visible posts by toggling classes. The classes would in turn would be the post's. I'm using an MVC theme and would like to get ...
0
votes
1answer
14 views

Remove Font-Awesome MaxCDN Link & Load Locally

MaxCDN is slowing down my site so I want to load font-awesome locally but I can't seem to write the correct function to remove it. function remove_unwanted_css(){ wp_dequeue_style(‘font-awesome’, ‘...
0
votes
0answers
49 views

Load CSS file conditionally

Trying to load CSS file conditionally – only for specific pages with the following: add_filter('tablepress_use_default_css', 'tablepress_css_conditional_load'); function ...
0
votes
0answers
25 views

How to have multiple the_content() tags

I am designing a wordpress blog where you click on the title of the post and the content of the post opens up from the right side of the website. I was wondering if it was possible to have multiple ...
0
votes
0answers
11 views

Webpage link got problem [closed]

When I'm using WordPress, i click on the product and it works, it direct to the product link page, but if i open as a user, the link are not working, it redirect to shop page instead of the product ...
0
votes
1answer
17 views

How best to check if a user is from China and hide content?

To speed up my website in China I thought of hiding blocked services from Chinese users and wrote this and put it in functions.php $isInChina = false; $ip = $_SERVER['REMOTE_ADDR']; // This will ...
0
votes
0answers
9 views

How to enqueue reactjs built theme to index.php to build wordpress theme

I am trying to make a wordpress theme using create-react-app package. But the problem is i have no idea how to put these files in wordpress directory to render it on index.php or how to enqueue these ...
0
votes
1answer
18 views

Add HTML before a specific div?

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox. So I got the idea to add an image with some ...
0
votes
1answer
16 views

Override filter variable not working

I'm currently trying to override a filter in a plugin. This filter has 1 variable which defines a root path to a folder where some templates are located. This root path is normally in the assets ...
1
vote
1answer
45 views

Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

I have been follow a tutorial here: https://rudrastyh.com/gutenberg/remove-default-blocks.html Where it discusses how to remove default Gutenberg blocks like so: add_filter( 'allowed_block_types', '...
0
votes
1answer
16 views

How to include any template using Shortcode fuction?

function custom_code(){ return include( get_stylesheet_directory() . '/custom-template.php'); } add_shortcode('custom_shortcode','custom_code'); As you can check above I want to include a ...
0
votes
1answer
12 views

Return category name with & Ampersand doesnt work

I have a category named: This & That However, for some strange reason my switch code doesn't pick it up. When I output $firstcat it does return This & That which makes it even more cumbersome....
0
votes
2answers
20 views

CSS change in woo commerce Place Order Text [closed]

add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text' ); function woo_custom_order_button_text() { return __( 'Your new button text here', 'woocommerce' ); } Above is the ...
0
votes
1answer
25 views

Why my wp_enqueue_script doesnt work on some page?

My wp_enqueue_script from my theme is working on home page and not on other page. This is my web : https://welgo.id. And here is not working : https://welgo.id/listing/rs-bandung-eye-center-bandung/ ...
2
votes
2answers
114 views

Influence of WordPress functions on site speed

We know, that wordpress has custom functions that create in wp-includes and etc... and its system has more includes and functions(without calling)... My question is: Is abound of wordpress functions ...
0
votes
1answer
11 views

Php function 301 redirect

I am using this code so that when the user visits the old permalink, he gets redirected to the new one. add_action( 'template_redirect', 'redirect_to_external_url' ); function ...
0
votes
1answer
23 views

Go top smooth function [closed]

I have a problem that I write the following code in the functions.php to realize the page go top. It works.but just work for the user fist visit the page and click the button for first time. I must ...
0
votes
0answers
18 views

Catch the first video,will it cause server pressure?

My mother tongue is not English. Here I use Google translation. I need to display the first video of the article on the home page. The following code is used But I have a question.Does this server ...
0
votes
0answers
14 views

Add number in increment of one to menu items

I'm trying to add sequential numbers to menu items in increments of one. So right now where I have the following: <li class="menu-item menu-item-type-taxonomy menu-item-object-category"></...
0
votes
0answers
26 views

Add hide featured image option

Hello, I wold like to add a check-box or button to have a choice between hide or display featured image in single post. i'm in wordpress 5.0.2 This is the code of my simple single.php in the theme : ...
0
votes
1answer
30 views

Can't properly set the_title add_filter to show short_URL

I am trying to show Bitly's Post short URLs for my blog posts but something seems off as when I am using this code, I see the output all over the page for menu items etc... Additionally, the URL ...
1
vote
2answers
18 views

Inserting a functions output after the content

So I am trying to add a button at the end of my blog posts, here is the code I have in the plugin so far: <?php /* Plugin Name: etc.... */ function shares_content() { ?> <div class='...
0
votes
0answers
13 views

Dynamically set front page featured image from first image in latest post's ACF gallery

My front page template is set to display the full content of the latest post using WP_Query and a custom page template. Now I want the home page featured image to dynamically change every time a new ...
0
votes
1answer
24 views

How to load a script code only in posts?

I want to load some JavaScript code only when it is posts, and not a home page or pagination! How can I do it with functions.php?
0
votes
1answer
15 views

Reference multiple style sheets, clearing styles for permalink page, custom fields for css

my wordpress theme will be styling posts on the index page based on their post-ID class -this will result in a lot of css code over longer durations of time. To keep the website lightweight as ...
0
votes
1answer
24 views

Only display table in the_content() in canonical page

please help me to display only tables on a canonical page main page https://www.printerdriverforwindows.com/hp-deskjet-ink-advantage-3700-driver <table style="height: 198px; width: autopx;"&...
1
vote
1answer
24 views

Handling Body class based on Template

Through a PHP function, I think I can handle body class, but I think WordPress would have some specific way to handle it. If Home.php then class in the body should be wbody else it should be bgody. ...
0
votes
1answer
38 views

Trigger popup in a php if/else statement

I am trying to trigger a popup within functions.php if certain conditions are met. The if else statement it self works perfectly, but I can't get the popup to open. I've tried calling a shortcode but ...
0
votes
1answer
25 views

Button click counter for login user

I am new with wordpress and trying to create button counter also saving click into database. This form is only for wordpress login users. Function.php function getcount($userID){ $...
1
vote
0answers
28 views

different id for same element visual composer [closed]

I have two same elements in visual composer page, I wanna add different custom id to this elements. <div class="posts"> // code </div> <div class="posts"> // code </div&...
0
votes
0answers
23 views

make a POST public and visible for everyone on a PRIVATE WordPress website

I have a privated my wordpress website. so you need to put the username and password to see the pages and posts of the site. I need to make a post called "Legal Notice" as a public post visible by ...
0
votes
0answers
16 views

How to block certain keywords from searching and redirect to different page on Wordpress?

I would like to block certain keywords (multiple keywords, banned keywords like fuk, sit etc.) from searching on Wordpress blog and show/redirect visitor/member (searcher) to different page. Used ...
0
votes
1answer
27 views

PHP/CSS: Shortcode won't display correctly, and only displays in the head (before content)

Trying to create a shortcode to be implemented to a popup. I'm trying to display four images in a 2x2 grid at the center of the page. The problem is that this shortcode now floats everything left and ...
0
votes
0answers
19 views

woocommerce_wp_select options for user list

Here is my code for users select option in woocommerce backend. I can not reach dynamic user list in option array. function woo_add_custom_general_fields() { echo '<div class="options_group"&...
-1
votes
0answers
18 views

How Do I Make My Comment Reply Button Made with <span> Element Work to Open Comment Reply Form Onclick [duplicate]

Please. I need your help to make it happen because I have just lost my hope to see this working. Here's the screenshot of the code he uses on his blog. (Once he clicks over reply button made with span ...
1
vote
2answers
40 views

Last updated date function

I want to show the "last updated date" on the front of the post and page. so I add the following code in the functions.php file. function wpb_last_updated_date( $content ) { $u_time = get_the_time('U'...
0
votes
1answer
35 views

Copyright info change - Corporate Plus Theme PHP [closed]

I have been trying to do this for hours now but just can't get this to work. What I am trying to do is change the copyright info in my wordpress theme which is being pulled from wp-content\themes\...
0
votes
0answers
24 views

How to modify the code to include “rel=next” and “rel=prev” tags?

I have a Wordpress site with some posts splitted in pages. I added post pagination via this code: Single.php: <?php wp_link_pages(array( 'before' => '<div class="page-links"><span ...