Show Full Post When Only One Post Per Category

Community Forums Forums Design Tips and Tricks Show Full Post When Only One Post Per Category

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Marco 1 year, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #39013

    martialwarrior
    Participant
    Post count: 38

    In the Blissful Child Theme, how do I show the full post in those categories where I only have one post?

    http://everythingessential.com/
    #39045

    Marco
    Participant
    Post count: 63

    The code below may help you, just paste it in functions.php:

    `
    /** Redirect to single post page if there is one post in category/tag */

    add_action(‘template_redirect’, ‘child_redirect_to_post’);

    function child_redirect_to_post(){
    global $wp_query;

    // If there is one post on archive page
    if( is_archive() && $wp_query->post_count == 1 ){
    // Setup post data
    the_post();
    // Get permalink
    $post_url = get_permalink();
    // Redirect to post page
    wp_redirect( $post_url );
    }

    }`


    • This reply was modified 1 year, 4 months ago by  Marco.
    • This reply was modified 1 year, 4 months ago by  Marco.
    • This reply was modified 1 year, 4 months ago by  Marco.
    • This reply was modified 1 year, 4 months ago by  Marco.
    #39127

    martialwarrior
    Participant
    Post count: 38

    Thank you soo much!!!

    #39128

    martialwarrior
    Participant
    Post count: 38

    Does this work for any Genesis child theme?

    #39212

    Marco
    Participant
    Post count: 63

    It works in any WordPress theme.


Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.