Community Forums › Forums › Archived Forums › General Discussion › I want to add a "widget" in my No Sidebar post/page
- This topic has 21 replies, 3 voices, and was last updated 10 years, 2 months ago by
Brad Dalton.
-
AuthorPosts
-
June 6, 2013 at 9:22 am #44320
lwoods
ParticipantI want to add a piece of code into my form (or page) content area. For example, I have a "No Sidebar" page that is an "About Us" but I would like to drop a "Sign up for our Newsletter" box into the content area; maybe on the right, for example. But I want the content to flow around the box. In other words it would be the same as having an image in my content but it's a piece of code instead.
How?
Thanks
June 6, 2013 at 9:26 am #44322Brad Dalton
ParticipantJune 6, 2013 at 9:28 am #44326lwoods
ParticipantSorry, but I don't understand your message. Link to what page?
June 6, 2013 at 10:03 am #44337Brad Dalton
ParticipantYour About Us” page please.
I'd like to take a look.
June 6, 2013 at 10:04 am #44338lwoods
ParticipantHi,
Sorry but I haven't built it yet. Just want to know how to do it. I think that answer is to find a plugin with a shortcode that I can drop into my content area.
June 6, 2013 at 10:26 am #44345Brad Dalton
ParticipantNo worries.
Post this when you have got the site up and i'll give you the solution.
July 20, 2013 at 10:15 pm #51670Chrissy Marquardt
MemberHey Brad, you've helped me out before and Im working on a new project and had the same question. Using the Innov8tive theme for my blog and I was able to figure out how to get my newsletter box to appear below posts but I want it to appear below my About page. I know its some code I have to put in the php file but just not sure what it is
http://www.cleaneatingsimplified.com/about/
Thanks
July 21, 2013 at 11:42 am #51711Brad Dalton
ParticipantWhat great timing. I just wrote about this for another community member.
http://www.studiopress.community/topic/modern-portfolio-about-widget/#post-51709
July 22, 2013 at 2:20 pm #51905Chrissy Marquardt
MemberHey Brad,
I read the other post and I had some follow up questions. Here is the code I have at the bottom of my themes php file that I grabbed based on a tutorial Brian Gardener posted on the eNews extended plugin
//* Add the newsletter widget after the post content add_action( 'genesis_after_post_content', 'custom_add_newsletter_box' ); function custom_add_newsletter_box() { if ( is_singular( 'post' ) ) genesis_widget_area( 'newsletter', array( 'before' => '<div id="newsletter">', ) ); }
So I want to add my newsletter sign up box after my about page and my contact me page ( possibly some other pages in the future but we'll start there for now). What code would I put in the php file ?
Thanks again !
July 22, 2013 at 4:44 pm #51936Brad Dalton
ParticipantChange the line for the conditional tag to an array:
if ( is_singular( 'post' ) )
To this:
if (is_page( array( 'about-me', 'contact-me' ) ) )
Use the page slug or page i.d's
If it doesn't work, try removing the single quotes and use the page i.d.
if ( is_page( array( 007, 1180 ) ) )
July 24, 2013 at 9:00 pm #52399Chrissy Marquardt
MemberHey again
Thanks for your help with this. I would like to keep my subscription box below my posts AND have it below the contact me and about page. So would it look like this:
//* Add the newsletter widget after the post content
add_action( 'genesis_after_post_content', 'custom_add_newsletter_box' );
function custom_add_newsletter_box() {
if ( is_singular( 'post' ) )
if (is_page( array( 'about', 'contact-me' ) ) )
genesis_widget_area( 'newsletter', array(
'before' => '<div id="newsletter">',
) );
}
`
Thanks again. Really appreciate your input
July 25, 2013 at 12:55 am #52421Brad Dalton
ParticipantJuly 25, 2013 at 3:24 pm #52495lwoods
ParticipantBrad:
In the previous reply is "dynamic_sidebar()" a method in a plug-in?
Thanks
July 25, 2013 at 3:32 pm #52498Brad Dalton
ParticipantThis Conditional Tag checks if the current sidebar has active widgets.
Source http://codex.wordpress.org/Function_Reference/is_dynamic_sidebar
July 25, 2013 at 4:16 pm #52511lwoods
ParticipantThanks for the info, Brad. I was just trying to figure out what the call to dynamic_sidebar did. In your example it doesn't look like it's doing anything---or am I missing something. The codex doc says that it returns true/false.
July 25, 2013 at 4:21 pm #52515Brad Dalton
ParticipantIf its a single post or one of 2 pages, it outputs the content of sidebar widget named newsletter. Without the dynamic_sidebar() function, the widget would not work so its essential.
July 25, 2013 at 4:28 pm #52516lwoods
ParticipantGot it. Thanks.
July 25, 2013 at 10:56 pm #52561Chrissy Marquardt
MemberJust to clarify ( I just want to make sure I dont screw up my php file so sorry for the questions
add_action( 'genesis_after_post_content', 'custom_add_newsletter_box' ); function custom_add_newsletter_box() { if ( is_singular( 'post' ) || is_page( array( 'about-me', 'contact-me' ) ) ) genesis_widget_area( 'newsletter', array( 'before' => '<div id="newsletter">', ) ); } genesis_register_sidebar( array( 'id' => 'newsletter', 'name' => __( 'Newsletter', 'wpsitesdotnet' ), 'description' => __( 'Newsletter widget.', 'wpsitesdotnet' ) ) ); /** * @author Brad Dalton - WP Sites * @example add_action( 'genesis_after_post_content', 'custom_add_newsletter_box' ); function custom_add_newsletter_box() { if ( is_singular( 'post' ) || is_page( array( 'about-me', 'contact-me' ) ) ) genesis_widget_area( 'newsletter', array( 'before' => '<div id="newsletter">', ) ); }
instead of wpsitesdotnet - I replace this with my site cleaneatingsimplifieddotcom ?
instead of @author Brad Dalton - @author Chrissy Marquardt - Clean Eating Simplified
instead of @example http://wp.me/p1Tu0-9Jr - @link http://cleaneatingsimplified.com/about/
@link http://cleaneatingsimplified.com/contact-meHere is where I am unclear. I am not sure what I am supposed to be putting here ? What do I replace this with - is it the link to my about page and my contact page ? Do I leave it as @example ? Do I put it twice ?
Thanks !
July 26, 2013 at 7:05 pm #52707Brad Dalton
ParticipantJuly 27, 2013 at 12:39 am #52736Brad Dalton
ParticipantYou can replace the about' and contact-me words with the page i'd's for those 2 pages which you can grab from the body class in the source code. Simply right click each page and view source code to find it.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.