how to show content of latest blog post with read more link?
Use get_posts() and set ‘numberposts’ to 1. The first and only entry will contain your latest blog post as a post object.
Use get_posts() and set ‘numberposts’ to 1. The first and only entry will contain your latest blog post as a post object.
Your best bet is to use custom fields for the YouTube video URL and then use get_post_meta(); to pull out the URL, then in your template files (index.php, single.php) set up the embed code on each template.
You need to reset the post data after your get_posts loop since your calling setup_postdata. It would be better to remove the setup_postdata all together. global $post; $recent_posts = get_posts( $yourargshere ); foreach($recent_posts as $post) : $return = ‘<h4 class=”recent-post-title c0″>’ . $post->post_title . ‘</h4>’; $return .= ‘<p class=”recent-content c0″>’ . apply_filters( ‘the_excerpt’, $post->post_excerpt ) … Read more
Add this to your functions.php file: function new_excerpt_more( $more ) { return ‘Read More’; } add_filter(‘excerpt_more’, ‘new_excerpt_more’);
Modify the callback and check the post category: function excerpt_read_more_link( $output ) { global $post; if ( in_category( ‘news’, $post ) ) return $output . ‘<a href=”‘. get_permalink( $post->ID ) . ‘”>more</a>’; return $output; } And you should prefix the function name. In its current form it is not safe enough.
Not sure if this is what you looking for… To display excerpt of specific page, you can use this code: <?php $post_id = 2; // substitute to your page id $my_post = get_post($post_id); echo “<p>$my_post->post_excerpt</p>”; echo ‘<a href=”‘.get_permalink( $post_id ).'”>read more</a>’; ?>
It sounds like your theme is using the_excerpt() instead of the_content() when displaying the post. If you want to display the full post you’ll need to edit your index.php file to use the_content() instead.
Not sure why this was so hard to answer, but after more research & playing around I have found the answer – for anyone else that is wondering, you just use wp_more in any of the theme_advanced_buttons indices.
You could add a link manually like: <a href=”https://wordpress.stackexchange.com/questions/88976/<?php echo get_permalink($post->ID) ?>”>Read More…</a> If you want to add the link at the end of the content you could do: return implode(‘ ‘, array_slice($words, 0, $word_limit)) . ‘<a href=”‘.get_permalink($post->ID).'”>Read More…</a>’;
In your index.php or front-page.php (if any): Find the_excerpt() Replace with the_content() I din’t check the Nexus theme. If you are unable to find the_excerpt(), then try locating any custom function within the loop: while ( have_posts() : the_post() ) and endwhile.