How can I filter a query by post id?

So you want the values 108,78,90 corresponding to the meta key ‘areas’ for the post with ID 94? First retrieve those IDs: $the_post_id = 94; $area_ids = get_post_meta( $the_post_id, ‘areas’, false ); //Make sure they’re all positive integers $area_ids = array_map( ‘absint’, $area_ids ); if( $area_ids ){ //We have IDs, retrieve posts $areas = get_posts( … Read more

How add class the_content();?

You don’t. You’ll need to put an element around it: <?php if ( $content_source == ‘excerpt’ ) { ?> <div class=”excerpt”> <?php the_excerpt(); ?> </div> <?php } else { ?> <div class=”content”> <?php the_content(); ?> </div> <?php } ?>

how to show only catergory titles on a page in wordpress

You will need to combine get_categories() and wp_query First you should get all categories and loop through each one of them. Inside the loop you need a wp_query to get the title and the image of the latest post per category. At last you should reset the post data. Place the code below inside your … Read more

Wp-theme Development

Please check how the Loop works, followed by the correct way to instantiate a new Query. Try this: <?php // The correct way to create a new Query $newquery = new WP_Query( array( ‘category_name’ => ‘notice’, ‘posts_per_page’ => 1 )); // Check if query found posts, then start the Loop if($newquery->have_posts) : while ($newquery->have_posts() ) … Read more