add widget area only above one page

Community Forums Forums Design Tips and Tricks add widget area only above one page

This topic is: not resolved

This topic contains 16 replies, has 2 voices, and was last updated by  braddalton 10 months, 1 week ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #71370

    erickuhn19
    Member
    Post count: 18

    I am trying to register the widget area on my forum page just after the header or before the content (it can be said both ways). I only want this widget area to be shown on my forum page and any subpages of the forum.

    I posted the code below to make sure I was doing this correctly. Most of the info was received from Carriedils.com (http://www.carriedils.com/add-widget-area-below-nav/)

    Is this correct? Or is there an easier way to do this? (I am using the Agency-Pro theme.

    //* Register before forum
    genesis_register_sidebar( array(
    ‘id’ => ‘genesis_before_forum’,
    ‘name’ => __( ‘Before Forum’, ‘agency-pro’ ),
    ‘description’ => __( ‘This is a widget area that can be placed before the forum’, ‘agency-pro’ ),

    add_action( ‘genesis_after_header’, ‘agency_login_widget’ );

    /**
    * Add login widget support for site. If widget not active, don’t display
    *
    */
    function agency_login_widget() {

    // Don’t display the login on the home page, since it’s built into the agency-pro theme
    if ( is_home() ) {
    return;
    }

    // If it’s the Forum page, display login widget
    elseif ( is_page( ‘forum’ ) ) {
    genesis_widget_area( ‘agency_login_widget’, array(
    ‘before’ => ‘<div id=”login”><div class=”wrap”>’,
    ‘after’ => ‘</div></div>’,
    ) );

    }

    #71391

    braddalton
    Participant
    Post count: 9722

    Use this code and change the conditional tag from this?

    [php]
    is_front_page()
    [/php]

    To:
    [php]
    is_page (’007′)
    [/php]

    Replace the 007 with your page i.d

    You can also change the hook from:
    [php]
    genesis_before_loop
    [/php]
    to:
    [php]
    genesis_before_content_sidebar_wrap
    [/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #71571

    erickuhn19
    Member
    Post count: 18

    I’m not sure what happened but I am getting this error message:

    Parse error: syntax error, unexpected ‘(‘ in /home/content/85/11958585/html/wp-content/themes/agency-pro/functions.php on line 149

    And I cant get back into my WordPress editor at all…

    #71573

    erickuhn19
    Member
    Post count: 18

    Nevermind I figured out how to go into my hosting and edit the functions file from there.

    Can you tell what is wrong with my code that created that error

    <script src=”https://github.com/erickuhn19/bbpress/blob/master/register%20widget%20in%20forum”></script>

    #71574

    erickuhn19
    Member
    Post count: 18

    Sorry I didn’t post that right:

    genesis_register_sidebar( array(
    ‘id’ => ‘before-loop’,
    ‘name’ => __( ‘Front Page Slider’, ‘wpsites’ ),
    ‘description’ => __( ‘This is the slider widget.’, ‘wpsites’ ),
    ) );

    add_action( ‘genesis_before_loop’, ‘wpsites_before_loop_widget’ );
    function wpsites_before_loop_widget() {
    if (is_page (‘forum’) && is_active_sidebar(‘before-loop’) ) {
    genesis_widget_area( ‘before-loop’, array(
    ‘before’ => ‘<div class=”before-loop”>’,
    ‘after’ => ‘</div>’,
    ) );

    }}

    #71583

    braddalton
    Participant
    Post count: 9722

    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++

    http://www.studiopress.com/forums/topic/add-widget-area-only-above-one-page/#post-71391

    I tested this code and it works.

    When you copy it from a web page, it turns the apostrophes (single qoutes) around causing an error.

    When you embed it in a web page, anyone that comes along and copies it will get an error.

    Please use Github gists to embed your code in a web page.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #71602

    erickuhn19
    Member
    Post count: 18

    I see thanks for the information. OK, I got my Github working.

    Is page ID /forum or do I have to assign a number custom fields?

    <script src=”https://gist.github.com/erickuhn19/7364210.js”></script>

    #71608

    braddalton
    Participant
    Post count: 9722

    Either is fine. I tested forum and it works but didn’t have your page i.d


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #71615

    erickuhn19
    Member
    Post count: 18

    For some reason it is not working for me. Maybe because the bbpress forum is the content before it? Or something to do with the Agency-Pro theme.

    I have tried a few variations using your method as well as: http://www.carriedils.com/add-widget-area-below-nav/#comment-3320
    Both are similar but still a little different.

    Can you tell whats wrong with these?

    <p><script src=”https://gist.github.com/erickuhn19/7365562.js”></script></p>

    <p><script src=”https://gist.github.com/erickuhn19/7365906.js”></script></p>

    • This reply was modified 10 months, 1 week ago by  erickuhn19.
    • This reply was modified 10 months, 1 week ago by  erickuhn19.
    #71636

    braddalton
    Participant
    Post count: 9722

    I didn’t test with the page i.d because you haven’t linked to it.

    I would suggest you use the page i.d.

    I have tested the code locally twice and it works so it must be the conditional tag.

    If you’re using bbpress, you may want to post a question on thier forum.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #71904

    erickuhn19
    Member
    Post count: 18

    Brad,
    I want to thank you for all of your help. I just tested the code applying the widget to my “resources” page, so there must be a bug with this working with the bbpress.

    I really appreciate your help and patience.

    #71915

    braddalton
    Participant
    Post count: 9722

    I’ll install bbpress and test it. I think you need to use the is_bbpress() conditional tag.

    Try this:


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #71917

    braddalton
    Participant
    Post count: 9722

    So you only want to display this widget on one page of the bbpress forum correct?


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #72110

    erickuhn19
    Member
    Post count: 18

    Brad,
    Yes! This worked!

    Thank you.

    #72215

    braddalton
    Participant
    Post count: 9722

    Good stuff.

    I’m still working out how to make it display on one specific page of bbPress.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.