• I have a custom WP_Query and wanted to have sticky posts show up top. I got that happening by reading the docs, and putting something together. But not sure if its a correct way to do it.

    But also is it normal to show the sticky posts on the same page in the default order below “x” amount of posts? It looks kind of funny if there is a sticky post up top then 3 posts down you see it in the correct order. I couldn’t figure out how to hide that if thats normal practice.

    Here is my code – https://pastebin.com/p2atVa2p

Viewing 4 replies - 1 through 4 (of 4 total)
  • It’s simple really.

    1st query: only sticky posts
    reset query
    2nd query (add a rule sticky=false)

    I trust you should be able to write the actual code for it.

    Hope this helps, lemme know how it goes ??

    Thread Starter mxpimp47

    (@mxpimp47)

    Would a conditional statement be better instead of two query’s?

    Honestly I think it’s a lot easier and cleaner with two queries.

    Thread Starter mxpimp47

    (@mxpimp47)

    I have made two queries like you suggested. One problem I have is I was using php count to insert a clearfix div for responsive purposes. Now with two queries its obviously not going to work correctly. Any suggestions on handling this?

    https://pastebin.com/CV3mS73r

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP_Query with sticky posts’ is closed to new replies.