WordPress.org

Forums

Customizr
Add Text Block Above Homepage Slider (4 posts)

  1. pembrokellc
    Member
    Posted 11 months ago #

    I would like to add a brief text block that explains the key values of our company. I found this on the Themesandcompany website; is this the right code to add to funcstions.php in child theme?

    //we add the action with priority set to 0 => it will be displayed in first position (before the slider if any)
    add_action ('__after_header' , 'add_content_after_header', 0);

    function add_content_after_header() {
    //checks if we are displaying the home page
    if ( !tc__f( '__is_home' ) )
    return;
    ?>
    <div id="my-content-header">
    <div class="row-fluid">
    <div class="span8 text-center">
    <?php
    printf('<h2>%1$s</h2>',
    __('My header message!')
    )
    ?>

    </div>

    <div class="span4 text-center">
    <?php
    printf('%1$s',
    __('Call to action')
    )
    ?>
    </div>
    </div>
    </div>
    <?php
    }

  2. ElectricFeet
    Member
    Posted 11 months ago #

    (Make sure you use backticks when you post code.)

    Well, your code works, as I'm sure you know.

    If you have a personal site—that is, you are the only one that updates it and works on the code—then adding content after the header with this snippet is fine.

    If it's a company site, then I think that in general, I would now recommend an approach similar to the snippet that adds a specific page or post content in another post or page. The reason is that when other people may be updating the site, they don't need to go through you to update the page; nor do you need to go fiddling around in php to change the text each time (with the risks that a stray semi-colon will bring down the site).

    Note that in that code example, the "<=" that nikeo placed before the comment "// set the id ..." needs to be removed before use.

  3. nikeo
    Member
    Theme Author

    Posted 11 months ago #

    Thanks for pointing the typo @eletricfeet : fixed

  4. ElectricFeet
    Member
    Posted 11 months ago #

    You're welcome. Thanks for posting the snippet! :-)

Reply

You must log in to post.

About this Theme

About this Topic