• Hi
    I think I may have missed a step when creating my plugin.
    I have set up my plugin file with
    @package, @author, @version
    and then have just added statements to

    define ('XXX_PLUGIN_DIR', WP_PLUGIN_DIR.'/xxx');
    require (XXX_PLUGIN_DIR . '/xxxfunctions.php'); //general functions
    require (XXX_PLUGIN_DIR . '/xxxdb.php'); //sql functions

    Everything is working as it should but when I use the normal WP site search function my tables do not seem to be searched
    My 3 plugin db tables do not have the database table prefix (wpxxx_).
    Do I “just” need to rename them to include the prefix or do I have to do something else to get them registered into WordPress so that the data is picked up in searches.
    Thanks in anticipation

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • You’ve made a big leap from entering some comments in a plugin file to tables being part of the search!
    The plugin header, which is the comment at the top of the main plugin file (and what makes it the main file), is used by WP to populate the plugin pages, and activate/deactivate the plugin. It has nothing whatsoever to do with anything the plugin code accomplishes.
    So if you chose to use your own tables, you need to do all the management of them, and that includes filtering the search query to JOIN your table in (if that’s what you want). Most plugins that want searchable data choose to use the WP tables, so that other plugins can seamlessly use that data like any other.

    Thread Starter encoreservices

    (@encoreservices)

    Thanks for the input, @joyously
    When you say
    Most plugins that want searchable data choose to use the WP tables
    I’m not sure what you mean – the structure of my tables does not match any of the WP standard tables so I don’t understand how I would insert data into the WP tables in the same structure e.g.

    myfield01 = "myvalue01"
    myfield02 = "myvalue02"
    myfield03 = "myvalue03"
    myfield04 = "myvalue04"

    I see other plugin tables in phpMyAdmin which have the same table wpxxx_ prefix but they may or not be searchable e.g. the Caldera Forms plugin has 7 wpxxx_cf_aaabbbccc
    If you are able to point me towards a link, that’d be helpful.
    Thanks

    If the data is post-like, you can put it in the posts table, with extra fields in post meta. That way WP and plugins/theme can all use the data with no extra effort.
    If not, put it in your own tables, but you can use the global $wpdb to manage the queries and connection, etc. You would still need to filter the search and add a JOIN for your tables, if it’s in separate tables though.

    If you look at core code, you will see that menu items, CSS changesets, custom CSS, attachments, and reusable blocks are all stored in the posts table. And soon we’ll have template parts also.

    https://codex.www.ads-software.com/Database_Description
    https://developer.www.ads-software.com/reference/hooks/posts_search/
    https://developer.www.ads-software.com/reference/hooks/posts_search_orderby/

    Thread Starter encoreservices

    (@encoreservices)

    Thanks @joyously – a bit of work for me to do it seems!!

    Thread Starter encoreservices

    (@encoreservices)

    Looks like I will be able to achieve what I want using plugins like PODS/CPT/ACF and some page template coding!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Booboo? Registering Bespoke Plugin for WordPress Searches’ is closed to new replies.