Support » Developing with WordPress » Sticky post button and display sticky per individual user

  • Resolved ndjworldnews

    (@ndjworldnews)


    Hi;

    Got a site where users can leave short remarks directly from front page (similar to Twitter). Users have no access to the WP dashboard. I wish to add a ‘sticky’ button that allows users to make one of their remarks sticky. Then when the user’s individual page is loaded I wish to display that sticky on top of the user’s page.

    Any suggestions how I can accomplish this?

    Thank you;

    Lode

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The default sticky functionality stores the sticky post’s ID as an option value. You’ll want to do something similar, storing sticky IDs as user meta. Use the “option_sticky_posts” filter to fool WP_Query into thinking the user’s sticky selection is the site’s sticky selection by using the page owner’s values in place of the site’s.

    Buttons don’t reflect a true/false state very well. I recommend using a check box field to indicate sticky status. The chosen state can be saved when the remark is first published. If the remark is already published, the sticky state could be changed via Ajax request triggered by the field’s change event.

    Thread Starter ndjworldnews

    (@ndjworldnews)

    Hello;

    Thank you for your response. I came up with this round-a-bout solution:

    Created a ‘sticky’ category;
    Users can select that category;
    When displaying post, 1st post in sticky cat gets displayed on top of page for that specific user by checking cat and author id.

    Works alright.

    Thanks again;

    Lode

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sticky post button and display sticky per individual user’ is closed to new replies.