I have been reading in the codex about the read more issue. It says when using the_excerpt, the character limit is 55 and then the read more should display which should look like this […]
I am not seeing that in my excerpt. I have also tried several filters for testing.
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function new_excerpt_more( $more ) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '">Read the full article…</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
Neither of them work. I found that if I post the information in the content and use the more button which makes the <!--more-->
then I see a link for the more button. I don’t want to have to push that every time. So I looked up some posts on here but didn’t find anything that helped. So I was wondering if I am doing something wrong in my query.
// The Query
$the_query = new WP_Query( array( 'category_name' => 'news', 'order' => 'ASC'));
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
global $more;
$more = 0;
?><li><?php
if ( has_post_thumbnail() ) {
?><figure><?php the_post_thumbnail('news'); ?></figure>
<?php } ?>
<!----------/ TITLE /---------->
<em><?php the_title(); ?></em>
<!----------/ DATE /---------->
<strong><?php the_date(); ?></strong>
<!----------/ PARAGRAPH /---------->
<?php if( has_excerpt()){
the_excerpt();
} else {
the_content('Read More');
} ?>
<!----------/ BUTTON /---------->
</li>
<?php
endwhile;
// Restore original Query & Post Data
wp_reset_query();
wp_reset_postdata(); ?>
All my research says that the filters should work or adding stuff into the content should work. Things like:
the_content( 'Read More' );
Is there something I am missing? I want to get the excerpt working so that I can limit the word count and automatically insert the read more link.
I think
if( has_excerpt())
return false that’s way its return full content remove condition and only usethe_excerpt()
then it will work.I have another solution that i use 🙂
this function returns 10 words of post. after echoing content you can add button code like
now you cant’t use
<!--more-->