Giter VIP home page Giter VIP logo

Comments (8)

bobbingwide avatar bobbingwide commented on June 17, 2024

Putting some text before the <!--more--> doesn't resolve the issue.

Converting to blocks results in the more tag going after the text. A known bug. See WordPress/gutenberg#18079

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

This is a bug in the bigram plugin which is looking for SB's and converting them into a link.
The method in error is sample_bigrams::process_contents().
There's a @todo comment that says @todo Needs to ignore HTML attributes.

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

The hack implemented in 996c6ee appears to prevent SB's from being found when the first word is of the form <p>Firstword.
The simple fix appears to be to remove the test that checks for the <
ie Here it's commented out

if ( false !== $pos /* && false === strpos( $word, '<' ) */ ) {
					$waitforgt = false;
				}

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

This is still not working in the SB theme for the first post displayed on https://s.b/bigram/category/sampled-bigram/

sample_bigrams::process_contents() is being passed a link.
which explodes to an array

 [0] => (string) ""
    [1] => (string) "<a"
    [2] => (string) "href="https://s.b/bigram/bigram/seventieth-bag/#more-6367""
    [3] => (string) "class="more-link"><span"
    [4] => (string) "aria-label="Continue"
    [5] => (string) "reading"
    [6] => (string) "Seventieth"
    [7] => (string) "Bag">(more&hellip;)</span></a>"

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

The problem is that WordPress's logic in the get_the_content() function is rather strange, in my opnion.
When there's a <!--more--> tag or block present it wants to display the content with the more tag acting as a link to the post. Whereas I expect the post's content to be displayed without this link.

But it would appear that I'm in the minority.
The pragmatic solution would be to generate Sampled bigrams without the <!--more--> tag.

Note: This won't fix the problem for the posts which have already been created with the <!--more--> tag.

In actual fact, the logic still doesn't work for posts which contain the <!--more--> tag even when there's a teaser.
I searched for "Sampled from" and the first post found was displayed incorrectly.

The "Sampled Bigrams" post contains.

SBs that have been automatically extracted from other SBs.

They get the same date as the original, but might subsequently be updated.
<!--more-->Sampled from Seen Before.

When this is displayed on the home page WordPress wants to show it as


SBs that have been automatically extracted from other SBs.

They get the same date as the original, but might subsequently be updated. (more…)


When you click on the More link the full text of the post's content is displayed.


SBs that have been automatically extracted from other SBs.

They get the same date as the original, but might subsequently be updated. Sampled from Seen Before.


It's the same content being displayed by the core/post-content block.
So what causes the output to be different?

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

So what causes the output to be different?

In gutenberg_render_block_core_post_content() there's this test.

if ( ! in_the_loop() && have_posts() ) {
	   the_post();
}

When it's a singular display and the core/post-content block is being used directly ( not within a query loop ) then
the_post() is being called. This calls WP_Query::the_post() which sets up the global $post and calls setup_postdata().
This method sets the other globals, which includes $more, $page and $pages.

These elements are used by get_the_content().

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

After further investigation I realised that I'd been looking at the get_the_content() function when attempting to correct the post title for sb thumbnail and sb links queries on the archive pages.
I also read https://codex.wordpress.org/Customizing_the_Read_More
and discovered that

if you set the $more variable to -1, the More tag will not be displayed. This can be useful in a "mullet loop", which displays the full content for only the first post, and then displays only excerpts for all remaining posts.

That's exactly what I want. The fix is implemented in sb_render_block_core_post_template_main_query() - in the SB theme.

Since on the archive page the content is only displayed for the first post I only need to set $more= -1;
This is done after calling the_post() and before rendering the post template.

from bigram.

bobbingwide avatar bobbingwide commented on June 17, 2024

This was fixed by changing the SB theme. v0.2.1 is now delivered.

from bigram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.