Set Cache-Control header for 301 redirects

You first problem is that $status is not coming from anywhere. In a filter you need to accept arguments in your callback function. If the number of arguments you’re accepting is greater than 1 then you also need to specify that number as the 4th argument to add_filter(). You also need to return that value … Read more

How to include seperate PHP file to class in callback function

Your problem is with the path you’re using to include the file. plugin_dir_path() just gets the directory of the given file/directory with a trailing slash. So if your code is here: plugin/admin/views/key-analyzer-groups.php Then dirname( __FILE__ ) will return plugin/admin/views So plugin_dir_path( dirname( __FILE__ ) ) will return plugin/admin/ Which means that you are trying to … Read more

Add user ID to woocommerce customer dashboard

WooCommerce doesn’t provide any such hook to display User ID on the dashbaord. But you can add it by overwriting dashboard template into your theme file. You can view in brief of how to overwrite templates from below WooCommerce reference link. https://docs.woocommerce.com/document/template-structure/ You need to copy template dashboard.php file from WooCommerce plugin template to woocommerce/myaccount/ … Read more

Getting content from a referenced post

Function get_the_content doesn’t take post_ID as param. It has 2 params: $more_link_text – (string) (optional) Content for when there is more text. $stripteaser – (boolean) (optional) Strip teaser content before the more text. So you can’t use it as in your code get_the_content( $p->ID ); – this will get content of current post and use … Read more

Email address not displaying where I expect it to

This is wrong: $emailaddress = the_author_meta(‘user_email’,$author_id); the_author_meta() will output the value as soon as it’s run, which is above everything else. If you want to put the value into a variable to echo later you should use get_the_author_meta(): $emailaddress = get_the_author_meta(‘user_email’,$author_id); The convention in WordPress is for functions beginning with get_ to return the value, … Read more

Changing the_posts_navigation() html output

This function use the get_the_posts_navigation() to change the text Older posts and Newer posts you can pass array with the args. See this example with the default values: the_posts_navigation( array( ‘prev_text’ => __(‘Older posts’, ‘theme_textdomain’), ‘next_text’ => __(‘Newer posts’, ‘theme_textdomain’), ‘screen_reader_text’ => __(‘Posts navigation’, ‘theme_textdomain’) ) );