Ok, so originally I wanted to remove the banner, but now I just want to move it to the bottom of the page on only specific posts. Not sure how to do this. I am using slider revolution for the banner. Thank you
Hi Brian,
To achieve that, you need to update the code in your child theme.
Update this part:
function custom_content_below_masthead() { ?>
<?php if ( is_single() ) : ?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="Fitness Banner 2"]'); ?>
</div>
<?php endif; ?>
<?php }
add_action('x_after_view_global__slider-below', 'custom_content_below_masthead');
Update it to this:
$posts_silder_below = array('2500','2505'); // REV SLIDER in the bottom for specific post IDs
function custom_content_below_masthead() { ?>
<?php if ( is_single() ) : ?>
<?php
global $posts_silder_below;
if( !in_array(get_the_ID(), $posts_silder_below ) ):
?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="Fitness Banner 2"]'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php }
add_action('x_after_view_global__slider-below', 'custom_content_below_masthead');
function custom_content_before_footer() { ?>
<?php if ( is_single() ) : ?>
<?php
global $posts_silder_below;
if( in_array(get_the_ID(), $posts_silder_below ) ):
?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="Fitness Banner 2"]'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php }
add_action('x_before_site_end', 'custom_content_before_footer');
So in the $posts_silder_below
array, you need to add the ids of the specific posts there, so that the slider revolution will appear at the bottom.
If you don’t know where to find the id
of the post yet. Here’s a link that will guide you https://pagely.com/blog/find-post-id-wordpress/.
Let us know how it goes. Thanks
Worked out perfectly, Thank you very much!
You’re welcome!
We’re glad @albrechtx were able to help you out.
Actually, even though it worked, I wanted to move the banner slightly higher. As of right now it is below the comment box on desktop, and mobile there are about 10 different elements that display before this banner. I’d prefer it displays directly after the content if possible.
Here is a link to a page as an example so you can see what I mean
If you check it on mobile, you’ll see how long it takes to get to it. If I was on mobile, I would probably never see it just because I wouldn’t think to scroll down that far.
Thanks again!
Hi Brian,
In that case, please remove this block of codes:
function custom_content_before_footer() { ?>
<?php if ( is_single() ) : ?>
<?php
global $posts_silder_below;
if( in_array(get_the_ID(), $posts_silder_below ) ):
?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="Fitness Banner 2"]'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php }
add_action('x_before_site_end', 'custom_content_before_footer');
then login through FTP and go to wp-content/themes/x-child/framework/views/integrity. If any of those directories are not yet created, kindly create them manually until you get to the integrity directory then create the file wp-single.php. Edit the file and add this code:
<?php
// =============================================================================
// VIEWS/INTEGRITY/WP-SINGLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Integrity.
// =============================================================================
$fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );
$posts_silder_below = array('2500','2505'); // REV SLIDER in the bottom for specific post IDs
get_header();
?>
<div class="x-container max width offset">
<div class="<?php x_main_content_class(); ?>" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php x_get_view( 'integrity', 'content', get_post_format() ); ?>
<?php if( in_array(get_the_ID(), $posts_silder_below ) ): ?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="Fitness Banner 2"]'); ?>
</div>
<?php endif; ?>
<?php x_get_view( 'global', '_comments-template' ); ?>
<?php endwhile; ?>
</div>
<?php if ( $fullwidth != 'on' ) : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Kindly note that since this is a custom code that changes the default behavior/display of the theme, you will be responsible to maintain or update the code in case you require further changes or if the code stops working in future updates. If you are uncertain how to proceed, it would be best to get in touch with a developer.
Hope this helps.
That looks like a pain lol… I may or may not do this… but… I have another slide I created in revolution slider. It’s called “Fitness Banner 2-1”… I want to include this one on only one specific page. It’s on a page that excludes the other slide. Hopefully revolution slider can handle this. So this one I WANT just below the masthead at the top… Here is the advanced theme code rev slider gave me for a single page insert. Not sure how to incorporate this code into the theme file without messing things up…
<?php add_revslider('fitness-banner-2-1','2,10'); ?>Any help would be appreciated, thanks!
Hi Brian,
We need the page ID where you want this code to be added. Something like this that can be added on your child theme functions.php file:
function fitness_banner_2_below_masthead() { ?>
<?php if ( is_page('210') ) : ?>
<div class="custom-shortcode">
<?php add_revslider('fitness-banner-2-1','2,10'); ?>
</div>
<?php endif; ?>
<?php }
add_action('x_after_view_global__slider-below', 'fitness_banner_2_below_masthead');
On this part: is_page('210')
change 210 to your actual page ID. Note we are using is_page function.
Hope this helps.
Here is the current code I have running as of right now. I feel like the general code that was applied to keep one specific banner (fitness banner 2) from displaying at the top and only on bottom is preventing the current (fitness banner 2-1) from currently being displayed… Please let me know because this code did not work.
Hello Brian,
The fitness_banner_2_below_masthead()
function will only display Fitness Banner 2-1 in one page bearing the ID 1832
.
And the custom_content_before_footer()
function will only display Fitness Banner 2 slider in single posts that the IDs were added in $posts_silder_below = array();
. If you remove this line, no slider will be displayed.
Hope this helps.
I think?? Are you telling me the code is ok as it is then? If so, then how do I get “fitness banner 2-1” to display on page “1832”? As of right now it isn’t displaying??
Im stuck
Hello Brian,
I have logged in and changed your code into this:
function fitness_banner_2_below_masthead() { ?>
<?php if ( is_page('1832') ) : ?>
<div class="custom-shortcode">
<?php echo do_shortcode('[rev_slider alias="fitness-banner-2-1"]'); ?>
</div>
<?php endif; ?>
<?php }
add_action('x_after_view_global__slider-below', 'fitness_banner_2_below_masthead');
The slider should display right away because I have temporarily deactivated your WP Rocket plugin. As it turns out that you are using SiteGround, please clear your site cache or at least temporarily disable the supercacher in your hosting panel? The SuperCacher is developed by SiteGround exclusively for their customers. It increases the number of hits a site can handle and boosts the website loading speed. The SuperCacher includes 4 different caching options for maximum optimization of your websites. You can access the tool by clicking on the SuperCacher icon in your cPanel.
For more information about this, please check it out here: https://www.siteground.com/tutorials/supercacher/supercacher_intro.htm
And also I found out that you are using CloudFlare. Right after these site changes, please log in to your CloudFlare account and purge your site cache. You also need to regenerate the minified HTML, CSS and JS files in CloudFlare.
- https://support.cloudflare.com/hc/en-us/articles/200169246-Purging-cached-resources-from-Cloudflare
- https://support.cloudflare.com/hc/en-us/articles/200169396-Why-aren-t-changes-to-my-site-showing-
- https://support.cloudflare.com/hc/en-us/articles/200168196-How-do-I-minify-HTML-CSS-and-JavaScript-to-optimize-my-site-
Hope this helps.
I appreciate you trying, but no such luck . I started disabling plugins to see if that might be an issue. I followed the step by step instructions. Still got nothing…
Any other suggestions for diagnosing the lack of appearance?
Hi Brian,
I tried to find which page is 1832. Then found it is not a page but rather a post. So it should be is_single() function. I adjusted it and it is working now here: https://thinkhealthyfitness.com/how-to-lose-20-pounds-in-a-month/
Hope this helps.
Worked out great! I was planning on doing this with like at least 8-9 other blog posts. So, I’m glad you figured it out. Thanks again!
Glad we could help.
Cheers!
Omg, I am so sorry guys… The never-ending thread of questions lol. Ok, so now I’ve run into a new problem. On the page https://thinkhealthyfitness.com/how-to-lose-20-pounds-in-a-month/
Now parts of the banner are disappearing… It displays for roughly 10 seconds, and then all of a sudden the button and cell phone image overlay disappear. Im hoping its something simple like a setting I made in slider revolution. Not sure at this point, but I disabled my ads and wp rocket to test if it was a plug in issue, and that wasn’t the case…
Again, the help is always appreciated
Hello Brian,
I have checked the page and in the console, I am seeing JS errors. This could be coming from the plugin. Can you please test for a plugin conflict? Please deactivate all third-party plugins ONE by ONE and not just the Ad or WP Rocket, and seeing if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.
Here is the view of the console:
OK, I deactivated all plugins, cleared browser cache… Still having the same issues… So, I don’t think it’s a plugin conflict. Do you think using a cdn might have anything to do with this. Not sure where else to look to resolve the issue.
Hi Brian,
That’s a slider/layer setting, please edit your slider and “Snap” those layers (image, button, etc.) to the end of there Timeline. see the link below for more details.
https://www.themepunch.com/faq/prevent-layers-from-disappearing/
Hope it helps,
Cheers!