Community Forums › Forums › Archived Forums › General Discussion › Putting a subcription form after the post
Tagged: after post, subscription form
- This topic has 22 replies, 2 voices, and was last updated 11 years ago by ludvig.
-
AuthorPosts
-
December 11, 2013 at 11:17 am #78340ludvigMember
Hello,
I would like to put a subscription form (or a text widget with an image linked to my subscription form) below my posts.
I currently have a custom field for this with the following details:
------------CSS-----------
/* After Post
------------------------------------------------------------ */
.after-post {
background-color: #edebe8;
border: 3px solid #E2DFDA;
font-size: 14px;
clear: both;
margin: 20px 0 0;
overflow: hidden;
padding: 20px;
}
---------------PHP----------------------add_action( 'genesis_after_post', 'streamline_post_markup_close' );
function streamline_post_markup_close() { ?>
</div>
<?php
}/** Add the after post section */
add_action( 'genesis_after_post_content', 'streamline_after_post' );
function streamline_after_post() {
if ( ! is_singular( 'post' ) )
return;
genesis_widget_area( 'after-post', array(
'before' => '<div class="after-post widget-area">',
) );
}What I'm currently using this after post widget section for is my related post, and I've made a neat looking box that I would like to keep the way it is.
What I (believe) I want to do is to create another section that comes immediately after my current "after post" section where I can input a text widget or a subscription form, because that way I get to keep my current related post box looking the same...(?)
Check out this link and scroll up to see the box:
http://www.startgainingmomentum.com/December 11, 2013 at 11:22 am #78345nutsandboltsMemberI think it would make sense to add another widget area, especially if you want the styling to be significantly different. Or you could try adding another widget to the After Post area to see how it looks.
I see you got your header and nav worked out (or at least it looks that way) - is it finally doing what you wanted it to do?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 11:25 am #78348ludvigMemberYes I think so too.
Will you please help me do it?
(It looks horrible to add another widget to the current after post area, so I definitely do not want that)
The header/nav is working somewhat how I want it to, I'm too scared to mess more with it for now.
Thanks for the help on that one 🙂
December 11, 2013 at 11:32 am #78350nutsandboltsMemberSure, I can help. You'll basically want to use a similar function to the one for the After Post area, and probably similar CSS to start (since you can always change it later). For example, I have two widget areas on my single posts - one at the top of the post and one at the bottom. So I have a genesis_register_sidebar function for each one and a function for each one to tell it to show up on single posts, like this:
add_action( 'genesis_before_comments', 'nabm_add_newsletter_box' ); function nabm_add_newsletter_box() { if ( is_singular( 'post' ) ) genesis_widget_area( 'newsletter', array( 'before' => '<div id="newsletter">', 'after' => '</div>' ) ); }
Just make sure your function name is different, as well as the name of the widget area. If you use the same function name twice it will throw an error. Let me know if you have questions or if something doesn't make sense.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 11:46 am #78357ludvigMemberHere's what I put into my PHP:
/** Add the before comments section */
add_action( 'genesis_before_comments', 'nabm_add_newsletter_box' );
function nabm_add_before_comments() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'newsletter', array(
'before' => '<div id="newsletter">',
'after' => '</div>'
) );
}But nothing happened when i refreshed my widgets area.
What is it i am doing wrong or missing?
December 11, 2013 at 11:48 am #78358nutsandboltsMemberCan you paste in your whole functions.php?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 11:52 am #78359ludvigMemberOk.
Btw I changed it again to:
/** Add the before comments section */
add_action( 'genesis_before_comments', 'nabm_add_newsletter_box' );
function nabm_add_before_comments() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'before_comments', array(
'before' => '<div id="comments">',
'after' => '</"after-post widget-area">'
) );
}HERE IS MY ENTIRE PHP
<?php
/** Start the engine */
require_once( get_template_directory() . '/lib/init.php' );/** Child theme (do not remove) */
define( 'CHILD_THEME_NAME', 'Streamline Theme' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/streamline' );/** Add Viewport meta tag for mobile browsers */
add_action( 'genesis_meta', 'streamline_add_viewport_meta_tag' );
function streamline_add_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}/** Create additional color style options */
add_theme_support( 'genesis-style-selector', array( 'streamline-blue' => 'Blue', 'streamline-green' => 'Green' ) );/** Add support for structural wraps */
add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'inner', 'footer-widgets', 'footer' ) );/** Add new image sizes */
add_image_size( 'home-featured', 255, 80, TRUE );
add_image_size( 'post-image', 642, 250, TRUE );
add_image_size( 'thumbnail', 150, 150, TRUE );
add_image_size( 'small', 50, 50, TRUE );
add_image_size( 'Slideshow', 520, 280, TRUE );
add_image_size( 'Small Thumbnail', 70, 70, TRUE );/** Unregister layout settings */
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );/** Unregister secondary sidebar */
unregister_sidebar( 'sidebar-alt' );/** Add support for custom background */
add_custom_background();/** Add support for custom header */
add_theme_support( 'genesis-custom-header', array( 'width' => 960, 'height' => 200 ) );/** Add newsletter section after header */
add_action( 'genesis_before_content_sidebar_wrap', 'streamline_newsletter' );
function streamline_newsletter() {
if ( ! is_home() )
return;genesis_widget_area( 'newsletter', array(
'before' => '<div class="newsletter widget-area">',
) );
}/** Reposition the breadcrumbs */
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_breadcrumbs' );/** Customize breadcrumbs display */
add_filter( 'genesis_breadcrumb_args', 'streamline_breadcrumb_args' );
function streamline_breadcrumb_args( $args ) {
$args['home'] = 'Home';
$args['sep'] = ' ';
$args['list_sep'] = ', '; // Genesis 1.5 and later
$args['prefix'] = '<div class="breadcrumb"><div class="inner">';
$args['suffix'] = '</div></div>';
$args['labels']['prefix'] = '<span class="home"></span>';
return $args;
}/** Relocate the post info function */
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
add_action( 'genesis_before_post', 'genesis_post_info' );/** Customize the post info function */
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
if ( !is_page() ) {
$post_info = '[post_author_posts_link] [post_date] [post_comments] [post_edit]';
return $post_info;
}}/** Add markup around post class */
add_action( 'genesis_before_post', 'streamline_post_markup' );
function streamline_post_markup() { ?>
<div class="post-wrap">
<?php
}add_action( 'genesis_after_post', 'streamline_post_markup_close' );
function streamline_post_markup_close() { ?>
</div>
<?php
}/** Modify the size of the Gravatar in the author box */
add_filter( 'genesis_author_box_gravatar_size', 'streamline_author_box_gravatar_size' );
function streamline_author_box_gravatar_size($size) {
return '80';
}/** Customize the post meta function */
add_filter( 'genesis_post_meta', 'post_meta_filter' );
function post_meta_filter($post_meta) {
if ( !is_page() ) {
$post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
return $post_meta;
}}/** Add the after post section */
add_action( 'genesis_after_post_content', 'streamline_after_post' );
function streamline_after_post() {
if ( ! is_singular( 'post' ) )
return;
genesis_widget_area( 'after-post', array(
'before' => '<div class="after-post widget-area">',
) );
}/** Add the before comments section */
add_action( 'genesis_before_comments', 'nabm_add_newsletter_box' );
function nabm_add_before_comments() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'before_comments', array(
'before' => '<div id="comments">',
'after' => '</"after-post widget-area">'
) );
}/** Add support for 3-column footer widgets */
add_theme_support( 'genesis-footer-widgets', 3 );/** Register widget areas */
genesis_register_sidebar( array('id' => 'newsletter',
'name' => __( 'Newsletter', 'streamline' ),
'description' => __( 'This is the newsletter section below the navigation.', 'streamline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-1',
'name' => __( 'Home Featured #1', 'streamline' ),
'description' => __( 'This is the featured #1 column on the homepage.', 'streamline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-2',
'name' => __( 'Home Featured #2', 'streamline' ),
'description' => __( 'This is the featured #2 column on the homepage.', 'streamline' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-3',
'name' => __( 'Home Featured #3', 'streamline' ),
'description' => __( 'This is the featured #3 column on the homepage.', 'streamline' ),
) );
genesis_register_sidebar( array(
'id' => 'after-post',
'name' => __( 'After Post', 'streamline' ),
'description' => __( 'This is the after post section.', 'streamline' ),
) );/** Load Lora and Oswald Google fonts
add_action( 'wp_enqueue_scripts', 'custom_load_google_fonts' );
function custom_load_google_fonts() {
wp_enqueue_style( 'google-font', 'http://fonts.googleapis.com/css?family=Lora);', array(), PARENT_THEME_VERSION );
}/** Moving Your Primary Navigation before Header **/
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_header', 'genesis_do_nav' );/** Read More changed to Continue Reading... **/
add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
function child_read_more_link() {
return 'Continue Reading...';}
add_filter( 'genesis_nav_items', 'sws_social_icons', 10, 2 );
add_filter( 'wp_nav_menu_items', 'sws_social_icons', 10, 2 );function sws_social_icons($menu, $args) {
$args = (array)$args;
if ( 'primary' !== $args['theme_location'] )
return $menu;
ob_start();
dynamic_sidebar('Social Menu');
$social = ob_get_clean();
return $menu . $social;
}if ( function_exists( ‘add_theme_support’ ) )
add_theme_support( ‘post-thumbnails’ );
/** MANUAL EXCEPRTS FOR RSS FEED... **/
function excerpt_read_more_link($output) {
global $post;
return $output . 'ID) . '"> Read More...';
}December 11, 2013 at 12:02 pm #78362nutsandboltsMemberYou need to register the widget area and make sure the names in the function match. Try these:
/** Add the before comments section */ add_action( ‘genesis_before_comments’, ‘nabm_add_extra_widget’ ); function nabm_add_extra_widget() { if ( is_singular( ‘post’ ) ) genesis_widget_area( ‘before-comments’, array( ‘before’ => ‘<div id=”before-comments”>’, ‘after’ => ‘</div”>’ ) ); }
genesis_register_sidebar( array( ‘id’ => ‘before-comments’, ‘name’ => __( ‘Before Comments, ‘streamline’ ), ‘description’ => __( ‘This is the second after post section.’, ‘streamline’ ), ) );
Then use #before-comments for your CSS.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 12:14 pm #78364ludvigMemberAlright, there we go, now the widget area is visible and "insertable".
But it still doesn't do anything when I put in the widgets into the widget area.
Any idea why?Do I need to use genesis sidebars or something?
Thanks for helping me so far Andrea!
December 11, 2013 at 12:44 pm #78377nutsandboltsMemberTry replacing the function with this one:
/** Add the before comments section */ add_action( ‘genesis_before_comments’, ‘nabm_add_extra_widget’ ); function nabm_add_extra_widget() { if ( is_singular( ‘post’ ) ) genesis_widget_area( ‘before-comments’, array( ‘before’ => ‘<div id=”before-comments”>’, ) ); }
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 12:49 pm #78379ludvigMemberNothing changed.
I can still see the widget area from the widget menu and put items into it, but it doesn't display anything.
Hmm...
I wonder why it differs. To me it looks pretty much the same as my other after post area that is working.
December 11, 2013 at 12:50 pm #78380nutsandboltsMemberIt definitely doesn't like something - the div for before-comments isn't on the page at all.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 12:57 pm #78382nutsandboltsMemberTry using the genesis_after_post_content hook to see if it at least shows up - if it's above the related posts, we can always adjust that. I'm just interested to see if it doesn't like the genesis_before_comments hook.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 1:04 pm #78385ludvigMemberIt didn't make any difference.
This is what you meant for me to put into the PHP right?
/** Add the before comments section */
add_action( ‘genesis_before_comments’, ‘nabm_add_extra_widget’ );
function nabm_add_extra_widget() {
if ( is_singular( ‘post’ ) )
genesis_widget_area( 'before_comments', array(
'before' => '<div id="genesis_after_post_content">',
) );
}December 11, 2013 at 1:06 pm #78387nutsandboltsMemberNo, sorry - I wasn't clear. Try this:
/** Add the before comments section */ add_action( ‘genesis_after_post_content’, ‘nabm_add_extra_widget’ ); function nabm_add_extra_widget() { if ( is_singular( ‘post’ ) ) genesis_widget_area( ‘before-comments’, array( ‘before’ => ‘<div id=”before-comments”>’, ) ); }
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 1:23 pm #78391ludvigMemberI changed it (correctly this time?), and here's what it looks like now in the php (+ what's above and working):
/** Add the after post section */
add_action( 'genesis_after_post_content', 'streamline_after_post' );
function streamline_after_post() {
if ( ! is_singular( 'post' ) )
return;
genesis_widget_area( 'after-post', array(
'before' => '<div class="after-post widget-area">',
) );
}/** Add the before comments section */
add_action( 'genesis_before_comments', 'nabm_add_extra_widget' );
function nabm_add_extra_widget() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'before_comments', array(
'before' => '<div id="before-comments">',
) );
}December 11, 2013 at 1:27 pm #78392nutsandboltsMemberSee my last reply - try changing the hook to see if it gets it working. I still don't see the div on the page.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 1:44 pm #78394ludvigMemberHere's what it looks like now, just like yours:
/** Add the before comments section */
add_action( 'genesis_after_post_content', 'nabm_add_extra_widget' );
function nabm_add_extra_widget() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'before_comments', array(
'before' => '<div id="before-comments">',
) );
}Still no difference...
Is there another way of creating this widget area?
I am totally lost on why this doesn't work as it seems to be the exact same as my other widget area that is working.
December 11, 2013 at 1:46 pm #78395nutsandboltsMemberSending you an email.... This has got me scratching my head.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+December 11, 2013 at 1:59 pm #78398ludvigMemberI'm not getting any emails...
Are you sending to [email protected] ?
I check my gmail as well, but no mail there either.
-
AuthorPosts
- The topic ‘Putting a subcription form after the post’ is closed to new replies.