Forums

[resolved] Content duplicates itself - Something wrong with my query? Need reset? How? (9 posts)

  1. devotee
    Member
    Posted 2 years ago #

    Hi. Im working on a site with a theme I´m building at the time. I think this problem arose when I wanted to use two different single.php templates depending on which category they where displaying. I duplicated my single.php and renamed it into single-portfolio and singel-news, then I replaced the content of single.php with a simply php code to load the right template depending on category.

    That worked. But now, my single-news.php is repeating its content twice for some reason. Its not doing so on the single-portfolio however.

    Any ideas why this is the case and what I can do about it? I´m thinking maybe some querys arent reset or something.

    On both single-news and single-portfolio I am using two querys, one regular for the content with this style:
    http://wordpress.pastebin.ca/2053962

    and one costum query below this which looks like this:
    http://wordpress.pastebin.ca/2053963

    Someone please help me with this because I´m so lost here!

  2. jkovis
    Member
    Posted 2 years ago #

    Can you post a link to a page where this is happening and the entire single-news.php file?

  3. devotee
    Member
    Posted 2 years ago #

    No. I abandoned the idea about specific single templates, some posts will be in several categories so it was a bad idea probably.

    I didnt do it for styling purposes anyway, but because I wanted to loop in thumbnails of posts from the same category that the single.php is currently displaying. Im guessing now that it might be better to do that through specific query. If you know how to do that I´ll be happy to be helped with that instead, if not thanks for wanting to help me with my initial problem :)

  4. jkovis
    Member
    Posted 2 years ago #

    How about something like this?

  5. devotee
    Member
    Posted 2 years ago #

    Uhm. Should I just put the php tags before and after that whole code? Im unsure about where to put them, if there are many...sry :) Could you past it again with php tags perhaps?

  6. jkovis
    Member
    Posted 2 years ago #

    It's all php code so place <?php at the start of the first line and ?> at the end of the last line.

  7. devotee
    Member
    Posted 2 years ago #

    Thank you! That worked well! I had to stop and start php tags on some places in the code to get my divs and markup in, you do need to do that right? Or can I mix html and php?

    It looks like this now: http://pastebin.com/ytFZtexU

    Im very grateful for your help, couldnt have done this by myself! :)

  8. jkovis
    Member
    Posted 2 years ago #

    Glad to hear it's working.

    I had to stop and start php tags on some places in the code to get my divs
    and markup in, you do need to do that right? Or can I mix html and php?

    - You can do either, I took a quick look at your pastebin and it looks good to me.

    Please mark this issue as resolved

  9. devotee
    Member
    Posted 2 years ago #

    Of course, thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic