banner in post
-
Hi,
How to add a banner in the end in every post? I’ve tried to find a solution through edit the php files but it is not working. It appears after the comments and I want to put the banner over them.Any idea?
-
Hi keres1982. I’m assuming you modified single.php in a child theme to add your banner. If so, please post the modified file on http://pastebin.com/ and then post a link here. Thanks.
Hi!
That’s right. Here is the link http://pastebin.com/4LUE1RGs
It appears after the comments
Meaning the facebooks comments? That’s because the FB plugin is inserting an iframe after the post content. My guess is that’s controlled somewhere in the plugin configuration.
Yes, I have tried this too but without any success.
Normally, if the plugin configuration says “after the post content”, then it goes immediately after the post content, which is what you’re seeing. If the plugin configuration doesn’t give you the option to change the location then you’re probably looking at modifying the plugin code.
I understand! So my mission is impossible. Thank you for your time!
Or, you might try modifying the content with a filter to include you banner:
// Add a banner at the end of every post page add_filter( 'the_content', 'my_the_content_filter', 20 ); function my_the_content_filter( $content ) { if ( is_single() ) { $my_content = $content . ' <div align=center><a href=http://bgtrekking.com><img src=http://planinar.org/store/banners/trekking.jpg alt=trekking/></a></div>'; } return $my_content; }Yes, but this is a hard work. I am searching automated soltion.
You already have a child theme. Just add that to the functions.php file and see if it works.
Does not work. Appears after the comments and the homepage disappear.
Here’s another option you could try using jQuery:
1. Create a new folder /js in your child theme
2. Add a new text file named my-scripts.js in the /js folder
3. Copy this into my-scripts.js:// append banner to post content jQuery( document ).ready( function( $ ) { $('.single .post .entry').append($('<div align=center><a href=http://bgtrekking.com><img src=http://planinar.org/store/banners/trekking.jpg alt=trekking/></a></div>')); })4. Add this function to your child theme functions.php file to load your script:
// Load my custom scripts file add_action( 'wp_enqueue_scripts', 'load_my_scripts' ); function load_my_scripts() { wp_enqueue_script('my-custom-scripts', get_stylesheet_directory_uri() . '/js/my-scripts.js', array('jquery'),'1.0', true); }5. Remove the function I posted above.
Steps 1 to 4 are OK, but what do you mean “Remove the function” – to remove my-scripts.js, only the content, part of it, or something else?
keres1982, probably need to remove
// Add a banner at the end of every post page add_filter( 'the_content', 'my_the_content_filter', 20 ); function my_the_content_filter( $content ) { if ( is_single() ) { $my_content = $content . ' <div align=center><a href=http://bgtrekking.com><img src=http://planinar.org/store/banners/trekking.jpg alt=trekking/></a></div>'; } return $my_content; }What @s7ranger said.
No success. May I ask you to check the content of my functions.php file?
Is it OK?
The topic ‘banner in post’ is closed to new replies.
