I have a custom WP_Query loop, to pull out specific posts, that is working exactly as expected. The link can be retrieved from get_permalink(), as can any content that I'm requesting including get_the_post_thumbnail and get_the_category.

However, when I am calling get_theexcerpt`, the "Continue Reading" URL for the links of some posts is being returned as the current page URL, not the URL of the post that it's supposed to link to. Other posts work just fine, and the actual content that's excerpted from the posts with defective links is also fine.

If I enter in an actual excerpt, rather that allow Wordpress to create one, the link shows up correctly. When I then remove that excerpt again, the problem returns.

All pages are made in Page Builder, and about 50% of pages are affected. Even copying the page content entirely from a working post to a defective one doesn't work, nor does the inverse break a working post.

Any ideas?

while ($the_query->have_posts())

    $coverPost .= get_the_post_thumbnail(get_the_ID(), 'medium_large'); //works

    $category = get_the_category(get_the_ID()); //works
    $coverPost .= '<h4>' . $category[0]->cat_name . '</h4>'; //works
    $coverPost .= '<h2>' . strtoupper(get_the_title()) . '</h2>'; //works
    $coverPost .= '<p>'.get_the_excerpt().'</p>'; //sometimes works

you can remove read more link by adding this filter to functions.php then add permalink to your loop

function new_excerpt_more($more) {
   global $post;
return '..';   }add_filter('excerpt_more', 'new_excerpt_more');
  • Thanks, this is actually what I've already done as a work-around, but I'd rather the actual function worked properly. I'm looking to see if the Coraline theme is the cause of this, as per the comment on the question. – JoeP Jan 13 at 13:20
  • the default has no link read more – hai_shar Jan 13 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.