-
AuthorPosts
-
July 2, 2017 at 7:42 pm #815594
Hello,
I would like to have a Newsletter subscription box displayed at the end of every article of my blog http://www.th-photography.net.
I use the plugin Email Subscribers and the plugin has the following code for such a box:
<?php es_subbox($namefield = “YES”, $desc = “”, $group = “Public”); ?>Where do i have to add this code, that it is displayed automatically under every article (but not for pages)?
If possible i would like to have it at the position after “You may also be interested in” and before the comments of the article.Thanks a lot!
TorstenJuly 3, 2017 at 4:13 am #815699Hey th-photography,
If you want a quick, easy and reliable solution take a look at https://wp-buddy.com/products/plugins/content-posts-wordpress-plugin/
If you want a native solution you can use e.g. the enfold action hook ‘ava_before_footer’ in a child theme.
Best regards,
Jordan ShannonJuly 4, 2017 at 8:17 pm #816471Hello,
thanks for your reply.
How can i do the native version?
I have the following codes:<?php es_subbox($namefield = “YES”, $desc = “Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!”, $group = “Public”); ?>
or:
[email-subscribers namefield=”NO” desc=”Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!” group=”Public”]
Thanks,
TorstenJuly 4, 2017 at 8:43 pm #816474Hi,
Try the adding the following to the bottom of functions.php:
add_action('ava_before_footer', 'ava_before_footer_mod', 10); function ava_before_footer_mod() { echo do_shortcode("[email-subscribers namefield=”NO” desc=”Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!” group=”Public”]"); }
If this generates correctly then we can work on hiding it where its not needed.
Best regards,
Jordan ShannonJuly 4, 2017 at 9:22 pm #816500Hello,
thanks for your reply.
It did not work fully correct. Only the first word of the sentence is visible….
See here: https://www.th-photography.net/wp-content/uploads/2017/07/newsletter.jpeg
July 4, 2017 at 9:32 pm #816503Hi,
Replace with this. I think the quotes were the issue:
add_action('ava_before_footer', 'ava_before_footer_mod', 10); function ava_before_footer_mod() { echo do_shortcode("[email-subscribers namefield="NO" desc="Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!" group="Public"]"); }
Best regards,
Jordan ShannonJuly 4, 2017 at 10:08 pm #816507No sorry, with that i only get the famous “white page”. So there must be an error.
July 4, 2017 at 10:22 pm #816511Hi,
This should fix it. I have tested it on my own machine:
add_action('ava_before_footer', 'ava_before_footer_mod', 10); function ava_before_footer_mod() { echo do_shortcode("[email-subscribers namefield=”NO” desc=\"Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!\" group=”Public”]"); }
Best regards,
Jordan ShannonJuly 4, 2017 at 10:43 pm #816519Ok the text is there.
But the box spans over the hole width of the blog (main page and sidebar) and not on the main page only.
See here: https://www.th-photography.net/wp-content/uploads/2017/07/newsletter2.jpegIs it also possible, to have a header over the displayed text line and a small frame around the whole added content?
Header: E-Mail BenachrichtigungThanks
- This reply was modified 7 years, 5 months ago by th-photography.
July 4, 2017 at 10:47 pm #816522Hi,
So this just needs to be on the homepage?
Best regards,
Jordan ShannonJuly 4, 2017 at 10:52 pm #816524Hello,
no i only whant to have it the articles. Also not on pages, only in the blog posts.
July 4, 2017 at 11:17 pm #816530Hi,
I see. So then remove the code from functions.php and place in single.php directly after:
<!--end content--> </main>
The code will now have to be wrapped in php tags like this:
<?php add_action('ava_before_footer', 'ava_before_footer_mod', 10); function ava_before_footer_mod() { echo do_shortcode("[email-subscribers namefield=”NO” desc=\"Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!\" group=”Public”]"); } ?>
To style this thing up a bit more add this to quick css:
.es_shortcode_form{ width: 900px; margin: 10px 180px; border: 1px solid black; padding: 20px; }
Best regards,
Jordan ShannonJuly 5, 2017 at 8:42 pm #816880Hello, i added the code to the single.php of the single.php (it is only available in the enfold main theme).
But it looks like before for the functions.php.
See here: https://www.th-photography.net/wp-content/uploads/2017/07/newsletter3.jpegHere also the code in the single.php:
<?php if ( !defined('ABSPATH') ){ die(); } global $avia_config; /* * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory. */ get_header(); $title = __('Blog - Latest News', 'avia_framework'); //default blog title $t_link = home_url('/'); $t_sub = ""; if(avia_get_option('frontpage') && $new = avia_get_option('blogpage')) { $title = get_the_title($new); //if the blog is attached to a page use this title $t_link = get_permalink($new); $t_sub = avia_post_meta($new, 'subtitle'); } if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(array('heading'=>'strong', 'title' => $title, 'link' => $t_link, 'subtitle' => $t_sub)); do_action( 'ava_after_main_title' ); ?> <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'> <div class='container template-blog template-single-blog '> <main class='content units <?php avia_layout_class( 'content' ); ?> <?php echo avia_blog_class_string(); ?>' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>> <?php /* Run the loop to output the posts. * If you want to overload this in a child theme then include a file * called loop-index.php and that will be used instead. * */ get_template_part( 'includes/loop', 'index' ); //show related posts based on tags if there are any get_template_part( 'includes/related-posts'); //wordpress function that loads the comments template "comments.php" comments_template(); ?> <!--end content--> </main> <?php add_action('ava_before_footer', 'ava_before_footer_mod', 10); function ava_before_footer_mod() { echo do_shortcode("[email-subscribers namefield=”NO” desc=\"Du willst künftig keinen Artikel mehr auf T.H. Photography verpassen? Dann trag dich gleich für die E-Mail Beitragsbenachrichtigung ein!\" group=”Public”]"); } ?> <?php $avia_config['currently_viewing'] = "blog"; //get the sidebar get_sidebar(); ?> </div><!--end container--> </div><!-- close default .container_wrap element --> <?php get_footer(); ?>
Is it also possible, to have a header over the displayed text line?
Header text: E-Mail BenachrichtigungThanks in advance.
July 5, 2017 at 11:27 pm #816933Hi,
Did you also add the css to style it?
Best regards,
Jordan ShannonJuly 6, 2017 at 4:49 pm #817349Hello,
when adding the css it looks like this: https://www.th-photography.net/wp-content/uploads/2017/07/newsletter4.jpeg
So it is still not in place…
Thanks,
TorstenJuly 6, 2017 at 4:54 pm #817353Hi,
Not in place as far as it being to far left? If that’s the case adjust that 180 figure on the margin. Or, is it not on the right spot on the page as far as structure?
.es_shortcode_form{ width: 900px; margin: 10px 180px; border: 1px solid black; padding: 20px; }
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.