Create widgets specific for archives and pages

Community Forums Forums General Discussion Create widgets specific for archives and pages

This topic is: resolved

This topic contains 11 replies, has 4 voices, and was last updated by  Jen Baumann 1 year, 8 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #6462

    fsco
    Participant
    Post count: 11

    Hello,

    Can you help me to create two widget areas that show up after the content in archives and pages? I understand this can be done in the functions.php because I don’t want to use yet another plugin.

    Any help will be most appreciated. Regards

    #6687

    nickthegeek
    Keymaster
    Post count: 751

    You can follow this tutorials to make the sidebars

    http://nickc.co/sidebar

    When adding them you can make them conditional

    http://nickc.co/conditional-content

    #6954

    fsco
    Participant
    Post count: 11

    Hello Nick,

    I’ve tried the code you suggest nut using the is_page part and I get an error. Can you help me here?

    /** Add content after page */
    genesis_register_sidebar(array(
    'name'=>'after-page-content',
    'id' => 'after-page',
    'description' => 'This is a widget after page',
    ));

    add_action( 'genesis_after_content_sidebar_wrap', 'child_after_content_ad_sidebar' );
    /** Loads a new sidebar after the content */
    function child_after_content_ad_sidebar() {
    if ( is_page() && is_active_sidebar('after-page') ) {
    echo '';
    dynamic_sidebar('after-page');
    echo '';
    }
    }

    #6959

    Ozzy
    Participant
    Post count: 214

    where are you seeing the error or what does the error say?


    #7004

    fsco
    Participant
    Post count: 11

    Hi Ozzy, this is the error:

     

    Parse error: syntax error, unexpected ';' in /home/public_html/wp-content/themes/balance/functions.php on line 150

    Where is that wrong?

    #7011

    nickthegeek
    Keymaster
    Post count: 751

    Could you create a paste with your code here

    http://pastie.org

    We are looking at better solutions for the forums but right now that makes for a much better way to share the code you are using so we can see why it didn’t work. Thanks.

    #7101

    fsco
    Participant
    Post count: 11

    Yes, I had difficulties to paste the code.

    Pastie looks really good and here it is:

    http://pastie.org/private/dyewlsrucbyv421g9yepw

    #7102

    fsco
    Participant
    Post count: 11

    Also, every time I post something, the next page is a 404 error :(

    #8939

    fsco
    Participant
    Post count: 11

    Hello? Can anybody help me?

    With the code above I cannot have new widgets for both archives and pages yet.

    Thanks in advance.

    #11427

    Jen Baumann
    Keymaster
    Post count: 325

    Try
    [php]if ( is_active_sidebar(‘after-page’) && ( is_page() || is_archive() ) )[/php]


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

    #11458

    fsco
    Participant
    Post count: 11

    Hello Jen,

    I finally managed to have the widget as I want it, thanks a lot for your help :)

    For those looking to add a widget area to pages and archives, this is the final code I’m now using:

    http://pastie.org/5674365

    As the widget still appears in all pages and the homepage, I’m using the “Conditional widgets” plugin to delete it from more specific places.

    #11503

    Jen Baumann
    Keymaster
    Post count: 325

    You’re welcome :)


    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

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

The topic ‘Create widgets specific for archives and pages’ is closed to new replies.