Infinite scroll and render option
-
Hi,
After many attempts, I still haven’t been able to make that the posts uploaded by him don’t have the default template of the Twenty Twenty theme, but a custom one.
If you click on the “Older Posts” button, you can clearly see what I mean: https://www.usualillusion.com/category/one-song-a-day/
Here’s what I did:
1) I created a child theme of Twenty Twenty
2) In the child theme, I created a filecategory-a-song-a-day.php
, to use as template of that category
3) in that file, there is this piece of code:<div class="ig-grid" id="ig-grid-infinite"> <?php if ( have_posts() ) { mytheme_infinite_scroll_loop(); }?> </div>
4) in
functions.php
(of the child theme) there is:function mytheme_infinite_scroll_loop(){ while ( have_posts() ) { the_post(); get_template_part( 'content-ig'); } } function mytheme_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'type' => 'click', 'footer_widgets' => true, 'container' => 'ig-grid-infinite', 'wrapper' => false, 'render' => 'mytheme_infinite_scroll_loop', ) ); } add_action( 'after_setup_theme', 'mytheme_infinite_scroll_init' );
5) finally, the file
content-ig.php
is:<div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <div class="ig-entry-content"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('medium_large') ?> </a> </div><!-- .entry-content --> </div><!-- .post -->
Thanks to anyone who can help me.
The page I need help with: [log in to see the link]
- The topic ‘Infinite scroll and render option’ is closed to new replies.