Pro - Customizing Single Posts

I recently migrated from X Theme to Pro and everything seemed to transfer over properly with the exception of some customization that was made to the single post template. I had worked with your team to modify it so that a full-width Slider Revolution would appear above_ the post content.

Below are the two changes that were made:

  1. Location: Pro Child Theme - functions.php

add_action(‘x_before_view_renew__landmark-header’, ‘custom_blog_header01’);
function custom_blog_header01(){
if (is_single()) {
echo do_shortcode(’[rev_slider alias=“POST-Header”]’);
}
}

  1. Location: Pro Child Theme \framework\views\renew\wp-single.php
<?php // ============================================================================= // VIEWS/RENEW/WP-SINGLE.PHP // ----------------------------------------------------------------------------- // Single post output for Renew. // ============================================================================= $fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true ); get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php x_get_view( 'renew', 'content', get_post_format() ); ?>
<?php x_get_view( 'global', '_comments-template' ); ?>
<?php endwhile; ?>
<?php if ( $fullwidth != 'on' ) : ?> <?php get_sidebar(); ?> <?php endif; ?>
<?php get_footer(); ?>

Any help or suggestions would be greatly appreciated to get this working again. Thanks!

Hello ComDoc,

Thank you for writing in!

Please be advised that this line will only work if you are using the default header of Pro theme:

add_action('x_before_view_renew__landmark-header', 'custom_blog_header01');

If ever you have created a custom header and have used the custom header globally, you may need to add this line:

add_action('x_after_masthead_end', 'custom_blog_header01');

You may have this:

add_action('x_before_view_renew__landmark-header', 'custom_blog_header01');
add_action('x_after_masthead_end', 'custom_blog_header01');
function custom_blog_header01(){
	if (is_single()) {
		echo do_shortcode('[rev_slider alias="POST-Header"]');
	}
}

Having those two lines will make sure that the code will work on pages using the default header or with a custom header.

Hope this helps. Please let us know how it goes.

Thanks, @RueNel!

That did it!

You’re most welcome, @comdoc-marketing.

@jade and @RueNel,

I may have spoke a little too soon!

That definitely made the header re-appear, but it’s not showing on WooCommerce product pages. Any idea on how to have it show on just blog posts?

Hi @comdoc-marketing,

I’ve just tested the code provided and it works on my end, with or without a custom header.

If you only want to show the Slider on a Blog Posts, please update this line:

if (is_single()) {

to this:
if( is_singular('post') ){
Wordpress - is_singular()

Remember to clear all your caching features (plugin, server-side, CDN, and browser’s cache) after updating so the changes will take effect immediately. This will help you to avoid any potential errors.

Thanks,

@friech, looks good! Thanks so much!

For future reference, if I wanted to target WooCommerce product pages, I would replace ‘post’ with ‘product’, right?

Hi @comdoc-marketing,

For that, you can use is_product() which comes with Woocommerce:

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.