1. The code you wrote for us previously for changing JSON-LD types to Recipe does not seem to be working (the code is below, with only the category # changed). Here's a page that should have the type changed but doesn't: https://paleomagazine.com/lemon-garlic-ghee-salmon-paleo-keto-aip/amp
Also - as an aside, we'd prefer to do it by tag, so I modified the code (the second version below), but it also doesn't work.
add_filter(
'weeblramp_json_manifest',
function ( $jsonld, $pageData ) {
// set document type based on post
$post = WeeblrampHelper_Content::getPostFromPageData( $pageData );
if ( ! empty( $post ) && 'single' == wbArrayGet( $pageData, 'request_type' ) ) {
$postCategories = wp_get_post_categories( $post->ID );
$recipeCategories = array( 603 );
// set document type
if ( array_intersect( $postCategories, $recipeCategories ) ) {
$jsonld['@type'] = 'Recipe';
}
}
return $jsonld;
},
10,
2
);
add_filter(
'weeblramp_json_manifest',
function ( $jsonld, $pageData ) {
// set document type based on post
$post = WeeblrampHelper_Content::getPostFromPageData( $pageData );
if ( ! empty( $post ) && 'single' == wbArrayGet( $pageData, 'request_type' ) ) {
$postTags = wp_get_post_tags ( $post->ID );
$recipeTags = array( 584 );
// set document type
if ( array_intersect( $postTags, $recipeTags ) ) {
$jsonld['@type'] = 'Recipe';
}
}
return $jsonld;
},
10,
2
);
2. Separate feature question - are you planning on allowing ads to be placed within the content? For us, this would be great, and I know many other food bloggers prefer this for ads.
Or, I imagine we could effectively use a filter like the one below (but with the correct weeblramp filter)?
add_filter('the_content', 'mte_add_incontent_ad');
function mte_add_incontent_ad($content)
{ if(is_single()){
$content_block = explode('<p>',$content);
if(!empty($content_block[2]))
{ $content_block[2] .= 'insert_ad_code_here';
}
for($i=1;$i<count($content_block);$i++)
{ $content_block[$i] = '<p>'.$content_block[$i];
}
$content = implode('',$content_block);
}
return $content;
};
Also - as an aside, we'd prefer to do it by tag, so I modified the code (the second version below), but it also doesn't work.
add_filter(
'weeblramp_json_manifest',
function ( $jsonld, $pageData ) {
// set document type based on post
$post = WeeblrampHelper_Content::getPostFromPageData( $pageData );
if ( ! empty( $post ) && 'single' == wbArrayGet( $pageData, 'request_type' ) ) {
$postCategories = wp_get_post_categories( $post->ID );
$recipeCategories = array( 603 );
// set document type
if ( array_intersect( $postCategories, $recipeCategories ) ) {
$jsonld['@type'] = 'Recipe';
}
}
return $jsonld;
},
10,
2
);
add_filter(
'weeblramp_json_manifest',
function ( $jsonld, $pageData ) {
// set document type based on post
$post = WeeblrampHelper_Content::getPostFromPageData( $pageData );
if ( ! empty( $post ) && 'single' == wbArrayGet( $pageData, 'request_type' ) ) {
$postTags = wp_get_post_tags ( $post->ID );
$recipeTags = array( 584 );
// set document type
if ( array_intersect( $postTags, $recipeTags ) ) {
$jsonld['@type'] = 'Recipe';
}
}
return $jsonld;
},
10,
2
);
2. Separate feature question - are you planning on allowing ads to be placed within the content? For us, this would be great, and I know many other food bloggers prefer this for ads.
Or, I imagine we could effectively use a filter like the one below (but with the correct weeblramp filter)?
add_filter('the_content', 'mte_add_incontent_ad');
function mte_add_incontent_ad($content)
{ if(is_single()){
$content_block = explode('<p>',$content);
if(!empty($content_block[2]))
{ $content_block[2] .= 'insert_ad_code_here';
}
for($i=1;$i<count($content_block);$i++)
{ $content_block[$i] = '<p>'.$content_block[$i];
}
$content = implode('',$content_block);
}
return $content;
};