简体   繁体   English

向WP REST API添加字幕

[英]Adding Subtitles to WP REST API

I am a beginner in WP, I apologize if this is a silly question. 我是WP的初学者,很抱歉这是一个愚蠢的问题。 I am looking to add subtitles to each of my posts where I can then access them via the WP REST API. 我希望在每个帖子中添加字幕,然后可以通过WP REST API访问它们。 I am using a plugin called Subtitles which seems to have good support. 我正在使用一个名为Subtitles的插件,该插件似乎有很好的支持。 I have copied the code below. 我已复制以下代码。

I am assuming I need to replace 'custom-post-type-slug' with something to make the below code work, but I have tried a number of things to no avail. 我假设我需要用某些东西替换“ custom-post-type-slug”以使下面的代码正常工作,但是我尝试了许多尝试都没有用。 Can you point me in the right direction? 你能为我指出正确的方向吗?

Here is the link to the plugin support as well which may be helpful https://github.com/professionalthemes/Subtitles/blob/master/README.md 这也是插件支持的链接,这可能会有所帮助https://github.com/professionalthemes/Subtitles/blob/master/README.md

function theme_slug_add_subtitles_support() {
add_post_type_support( 'custom-post-type-slug', 'subtitles' );
}

add_action( 'init', 'theme_slug_add_subtitles_support' );

Are you using a custom post type? 您是否使用自定义帖子类型? If so then you need to replace 'custom-post-type-slug' with the slug of your custom post type. 如果是这样,那么您需要将“ custom-post-type-slug”替换为您的自定义帖子类型的标签。

Where can you find the slug? 在哪里可以找到the?

I believe that if you select the custom post type from the left hand admin menu, the slug name will shown at the top left of the page (as the title for the admin page that you're on). 我相信,如果您从左侧管理菜单中选择自定义帖子类型,则该标签名称将显示在页面的左上方(作为您所在的管理页面的标题)。

And if it's not a custom post type (Just the regular posts section from the admin side), then according to your pluggins documentation the subheaders should already be added to your posts 而且,如果它不是自定义帖子类型(只是管理员侧的常规帖子部分),那么根据您的插件文档,子标题应该已经添加到您的帖子中

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM