Hi Greg,
Sure thing.
The easiest (and sure-fire) way to do this would be to wrap the form you add to the end of all your posts in another element, so we can then target this element in our CSS selector.
function mytheme_add_signup_form_to_posts( $content ) {
if ( is_single() && get_post_type() == 'post' ) {
$content .= '<div class="end-of-post-optin">'. mc4wp_get_form() . '</div>';
}
return $content;
}
add_filter( 'the_content', 'mytheme_add_signup_form_to_posts' );
(based on: add MailChimp sign-up form to end of all posts)
Then, to add a black background to just this form, we can use the following CSS rule.
.end-of-post-optin .mc4wp-form {
background: black;
color: white;
padding:25px;
text-align:center;
}
Hope that helps! If you have a quick minute, a plugin review here on WP.org would make me really happy.
Worked perfectly! Thanks Danny.
How can I get a title to the black box under the single posts only. I want the title to say, “Get Updates! Keep Growing!” in a slightly bigger font then the text. I just don’t want the title in the black box under the post to disturb what I have going on the sidebar. Hope this makes sense.
Thanks Again!
Greg
Hi Greg,
You can upgrade to MailChimp for WP Pro which lets you create multiple forms. This way, you can create short and more extensive forms or alter the text in the various forms you show throughout your website.
If you’re not afraid of adding code to your theme its functions.php
file, you can also add the title programmatically.
function mytheme_add_signup_form_to_posts( $content ) {
if ( is_single() && get_post_type() == 'post' ) {
$content .= '<div class="end-of-post-optin">';
$content .= '<h3>Get Updates! Keep Growing!</h3>';
$content .= mc4wp_get_form();
$content .= '</div>';
}
return $content;
}
add_filter( 'the_content', 'mytheme_add_signup_form_to_posts' );
This approach is a little less flexible but I suppose it does the trick. 🙂
Danny,
I forgot to mention…I wanted the title inside the box right above the paragraph like this.
http://www.briangardner.com/bleed-all-over-your-blog/ Title: Email Newsletter
My Title will say: Get Updates! Keep Growing!
I just don’t want the title in the black box to impact the sidebar at all.
Hope this makes sense.
Sorry for the confusion.
Thanks – Greg
Hi Greg,
Yes, I understood. You can do that with the example I showed you or by upgrading to Pro and then creating two different forms, one for the sidebar and one for at the end of your posts.
Hope that helps!
Danny,
Oh, ok. Great. I will upgrade to Pro. 🙂
Thanks Again!
Greg