Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

read more in query loop

  • Hi friends at Generate Press,

    I use GP Query Loop on several sites (it’s great!) and also on two pages of the same website.

    On one page (https://www.biesterhof.nl/blog/) the style is pretty basic and I used the standard readmore-link – fine.

    On the front-page (https://www.biesterhof.nl/), however, I would like to use a button in the (mini-)query-loop (so far just 1 item, but more to come). I learned how to do this from your support forums (!) and have done it for a few other sites. However, this time I can’t get rid of the ‘read more…’ text at the end of the excerpt.

    I de-activated the ‘use standard more link’ in the excerpt block but that makes no difference. I also checked whether plugins are causing this but can’t locate the problem.

    I compared settings with another website I manage, where all is as it should be. But that site has only one query loop, with a custom button, while in the customizer the ‘read more’ label is left empty (not needed, the’read more’ option is used nowhere else).So there can be no conflict.

    But it made me think that it might work for my ‘problem site’ if I cleared the label in the customizer there too. (No, I shouldn’t have to do that, given there is a specific option to deactivate the default, but think of it as a workaround). Oviously this worked, irrespective whether the default is checked or left unchecked.

    However, as I had removed the customizer text/label, on the other page the links were now gone too. So I tried to get back a basic link by adding text in ‘custom more-link text’ option of the excerpt block. Then the text/link appeared in the editor – but not on the frontend.

    So what am I missing? I’ve searched the support forums and checked documentation, but can’t figure it out.

    I could leave the default customizer label empty and use buttons in both cases – that would be a pragmatic solution. But still, I’d like to know why I can’t get the recommended procedure to work.

    (Both QL’s are now again defined as I’d originally defined them, before all the experimenting.)

  • Hi there,

    To clarify, is this the Block you’re referring to?: https://share.zight.com/8LulbvKO

    Moreover, could you share admin login credentials through the Private Information field so we can investigate?

  • Thanks for the quick response Fernando.

    Yes, this is the block in case. A minor thing now, I know, but in due course it should become the central block on the site.

  • Could you try editing this code you have:

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
    	$output = $excerpt;
            $settings = wp_parse_args( 
    		get_option( 'generate_blog_settings', array() ), 
    		generate_blog_get_defaults() 
    	);
    	
    	if ( has_excerpt() ) {
    		$output = sprintf( '%1$s <a href="%2$s">%3$s</a>',
    			$excerpt,
    			get_permalink(),
                            wp_kses_post( $settings['read_more'] )
    		);
    	}
    	
    	return $output;
    }

    to:

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
    	if(is_home || is_archive()) {
    		$output = $excerpt;
    			$settings = wp_parse_args( 
    			get_option( 'generate_blog_settings', array() ), 
    			generate_blog_get_defaults() 
    		);
    
    		if ( has_excerpt() ) {
    			$output = sprintf( '%1$s <a href="%2$s">%3$s</a>',
    				$excerpt,
    				get_permalink(),
    							wp_kses_post( $settings['read_more'] )
    			);
    		}
    	}
    	
    	return $output;
    }
  • Thank you Fernando, I’m sorry but there must be some mistake in the code for the site gave a ‘critical error’ (I tried twice).

    But: this exercise has helped me understand why the ‘readmore’ so stubbornly appears whatever I do, how this snippet relates to the overall settings and why what it is doing was necessary at some point.

    But no longer, I realized. For now it is more straightforward to rely what the QL block can do, in other words, it is better to deactivate the snippet and create a custom ‘read more’ GP button whenever you need one. Then you don’t have to force WP to do what it doesn’t naturally want to do, for some obscure reason, and you have perfect control with a GP button wherever and however you want it to appear.

    So thank you for pointing me in the right direction! I understand a couple of things much better now.

  • I see. You’re welcome!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.