• Resolved Udegbunam Chukwudi

    (@strictlyonlinebiz)


    How do I get the theme to ignore posts with read more tag and just show excerpts instead on home and archive pages? Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author ScriptsTown

    (@scriptstown)

    Hello,

    Do you want to show the full content in archive pages? You can do so in Appearance > Customize > “General Options” > “Blog Content Archive”. Set it to “Full text”.

    Or, do you want to remove the “Read More” button? You can use add_filter for this filter hook: galaxis_excerpt_more. Using a custom plugin or child theme’s functions.php, you can add this code:

    add_filter( 'galaxis_excerpt_more', function( $more ) ) {
    	$more = ' [...]';
    
    	return $more;
    } 

    It has a read more button after […] by default.

    Or, you mean to ignore the posts where you add a read more tag using the block in the editor. For this you can filter the posts before returning like this:

    add_filter( 'pre_get_posts', function( $query ) {
    	if ( is_home() || is_archive() ) {
    		$query->set( 's', '-<!--more-->' );
    	}
    
    	return $query;
    } );

    Prepending a term with a hyphen(-) will exclude posts matching that term.

    Thread Starter Udegbunam Chukwudi

    (@strictlyonlinebiz)

    @scriptstown Thanks man. I actually want the more tag to be ignored and excerpts given preference.

    I just ran search and replace on my database to remove all <!–more–> from blog posts and that seems to have worked.

    Theme Author ScriptsTown

    (@scriptstown)

    Oh! you meant to remove the actual more tag and not the posts with the more tag.

    • This reply was modified 4 years, 2 months ago by ScriptsTown.
    Thread Starter Udegbunam Chukwudi

    (@strictlyonlinebiz)

    Unfortunately I didn’t take a screenshot before I fixed this issue so let me see if I can explain clearly.

    By default, your theme shows excerpts on home, archive, category pages.

    Now the problem is if a post has a more tag in place, your theme DOES NOT show an excerpt per say. It just outputs whatever is above the more tag as the excerpt for that post.

    Your theme shows an excerpt of 50 words for posts without the more tag BUT if there’s a more tag in place, the excerpt could sometimes run into 400 words depending on where the more tag was inserted in the post.

    I hope this makes things clear. Thanks for your patience sir ??

    Theme Author ScriptsTown

    (@scriptstown)

    Yes, I get it. Thanks for explaining! That’s the intended behavior defined in this function: galaxis_show_excerpt.

    It basically allows the user to specify the exact sentence to be used (before the more tag) in place of an auto-computed excerpt.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show excerpt only’ is closed to new replies.