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

post-content like post-excerpt and vice-versa? #43

Open
bobbingwide opened this issue Nov 23, 2020 · 8 comments
Open

post-content like post-excerpt and vice-versa? #43

bobbingwide opened this issue Nov 23, 2020 · 8 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Nov 23, 2020

Interestingly the post-excerpt block appeared more like the post-content block and vice-versa.

Well, the post-content block appeared more like an excerpt than post content.
In order to fix this I had to change the core function get_the_content() to set $elements['more'] to true, since generate_postdata() hadn't.

Not surprisingly this didn't resolve the problem with the post-excerpt ignoring the more block.

Originally posted by @bobbingwide in #27 (comment)

Problem

core/post-content when nested in a query in another post's query-loop's core/post-content block is broken by a more block.

image

While developing my fix for the post-content infinite recursion problem, I became aware of a problem with the display of post content in the nested posts. The workaround I implemented for #27 was to eliminate the more block from the content that was being displayed.

In the above screen capture I've re-introduced the core/more block into the Aab page.
The post content should be 'Aab - excerpt before more. Aab - post content after more.'
The More link shouldn't appear.

@bobbingwide bobbingwide self-assigned this Nov 23, 2020
@bobbingwide bobbingwide added bug Something isn't working help wanted Extra attention is needed labels Nov 23, 2020
@bobbingwide
Copy link
Owner Author

While trying to create a simple test for the problem I accidentally moved a block from a dynamically displayed post out of the Post content block. This shouldn't be possible. Here the WordPress block came from the post entitled WordPress.
I was trying to move the Post content block into the first column.

image

@bobbingwide
Copy link
Owner Author

Here's the result where page Aaf uses a query to display the last post in two columns with Post content on the left and Post excerpt on the right. The Post content looks more like that which I'd expect the Post excerpt should look.
The Post excerpt should display the more link.

image

In the block editor the display is more confusing.
image

@bobbingwide
Copy link
Owner Author

The content of page Aaf is

<!-- wp:paragraph -->
<p>aaf's post excerpt before more.</p>
<!-- /wp:paragraph -->

<!-- wp:query {"queryId":1,"query":{"perPage":1,"pages":1,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"title","author":"","search":"","exclude":[1346],"sticky":""},"className":"border"} -->
<!-- wp:query-loop -->
<!-- wp:post-title {"isLink":true} /-->

<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
<h3>Post content</h3>
<!-- /wp:heading -->

<!-- wp:post-content /--></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
<h3>Post excerpt</h3>
<!-- /wp:heading -->

<!-- wp:post-excerpt {"wordCount":43,"showMoreOnNewLine":false} /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:query-loop -->
<!-- /wp:query -->

<!-- wp:more -->
<!--more-->
<!-- /wp:more -->

<!-- wp:paragraph -->
<p>aaf's post content after more.</p>
<!-- /wp:paragraph -->

The content of the post with the highest title ( Zzz ) is

<!-- wp:paragraph -->
<p>Zzz - post excerpt before more.</p>
<!-- /wp:paragraph -->

<!-- wp:separator -->
<hr class="wp-block-separator"/>
<!-- /wp:separator -->

<!-- wp:more -->
<!--more-->
<!-- /wp:more -->

<!-- wp:paragraph -->
<p>Zzz - start of post content after more. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This post was created to test post content &amp; post excerpt extraction for the <code>core/post-content</code> and <code>core/post-excerpt</code> blocks when they're inner blocks of the <code>core/query</code> <code>core/query-loop</code> constructs. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>See <a href="https://s.b/wp56/aaf/">page Aaf</a>.</p>
<!-- /wp:paragraph -->

@bobbingwide
Copy link
Owner Author

Expected result - front end

image

Expected result - editor

Post content

The More block should not be a problem

Post excerpt

Should be processed the same as on the front end.
That may involve:

  • using the post_excerpt field, if set

or

  • expanding shortcodes
  • stopping at the more tag
  • NOT stripping HTML tags
  • displaying the more link as specified in the block

@bobbingwide
Copy link
Owner Author

I've been retesting this using the original data for #27 and I'm still getting strange results.

The content of post B is

<!-- wp:paragraph -->
<p>B's normal excerpt</p>
<!-- /wp:paragraph -->

<!-- wp:more -->
<!--more-->
<!-- /wp:more -->

<!-- wp:paragraph -->
<p> [bw_wpadmin]</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>B's normal content</p>
<!-- /wp:paragraph -->

When displaying the post excerpt for B I'd expect to see "B's normal excerpt"
For the post content I'd expect to see all of the above.

What I'm actually getting is just the post content, there's no post excerpt.

<div class="entry-content wp-block-post-content is-layout-flow">
<p>B’s normal excerpt</p>
<p> <a href="https://s.b/wp55/tt1/b/#more-92" class="more-link"><span aria-label="Continue reading B">(more…)</span></a></p>
</div>

Perhaps it's my understanding of what the more block is supposed to do!
When there isn't a more block it seems OK.
I'll have to check the query loop again.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 12, 2023

I'll have to check the query loop again.

OK, the reason we don't see post excerpt is because it's not included in the post-template.

I should be attempting to reproduce the problem with page Aaf and post Zzz.
... and then understand / believe that what I got told in Nov 2020 is that what I'm seeing is what was intended!

Environment now is s.b/wp URL: https://s.b/wp/aaf/

  • When there isn't a more block in Zzz then the post content and post excerpt are displayed the same on the front end.

  • When there's a hand cranked excerpt then we see the hand cranked excerpt.

  • When there's a more block then the post content is truncated at the more.

  • When the more block "Hide the excerpt on the full content page" is toggled on then

    • the post content in the query loop shows the excerpt
    • the content before the more is not displayed when when viewing the post

These were the results testing with WordPress 6.0.1 and Gutenberg 12.3.0
I'd better repeat the tests with the latest versions: WordPress 6.2-RC1 and Gutenberg 15.3.1

@bobbingwide
Copy link
Owner Author

With WordPress 6.2-RC1 and Gutenberg 15.3.1 the results are different.

  • DIFFERENT When there isn't a more block in Zzz then the post content and post excerpt contain the same data but the excerpt has lost all the HTML formatting.
    image

  • SAME When there's a hand cranked excerpt we see the hand cranked excerpt

  • SAME When there's a more block then the post content is truncated at the more. See the first screen capture in post-content like post-excerpt and vice-versa? #43 (comment)

  • When the more block "Hide the excerpt on the full content page" is toggled on then

    • SAME the post content in the query loop shows the excerpt
    • SAME the content before the more is not displayed when when viewing the post

The Expected result - front end that I documented on 23 Nov 2020 at 10:54 pm reflects the results I used to get using the [bw_pages] shortcode displaying post_content (C) or post_excerpt (E).

#43 (comment)

@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 12, 2023

I've reproduced the Expected result - front end with the page Aaf 2023.
This page uses the [bw_field] shortcode to display post_content and post_excerpt directly from the post's fields. These have the green background. Below these are the output of the blocks.

image

Note that what's displayed for the post content block is different in the editor.
image

What I see in the editor is what I want in the front end!

I suppose I could override the behaviour of the post-content and post-excerpt blocks to achieve this. I won't close this issue yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant