Detect featured image among the attached images

Simply add an post__not_in argument and use the get_post_thumbnail_id() function. $args = array( ‘post_type’ => ‘attachment’, ‘post_parent’ => $product_id, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘numberposts’ => -1, ‘post__not_in’ => array(get_post_thumbnail_id($product_id)) ); $attachments = get_posts($args);

wp query with dynamic taxonomies and terms?

Here is one idea for a dynamic multiple taxonomy query: // construct the tax-query: $tax_query = array( ‘relation’ => ‘AND’ ); // check if movie_genre taxonomy is to be included if( $bMovieGenre ){ $tax_query[] = array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ); } // check if actor taxonomy … Read more

Undefined property: WP_Query::$post

First of all post field of WP_Query is current post ID and not post object. But I don’t think you should use it before calling the_post() method. Normally you should do it in this way: $args = … $hometeams = new WP_Query( $args ); $teamishome = $hometeams->have_posts(); while ( $hometeams->have_posts() ) { $hometeams->the_post(); $scorehome = … Read more

Why wont this wp_query exclude certain pages?

A hardcoded array( 12, 31 ) is not the same as array($implode_pages). The earlier is equivalent to array( 0 => 12, 1 => 31 ) The latter is equivalent to array( 0 => ’12, 31′ ) $implode_pages = implode(‘, ‘,array_keys($pages, 1)); makes $implode_pages a string – which is not what you want. Not only that, … Read more

Using $paged redirects /page/2 to page 1

If anyone comes across this issue, you can add this to your functions.php code add_filter(‘redirect_canonical’,’pif_disable_redirect_canonical’); function pif_disable_redirect_canonical($redirect_url) { if (is_singular()) $redirect_url = false; return $redirect_url; } Source