Is there a way to define the "slider above masthead" in functions.php?

I’m using the Toolset plugin (Types & Views) to create a custom post type in my site. However, when the single-view version of the custom post type is generated dynamically, the page created doesn’t contain the Slider Above the Masthead, which breaks the layout of my theme. Is there a way to define the Slider Above Masthead using functions.php in order to get it display on the custom post type’s pages (as well as other pages, such as taxonomy index pages)?

Thanks!

Hello @tdzl,

Thank you for the very detailed posts. The Slider Above Masthead is meta box option which is only available to the pages. You can add a custom slider in your custom post types with the help of a custom php code and a slider shortcode. Assuming the child theme is set up, please add the following code in your child theme’s functions.php file

// Add custom content above the masthead
// =============================================================================
function custom_content_above_masthead() { ?>
  <?php if ( is_home() || is_archive() || is_single() || is_search() ) : ?>
    <div class="custom-shortcode">
      <?php echo do_shortcode('[rev_slider alias="name"]'); ?>
    </div>
  <?php endif; ?>
<?php }
add_action('x_after_view_global__slider-above', 'custom_content_above_masthead');
// =============================================================================

Just make sure to change the [rev_slider] so that it displays the correct slider. The slider will display in blog index, archive pages, single posts and search page. You can remove or add your own condition so that the slider will only display in your custom post type pages.

Hope this helps.

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