Link for Most Recent Post

You’ll need to use get_posts() to get the latest post, then pass it to get_the_permalink() to get the URL to it: <?php $latest_posts = get_posts( array( ‘numberposts’ => 1 ) ); if ( ! empty( $latest_posts ) ) : $latest_post = $latest_posts[0]; if ( $latest_post->ID !== get_the_ID() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/284553/<?php echo get_the_permalink( $latest_post … Read more

Need to display same custom post type on 2 different singles templates

To display different templates for the same post type I would make 2 different links, check on which link I’m currently on and decide which template to load. Working example: /** * Register event post type * * Registering event post type will add such a permalink structure event/([^/]+)/?$ */ function wpse_288345_register_event_post_type() { $labels = … Read more

How to delete read more span on single post view?

As stated in the docs, if the quicktag <!–more–> is used in a post to designate the “cut-off” point for the post to be excerpted, the_content() tag will only show the excerpt up to the <!–more–> quicktag point on non-single/non-permalink post pages. WordPress adds <span id=”more-‘ . $post->ID . ‘”></span> to the content in this … Read more

Pagination on single post page?

I know Twenty Eleven include this functionality by default and I’ve come to expect it as default behavior, so I hope I’m not missing something here. You should be able to add this to single.php by using the previous_post_link() and next_post_link() functions.

Add code just after Post content

There are some global variables available (or not) to detect the current page number: if ( empty ( $GLOBALS[‘multipage’] ) or $GLOBALS[‘numpages’] === $GLOBALS[‘page’] ) echo ‘<a id=”lastPageLink” href=”#comment”>comment</a>’; The best way to understand what they do is a look at the internals of wp_link_pages(). (bool) $GLOBALS[‘multipage’] is TRUE if there is more than one … Read more