Twentytwelve: Slider code repeats under posts
-
I needed a permanent slider above the posts on a home page. So I created the slider and inserted the following short code near the top of content.php, right after opening PHP statement and just above the post code. Here’s the first few lines (condensed):
<?php …
?>
<?php if (is_front_page()) {echo do_shortcode(“[metaslider id=40]”);}?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class=”featured-post”> …etc.Weirdly, the slider’s CSS styles show up underneath each post on the page. Somehow the slider code is getting caught up in the post loop, although the slider itself only shows up once. Its just the CSS styles (border and margin) that repeat.
I also replaced the slider code with <?php echo (“HELLO!”); ?> And sure enough, HELLO appears after each post.
PHP isn’t my thing, but I would have thought that any code inserted above the post code would only run once. Obviously I’m missing something. Advice would be greatly appreciated.
- The topic ‘Twentytwelve: Slider code repeats under posts’ is closed to new replies.