Support » Plugin: Connections Business Directory » Connections and api rest v2

  • Resolved otmenton

    (@otmenton)


    Hello i would like to use this plugin with WP api rest V2 for calling data in Json

    i try the following code in functions.php

    // Hook for connections and api rest
    
    add_action( 'init', 'my_custom_post_type_rest_support', 25 );
      function my_custom_post_type_rest_support() {
        global $wp_post_types;
    
        $post_type_name = 'connections';
        if( isset( $wp_post_types[ $post_type_name ] ) ) {
            $wp_post_types[$post_type_name]->show_in_rest = true;
            $wp_post_types[$post_type_name]->rest_base = $post_type_name;
            $wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
    
        }
    
      }

    but it doesnt work

    where i can put the following instruction in the plugin code?
    'show_in_rest' => true,

    https://wordpress.org/plugins/connections/

    thanks for your work your plugin rock !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Steven

    (@shazahm1hotmailcom)

    @ otmenton

    Connections uses a custom db schema which is more optimized for directory content and not a custom post type (CPT) which uses a db schema optimized for post content. Since Connections uses custom tables and not a CPT it can not be registered in the wp-api using the CPT show_in_rest parameter.

    I have not yet looked into the wp-api to see if it can be extended to custom tables, but I doubt it since the wp-api team is still working on core features.

    I want to add a rest api in the future and I am hoping I can simply extend the wp-api but if that is not possible I’ll do want a lot of other plugins do which is create my own (one example, Easy Digital Downloads which actually is a CPT but is moving more and more of their data to custom tables in order to make their schema more optimized for better performance [in my understanding anyway]).

    Hope that answers your question thoroughly!

    Thread Starter otmenton

    (@otmenton)

    Hello shazahm1.

    Thanks for your reply

    I bought this plug-in but was disappointed as they do not reveal what exactly is not included in the basic license. For example the bulk import of categories is not included (this is important if you want a list of cities as categories). I have noticed that along the way I should expect many such surprises so I have decided to give up what I paid and I un-installed the plugin!!

    Plugin Author Steven

    (@shazahm1hotmailcom)

    @ rynetmedia

    re: I bought this plug-in but was disappointed as they do not reveal what exactly is not included in the basic license

    Could you explain more on what you mean? If you install the core Connections plugin, then you know what is exactly included.

    On this page: https://wordpress.org/plugins/connections/

    The Features section outlines a lot of included feature in the core plugin.

    The Premium Extension section list all the commercial add-ons. Same with the Premium Templates section.

    Nothing is being hidden. If you can provide some specific on what was confusing or not clear, I can look into addressing them.

    For example the bulk import of categories is not included (this is important if you want a list of cities as categories).

    Ummm… this is listed right under the Features section with a link right to the documentation. This is free tool included right in the core plugin. You’ll find it right on the Connections : Tools admin page under the Import tab.

    In closing, I do have support forums available to you. If you need help with something, please ask, I am available and answer most posts quite quickly.

    http://connections-pro.com/support/

    Hope that helps!

    Plugin Author Steven

    (@shazahm1hotmailcom)

    @ otmenton

    Just a follow up reply because I thought you’d be interested…

    I’ve begun to incorporate support for the WP REST API. The next update will include beta support for categories. You’ll be able to work with the Connections categories in the same way you can work with the core WP categories.

    This seems to work quite well… I was even able to add support for the REST API in the Custom Category Order extension and it worked perfectly; as in it correctly ordered the results and are able to set and update the custom order assigned to categories.

    The best part it only took a couple afternoons since I was able to base the code on the REST API category controller.

    Adding support for entries is going to take much more work though, because of the custom schema that I’ll need to develop. I’m thing to return the entry data structured as GeoJSON-LD that was the responses could be feed directly into any of the popular mapping APIs such as Google Maps JavaScript API.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Connections and api rest v2’ is closed to new replies.