How to force update all posts after import

There are 2 ways that you could do this. The first and more difficult is to write a program, the other is to do a bulk update. Why do difficult when easy way will work equally well? and especially as this is a once-off requirement The easy way: In the admin dashboard, select the view … Read more

AJAX Implementation

First, enqueue your script correctly, in functions.php: function my_enqueue_scripts() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); Then, Authenticated users only (see https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)) (can also be in functions.php): function fetchData(){ // Not needed anymore, as you manage the case through the `add_action` method // if ( ! is_user_logged_in() ) { // return; // } // this can be … Read more

Updating User Meta with SQL Query

How can I write a bulk MySQL command to add in the value wp_capabilites=”a:1:{s:10:”subscriber”;b:1;}” into each user_id except 1, 2 and 3 ie. the newly imported users? You don’t. That is a serialized array which is a PHP construct. MySQL has no idea what to do with it. To the database, it is just an … Read more

What’s wrong with this WP query?

Turns out, WordPress joins the postmeta table several times, depending on the meta query arguments. Yes that’s correct, and it’s also the reason why I said (in my other answer) that in an orderby array, you should use the key of an array in the meta_query which contains a direct item named/keyed key (where the … Read more

tag search using WP_Query

new WP_Query(array(‘tag_slug__in’ => array(‘forrest-gump’, ‘forest-gump’, ‘questend’))); new WP_Query(‘tag=forrest+gump,forest+gump,questend’); should work too…