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
1 answer
18 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
30 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
19 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
19 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
-1 votes
0 answers
12 views

please sejession me [closed]

Problem Occurred When Importing Database! Please Make Sure The Database is Empty.
Sabjal's user avatar
  • 1
0 votes
0 answers
28 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
60 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
24 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
14 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
-1 votes
0 answers
11 views

I want students to be able to insert Mathematical notation for answer to QSM plugin question

I am creating a quiz using QSM plugin on wordpress. I have mathjax also loaded. I can i set you quiz so students can input Mathematical notation in their answers.
Raj's user avatar
  • 1
0 votes
1 answer
34 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
  • 103
0 votes
0 answers
14 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
16 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
  • 113
1 vote
0 answers
32 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
28 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
  • 37
0 votes
1 answer
17 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
23 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
86 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
  • 15
0 votes
0 answers
16 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
48 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
  • 153
0 votes
1 answer
27 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
49 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
38 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
39 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
20 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
19 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
27 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
22 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
16 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
23 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
21 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
11 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
24 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
99 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
31 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
15 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
70 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
  • 113
0 votes
2 answers
28 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
18 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
10 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
233 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
50 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
16 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

1
2 3 4 5
115