[Resolved] Remove words Read More when post length exceeds limit

Home Forums Support [Resolved] Remove words Read More when post length exceeds limit

Home Forums Support Remove words Read More when post length exceeds limit

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #881034
    Steig

    Hello,

    On the post archive page, which is my home page, I have the content type set to excerpt with 20 word count.

    When the words exceed this figure, three dots and then the words Read more are appended.

    Can the hyperlink for “read more” be removed?

    In fact, what I’d like is for the entire post excerpt to be clickable. Right now just the post title is. That is done through PHP in the content.php file

    <?php
    /**
     * The template for displaying posts within the loop.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
    	<div class="inside-article">
    		<?php
    		/**
    		 * generate_before_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_featured_page_header_inside_single - 10
    		 */
    		do_action( 'generate_before_content' );
    		?>
    
    		<header class="entry-header">
    			<?php
    			/**
    			 * generate_before_entry_title hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_entry_title' );
    
    			the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
    
    			/**
    			 * generate_after_entry_title hook.
    			 *
    			 * @since 0.1
    			 *
    			 * @hooked generate_post_meta - 10
    			 */
    			do_action( 'generate_after_entry_title' );
    			?>
    		</header><!-- .entry-header -->
    
    		<?php
    		/**
    		 * generate_after_entry_header hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_post_image - 10
    		 */
    		do_action( 'generate_after_entry_header' );
    
    		if ( generate_show_excerpt() ) : ?>
    
    			<div class="entry-summary" itemprop="text">
    				<?php the_excerpt(); ?>
    			</div><!-- .entry-summary -->
    
    		<?php else : ?>
    
    			<div class="entry-content" itemprop="text">
    				<?php
    				the_content();
    
    				wp_link_pages( array(
    					'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
    					'after'  => '</div>',
    				) );
    				?>
    			</div><!-- .entry-content -->
    
    		<?php endif;
    
    		/**
    		 * generate_after_entry_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_footer_meta - 10
    		 */
    		do_action( 'generate_after_entry_content' );
    
    		/**
    		 * generate_after_content hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_after_content' );
    		?>
    	</div><!-- .inside-article -->
    </article><!-- #post-## -->
    

    Could you tell me how to make the entire excerpt clickable so I can trigger this popup?

    Thanks

    GeneratePress 2.2.2
    GP Premium 1.8.1
    #881091
    Leo
    Staff
    Customer Support

    Hi there,

    Have you tried using the customizer option to remove the read more tag?
    https://docs.generatepress.com/article/blog-content-layout/

    As to make the excerpt clickable, this might help:
    https://generatepress.com/forums/topic/how-to-link-excerpt-field-to-post/#post-789097

    #881338
    Steig

    I’ve edited the footer.php file as follows. I get an error message on line 44, which is the row where <script> is

    <?php
    /**
     * The template for displaying the footer.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    ?>
    
    	</div><!-- #content -->
    </div><!-- #page -->
    
    <?php
    /**
     * generate_before_footer hook.
     *
     * @since 0.1
     */
    do_action( 'generate_before_footer' );
    ?>
    
    <div <?php generate_do_element_classes( 'footer' ); ?>>
    	<?php
    	/**
    	 * generate_before_footer_content hook.
    	 *
    	 * @since 0.1
    	 */
    	do_action( 'generate_before_footer_content' );
    
    	/**
    	 * generate_footer hook.
    	 *
    	 * @since 1.3.42
    	 *
    	 * @hooked generate_construct_footer_widgets - 5
    	 * @hooked generate_construct_footer - 10
    	 */
    	do_action( 'generate_footer' );
    
    <script>
    jQuery( document ).ready( function($) {
        var body = $( 'body' );
        if ( body.hasClass( 'blog' ) || body.hasClass( 'archive' ) ) {
            $( '.type-post' ).on( 'click', function() {
                var link = $( this ).find( '.entry-title a' ).attr( 'href' );
                if ( link ) {
                    window.location = link;
                }
            } );
        }
    } );
    </script>
    
    	/**
    	 * generate_after_footer_content hook.
    	 *
    	 * @since 0.1
    	 */
    	do_action( 'generate_after_footer_content' );
    	?>
    </div><!-- .site-footer -->
    
    <?php
    /**
     * generate_after_footer hook.
     *
     * @since 2.1
     */
    do_action( 'generate_after_footer' );
    
    wp_footer();
    ?>
    
    </body>
    </html>
    #881516
    Tom
    Lead Developer
    Lead Developer

    Instead of adding that script to the footer file, use a Hook Element:

    1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
    2. Set the hook to wp_footer
    3. Add your script into the content area

    Let me know ๐Ÿ™‚

    #881525
    Steig

    My goal has been to make the entire excerpt clickable so it launches a pop up.

    I had placed a call in the content.php file that did that for the post title only:

    <header class="entry-header">
    			<?php
    			/**
    			 * generate_before_entry_title hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_entry_title' );
    
    			the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
    
    			/**
    			 * generate_after_entry_title hook.
    			 *
    			 * @since 0.1
    			 *
    			 * @hooked generate_post_meta - 10
    			 */
    			do_action( 'generate_after_entry_title' );
    			?>
    		</header>

    the relevant call is <a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>

    Could that be inserted into this wp-footer hook somehow to make the entire excerpt call this popup?

    #881770
    Tom
    Lead Developer
    Lead Developer

    It depends on how the popup is initiated. If it’s initiated via javascript, it might be possible to initiate it when clicking the entire area instead of the sg-iframe-popup-133 element. However, you’d need to bring this up with the popup plugin developer to know for sure.

    #882112
    Steig

    One thing I’ve noticed is that while the post excerpt does appear to be a single clickable area now, clicking it doesn’t do anything. I would assume it would at least take the view to the post detail page.

    I removed the content.php code that caused a click to the post title to launch the popup just to see if that was causing a conflict and now a click to the post title simply now moves to the detailed post page.

    How can clicking the entire excerpt container produce the same behavior?

    #882371
    Tom
    Lead Developer
    Lead Developer

    Did you add the script to your site as well?: https://generatepress.com/forums/topic/making-blog-post-container-clickable/#post-602864

    I’m not seeing it in your source.

    Let me know ๐Ÿ™‚

    #882464
    Steig

    I do have that added into the Simple CSS window:

    /* excerpt container is clickable with wp footer javascript */
    .blog .type-post, 
    .archive .type-post {
        cursor: pointer;
    }

    When I mouse over the blog excerpt, I do have a the hand pointer cursor, but it doesn’t click to anywhere, except on the title only.

    #882574
    Tom
    Lead Developer
    Lead Developer

    You need the other part of the code as well:

    1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
    2. Set the hook to wp_footer
    3. Add this code as the content:

    <script>
    jQuery( document ).ready( function($) {
        var body = $( 'body' );
        if ( body.hasClass( 'blog' ) || body.hasClass( 'archive' ) ) {
            $( '.type-post' ).on( 'click', function() {
                var link = $( this ).find( '.entry-title a' ).attr( 'href' );
                if ( link ) {
                    window.location = link;
                }
            } );
        }
    } );
    </script>

    Then set the Display Rules.

    #882589
    Steig

    I do have that Hook element created, but realized I didn’t have a display rule set. I tried post archive and also just post and neither caused the desired effect.

    #882595
    David
    Staff
    Customer Support

    Try setting your display rule to Front Page

    #882618
    Steig

    super; thank you!

    #883000
    David
    Staff
    Customer Support

    Glad we could be of help.

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