Can't modify "Read More…" in functions.php
-
So my WordPress blog is only a small part of my personal site. As such, I create a script to output excerpts for the most recent posts on my home page. My custom Read More worked fine until I switched themes recently. Here’s what I have:
foreach ($postslist as $post) { setup_postdata($post); $excerpt = get_the_excerpt(); ?> <div class='blog-entry col-sm-4'> <a href="<?php the_permalink(); ?>"> <h3><?php the_title(); ?></h3> </a> <div class='blog-entry-text'> <?php the_excerpt(); ?> </div> <div class='blog-entry-category'> <?php //echo the_category(); outputCategories(); ?> </div> </div> <?php }
Relevant section of functions.php:
function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); function new_excerpt_more( $more ) { return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>'; } add_filter( 'excerpt_more', 'new_excerpt_more' );
Any help would be awesome!
- The topic ‘Can't modify "Read More…" in functions.php’ is closed to new replies.