UPDATE:
Reverting to older PHP removed the error message, but the excerpt still didn’t work when not specifically defined for post – i.e. failed to create excerpt from post content.
FIX:
Inserting ‘setup_postdata($post);’ just before the call to ‘get_the_excerpt($post);’ seems to fix the problem, with any PHP version. (This sets up the necessary data as if the call was from within the loop, and is recommended in the WP Codex.)
Note: the excerpt problem didn’t always occur – seemed ok on a test site, but not the real one – presumably depends on the state of the global vars when the ticker is rendered.
HTH, Rick.
Hi,
I couldn’t reproduce the error but did some reading and took your advice to call setup_postdata. Please get latest version and check if this resolves your issue.
Cheers,
Paul
Thanks for the update, but it’s causing a new problem!
You’ve declared $post global, so the ticker shows the data from the current page (which is what the global $post holds), and not the specified post!
My version looks like this:
if ($options['show_excerpt'] == 'true') {
setup_postdata( $post ); // RCF added
$content .= ' - '.get_the_excerpt($post);
}
Just the commented line added – nothing else.
Cheers, Rick.
-
This reply was modified 7 years, 8 months ago by
rickfitz.
-
This reply was modified 7 years, 8 months ago by
rickfitz.
Hi,
The global thing I copied from a post on the WordPress site. Anyway, made the change as you suggest. Check the latest version again, please.
Cheers,
Paul
Looks correct to me. Can’t test immediately as I have several other mods in the file and it’s on a live site!
I’ll email separately to describe my changes and see if you’d like to merge into your plugin or whether my requirement is too different to make it worthwhile.
Many thanks for the really useful plugin and lightning fast support!
Rick.