WordPress.org

Ready to get started?Download WordPress

Forums

sticky posts not displaying (13 posts)

  1. emaarkhan
    Member
    Posted 1 year ago #

    Hello,
    I am trying access one sticky post in my homepage. where one sticky display different (big) and rest displays normally. till now i am able to make this code bt its not working.what could be wrong

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    I see that you are using query_posts(). Is this the only loop on the page?

  3. emaarkhan
    Member
    Posted 1 year ago #

    I think so, because loop surrounds the get_template_part in the index page and within that template part the page is called.does it count as in the loop or not

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    I don't see any reference to get_template_part in that pastebin code. query_posts() should only be used to modify the main Loop - not any secondary Loops. From the sound of it, you're using it to create a secondary query before - or within - the main Loop when you should be using WP_Query.

  5. emaarkhan
    Member
    Posted 1 year ago #

    you didn't see the template_part as its standard index. i am calling homepage-custom from that loop and the above code is homepage-custom code.

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Can you drop a complete copy of the relevant template file into the pastebin?

  7. emaarkhan
    Member
    Posted 1 year ago #

    Basically what i want is the content to display latest post on homepage as a sticky as it has some different css and other to be displayed in other styling which i will define also by css.do you still need the code?

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    Hmmm... you might just be approaching this in the wrong way and over-complicating it. Is this just about adding some extra CSS classes & perhaps some new markup to the latest post? if so, it should be possible to achieve using the main Loop with no need for any extra queries.

    Is the most recent posts always going to use the standard port format? Or could it use any one of a number of supported posts formats?

  9. emaarkhan
    Member
    Posted 1 year ago #

    This is my approach for homepage the latest post keeps the same big format while other just display a thumbnails and roll over that will show some content of post. i hope you got the idea?

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    This should be possible to achieve using the main Loop with no need for any extra queries. All you need to do is add a incremental counter to the Loop and then add your CSS and/or markup using the counter as a conditional.

  11. emaarkhan
    Member
    Posted 1 year ago #

    Although i am good with css and customizing wordpress templates file as i know which section is called when bt not good with php or loop.any pointing in right direction?

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    That's why I was asking for a complete copy of the relevant template file in the pastebin. And if the most recent posts always going to use the standard port format or could it use any one of a number of supported posts formats?

  13. emaarkhan
    Member
    Posted 1 year ago #

    here is the code, i explain in comments too.
    the format changes of different pages but on homepage the style remain same i.e latest one get big full space and other ones get clickable thumbnails

    [This is not a live chat box. Wait for your answer]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags