- This topic has 12 replies, 3 voices, and was last updated 5 months, 2 weeks ago by
Fernando.
-
AuthorPosts
-
October 8, 2022 at 4:25 pm #2367402
Butch Pornebo
GP has “WP Show Post” article tags that declares via microdata as CreativeWork schema.
How do I add “@id” property to the microdata so that I can refer back to my WebPage json/ld the I am using.
The WebPage json/ld has a property of @id = https://postURL/#webpage
Essential I want the same @id of https://postURL/#webpage into the CreativeWork so that it “links” together with the Webpage schema instead of just floating with no connection.
Schema Visualization screenshot
https://postimg.cc/SYC6r6GgOctober 10, 2022 at 1:48 am #2368460Fernando Customer Support
Hi Butch,
We’ll need a workaround. Try adding the PHP:
Try this:
add_filter( 'wpsp_settings', function($settings){ if(394283 == (int) $settings['list_id']){ $settings[ 'itemtype' ] .= '" ' . '@id ="' . get_permalink() . '/#webpage"'; } return $settings; });
Replace
394283
with the WPSP list.Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
October 10, 2022 at 10:02 am #2369047Butch Pornebo
Replace 394283 with the WPSP list.
Please elaborate.
What do you mean “WPSP list”?
Where do I get this info?
October 10, 2022 at 12:43 pm #2369166Ying
StaffCustomer SupportReplace 394283 with the WPSP list ID that you want this to work.
You can find it at dashboard > WP show posts, all the WP show posts lists have their own unique IDs.
October 10, 2022 at 12:44 pm #2369168Butch Pornebo
Additional information that might unravel how to properly link this microdata to the json/ld @id of the webpage schema type.
https://www.semrush.com/webinars/schema-markup-as-a-tactic-for-aeo/
“There are lots of separate ways to use it. And you’ll hear it called @id for JSON-LD, but for anyone that uses microdata, it’s the item id. ”
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemid
“An itemid attribute can only be specified for an element that has both itemscope and itemtype attributes.”
October 10, 2022 at 1:44 pm #2369208Butch Pornebo
I have multiple WPSP list that I want to incorporate this.
What would be code change to make it to work for multiple WPSP list?
October 10, 2022 at 2:48 pm #2369243Butch Pornebo
Sorry BUT the original suggested workaround did not work.
Here is the generated result:
<article class=" wp-show-posts-single wpsp-clearfix post-1926 post type-post status-publish format-standard has-post-thumbnail category-kitchen-cabinets tag-featured" itemtype="http://schema.org/CreativeWork" @id="https://exploreyourkitchen.com/should-i-paint-my-kitchen-cabinets/#webpage" "="" itemscope="">
I think the @id needs to be itemid. Please see my previous reply.
also, do you see the “=”” after #webpage right before the itemscope?
Where that come from?
Here is the code snippet I used:
add_filter( 'wpsp_settings', function($settings){ if(1207 == (int) $settings['list_id']){ $settings[ 'itemtype' ] .= '" ' . '@id ="' . get_permalink() . '#webpage"'; } return $settings; });
October 10, 2022 at 5:50 pm #2369334Fernando Customer Support
How about something like this?:
add_filter( 'wpsp_settings', function($settings){ $settings[ 'itemtype' ] .= '" itemid="' . $settings['list_id']; return $settings; });
This should add
itemid
with the uniquelist_id
of the post.October 10, 2022 at 11:48 pm #2369484Butch Pornebo
I don’t think that will work because I still need the url/#webpage as the itemid
October 10, 2022 at 11:56 pm #2369489Butch Pornebo
what do you think of this tho?
add_filter( 'wpsp_settings', function($settings){ if(1207 == (int) $settings['list_id']){ $settings[ 'itemid' ] = '"' . get_permalink() . '#webpage"'; } return $settings; });
October 11, 2022 at 12:08 am #2369494Fernando Customer Support
I see. For reference, can you manually provide a sample of your ideal itemid attribute for two articles?
For instance,
itemid="https://exploreyourkitchen.com/should-i-paint-my-kitchen-cabinets/#webpage"
? Will the URL be consistent for all articles?October 11, 2022 at 8:00 am #2370049Butch Pornebo
For ALL post,
itemid="https://url-of-a-specific-post/#webpage"
So, you think this will. right?
add_filter( 'wpsp_settings', function($settings){ if(1207 == (int) $settings['list_id']){ $settings[ 'itemid' ] = '"' . get_permalink() . '#webpage"'; } return $settings; });
October 11, 2022 at 5:59 pm #2370499Fernando Customer Support
I see. If it’s the specific URL of each post, it wouldn’t be possible to inject it to that tag in WP Show Posts through that filter.
It would be possible if you use GenerateBlocks Query Loop Block.
Side note: WP Show Posts was merged with GenerateBlocks. Relevant article: https://wpshowposts.com/weve-made-the-decision-to-merge-wp-show-posts-with-generateblocks/
-
AuthorPosts
- You must be logged in to reply to this topic.