1

My client is using an old classipress version, here's a github repo I found but what he's using is much older. Running the latest Wordpress version. Here's Functions.php.

He'd like to create a mobile app, so I need to create an API. The theme does not have an api and wordpress api does not work with it, AD posts are not wordpress posts, every ad you post in the theme is specific for the theme. So if you go to wp-api you don't see anything related to ads.

Is it possible to create endpoints for such a theme? Can you show a small example how please? If there an alternative solution? Or do we have to recreate the website and design the API?

2 Answers 2

2

WordPress REST API has nothing directly to do with the theme, REST API is in the WordPress core, and any plugin and theme can be made to support it. Normal WordPress themes don't use REST API: it is relatively new part of the WordPress, and so far, very few themes are made to use REST API.

If you need a mobile app that will have own interface ( the theme is not used for the interface), that app can be made to use REST API, and that has nothing to do with the theme. The app can also be a theme, and it can be made not to use REST API.

It all depends on your specifications and what you want to do and how. WordPress can be used in many ways, and any task can be done in more ways than one. Anything can be made to use REST API or to work without REST API. API returns result only, the app (or theme) needs to render those results. The main point in using API is to separate the server side from the front end rending.

You should learn more about WP REST API, understand better what it does and how it is used before deciding on using it: WP REST API Documentation and REST API Handbook, and you need to better formulate your project before deciding one way or the other.

4
  • I don't have the choice to formulate my project. The website is very complex and has thousands of users, suddenly the client asks for a mobile app and I'm stuck. Rewriting it means migrating the database and all that.
    – Lynob
    Commented Oct 21, 2017 at 18:03
  • If your app has own interface (not the theme), use the REST API, and theme can work for the website as it is now. If you want the theme to work as the app, that can be made as it is, without REST API. It all depends on your choice of how to do things. It depends, do you make a native mobile app, for iOS or Android or both, do you use same JavaScript based tech for both. There are many, many ways to do that, and you need to learn more about them and decide what to do. Commented Oct 21, 2017 at 18:07
  • I don't want the website itself to be a mobile app. Out of curiosity can that be done for free? I heard of apppresser.com but wonder if there's a way to do it programmatically without using a paid service? I guess I have to follow the links you gave me and use the api
    – Lynob
    Commented Oct 21, 2017 at 18:41
  • Check out WordPress.org for free plugins for WordPress to mobile app solutions: wordpress.org/plugins/tags/mobile-app Commented Oct 21, 2017 at 19:11
0

I just discovered the easiest way to do it, just install WP REST API Controller plugin and enable any endpoint you choose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.