WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display content on a specific level category and on their parent (4 posts)

  1. starbug81
    Member
    Posted 2 years ago #

    Hi everyone.
    Does anyone know how to display content on a specific level category and their parent? I found a few close solutions but none of them works for my case.
    Here's the situation i have:

    Main category
    |----Submenu1
    |----Submenu level 2
    |----Submenu level 2
    |----Submenu level 2
    |----Submenu2
    |----Submenu3

    I would need for content to be shown just on Submenu level 2 and their parent (Submenu1). And since the categories are dynamic (more can be added over time) - I can't use targeting specific category ID.

    I would appreciate any help :).

  2. Denis Leblanc
    Member
    Posted 2 years ago #

    Can you just add the content in a custom field for each post that needs it? Then you can just edit the template file to check if there's a value for a specific CF key and pop it in where needed. If there's no value then nothing shows up.

    If the content is to be the same on each page then you can just create the content in static page, and on each of the pages that need that particular content to show up on just create a custom field called 'content' with a value of 'true'. In you template file you can check if the meta key 'content' has a value of 'true' and if it does then you run a query to fetch the page_ID that contains the content.

  3. starbug81
    Member
    Posted 2 years ago #

    Hey Denis, thanks for the quick reply!
    You gave me a great idea - I used description field and, as you wrote, checked in template for specific value. That pretty much solved my problem.

    Thank you, again, for your help :) !

  4. Denis Leblanc
    Member
    Posted 2 years ago #

    Didn't think of that one, yeah that should work. The only drawback is not having the editor to work with.

Topic Closed

This topic has been closed to new replies.

About this Topic