is_page_template showing partial results

The is_page_template() function is for checking if the current page is using a specific custom page template. That being a template selected from the Template dropdown in the Page Attributes box when editing the page. The WordPress conditional tags are not based around which template files are used. They are used to tell you what … Read more

Syntax issue on rest object’s callback

The callback has to be public: public function respondWithString() And in your register_rest_route() call, set the callback to [ $this, ‘respondWithString’ ]: register_rest_route( $this->urlBase, ‘dummy’, [ ‘methods’ => ‘GET’, ‘callback’ => [ $this, ‘respondWithString’ ], ] );

How can I hook into the wp_mail function used by BackWPup?

Looking at the source of the wp_mail() function, there’s a filter right near the top: $atts = apply_filters( ‘wp_mail’, compact( ‘to’, ‘subject’, ‘message’, ‘headers’, ‘attachments’ ) ); // Expanded for clarity. (Aside: compact() is a PHP function that creates an array from a set of arguments. In this case, it’s making an array of the … Read more

How to use AJAX to call php page with parameter

Your code should work just fine, because there’s nothing wrong with it, but… You use relative URL in it You pass loaddata.php?id1= as URL. It’s relative, so it will try to find loaddata.php file in current directory. So if you’re at the home page, then it will try to load that file from root directory. … Read more

Get posts from Custom Taxonomy

Your very first block of code is the correct way to do things. Under no circumstances should an archive template be using a custom WP_Query for querying its posts. WordPress queries the correct posts for you based on the URL, and you output them with the standard WordPress Loop: while ( have_posts() ) : the_post(); … Read more

Undefined $post in wp_query

The most reliable way to get the current post being viewed is not the global $post variable. Instead you should first check is_singular(), and then use get_queried_object() to get the post object, or get_queried_object_id() to just get the ID. if ( ! is_singular() ) { return; } $post_id = get_queried_object_id(); $args = array( ‘post_type’ => … Read more

Call WC_Product get_price()?

Regarding the filter, you tried, not working, my hunch is that it’ not working, because it’s missing (priority and) accepted arg count parameter(s). At the moment add_filter(‘woocommerce_product_get_price’, ‘test_change’); Defaults to priority 10 and 1 parameter for your callback, but you’re using two args in function test_change($value, $prop) { return 666; } Thus you’d need to … Read more