• Resolved Swedish_Soul

    (@swedish_soul)


    I’m developing a theme for multiple bloggers that should have give the bloggers the ability to feature their posts on the front page, but only one post per week.

    So, to break it down:
    Featured checkbox in post view (not hidden away), clicking the box and publish the post will set a time-stamp for the profile and make the post featured, the box won’t be clickable again until a week later.

    Anyone know how I can make this happen?

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

    (@bcworkz)

    The easy part is setting a timestamp in user meta when a featured post is published. I see no clean way to suppress the checkbox in PHP though. What might be possible is to enqueue jQuery that hides or changes the checkbox container. The script could be selectively enqueued only when the current user’s timestamp is fresher than a week and the current screen is post edit or quick edit.

    Thread Starter Swedish_Soul

    (@swedish_soul)

    What I’m struggling with though is how to add the timestamp to the profile.

    Moderator bcworkz

    (@bcworkz)

    update_user_meta( get_current_user_id(), 'last_featured', time());

    Hook into ‘draft_to_publish’ which only fires when a post is first published. If you want to see this value in the profile it’s more involved, but doable. How depends on where you want it to appear.

    Thread Starter Swedish_Soul

    (@swedish_soul)

    So, I finally got it to work. I used a third party plugin since I couldn’t save my own field for some reason. Have to check that out in the future when I make an update. But for now, it’s working.

    Thanks for your help½

    Thread Starter Swedish_Soul

    (@swedish_soul)

    Sorry, forgot to click resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Featured post hack’ is closed to new replies.