Query posts by a type and another type only if post is in specific category

Untested, but I think you’d need to do two separate queries and merge them together: $args = array( ‘post_type’ => ‘featured-posts’ ); $featured_posts = get_posts($args); $args = array( ‘post_type’ => ‘review-posts’, ‘category_name’ => ‘featured-category’ ); $review_posts = get_posts($args); $result = array_merge($featured_posts->posts, $review_posts->posts); $final_query = WP_Query($result);

get_posts works but new wp_query doesn’t

You forget $query->the_post(), which makes the same as setup_postdata(). Also you are using $post->ID inside the loop but $post is not current post object in the loop. You have also syntax errors; for example you pass thumnail to wp_get_attachment_image() instead of a string “thumbnail”, and pass name as orderby argument instead of the string “name”, … Read more

show posts in different styling

Recently I have developed a theme almost identical to yours. This is how you can achieve this: Basic idea is, create two different layouts: layout-three.php and layout-two.php We will call them based on requirement. I have used an array to achieve this. Below is the sample code for the template file (assuming you will show … Read more

Sort order in get_posts [closed]

The problem here is not that the posts that are being wrongly displayed are displayed under the wrong category, it’s that they’re not actually in the right category. For example, the post “Supporting healthy eating choices” is displayed under “O” as it has the category “O”. Going to your backend and assigning the proper category … Read more

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