Skip Navigation

[Resolved] Post excerpt empty but page content loading

This thread is resolved. Here is a description of the problem and solution.

Problem: [wpv-post-excerpt] seems to output the post body content when the post excerpt field is empty. This is breaking some conditionals that rely on the value of the post excerpt field.

Solution: [wpv-post-excerpt] will fall back to display part of the post body if the post excerpt field is empty. The way to work around this is to create a custom shortcode that returns the actual value of the post excerpt field. Add this code to functions.php:

add_shortcode('wpv-post-real-excerpt', 'real_excerpt_shortcode');
function real_excerpt_shortcode() {
  global $post;
  return $post->post_excerpt;
}

Then you should be able to modify your conditional like this:

[wpv-conditional if="( '[wpv-post-real-excerpt]' ne '' )"] [wpv-post-excerpt length="230" count="character" more="..." format="noautop"][/wpv-conditional]
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Dallin Chase 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#535702

I am trying to: Load the expert when it had a value in it. But not load the post body content when it has a value and the excerpt is blank.

I visited this URL: hidden link

Instead, I got: When the excerpt is empty but there is text in the body. The body text loads.

Here is a brief video explaining the situation hidden link

Here is the code I am currently using:
[wpv-conditional if="( '[wpv-post-excerpt]' ne '' )"] [wpv-post-excerpt length="230" count="character" more="..." format="noautop"][/wpv-conditional]

#535760

Hi, as I understand it the [wpv-post-excerpt] shortcode will output the post body if you don't provide an excerpt for the post, so your conditional won't work as expected. Instead you could create your own custom shortcode that outputs the actual post excerpt value, then test that value in your conditional.

Add this code to functions.php:

add_shortcode('wpv-post-real-excerpt', 'real_excerpt_shortcode');
function real_excerpt_shortcode() {
  global $post;
  return $post->post_excerpt;
}

Then you should be able to modify your conditional like this:

 [wpv-conditional if="( '[wpv-post-real-excerpt]' ne '' )"] [wpv-post-excerpt length="230" count="character" more="..." format="noautop"][/wpv-conditional]

Let me know if this doesn't work for you.

#536745

This worked perfectly! Thank you Christian.