Replace post/page content dinamically (5 posts)

  1. 2olive
    Posted 3 years ago #

    Hi all.
    I'm wondering if this is possible.
    All this regards a possible emergency situation:
    if there's no emergency, then you have to behave like this
    if there's this emergency, then you have to do this, this and this.
    The emergency situation is published on the front page of the website.

    I've planned a situation like the following:
    In the front page I have one sticky post, let's call it Apost, that belongs to category A. If this is published, then I have a particular page (Apage) published too.
    If I publish Bpost, and this is sticky, I want to have Bpage published, no more Apage.

    How can I develop that?

    Thank you

  2. bcworkz
    Posted 3 years ago #

    Sticky post IDs are stored in options table as an array under the key "sticky_posts". Just use get_option() and update_option() to swap post IDs.

  3. 2olive
    Posted 3 years ago #

    Ooohh, thank you bcworkz!!! I'll give it a try!

  4. 2olive
    Posted 3 years ago #

    I'm thinking about developing a child theme that's triggered in that situation.

  5. bcworkz
    Posted 3 years ago #

    Good idea. Child themes are a good place to keep your hacks and modifications so they do not get overwritten during an update.

    I imagine many people could use this sort of feature. If you're hoping others can benefit from your efforts, most people will find a plugin more useful, if you can stay away from theme specific coding.

Topic Closed

This topic has been closed to new replies.

About this Topic