How to pass a PHP $_GET variable and fetch/output it?

get_query_var() only works with the Core WP_Query object: Retrieve public query variable in the WP_Query class of the global $wp_query object. https://codex.wordpress.org/Function_Reference/get_query_var Your mistake is a simple PHP one: The key is foo, not bar. $foo = $_GET[‘foo’]; echo $foo; But please do not echo user supplied data to the page without sanitizing it.

Define PHP variable from a seperate API if statement

Hi I’m the author of Multi Rating Pro. The simplest way to do this is to put this logic within the rating-result.php template file. You can call the API function passing in your own result_type and then check this in the template. if ( class_exists( ‘MRP_Multi_Rating_API’ ) ) { MRP_Multi_Rating_API::display_rating_result( array( ‘rating_item_ids’ => 1, ‘show_count’ … Read more

Assign custom parameter to each post in query

It’s a neat idea! The way I would tackle the problem is to create an associative array of post IDs mapped to their individual weights. Since weights are subjective – that is, the represent the value of other posts’ relationships with the post currently being displayed – it doesn’t make much sense to store these … Read more

Add a variable in a post

One option would be to set up a shortcode. You can add this either in your theme’s functions.php, or as a plugin: add_shortcode(‘varnumber’, ‘my_var_number’); function my_var_number($atts, $content = null) { return ‘Put whatever number you want here instead of this text’; } Wherever you want the number to appear, use the shortcode [varnumber] in the … Read more

How to search variable product by its variation id in woocommerce admin product search box?

Finally I have implement the above functionality by modifying the filter “posts_search”. By using bellow code you can search variable products by their variations id in woocommerce admin product search area. add_filter( ‘posts_search’, ‘product_search’ ); function product_search( $where ) { global $pagenow, $wpdb, $wp; if ( ‘edit.php’ != $pagenow || ! is_search() || ! isset( … Read more