• First I have to give credit to Kafkaesqui for this piece of code.

    <?php
    $wp_query->is_single = true;
    previous_post();
    $wp_query->is_single = false;
    ?>

    I altered the code to replacing template tags: previous_post_link, and next_post_link. Why, I didn’t like the output and needed to exclude some categories.

    This works, but the code doesn’t generate the post title. When I check the source to see what is there, I find an a tag with a link that is not part of the excluded categories {good thing}. Just no text for a visitor to see or check. {bad thing}

    <?php
    $wp_query->is_single = true;
    previous_post_link('%link', false, '2 and 3 and 4 and 5 and 6 and 7 and 8');
    $wp_query->is_single = false;
    ?>

    However, if I do this with the addition of %title. The problem is, the functions quits excluding the categories I asked.

    <?php
    $wp_query->is_single = true;
    previous_post_link('%link','%title', false, '2 and 3 and 4 and 5 and 6 and 7 and 8');
    $wp_query->is_single = false;
    ?>

    Has any one else had the same problem or is there a better way of doing this?

    Thanks in advance for helping.

  • The topic ‘Single post on home page w/ post_link’ is closed to new replies.