Stack Exchange Network

Stack Exchange network consists of 175 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
1answer
25 views

Filter to wp_list_authors

I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in ...
1
vote
1answer
19 views

Auto delete post if certain custom field data is empty

This question can be stupid but I really need a solution for it.. I am generating classified post using cron job. I have some custom filed as well with the cron job like 'source_link'. Sometimes that ...
1
vote
1answer
68 views

Dropdown menu on custom page with product to choose number of products per page

I have almost zero knowledge with Wordpress and Wocoommerce cores and api's so, please bear with me. I have showing ~140 products on custom page (e.g. not the default shop page for woocommerce) ...
0
votes
1answer
17 views

Get arguments from URL

I have example link http://mysite/login?user_id=6?reg=true how get user_id and reg values form $_GET? Or how construct link, because this is link from e-mail verification user. if i write: echo ($...
-1
votes
1answer
30 views

Disable every rss feed except home feed

I would like to disable every feed (comments, category, tags, author) as detailed here: https://wordpress.org/support/article/wordpress-feeds/ except for the "home-page feed" that you can found here: ...
0
votes
1answer
22 views

Combine multiple menus using the filter wp_nav_menu_items

Is there a way to combine multiple menus in the functions.php file using wp_nav_menu_items()? I need to hook in a second menu to the main menu. The site has two separate menus in the header. One is a ...
0
votes
1answer
32 views

Get user by meta data key and velue

I have create custom user meta, but it was array how i can call only one of them by key like I want to get only course_id = 22 list. Here this my user meta array [certifications] => Array ...
0
votes
1answer
60 views

Modifying the_posts_pagination from within functions.php instead of template files

I know that using a function like the following (in functions.php) allows me to customize pagination options: function custom_theme_pagination(){ global $wp_query; echo paginate_links(); } ....
0
votes
1answer
25 views

Trying to publish a little bit of Javascript on the homepage AND at the bottom

<script type="text/javascript"> function toggleDiv() { var triggeredDiv = document.querySelector('.triggeredDiv'); if (document.getElementById('myonoffswitch').checked) { ...
0
votes
1answer
84 views

Woocommerce singe product custom gallery output works just on the first slide

I copied the "product-image.php" to my theme folder in order to change the HTML output a bit, so instead of using wc_get_gallery_image_html I created my function and changed the output there. Here's ...
0
votes
1answer
44 views

Contact Form 7 If Condition

I have used the following code to successfully redirect a form to an URL after submission using contact form 7. <add_action( 'wp_footer', 'redirect_cf7' ); function redirect_cf7() { ?> <...
0
votes
1answer
32 views

Getting the post terms 'wp_get_post_terms' per post when within the functions.php file

I have used a form with an Ajax action to pull post information through on submit. It works a charm. However, I have used categories to separate the work into categories. One of which is the brand. ...
0
votes
1answer
38 views

Access to “My Site” is missing from the admin bar

You know there´s a direct access to every wordpress site right on the left side of the admin bar (or tool bar) once you get access to the wp dashboard which is intended to connect your website backend ...
0
votes
0answers
11 views

Logo custom width not implementing

add_theme_support( 'custom-logo', array( 'height' => auto, 'width' => 200, 'flex-width' => true, 'flex-height' => true, ) ); and function ...
0
votes
1answer
33 views

Check if post visited first time

How to check if post visited first time? If post already never visited by nobody.
0
votes
1answer
35 views

Enqueing External JS on the remote server JS

wp_register_script( 'custom-js', 'https://s3.amazonaws.com/codexo/custom.js', array( 'jquery' ), '1.1', true ); wp_enqueue_script( 'custom-js' ); Above is the function through which I am ...
1
vote
1answer
95 views

Use of undefined constant bloginfo

I am a webmaster of a site which was made with WordPress. I don't know PHP. I changed PHP version from 5.6 to 7.2. Since this change, I have an error on my site : Warning: Use of undefined constant ...
0
votes
1answer
73 views

Setting custom canonical urls

I have a page that requests and displays information from a database. All is fine but I'm having some trouble setting custom canonical URLs for this single page only and its URLs (with parameters ...
0
votes
1answer
11 views

Function for Sticky Post on Categories causes issues with 404 behavior

I want to how sticky posts on category pages and I am using a code on my function.php file in order to manage it. The sticky posts are being shown on the category pages, everything is OK. But with ...
0
votes
1answer
33 views

How to redirect (301) trashed post to it's parent taxonomy TERM ARCHIVE instead of 404 page

I have a taxonomy called "Sports", that includes terms: Football, Rugby, Tennis... What I want to achieve is when (for instance) a post that has the term football is trashed and a visitor try access ...
0
votes
1answer
32 views

providing access to post_id or post inside functions.php

I'm trying to add metaboxes to the bottom of any post which is created from a specific post template. ie I don't want metaboxes on all my posts, just certain posts. At the point when I decided to ...
0
votes
1answer
22 views

add_filter function concatenate string and locate_template function

I am trying to inject a small php component to the end of my main site navigation. I have written this filter: add_filter('wp_nav_menu_items', 'add_css_switcher', 10, 2); function add_css_switcher(...
0
votes
1answer
37 views

Strip div From Excerpt

I have the_excerpt() in a specific page, I need to strip a div and keep the text, but only in the excerpt of that page. I believe I need to create a function with custom excerpt, but I don't how to ...
0
votes
1answer
48 views

add code in functions.php will slow down the Execution speed?

I put these code in functions.php to custom what I need. before I add these code,the back_end`s ttfb is 746ms. after adding,the ttfb is 3.6s !!! speed becomes slow obviously! Is there any way to ...
0
votes
0answers
54 views

How to offset main query without affecting other queries and backend

I'm trying to offset my main blog query by 3 posts whilst trying to get the pagination to function correctly. I've been following the codex reference here but I'm struggling to get it working as I ...
0
votes
1answer
14 views

Defined function isn't showed on page

I've defined a function in function.php and then I tried to call it but it's not visible when I call it. This is the function function social_sharing_buttons($content) { global $post; if(!...
0
votes
2answers
100 views

Woocommerce image sizes missing from Appearance › Customize but not declared by theme

I would like to resize the 100px x 100px store thumbnail images. The sizes are supposed to be set under Appearance › Customize › WooCommerce › Product Images These size settings are missing. After ...
1
vote
1answer
589 views

how to fix Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP)

Warning: Use of undefined constant _ - assumed '_' (this will throw an Error in a future version of PHP) in D:\xampp\htdocs\keuangan_rs\aksi_konten.php on line 52 elseif($aksi=="edit" AND $_POST['...
0
votes
1answer
67 views

Personalize checkout text

I would like to hide some of the text in the checkout page: billing details, Order notes (optional) and product/total row in "your order" section. I am able to remove the input fields, but I cant ...
0
votes
1answer
154 views

Woocommerce textarea format ignored

I used the code posted by ClemC in Woocommerce add extra field to variation product with a textarea instead of a text_input. I succeeded to show my textarea under wooocommerce-default "variation ...
0
votes
1answer
152 views

ACF Date Form in Custom Admin Field

I have this function code, that brings in a ACF date picker data, and adds it to the columns view. It;s raw format is YYYYMMDD My next step is to change the format of the date to, Day Month Year so ...
0
votes
1answer
60 views

Where do I implement this display of User Meta Data, and how to put it in a table?

So I have the code below that should pull the user metadata of the currently logged-in user. <?php $current_user = wp_get_current_user(); echo 'Username: ' . $current_user->user_login . '<...
0
votes
1answer
67 views

Enable right click on WordPress site

I can not right click on my site and I don't know why! Is there any function to enable right click on the site?
0
votes
1answer
185 views

How to auto-generate random numbers in username?

I have a public-viewed community site. I am able to insert First & Last Name fields in WooCommerce Registration form, and auto-generate username based on the combination of First+Last Name. But ...
1
vote
1answer
156 views

How do I create page navigation linking to each H2 within the page? [closed]

I require each page on a WordPress site that I'm developing to have page-level navigation linking to each H2 on the page. How do I best automate this?
0
votes
1answer
39 views

get_current_site() is undefined

I get the error Fatal error: Uncaught Error: Call to undefined function get_current_site() in XXXXXXXX Why is this happening? Do I need to load something before I can use that function? Is my ...
0
votes
1answer
23 views

How to display different blocks for mobile and desktops

I want to display a fixed banner from the bottom left of the screen. But at the same time, the banner is different for desktops and mobile devices. Please tell me. How can I determine the user's ...
0
votes
0answers
16 views

Last Page or First Page Pagination

How can I make a first page and last page link? $pagination = paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?...
2
votes
1answer
82 views

WP showing “warning: call_user_func_array()”, What to do?

I am currently working on designing my blog and am almost done but when I updated to 5.1 WordPress version in XAMPP, it started showing up this error message: Warning: call_user_func_array() expects ...
0
votes
2answers
26 views

Prevent Wordpress Automatic Logout

I am using this function which is supposed to prevent wordpress from automatically logging me out. However, I am still being logged out every so often. function my_logged_in( $expirein ) { return ...
0
votes
1answer
44 views

add referrer to woo

we just moved from Shopify to Woo and wanted to add a custom field "referrer" to an order, to track our ads. I found this article, but somehow does not manage to make it work. maybe it is a bit ...
0
votes
1answer
114 views

Overriding an Array in a Plugin's Class/Function from functions.php

There is a plugin I have installed that loads a metabox of an array ($requirements) list of items in edit post. When I print_r the plugin's array it shows: Array ( [item1] => Array ( ...
0
votes
0answers
14 views

Edit address field on checkout page

Is there any way to display my account edit address page or fields can be displayed in the checkout field so that customer while reaches to the checkout page after login/registration can view both the ...
0
votes
0answers
22 views

Handling form actions in Wordpress

A non wordpress PHP file has this kind of code: <form class="someclass" action="page-contact.php" method="post"> But when in WordPress it doesn’t work. suppose we are here(a WordPress page or ...
0
votes
1answer
28 views

How to add custom li item to wordpress menu

I have tried to add custom li to my wordpress header menu using functions.php. Here is my code in function file. function register_header_menu() { register_nav_menu('header-menu',__( 'Header Menu' ...
1
vote
0answers
17 views

How to make custom posts types display when published for the future

I'm having a hard time accomplishing two things. I've created a custom post type for Events. I would like for the client to be able to post the event by the date. This means publishing posts that are ...
0
votes
1answer
11 views

Prevent function from triggering on current page

I created a list of posts, each post about a car model. After that, I created a post about the best car models. This post grabs each post about every car model and displays them in a snippet list ...
2
votes
1answer
36 views

How to update Wordpress and plugins at specific day and time in PHP?

We use automatic updates on our sites due to having many sites and so manual updates not being feasible in the low hosting costs. But due to Wordpress or mainly plugin updates having the possibility ...
0
votes
0answers
28 views

Is it possible to intercept all ajax requests and get the parameters and the returns?

Is there any hook that always goes through it, where I can see all the requests, and also the returns after the "action" that is executed? I need to intercept all requests, including requests from ...
0
votes
1answer
36 views

Custom user role not working as expected

I've defined a custom user role in functions.php called "Dashboard Admin" with the capabilities defined below. The site has a number of custom post types- all with capability post- and I'd basically ...