This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Add Widget Area After Posts

  • Creator
    Topic
  • #3284
    Herb Trevathan
    Participant

    I have added a widget area to the after content area, however this presents wider than I would like.

    What I am trying to do is add the typical “after post widget” which normally would be used for an author bio or a “this website powered by WP Jumpstart…etc”

    I have tried this function and it produced an error message

    themeblvd_add_sidebar_location( 'jumpstart_after_post_content', 'After Post Widget', 'collapsible' );
    function display_jumpstart_after_post_content() {
        echo '';
        themeblvd_display_sidebar( 'after_post_widget' );
        echo '';
    }
    add_action( 'themeblvd_single_footer', 'display_after_post_widget' );

    I tried moving things around in that block of code, but I am thinking I have a fundamental misunderstanding of functions haha, since I am really just moving things around and crossing my fingers…

    I read the actions map…I did not see a hook for after post. So I went into the framework to ‘single.php’ and saw this:
    <?php themeblvd_single_footer(); ?>

    and stole the ‘themeblvd_single_footer’ – thinking this was an available hook?…

    At any rate I am quite certain my function is formatted wrong, but hopefully there is a way to hook into this area without hacking the single.php??

    Any help would be appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #3313
    Jason Bobich
    Keymaster

    Yeah, it looks like you’re getting a few things mixed up. In your call to add_action, you’re declaring your callback function as “display_after_post_widget”, which doesn’t exist; so it makes sense this would be outputting some kind of error like “Invalid callback …”

    I think this is more what you’re going for:

    // Create the widget area location
    themeblvd_add_sidebar_location( 'after_post_widget', 'After Post Widget', 'collapsible' );
    
    // Display it
    function display_jumpstart_after_post_content() {
        themeblvd_display_sidebar( 'after_post_widget' );
    }
    add_action( 'themeblvd_single_footer', 'display_jumpstart_after_post_content' );

    And just as a little bit better practice, it’s better to name your functions prefixed with something unique to you or your Child theme like this:

    // Create the widget area location
    themeblvd_add_sidebar_location( 'after_post_widget', 'After Post Widget', 'collapsible' );
    
    // Display it
    function herb_display_after_post_content() {
        themeblvd_display_sidebar( 'after_post_widget' );
    }
    add_action( 'themeblvd_single_footer', 'herb_display_after_post_content' );
    #3330
    Herb Trevathan
    Participant

    Haha! Worked perfectly…Thank You so much.

    I will use this for reference going forward : )

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.