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

Do not want excerpt to auto-generate if empty #62

Open
simonrjones opened this issue Jan 20, 2020 · 1 comment
Open

Do not want excerpt to auto-generate if empty #62

simonrjones opened this issue Jan 20, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@simonrjones
Copy link
Member

Currently {{ page.excerpt }} returns the first line of content if it is empty in WordPress. This is not desired on the template Sean is working on.

Ideally this would behave like so:

  • Output the actual content that exists (even if empty)
  • Give the user the option to auto-generate but do not make this default
    public function getExcerpt(int $limit = 200): string
    {
        if (empty($this->excerpt)) {
            return $this->trimContent($this->__toString(), $limit);
        }

        return $this->excerpt;
    }
@simonrjones simonrjones added the enhancement New feature or request label Jan 20, 2020
@simonrjones
Copy link
Member Author

One solution, which does break backward compatibility:

    public function getExcerpt(bool $generate = false, int $limit = 200): string
    {
        if (empty($this->excerpt) && $generate) {
            return $this->trimContent($this->__toString(), $limit);
        }

        return $this->excerpt;
    }

@simonrjones simonrjones modified the milestones: 0.7.0, 0.6.6 Jan 20, 2020
@simonrjones simonrjones removed this from the 0.6.6 milestone May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant