Site logo

Archived topic

Article CreativeWork schema

12 replies · Started by Butch Pornebo on October 8, 2022

Viewing posts 1–13 of 13

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/SYC6r6Gg

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

Replace 394283 with the WPSP list.

Please elaborate.

What do you mean "WPSP list"?

Where do I get this info?

Replace 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.

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."

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?

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; 
});

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 unique list_id of the post.

I don't think that will work because I still need the url/#webpage as the itemid

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; 
});

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?

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; 
});
This archived topic is closed to new replies.