Reputation: 2429
I have a custom carousel that I want to show only the home page. I've placed the carousel's code a file called slider.php I can get the slider to show when I include it inside the header.php file:
<?php require('../BlueQuote/wp-content/themes/greatmag/slider.php'); ?>
But when I place it in index.php or in home.php it's not showing up on the page (for curiosity I've tried including it inside footer.php and it does show up there as well, but that's not what I need). I'm using a child theme, based on the GreatMag theme. WordPress 4.9.4 and PHP 7 with XAMPP on Windows 7, thanks in advance!
Upvotes: 0
Views: 294
Reputation: 545
I tried to debug this theme and found the following.
Header.php will force this to show on every page that uses a header (so this won't work), and index.php is a generic template file and is used to display a page when nothing more specific matches a query (so this won't work too).
So you have to edit only home.php file. Add this code after the php function and right before the content area div. This is a snippet of the part:
/.../
} else {
$cols = 'col-md-8';
}
?>
<!-- This is where your code starts -->
<?php require('../BlueQuote/wp-content/themes/greatmag/slider.php'); ?>
<!--- This is where your code ends -->
<div id="primary" class="content-area <?php echo $cols; ?>">
<main id="main" class="site-main">
<?php
if ( have_posts() ) : ?>
<div class="<?php greatmag_blog_layout(); ?>">
<?php greatmag_grid_sizer(); ?>
/.../
This should do the trick, because you were trying to add code to a wrong part.
Upvotes: 1