WP_User_Query order by meta_key that is an array

You could save the values with the separate user meta keys: x1, …, x6, points instead of the array: achievements to simplify your WP_User_Query() usage and not having to deal with serialized arrays as user meta values. But I guess you’ve already considered this setup and wanted to avoid it 😉 A compromise would be … Read more

WordPress template_include filter not working properly

Ok i done by my own. I delete all above code and write this code. It works perfectly for me Code: function template_chooser($template){ global $wp_query; $plugindir = dirname(__FILE__); $post_type = get_query_var(‘post_type’); if( $post_type == ‘product’ ){ return $plugindir . ‘/themefiles/single-product.php’; } if (is_tax(‘prodcategories’)) { return $plugindir . ‘/themefiles/taxonomy-prodcategories.php’; } return $template; } add_filter(‘template_include’, ‘template_chooser’);

Check if a user already voted [closed]

Creating a table for such functionality in WordPress is not an efficient move. I would prefer to do this using follwoing approach. Create Custom post type for your voters info. For this you can try Generate WP post type generator. When ever user visits your site; save IP and rating in post meta using wp … Read more

WooCommerce Link to Product Category

For this purpose there is get_term_link function (documentation). <a href=”https://wordpress.stackexchange.com/questions/199226/<?php echo get_term_link( 42 ,”product_cat’) ?>”>Fine Art … etc.</a> Product category is just WP taxonomy, so there is plenty of functions to work with. In this case you have to know your product category ID (taxonomy term ID, actually). When editing category, you will find it … Read more

Initiate only latest version of a class

CMB2 has a clever way of handling the same situation. It establishes a version constant that is a high number for the first release (9999), and on each subsequent release, the version constant is decremented. The version number is used for the priority of the action that instantiates the main class. This ensures that the … Read more

How to change

You should hook with the locale filter: add_filter(‘locale’, ‘my_get_locale’); function my_get_locale($locale) { if ( is_page( 2846) ) { return “en_GB”; } return $locale; }

Add custom HTML to posts page

If you want to modify the main <header> output take a look at header.php. This file will be called before the other templates. If you want to modify the template that is used to display your latest blog posts, index.php would be the file of choice. Index.php is also the fallback template for any post … Read more