admin管理员组文章数量:1391947
I am building a native mobile app where I need to display categories of products in different screens, and my client uses Wordpress as their CMS. I see that in order to return images from a gallery, I will need to use get_post_galleries() or get_post_gallery() per the instructions here:
How to get the attached gallery in the rest API?
My question is, to which file do I add the custom endpoints? So far my CMS is very bare bones so for the purposes of this question, you can assume I only have the files included with a new Wordpress installation.
I am building a native mobile app where I need to display categories of products in different screens, and my client uses Wordpress as their CMS. I see that in order to return images from a gallery, I will need to use get_post_galleries() or get_post_gallery() per the instructions here:
How to get the attached gallery in the rest API?
My question is, to which file do I add the custom endpoints? So far my CMS is very bare bones so for the purposes of this question, you can assume I only have the files included with a new Wordpress installation.
Share Improve this question asked Mar 6, 2020 at 2:08 HeidiWFHeidiWF 32 bronze badges1 Answer
Reset to default 0Typically changes like this you would either create a plugin or create a child theme and put your code in your child theme's functions.php file. You make changes to a child theme because if your theme updates you will lose any changes you have made directly to it.
Code in a plugin is always run as long as the plugin is active, where as code in a theme or child theme won't work if you change themes down the road. If the changes you want to make are not theme specific its probably best to just create a small plugin. Which is really nothing more than adding a comment at the top of a PHP file.
Here is an example plugin...
<?php
/*
Plugin Name: Example Plugin
*/
// Your PHP here
Name this file, something like example-plugin.php, put it in the plugin directory then activate it in the admin.
Here is some info on creating a child theme.
Good article on plugins vs themes.
本文标签: imagesWhere to put code that customizes API
版权声明:本文标题:images - Where to put code that customizes API 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744692630a2620086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论