How to insert code snippet after slider in PRO

Hello, we are trying to insert some code right after the slide rendering ends in PRO (It’s a call to action with links ).

I have researched here in the forums, but every solution i found had no result in my case.

We have PRO, and are using PRO header and footer + revslider.

We are using the following PHP in the child theme functions.php file:

   function dmc_slider_cta_func() { ?>

  <h1>Hey it works!</h1>

<? }

add_action( 'x_after_view_global__slider-below', 'dmc_slider_cta_func', 10 );

But it outputs nothing.

If you look at the image below you will see the call to action inserted into the page content, the white and red call to action should be rendered right after the slider and before content margins/padding ecc. This is the reason we are trying to use the theme hooks to insert the HTML.

thank you.

One other thing, the call to action is supposed to appear only when a revslider slider/revslider hero is present.

Hello Brigham,

Thank for writing in!

Your code will only work if you are using the default header. If you ever added a custom header, you will use this code instead:

function dmc_slider_cta_func() { ?>

  <h1>Hey it works!</h1>

<? }

add_action( 'x_after_masthead_end', 'dmc_slider_cta_func', 10 );

We would love to know if this has worked for you. Thank you.

Unfortunately, this also doesn’t output anything. On any page.

Hey Brigham,

Your server might be ignoring PHP code using the shorthand method <? which is the reason why you don’t see the result. It’s possible that it’s also due to caching. I tested the standard which is <?php and the code works.

That will output the HTML above the slider though so that is not the correct solution. We’re sorry about that.

There are 2 correct solutions for this. I’ll start with the simple one since you’re using Pro. You can output the slider inside the Pro header by inserting the slider’s shortcode in a Content Area element. Here’s a video showing an example: https://www.youtube.com/watch?v=OBy5TKtpfEk

The other solution which requires theme customization is to copy the _slider-below.php file inside the \framework\views\global directory in the parent theme to the same folder structure in your child theme. For example, if you already have \framework\views in your child theme, create a folder called global then paste the copied file in that folder. For more details about customizing our themes, please see our customization guide at https://theme.co/apex/forum/t/customizations-best-practices/205

Once that is accomplished, edit the copied file and add your custom HTML below the slider output or markup. Preferably after the closing </div> like in the screenshot below.

That should work when followed correctly. See result screenshot below.

Regarding the second solution, please just note that our intention here is to help you get started if you wish to customize our themes. Fixing issues arising from custom code nor enhancing custom code is not a part of our product support. With that said, if you encounter issues using the 2nd method, please use the first one or you could consult a third-party developer to fix the custom code.

Hope that helps.

Great help!

That PHP opening tag tip was awesome, and that was the reason nothing was happening!

Il will use the second method, using a custom hook to modify the template.

Nice support, really appreciated!

You’re most welcome, Brigham. :slight_smile:

So i copied the template _slider-below.php to the child theme, taking care to place it in the right folder, as you asked.

Inside the copied template, after the slider shortcode i used:

<?php echo do_shortcode( x_get_slider_shortcode( $slider ) ); ?>
  </div>


  <?php x_get_view( 'global', '_dmc_cta_below_slider' ); ?>


<?php endif;

then i added a file called “_dmc_cta_below_slider.php” file alongside the copied template file, so that i could use “x_get_view” function with it.

Now i can run any code inside that new file i created, and it uses the Slider logic to determine if it shows or not.

Thanks for your help!

We’re glad you now know how to add your own template.

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