• Resolved Chad R. Schulz

    (@chadschulz)


    I want a simple way for my visitors to hit a button on my front page and immediately link to the most recent post I’ve made. I’ve got many custom post types and would like to include/exclude the types I don’t want to the link to use.

    I’m kind of new to .php and have been using a premium theme to workaround the coding.

    But I’ve worked with/modified the code as instructed for other issues and I’m willing to learn.

    Thanks
    Chad

Viewing 6 replies - 1 through 6 (of 6 total)
  • What do you mean by “immediately link to the most recent post”?

    Thread Starter Chad R. Schulz

    (@chadschulz)

    I want them to get the correct url of the post/ not a redirect to a static page that has the recent post.

    Are you currently using a static front page or displaying your recent posts on your front page?

    Thread Starter Chad R. Schulz

    (@chadschulz)

    I’m using a static home page with numerous links to posts from many custom post types–for a CMS-type website.

    But I want a simple button at the top for visitors to use and find my lastest post.

    Thanks

    The easiest approach would be to have a small custom query to generate the link in the relevant theme template file. Something like:

    $args= array(
    	'posts_per_page' => 1
    );
    $the_query = new WP_Query( $args );
    // The Loop
    while ( $the_query->have_posts() ) {
    	$the_query->the_post();?>
    	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?></a><?php
    }
    wp_reset_postdata();

    should do the trick.

    Thread Starter Chad R. Schulz

    (@chadschulz)

    Thanks,
    I’ll try it out.
    Chad

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘A Most Recent Post Link’ is closed to new replies.