Style post content for a category

Community Forums Forums Design Tips and Tricks Style post content for a category

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  sheilab 1 year, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #21829

    sheilab
    Participant
    Post count: 16

    How would I go about adding a div inside the content of single posts of a particular category?

    Can I do this from the functions.php file?

    Thanks.

    Sheila

    #21844

    Sridhar Katakam
    Participant
    Post count: 1003

    1) (Not mandatory, but will make this easy) Install and activate Genesis Simple Hooks plugin.

    2) Go to Genesis -> Simple Hooks -> genesis_after_post_content Hook (Reference)

    Enter

    [php]
    <?php if(is_single() && in_category( ‘Cat A’ )) { ?> <div id="my-custom-div">Hello hello.</div> <?php } ?>
    [/php]

    Change ‘Cat A’ to the name of your desired category and the div’s content of course.

    Tick ‘Execute PHP on this hook?’.


    #21989

    sheilab
    Participant
    Post count: 16

    Thanks for this! I now understand how to use Genesis Simple Hooks. Very useful. Unfortunately it turns out not to be what I need in this particular case.

    What I need is to format a category of single posts with a short-code initiated slideshow and a block of descriptive text sitting to its right.  The slide show and text need to be centered on the page. My client will be adding links etc to the descriptive text so it has to be added from the post editor.

    http://www.bergmanmediaservices.com/test-slideshow-page/

    Can you tell me the best way to go about this?

    Thanks again! Sheila

     

     

     

     

    #22165

    Sridhar Katakam
    Participant
    Post count: 1003

    Are all posts going to be like that or only some?

    Do you want two custom fields, one for slideshow shortcode and the other for corresponding text?

    Yesterday I made a post regarding showing value of a custom field above the content area that you might find useful. See http://websitesetuppro.com/how-to-show-a-custom-fields-value-at-the-top-of-every-post-or-page-in-genesis/


    #22250

    sheilab
    Participant
    Post count: 16

    Thank you!

    Your custom field post was very valuable. I installed ACF and drawing from you code I was able to use Simple Hooks to display the fields.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.