Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research avoiding overruling the global $post in get_exerpt #122

Open
rianrietveld opened this issue Jun 26, 2018 · 3 comments
Open

Research avoiding overruling the global $post in get_exerpt #122

rianrietveld opened this issue Jun 26, 2018 · 3 comments

Comments

@rianrietveld
Copy link

Research other way to retrieve the excerpt without overruling the global $post in Clarkson_Object.php in the function get_excerpt.
See also https://developer.wordpress.org/reference/functions/get_the_excerpt/#comment-2457

@jmslbam
Copy link
Contributor

jmslbam commented Jun 27, 2018

Looking at the code, maybe we should just copy the code from WP? We didn't want to do the at first, because we would have to monitor the inner workings of this WP function and sync it when it has changes.

This may be the only code needed, but it should be thoroughly tested, because previous versions of this function broke a bunch of sites.

    $post = $this->_post->post_excerpt;
    if ( post_password_required( $post ) ) {
        return __( 'There is no excerpt because this is a protected post.' );
    }
    return apply_filters( 'the_excerpt', $post, $post );
    // should we also apply get_the_excerpt filter?

It may even have happend that we tried the above code, but we ask @MarcZijderveld or @NielsdeBlaauw if they did so.

@NielsdeBlaauw
Copy link
Member

@jmslbam The problem with the copy is that when $this->_post->post_excerpt is empty or null, WordPress takes the post_content of the current global $post. This is fine in the while(have_posts()) loop, but does not work for our use case. We want to have the excerpt of a post we specify, instead of the global one (or hope the post_excerpt is not empty).

@NielsdeBlaauw
Copy link
Member

This was originally added because of #89

@NielsdeBlaauw NielsdeBlaauw added this to the 0.next milestone Sep 10, 2019
@NielsdeBlaauw NielsdeBlaauw removed this from the 0.next milestone Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants