Automattic / Automattic/jetpack

Content Options: apply_filters issue

Open
#7,153 5 comments 0 reactions 0 assignees View on GitHub
[Feature] Theme Tools [Pri] Low [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Hello,
I am having some issues with the Content Options module.

#### Steps to reproduce the issue

I am using this code to display Posts Page content (page title and page content) in the Blog static page:

```
$current_post = get_post( get_option( 'page_for_posts' ) );

// Print HTML with the title for blog page.
if ( '' != $current_post->post_title ) {
printf( '

%s

', apply_filters( 'the_title', $current_post->post_title ) );
}

// Print HTML with the content for blog page.
if ( '' != $current_post->post_content ) {
printf( '

%s
', apply_filters( 'the_content', $current_post->post_content ) );
}
```

#### What happened

This code works fine. It displays the title and the content that was added to the static Blog page (the page that was assigned for the "Posts page" option in: Settings > Readings).

When I add support for "jetpack-content-options" then instead of the original content of the static Blog page, I am getting the content of the first blog post.

Example of "jetpack-content-options" support:

```
add_theme_support( 'jetpack-content-options', array(
'blog-display' => 'content',
'author-bio' => true,
'author-bio-default' => false,
'masonry' => '',
) );
```
The reason why I think the issue is caused by apply_filters is because it works fine when I remove apply_filters from the code:

```
// Print HTML with the content for blog page.
if ( '' != $current_post->post_content ) {
printf( '

%s
', $current_post->post_content );
}
```

Do you know why it's not working with apply_filters?

Thank you,
Taras

Contributor guide

Open the contributing guide

Research direction

Start with the Content Options module entry points handling the jetpack-content-options support and the blog-display setting, then trace how apply_filters('the_title') and apply_filters('the_content') process Posts Page content. Reproduce the provided setup with the filtered and unfiltered snippets; done means the static Blog page's title and content remain correct when Content Options support is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, content
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.