how to display an excerpt of the latest post on the homepage?

To show the excerpt from the latest post you can use query_posts. Example Query Posts Showing the Latest Post with the Featured Image: <?php query_posts(‘showposts=1’); ?> <?php while (have_posts()) : the_post(); ?> <h3 class=”home link”><a href=”https://wordpress.stackexchange.com/questions/1575/<?php the_permalink(); ?>”><?php the_title(); ?></a></h3> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> You will need to reset the … Read more

get post id using custom filed value

Try something like this $posts = get_posts( array( ‘numberposts’ => -1, ‘meta_key’ => ‘prime’, ‘meta_value’ => ‘yes’ ) ); $post_ids = array(); if ( $posts ) { foreach ( $posts as $post ) { // Push post’s IDs into array array_push( $post_ids, $post->ID ); } } code isn’t tested but it should work. If you … Read more

get_post_meta() retrieves meta from a specific post on pages, not the page currently viewed

There is some other query which replaces the main post ID. Might be another widget, some strange plugin code or something else If you have no control over the context, collect the post ID earlier: add_action( ‘template_redirect’, ‘collect_post_id’ ); function collect_post_id() { static $id = 0; if ( ‘template_redirect’ === current_filter() && is_singular() ) $id … Read more