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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

How to cache results of of get_available_post_statuses() function as it is causing a slow query on a website with over 1 million posts?

The function get_available_post_statuses() is being called by WP_Posts_List_Table->prepare_items(), which is calculating posts on each load of admin. Since this is a core wordpress function and I ...
dc09's user avatar
  • 195
0 votes
1 answer
20 views

How to call a logging function from a generic utility plugin from another plguin

I want to add some logging to my plugin, and for various reason want to create my own wrapper function around error_log(). And for reusability, I'd like to stick my wrapper function in a separate ...
florismk's user avatar
0 votes
1 answer
46 views

How to get next day date of a specific day

I have created a shortcode in WordPress to show next day date of a specific day but it does not show the correct date when I am passing the parameter through the shortcode. Can anyone tell me what I ...
v morgesh's user avatar
0 votes
2 answers
82 views

Function attached to cron job not running but will run if called manually

I have a cron job set up with the following code in my functions.php file I have a CPT with a custom field that defines an expiration date for each post. All I am doing is checking if the date has ...
grzybowski1911's user avatar
0 votes
1 answer
49 views

wp_update_post breaks my function

Good evening! I'm trying to adjust the post title + some ACF fields after a user have submitted a custom post type ('booking'). The function I've created almost works! The only problem is that ...
joxyzan's user avatar
  • 13
0 votes
0 answers
34 views

How to change product title color in shop page if product has specific product tag (Woocommerce)?

How to make Woocommerce automatically change product title color for shop page if product has specific product tag (Woocommerce)? Example: if products have tag "banana" or "melon", ...
null's user avatar
  • 1
0 votes
3 answers
88 views

Modify the permalink structure for a specific category

I searched for many solutions before opening this post, but none worked correctly. This is a complicated matter because it can significantly impact the site if not done correctly. I need to have a ...
Jader's user avatar
  • 1
0 votes
0 answers
25 views

post_content return zero!

I am new to WordPress I made a function as a subscription form. when I want to check it on another function I use global $post; if (has_shortcode($post->post_content, 'up-vip')) {....} I don'...
D.JCode's user avatar
  • 201
0 votes
0 answers
20 views

If you want to implement custom field-wise search functionality in the WordPress admin area

function extend_admin_search( $query ) { // Extend search for document post type $post_type = 'document'; // Custom fields to search for $custom_fields = array( "...
Tansukh Parmar's user avatar
0 votes
1 answer
43 views

Mixed results with is_page() WordPress function, when using $this, or self

I'm converting an old plugin from PHP5 -> PHP8 and I came across this check, which caused an error when executing: Notice: Accessing static property PropertySearch::$listing_details_template_name ...
level42's user avatar
  • 113
0 votes
0 answers
94 views

How to force Cover block to use the full size image resolution

Is there anyway to force Cover block to use the full size image resolution? It changes it based on the screen dimension and some times it gets so blurry which is awful! Should I write some lines of ...
Poorya Ghorbani's user avatar
0 votes
0 answers
20 views

check difference between two timestamp in custom plugin

I have this code in my custom plugin. It's supposed to check if a timestamp is older than 24 hours $today = new DateTime(); foreach( $customers_to_activate as $customer_details ){ $time = $...
ICTDEV's user avatar
  • 123
1 vote
0 answers
48 views

WordPress PHP Redirect - which hook to use?

I have site where users sign up to a subscription. When the subscription has ended (I can query that using PHP), I want the user to be redirected to the "subscription-ended" page. My current ...
roland's user avatar
  • 21
0 votes
2 answers
33 views

Send post to remote wp site from post edit window with all data excerpt image

I have to wp site ex1.com and ex2.com, at ex1.com i have created a post and i want to send it to ex2.com with Title, content, custom fields, tags, category with a form submit button at edit window. I ...
Puneet's user avatar
  • 47
0 votes
1 answer
22 views

Adding Author Filter to CPTs

I'm trying to add an author filter to the WP Admin pages for the CPTs 'booking' and 'ticket' The code below works when using only one post type, but adding || and the second cpt stops it. I've tried ...
Blakar1988's user avatar
0 votes
0 answers
25 views

How can I display formatted content using the_content filter?

I am using the_content filter to append comment summaries to posts on a blog page. That part of my code works. I am having a problem with the display of pages where they are not formatted and ...
bigmoxy's user avatar
0 votes
0 answers
220 views

warning: trying to access array offset on value of type bool ACF field image group

I have a problem with an acf function for displaying an image by array. I can get my image to work well when I upload it to the field associated with it. On the other hand, when I don't put an image, ...
Thica's user avatar
  • 17
0 votes
0 answers
40 views

Sticky bar with filter button and product count

I use elementor and hello theme. I need to create a sticky bar with filter button and product count when you scroll product archive, similar to https://www.chanel.com/it/make-up/labbra/c/5x1x1x31/...
avenz's user avatar
  • 1
0 votes
1 answer
151 views

How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters

I wonder how to use webpack while bulding theme for WordPress the correct way. Everything is pretty easy until I have to make some unusual things. So in the most simple scenario I just have some JS ...
Mateusz's user avatar
  • 255
0 votes
1 answer
35 views

wp_logout action hook is not firing

Why the user meta value is not being changed after logout using the following code: function update_login_status_on_logout() { $user_id = get_current_user_id(); if ($user_id) { ...
rock's user avatar
  • 1
0 votes
1 answer
60 views

How to make my logged-in user-role shortcode displaying name instead of slug?

I am trying to get my frontend to show the role of a logged-in user via Shortcode. I have the Shortcode functional (see below) but it displays the slug and not the real name in the frontend. This is a ...
user235991's user avatar
0 votes
1 answer
75 views

How to capture number input from wordpress form into acf field in woocommerce

WUFP Phone fieldI am trying to capture the phone number of guests that submit a form on my woocommerce website using the advancedwoocommerce custom field for phone no custom field plugin. I noticed ...
Titus's user avatar
  • 1
0 votes
2 answers
85 views

wp_mail() return false . waiting for response please or suggestions ou recommandations?

public function send_newsletter() { global $wpdb; $recipients = $wpdb->get_results("SELECT email FROM {$wpdb->prefix}zero_newsletter_email"); $object = ...
gerard principe's user avatar
0 votes
0 answers
37 views

Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook

I am using the Breadcrumb NavXT Plugin. I have 2 links at a page, and want to add 2 more links in between on that specific page. I used the below hook, but did not get the result. add_filter('...
Rizeen's user avatar
  • 101
0 votes
1 answer
21 views

Exclude in search post and include only 3 pages

I need that when a costumer search in my page, it includes only post but I need to included 3 important pages too... It is possible. For include only posts I have this code, but now How can include 3 ...
Laurapnunez's user avatar
0 votes
0 answers
41 views

add class to woocommerce single product template gallery thumbnails if media attachment ACF field toggled (true/false)

i have the following custom field (quick_ship): i've added this in functions but not working at the moment: <?php $image = get_field('quick_ship'); $size = 'full'; // (thumbnail, medium, ...
vulgarbulgar's user avatar
0 votes
0 answers
26 views

how to call a non-AJAX function from within an AJAX function

I have added an AJAX function to my installation and confirmed that it works successfully. I have an AJAX function local_commit_button, and from inside that function I am trying to call a regular php ...
steve8094's user avatar
0 votes
1 answer
22 views

CPU Overloading due to some hooks

I have some functions restricted in some hooks. The purpose of these hooks was to have consistent author name in the DB(which is a product attribute) and also update the display name. I placed this in ...
Varun Muchanapally's user avatar
0 votes
1 answer
23 views

Printing the value of 2 functions one near the other

I have 2 functions, one is set in a custom plug in, the other in functions.php $pulizia_esc = get_the_author_meta( 'pulizia_esc', $post->post_author ); if ( ! empty( $pulizia_esc)) { $pulizia_esc = ...
Andrea Sacconi's user avatar
0 votes
0 answers
13 views

Custom User Role not working

I've created a custom user role that I want to only be able to access a CPT Job Listings Below is my code for the custom user role ( this is on a multisite network ) which I have added to my themes ...
grzybowski1911's user avatar
0 votes
0 answers
25 views

Sections dependent on checkbox the Wordpress WP_Customize_Control

I would need to create checkbox dependent sections in wordpress customization panel if possible. They should work so that when the checkbox is checked the section "eg 1" will be shown and ...
Josef Volný's user avatar
0 votes
0 answers
22 views

Help with get_categories code

I have listed the following code below, and where it is pulling the sub-title into the banner I need to change this to pull the category of the linked article instead. This is the link to the website ...
Richard Pearson's user avatar
0 votes
0 answers
20 views

WooCommerce Checkout - Validate User Role

I'm facing a challenge with WooCommerce's checkout process. I use the "B2B for WooCommerce" plugin to differentiate between regular and B2B clients. I have two product categories "...
helio's user avatar
  • 1
0 votes
0 answers
27 views

Using .net VB I ftp an image to woocommerce but it wrongly places it in a non existent URL

I place an image using a FTP upload(.net vb) in the folder https://streetgym.co.za/wp-content/uploads/ProductImage/2-807.jpg; wordpress then creates a url AT https://streetgym.co.za/wp-content/uploads/...
BASit Bulbulia's user avatar
0 votes
1 answer
358 views

Uploading images via ACF update_field function

I am trying to update image fields within a group in ACF via the update_field function I am successfully adding the images to the media gallery but I am having trouble getting them added to each ACF ...
grzybowski1911's user avatar
0 votes
0 answers
26 views

Is it possible to go to the next post in the same category?

Is there someone who can help me to change the code so the button goes to the next post in the same category? TaaaaannnnnXXXX <div class="nk-pagination nk-pagination-center"> ...
Jasper Stamm's user avatar
0 votes
0 answers
5 views

Store the query string parameter in session value and use it once user logged in

I tried to store the query parameter in session value and use it once user logged in and destory after that For example https://example.com/requesttok=https://filelink.com/file.pdf $_SESSION['...
mike's user avatar
  • 1
0 votes
0 answers
10 views

No token generate and appending to the jwt token once logged in redirect

If no token is there redirecting to pdf file and generate token appending and logged in redirecting the user to pdf
mike's user avatar
  • 1
2 votes
1 answer
38 views

Cron Register everytime if i reload admin if i pass some extra argument in wp_schedule_event function

Cron Register everytime if i reload admin if i pass some extra argument in wp_schedule_event function. Here you can check the scrrenshot I have checked the cron using the plugin WP Control. function ...
Prits's user avatar
  • 278
0 votes
0 answers
13 views

How to insert script in AMP WordPress

I'm helping a company with their WordPress website, and it is running AMP. They want to add a script, so i have tried inserting it in functions.php, header.php, and footer.php but it doesn't show on ...
Anders Jytzler's user avatar
0 votes
0 answers
7 views

Moved Apple Google express pay option

Express payment option for Google and Apple pay has moved. It use to display under 'Add Cart; button. It now appears above our options drop-down. I have disabled and re-enabled the feature but the ...
Spacejams's user avatar
0 votes
1 answer
20 views

Read page- or post-content across different builder-plugins

I am currently working on a WordPress-plugin to analyse post- and page-content. The plugin contains a php-function that read the post- and page-content across several different builder-plugins (such ...
Dennis's user avatar
  • 103
0 votes
1 answer
213 views

Unable to logout correctly after wp-login file was modified

I'm using a custom url for the login of my WordPress site. I've added this code in my functions.php file /** Hide default login */ function hide_default_login() { //Only proceed for guests if ...
ICTDEV's user avatar
  • 123
0 votes
2 answers
32 views

custom function works on page.php template but not in functions.php

I have a basic function attached to a button on the settings page of the dashboard add_action('admin_menu', 'add_streamline'); function add_streamline() { add_options_page('Streamline', '...
grzybowski1911's user avatar
0 votes
1 answer
36 views

Add custom css to specific user

I need help with something for my wordpress site. I want to add custom css to a specific user. For example, user B. but I couldn't do it. Here I tried the following css code: div [user="id"] ...
ByWorld's user avatar
0 votes
0 answers
12 views

Wordpress Theme file editor - error with sleep() php function

I'm doing some tests by modifying my .php files directly from the wordpress theme editing interface ( /wp-admin/theme-editor.php ). (to avoid lengthy deployment pipelines) However, as soon as I add ...
Vincent Rocher's user avatar
2 votes
1 answer
234 views

WordPress internal functions : why not use them?

When I was looking at the latest WP 6.3 release note, I saw that they improved performances on the _wp_array_get() function and I thought: That's a sweet function that I would like to use (I had a ...
Tim's user avatar
  • 516
0 votes
0 answers
100 views

Woocommerce change image based on a single attribute

I've been searching for a while for this one. We have an online store which will have about 1000 products. Most of them are variable products. The set up is that the rings will have different ...
Martin's user avatar
  • 1
0 votes
0 answers
18 views

get_the_category() doesn't work outsideThe Loop?

I am trying to put the following code in the functions.php, to update a custom post's meta field whenever I publish a post. function run_on_publish_post_only( $new_status, $old_status, $post ) { ...
Tian's user avatar
  • 1
0 votes
1 answer
35 views

How can we upload custom page files?

By making our own .html, .css and .js pages, how can we upload them in WordPress directory correctly? And then, how can we insert, for example, our Elementor's header (which is being used in all ...
Maria's user avatar
  • 3