Site logo

Archived topic

Feature Request: Itemprop we can use as filter + Help

6 replies · Started by Pierre Eustache on August 11, 2018

Viewing posts 1–7 of 7

Hi,
Can you add some itemprop as filters, please?
By example, I want to display the excerpt as description, not text for archive page, and link to the actual content with url itemprop. But it is hard coded in content template part.

I don't want to use a child theme. That's the reason I choosed GP.

Can you add this feature in next release, please? Like you did with generate_article_schema( 'CreativeWork' ), it could be generate_itemprop_schema( 'target', 'value' ) as it is not unique on the page. ex: <h2 class="entry-title" generate_article_schema( 'title','headline' )>

Now, for the help:
How can i edit "4 thoughts on “Article Title”" to "4 comments"?

PS: it's not live yet on my website.

Thanks

Hi Tom,
Thank you for the references.

I can't remove that line 65 because it is exactly the behavior expected. The line I wanted to change is on line 59 because it is not exactly the post (on archive listing) but a reference to it instead.
https://github.com/tomusborne/generatepress/blob/master/content.php#L59
Hope it was clear.

However, it can't be coded directly on your theme because you don't know how every user will use the theme. I just wanted it to be something I can edit via filter.

For the comment title, if I can't do it via filter, I'll leave it as it.
I wanted to make the theme as close to my current one as possible. I edited to comment.php template.

If so, how come? Is it causing any specific issues?

I get some errors on Google schema testing tool when I change 'CreativeWork' to 'BlogPost'.

I'll make further researches and let you know if I face issues.

Interesting - I would think you'd still want to tell search engines that the excerpt block is the text, as other meta data exists in their as well.

In GP 2.2, we're introducing a new attribute system that will allow things like classes, schema etc.. to filtered. However, I'm not sure if that specific element will have the function, as there's not a lot of classes etc..

Let me think about the best way to make the itemprop filtered there. It may be easier just to copy content.php into your child theme?

You could likely add a filter for the comments like this:

add_filter( 'gettext', function( $text ) {
    if ( 'One thought on &ldquo;%s&rdquo;' === $text ) {
        return 'Your new text';
    }

    if ( '%1$s thought on &ldquo;%2$s&rdquo;' === $text ) {
        return 'Your new text';
    }

    if ( '%1$s thoughts on &ldquo;%2$s&rdquo;' === $text ) {
        return 'Your new text';
    }
} );

Let me think about the best way to make the itemprop filtered there. It may be easier just to copy content.php into your child theme?

OK! Waiting for 2.2.
I don't like child theme nor a lot of plugins. I created a plugin instead to extend GeneratePress, Gutenberg or any other plugin/theme. And being developer friendly is what I like the most about GP.

[An idea]: being the main content, it can have its filter like generate_article_schema( ‘CreativeWork’ ).

  • <h2 class="entry-title" generate_itemprop_schema( 'headline' )> : instead of <h2 class="entry-title" itemprop="headline">
  • generate_itemprop_schema( 'publisher')

It would need two arguments for distinct element.

A real life scenario: I want to change my post to BlogPosting which is more specific than Article or CreativeWork. The extension makes it possible to use articleBody itemprop instead of text as itemprop. It's better because a blog post is not just textual content.

I can add the other itemprops such as url, description, articleSection, image, InteractionCount, etc... via filter and hooks to make it work. But an existing property need a way to change it.
[/An idea]

If you have to make only one. Make the content body.

I am still working on the comment filter. It does not work yet. I just keep it like you wrote to echo the "Your New Text", but nothing. It would help me for this:

<meta itemprop="interactionType" content="https://schema.org/CommentAction" />
<meta itemprop="userInteractionCount" content="%1$s" />

Let me think about the best way to make the itemprop filtered there. It may be easier just to copy content.php into your child theme?

Definitely, a child theme is better. I did not see that you wrapped the functions with function_exists(). Thumb up!
And I have small tweaks where I can't only use filter. Like adding itemtype Blog to single at <main> tag and make each comment an itemprop of BlogPosting. I add ads before h2-h4 headings instead of paragraphs and I want to reduce the calls to the_content, etc...

I digged! A child theme will fix all of my issues.

Really appreciate your feedback here! I think you'll really like the 2.2 update :)

This archived topic is closed to new replies.