Home>Support>Post Excerpt Read More Issue with Page Builder

Post Excerpt Read More Issue with Page Builder

Hi. I’ve come across a possible ‘issue’ with the excerpt when using PB. Basically, I have a custom loop in a static front page that is pulling specific post excerpts. I think I’ve narrowed it down to the page builder editor that is applied in each post of I have. The excerpt does output on the front page but the ‘read more’ does not link to the post. It just links to root/front page. I’m using the excerpt generation method.

If I remove the page builder editor and use WP’s standard visual/text editor on each post the read more links work on the excerpt. Here is what I have:

front-page.php

array( 1015, 1109, 1340, 1000, 735, 1422));
$query = new WP_Query( $args ); ?>

have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

<a href="”>

<a href="”>

In my functions.php I have:

function new_excerpt_more($more) {
global $post;
return ‘…ID) . ‘”>Read More »‘;
}
add_filter(‘excerpt_more’, ‘new_excerpt_more’);

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 9 months ago Lance

    Whoops Im sorry about the code up top. Hopefully this works. LOL I wish there was a preview. ;)

    
     <?php $args  = array ('post__in' => array( 1015, 1109, 1340, 1000, 735, 1422));
    	    $query = new WP_Query( $args ); ?>
    	
    	<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
    	<?php if ( has_post_thumbnail() ) : ?>
    	<div class="front-post-container">
    		<div class="front-post">
    			<div class="front-thumb">
    				<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail();?></a>
    			</div>
    			<?php endif ; ?>
    			<div class="front-post-content">
    				<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    				<?php the_excerpt(); ?>
    			</div>
    		</div>
    	</div>
    	
    	<?php endwhile; else : ?>
    	<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
    
    
    	<?php endif; ?>
    

    in my functions.php I have:

    
    function new_excerpt_more($more) {
    
        return '...<a class="readmore" href="'. get_permalink($post->ID) . '">Read More »</a>
    
    ';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    
    
    
  2. 7 years, 9 months ago Lance

    Hmm…ok So Im back, I reworked my code on the front page to just use the standard WP loop and added The Post Loop widget on the post. Just a quick observation, it works but for some reason its not pulling in the post thumbnail. Will check back with update. I probably set this up totally wrong.

  3. 7 years, 9 months ago Lance

    Ok. So I managed to get this working. Here is what I did, if anyone is interested. Use at your discretion.

    So when you use the post loop widget, you have the option to use another template-part of your choice. I made a custom one with different html tags for a dif layout. Thumbnail left and teaser/excerpt right. From within the post loop build query you can select whatever posts you want. Im sure at some point someone will want to break that loop but for now it works.

    Though, the readmore filter excerpt is no longer working from the function. It displays (more…) which is something I dont want. I need it to be ‘Read More’ I’ll be back with an update.

    front-page.php

    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    		<?php get_template_part( 'template-parts/content', 'page' );?>
    	<?php endwhile; else : ?>
    	<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
    
    
    	<?php endif; ?>
    

    content-front-page.php

    <div class="front-post-container">
    		<div class="front-post">
    			<div class="front-thumb">
    				<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail();?></a>
    			</div>
    		
    			<div class="front-post-content">
    						<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
          					<?php the_content();?>
          		</div>
    	</div>
    </div>
    
    
    
    
  4. 7 years, 9 months ago Lance

    Ok. So Im thinking I still have a lot to learn about the excerpts within WP. :P All I had to do is change the way i was doing the excerpts. From generated to manual with the more button, which is fine. I swapped out the_excerpt to the_content and added this into the functions.php file and all is good.

    
    //Using the content more....this will change (more..) to Read More
    
    function modify_read_more_link() {
        return '<a class="readmore more-link" href="' . get_permalink() . '"> Read More »</a>
    
    ';
    }
    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    
    
    
Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More