Forums

[resolved] how to place a post before single post? (3 posts)

  1. afdownload
    Member
    Posted 4 months ago #

    hi guys,

    I have a problem with my single post template, i want to place some post before my single post in template for some reasons, but after I place them in template It affects my single post. what ever my single post is it repeats the previous query again instead of showing my supposed post?

    [code moderated - please use the pastebin]

  2. alchymyth
    The Sweeper
    Posted 4 months ago #

    don't use query_posts() for secondary loops; use WP_Query() or get_posts() instead.

    and always reset the query after secundary loops, with wp_reset_postdata() or wp_reset_query()

    http://codex.wordpress.org/Class_Reference/WP_Query
    http://codex.wordpress.org/Template_Tags/get_posts

    http://codex.wordpress.org/Function_Reference/wp_reset_query
    http://codex.wordpress.org/Function_Reference/wp_reset_postdata

  3. afdownload
    Member
    Posted 4 months ago #

    thanks man,

    actually your reset code worked fine!

    <?php wp_reset_query() ?>

Reply

You must log in to post.

About this Topic