Skip to content

Commit

Permalink
Update for Image
Browse files Browse the repository at this point in the history
  • Loading branch information
conradfuhrman committed Aug 21, 2020
1 parent eb5284b commit e49e1c1
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions seo-to-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,45 @@
'show_in_rest' => true,
];

$args = [
'name' => $_REQUEST['slug'],
'post_type' => ['post', 'page', 'work'],
'post_status' => 'publish',
'numberposts' => 1
];
if (isset($_REQUEST['slug'])) {
$args = [
'name' => $_REQUEST['slug'],
'post_type' => ['post', 'page', 'work'],
'post_status' => 'publish',
'numberposts' => 1
];

$post = get_posts($args)[0];
$post = get_posts($args)[0];



register_rest_field(['post', 'page', 'work'], 'meta_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_title($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_title($post->ID)); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_description($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_description($post->ID)); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_social_image_url', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_image_from_cache($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_social_image_url', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_social_image( ['post_id' => $post->ID,])); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_open_graph_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_open_graph_title($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_open_graph_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_open_graph_title($post->ID)); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_open_graph_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_open_graph_description($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_open_graph_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_open_graph_description($post->ID)); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_twitter_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_twitter_title($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_twitter_title', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_twitter_title($post->ID)); }
]);

register_rest_field(['post', 'page', 'work'], 'meta_twitter_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_twitter_description($post->ID)); }
]);
register_rest_field(['post', 'page', 'work'], 'meta_twitter_description', [
'get_callback' => function () use ($post) { return html_entity_decode(the_seo_framework()->get_twitter_description($post->ID)); }
]);
}

});

0 comments on commit e49e1c1

Please sign in to comment.