Add static text before grid loop on home page

Community Forums Forums Design Tips and Tricks Add static text before grid loop on home page

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  maui 1 year, 3 months ago.

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

    CaveCanem
    Participant
    Post count: 3

    I’m using a three-column Mocha theme. The home page uses a grid loop of the top five recent posts in the center column. I want to include some static “Welcome” text just before the grid loop in this column (but not in a sticky post). If I add the text before the opening “<?php” in the home.php file, the text gets added before the header instead of at the top of the center column. If I add it anywhere after the opening “<?php”, I get a parsing error.

    Where can I add text so that it appears at the top of the column?

    Thanks for any help.

    #8223

    Chris Cree
    Participant
    Post count: 147

    You can add something like the following to your home.php file:

    add_action( 'genesis_before_content', 'child_home_welcome' );
    function child_home_welcome() {
    	echo '<div class="home-welcome">'; 
    	echo '<p>YOUR WELCOME MESSAGE GOES HERE</p>';
    	echo '</div><!-- end .home-welcome -->';
    }

    Then you will want to add a little CSS to your style sheet for the .home-welcome class to make it look the way you want.


    #8262

    CaveCanem
    Participant
    Post count: 3

    Excellent! That did exactly what I needed. One last question: I want to style this text to match the center column in background, font, padding, etc. Where can I find that CSS in my style sheet so that I can reference the values? What is that class called?

    Thanks again!

    #8287

    CaveCanem
    Participant
    Post count: 3

    Never mind that question, I found the CSS for the content column. It seems that I’ve got to learn my way around CSS a little better, though. Since Mocha is a responsive theme, I’ve got to style my welcome text “box” to match the changing styles of the content column for different screen widths. I think that I understand how that works, but I’m not sure yet.

    Also, the primary (right) sidebar seems to be anchored to the content column such that the welcome text box “pushes” the primary sidebar down along with the content column. I’m guessing I’d have to modify the primary sidebar CSS  to get it to stay anchored to its original position, but I’m not sure how. The secondary (left) sidebar remains unaffected.

    Is it possible to incorporate the welcome text into the central content column before the grid loop begins (instead of above the content column in its own separate “box”)? Or is the content column restricted to only grid loop content?

    Hope that this makes sense. Thanks again.

    #8334

    maui
    Participant
    Post count: 22

    How can I use this code snippet if I do not have a home.php. Include in functions.php?

    Thanks
    Maui

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

You must be logged in to reply to this topic.