Community Forums › Forums › Archived Forums › Design Tips and Tricks › add widget area only above one page
Tagged: genesis_after_header
- This topic has 16 replies, 2 voices, and was last updated 11 years, 5 months ago by
Brad Dalton.
-
AuthorPosts
-
November 6, 2013 at 8:20 pm #71370
erickuhn19
MemberI 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>',
) );}
November 6, 2013 at 11:52 pm #71391Brad Dalton
Participant
Use this code and change the conditional tag from this?
is_front_page()
To:
is_page ('007')
Replace the 007 with your page i.d
You can also change the hook from:
genesis_before_loop
to:
genesis_before_content_sidebar_wrap
November 7, 2013 at 5:52 pm #71571erickuhn19
MemberI'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...
November 7, 2013 at 6:07 pm #71573erickuhn19
MemberNevermind 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>
November 7, 2013 at 6:17 pm #71574erickuhn19
MemberSorry 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>',
) );}}
November 7, 2013 at 7:20 pm #71583Brad Dalton
ParticipantPlease 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++
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.
November 7, 2013 at 8:05 pm #71602erickuhn19
MemberI 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>
November 7, 2013 at 8:23 pm #71608Brad Dalton
ParticipantEither is fine. I tested forum and it works but didn't have your page i.d
November 7, 2013 at 9:36 pm #71615erickuhn19
MemberFor 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>
November 8, 2013 at 1:38 am #71636Brad Dalton
ParticipantI 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.
November 9, 2013 at 4:22 pm #71904erickuhn19
MemberBrad,
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.
November 9, 2013 at 6:14 pm #71915Brad Dalton
ParticipantI'll install bbpress and test it. I think you need to use the is_bbpress() conditional tag.
Try this:
November 9, 2013 at 6:35 pm #71917Brad Dalton
ParticipantSo you only want to display this widget on one page of the bbpress forum correct?
November 10, 2013 at 2:55 pm #72110erickuhn19
MemberBrad,
Yes! This worked!Thank you.
November 10, 2013 at 8:00 pm #72215Brad Dalton
ParticipantGood stuff.
I'm still working out how to make it display on one specific page of bbPress.
November 10, 2013 at 8:39 pm #72225erickuhn19
MemberCool, I actually prefer it showing up on every page of the forum, so this works grrat for me. My next step is customizing the background of the widget so it matches the forum.
November 10, 2013 at 8:54 pm #72226Brad Dalton
ParticipantTry this http://wpsites.net/web-design/style-widgets-individually-beginners-guide/
You'll need to find the section i.d class for the widget using a tool like Google Chrome dev or Firebug and then add your background declaration:
Example:
#widget-i.d { background-color: red; }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.