WordPress基於PHP構建。所以WP REST API插件也是用PHP編寫的。 正如你所說的,你使用WordPress REST api v2。 讓我從共享代碼的位置開始:WordPress REST api v2
正如你可以看到這個WP REST API不包括任何SEO的東西。
現在你還安裝了'all-in-one-seo-pack'插件。 free version不包含內置API。你可以升級到Pro Version這個'all-in-one-seo-pack',它有一個內置的API。
或者你可以自己擴展WordPress REST api v2通過添加額外的端點。然後自己編寫PHP代碼,通過REST API管理你的SEO插件。
它並不那麼困難 - >正如Raunak Gupta已經告訴你的那樣:這些都是'一體式seo包裝'中使用的領域。用其他端點擴展REST API來配置它們。然後從C#代碼中調用您的端點。
<wpml-config>
<custom-fields>
<custom-field action="translate">_aioseop_title</custom-field>
<custom-field action="translate">_aioseop_description</custom-field>
<custom-field action="translate">_aioseop_keywords</custom-field>
</custom-fields>
<admin-texts>
<key name="aioseop_options">
<key name="aiosp_home_title" />
<key name="aiosp_home_description" />
<key name="aiosp_home_keywords" />
<key name="aiosp_post_title_format" />
<key name="aiosp_page_title_format" />
<key name="aiosp_category_title_format" />
<key name="aiosp_archive_title_format" />
<key name="aiosp_tag_title_format" />
<key name="aiosp_search_title_format" />
<key name="aiosp_description_format" />
<key name="aiosp_404_title_format" />
<key name="aiosp_paged_format" />
</key>
</admin-texts>
</wpml-config>
看看免費版本的代碼。使用此代碼可以在編寫自己的代碼時獲得靈感。 WordPress希望你擴展功能。爲社區做貢獻!
if (!function_exists('aioseop_ajax_save_meta')) {
function aioseop_ajax_save_meta() {
if (!empty($_POST['_inline_edit']) && ($_POST['_inline_edit'] != 'undefined'))
check_ajax_referer('inlineeditnonce', '_inline_edit');
$post_id = intval($_POST['post_id']);
$new_meta = strip_tags($_POST['new_meta']);
$target = $_POST['target_meta'];
check_ajax_referer('aioseop_meta_' . $target . '_' . $post_id, '_nonce');
$result = '';
if (in_array($target, Array('title', 'description', 'keywords')) && current_user_can('edit_post', $post_id)) {
update_post_meta($post_id, '_aioseop_' . $target, esc_attr($new_meta));
$result = get_post_meta($post_id, '_aioseop_' . $target, true);
} else {
die();
}
if($result != ''):
$label = "<label id='aioseop_label_{$target}_{$post_id}'><span style='width: 20px;display: inline-block;'></span>" . $result . '</label>';
else:
$label = "<label id='aioseop_label_{$target}_{$post_id}'></label><span style='width: 20px;display: inline-block;'></span><strong><i>" . __('No', 'all-in-one-seo-pack') . ' ' . $target . '</i></strong>';
endif;
$nonce = wp_create_nonce("aioseop_meta_{$target}_{$post_id}");
$output = '<a id="' . $target . 'editlink' . $post_id . '" class="aioseop_edit_link" href="javascript:void(0);"'
. 'onclick=\'aioseop_ajax_edit_meta_form(' . $post_id . ', "' . $target . '", "' . $nonce . '");return false;\' title="' . __('Edit') . '">'
. '<img class="aioseop_edit_button" id="aioseop_edit_id" src="' . AIOSEOP_PLUGIN_IMAGES_URL . '/cog_edit.png" /></a> ' . $label;
die("jQuery('div#aioseop_" . $target . "_" . $post_id . "').fadeOut('fast', function() { var my_label = " . json_encode($output) . ";
jQuery('div#aioseop_" . $target . "_" . $post_id . "').html(my_label).fadeIn('fast');
});");
}
}
我看到了什麼,你的代碼是呈三角[發佈WordPress的使用WP REST API C#](http://stackoverflow.com/questions/38458678/post-on-wordpress-using-wp-rest- api-c-sharp)的問題,但有人提出了任何解決方案。我不是C#的人,但如果你需要任何幫助,我可以幫助你。和_All In One SEO Pack_使用以下post_meta來保存元標籤的元標籤:'_aioseop_title',元描述的'_aioseop_description'和Meta關鍵字的'_aioseop_keywords'。希望這可以幫助你。 –
@RaunakGupta這是類似的,因爲這是我的問題(來自另一個帳戶)...謝謝:) –