After single post widget

Community Forums Forums Design Tips and Tricks After single post widget

This topic is: not resolved

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

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

    brankica
    Participant
    Post count: 16

    I was following this tutorial http://my.studiopress.com/tutorials/add-genesis-box/ so I can add a box on single posts after content.

    The code isn’t working for some reason.

    I have a widget I added that displays on single posts as a featured box under header and I notice a few differences but considering I don’t know PHP I am not sure what I am missing.

    So the code that worked for my featured box below header is

    genesis_register_sidebar( array(
        'id' => 'featured-box',
        'name' => __( 'Featured Box', 'fcc' ),
        'description' => __( 'This is the featured box.', 'fcc' ),
    ) );
    
    add_action( 'genesis_after_header', 'genesis_featured_box' );
    function genesis_featured_box() {
    if ( is_single() && is_active_sidebar( 'featured-box' ) ) {
        echo '<div class="featured-box">';
        dynamic_sidebar( 'featured-box' );
        echo '</div><!-- end .featured-box -->';
    }
    }

    The tutorial is showing

    //* Register Genesis box widget area
    genesis_register_sidebar( array(
    	'id'            => 'genesis-box',
    	'name'          => __( 'Genesis Box', 'themename' ),
    	'description'   => __( 'This is a widget area that can be placed after the post', 'themename' ),
    ) );
    
    //* Hook Genesis box widget area after post content
    add_action( 'genesis_after_post_content', 'sp_genesis_box', 9 );
    	function sp_genesis_box() {
    	if ( is_singular( 'post' ) )
    		genesis_widget_area( 'after-post', array(
    			'before' => '<div class="genesis-box widget-area">',
    			'after' => '</div>',
    	) );
    }

    The things I see are different are for example in first code there is “IS SINGLE” while in the second “IS SINGULAR”. I definitely don’t know enough about PHP to figure this one out so if any one can help me figure out how to add a content box after main post content (above author box) I would really appreciate it.

    I do have the hooks plugin if that helps but I don’t know how to use this after post box and limit it to single post only.

    Thanks

    #63797

    braddalton
    Participant
    Post count: 10669

    The code uses the old hooks which is why it ay not work if your child theme is running HTML 5.

    Try this:
    [php]
    //* Register Genesis box widget area
    genesis_register_sidebar( array(
    ‘id’ => ‘genesis-box’,
    ‘name’ => __( ‘Genesis Box’, ‘themename’ ),
    ‘description’ => __( ‘This is a widget area that can be placed after the post’, ‘themename’ ),
    ) );

    //* Hook Genesis box widget area after post content
    add_action( ‘genesis_entry_footer’, ‘sp_genesis_box’, 9 );
    function sp_genesis_box() {
    if ( is_single( ) )
    genesis_widget_area( ‘after-post’, array(
    ‘before’ => ‘<div class="genesis-box widget-area">’,
    ‘after’ => ‘</div>’,
    ) );
    }
    [/php]

    Will only work on HTML 5 themes.

    Change the 9 if needed for positioning priority http://wpsites.net/web-design/3rd-parameter-action-hooks/

    If you’re running XHTML, change:
    [php]
    genesis_entry_footer
    [/php]

    To this:
    [php]
    genesis_after_post_content
    [/php]

    Hooks comparison chart.


    #66500

    Scott Buehler
    Participant
    Post count: 51

    This doesn’t work for me either. On new Lifestyle theme:

    genesis_register_sidebar( array(
        'id'            => 'genesis-box',
        'name'          => __( 'Genesis Box', 'lifestyle' ),
        'description'   => __( 'This is a widget area that can be placed after the post', 'lifestyle' ),
    ) );
    //* Hook Genesis box widget area after post content
    add_action( 'genesis_entry_footer', 'sp_genesis_box', 9 );
        function sp_genesis_box() {
        if ( is_single( ) )
            genesis_widget_area( 'after-post', array(
                'before' => '<div class="genesis-box widget-area">',
                'after' => '</div>',
        ) );
    }

    Regular post page doesn’t display the genesis box. Using HTML5


    TygrScott on Social Media

    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
    #66504

    braddalton
    Participant
    Post count: 10669

    Sorry, typo, my bad:

    Tested and works

    Please copy the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++


    #66557

    Scott Buehler
    Participant
    Post count: 51

    Yep, the error was the line
    genesis_widget_area( 'after-post', array(

    Needed to be
    genesis_widget_area( 'genesis-box', array(

    Thanks Brad. Genesis support showed me the error and I appreciate both you and StudioPress support very much!


    TygrScott on Social Media

    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
    • This reply was modified 1 year, 2 months ago by  Scott Buehler.
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.