Ajax call returning 0

When defining an Ajax handler, you should consider defining both for logged in and non logged in users. You can do so by using: add_action(‘wp_ajax_my_handler’, ‘callback_function’); add_action(‘wp_ajax_nopriv_my_handler’, ‘callback_function’); Now, as for your question. We can turn this code into a REST endpoint, if you are interested, which is faster and easier to set up. Let’s … Read more

I want to add custom add to cart link [closed]

Your problem is that get_page_by_path() returns a WP_Post object, not a WC_Product object. You need a WC_Product object, because that’s the object that contains the product_type property. You can get a WC_Product from a WP_Post via the wc_get_product() function: $post_obj = get_page_by_path( $slug, OBJECT, ‘product’ ); // this code help me to get product detials … Read more

Function to capture a value and store it in a variable

I had a similar task with Contact Form 7, my approach was to add a hidden field to the form in CF7 and then write some jQuery to assign the value to the hidden field when the page was ready. <script> jQuery(document).Ready(function(){ document.getElementById(‘hiddeninputID’).value = document.getElementById(‘cphone’).value; }); </script> Using the above script is the simplest way … Read more

WP Cron job timeout issues

In my opinion function that works 10min is not a best idea. Can You maybe refactor Your function or simply try to build batch processing? My favorite article about that: https://pippinsplugins.com/batch-processing-for-big-data/

How to use thumbnail size of image if I’m only using src to get image

Since you are using get_sub_field() i assume you are inside a have_rows() (a repeater), in theory it should work like this: $image = get_sub_field(‘image’); <img src=”https://wordpress.stackexchange.com/questions/278286/<?php echo $image[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/278286/<?php echo $image[“alt’] ?>” /> and this is what you can get: $image[‘url’] //this is the full image echo $image[‘sizes’][‘medium’]; //medium image echo $image[‘sizes’][‘thumbnail’]; //thumbnail image … Read more

Change title only in dynamic page

Just to make sure, does the title tag in your <head> area (presumably in header.php) look like this? <title><?php wp_title(); ?></title> It has to be like that for Yoast to work with it, and be able to override titles. Anyway if you add this to your single.php (or at least before get_header() is run for … Read more