Merge two queries and remove duplicate

Why not do something like this? $fav_author_list = get_user_option( ‘favorite-authors’, fav_authors_get_user_id() ); $fav_category_list = get_user_option( ‘favorite-categories’, fav_categories_get_user_id() ); if(!empty($fav_author_list) && !empty($fav_category_list)) { $rm_args = array( ‘posts_per_page’ => -1, ‘author__in’=> $fav_author_list, ‘category__in’=> $fav_category_list, ‘post_type’ => ‘post’ ); } elseif(!empty($fav_author_list) && empty($fav_category_list)) { $rm_args = array( ‘posts_per_page’ => -1, ‘author__in’=> $fav_author_list, ‘post_type’ => ‘post’ ); } elseif(empty($fav_author_list) … Read more

Numbering author posts in posts query

You could have an authors totals array and on each iteration you would increment that author’s key: <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <?php $author_count = isset( $authors_totals[ get_the_author_meta(‘ID’) ] ) ? int_val( $authors_totals[ get_the_author_meta(‘ID’) ] ) + 1 : 1; ?> Date: <?php the_date(‘d/m/Y’); ?> Title: <?php the_title(); … Read more

How to delete all posts with dead image urls?

I’m only going to cover this in the broadest terms because I don’t know the details of how the linked images appear in your site, but assuming each post contains one hotlinked image: You need to write a script that loops through all your posts and parses the post content for a non-local URL. It … Read more

Category_in return empty

You can achieve that using the tax_query, see the example in the code below: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘taxonomy’ => ‘the_taxonomy_slug’, //the slug of the taxonomy you want to get ‘field’ => ‘term_id’, ‘terms’ => $categories ) ); See reference in the Codex

Filter on the day of the week from timestamp

This answer may help someone who really wants to customize their filters. With PhpStorm and breakpoints I could walk through how the meta_query is constructed before posts are fetched. There are no hook points in the flow that let developers accomplish this; I’ve used a SQL-injection trick to achieve the filter. // Do advanced SQL … Read more

Multiple Meta key in search

You will need to switch between using query_posts (not recommended), to using WP_Query. Using WP Query is similar to query_posts, you will pass an array of arguments, and include the meta_query args. Something like: $args = array( ‘posts_per_page’ => 1, ‘no_found_rows’ => true, ‘post_type’ => ‘rrf-result’, ‘rrf_result_year’ => wp_unslash( ( string ) $_POST[‘result_year’] ), ‘meta_query’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)