How to query ‘posts_per_page’ to display a different blog posts index template?

You can control what template loads for any type of query via the Template Filters. Here’s an example using home_template that checks if posts_per_page is equal to 1, and loads single.php in that case. function wpd_home_template( $home_template=”” ){ if( get_option( ‘posts_per_page’ ) == 1 ){ $home_template = locate_template( ‘single.php’, false ); } return $home_template; } … Read more

Slow meta query with multi meta keys

The problem here is that post meta wasn’t designed for these kinds of searches, that’s why the taxonomy tables exist, else categories and tags would be stored as post meta Post meta is optimised for fetching data when you already know the post ID Taxonomies are optimised for finding posts when you already know the … Read more

delete_user_meta Delete one value out of array

Thanks yo Howdy_McGee, Here is working code. // Remove favorite authors from current users DB function fav_author_remove_user(){ check_ajax_referer( ‘fav_authors_obj_ajax’, ‘security’ ); $remove_this_author = $_POST[‘clicked_author_id’]; if ( current_user_can( ‘edit_posts’ ) ){ $user_id = fav_authors_get_user_id(); $author_list = get_user_meta( $user_id, FAV_AUTHORS_META_KEY, true ); //print_r($author_list); $author_saved = array_search($remove_this_author, $author_list); if( FALSE !== $author_saved ){ // Remove $author_saved unset($author_list[$author_saved]); $author_arr … Read more