Custom Fields
Re-Envisioned
Support General Create a custom search form

  • Creator
    Topic
  • #31207
    Bellul
    Participant

    I am thinking of creating a custom search form, which searches both in regular post types/fields and in custom post types/fields created with MB. I would like to test this code: https://awhitepixel.com/blog/wordpress-how-to-create-custom-advanced-search-template/

    Will this kind of code work with MB post types and fields? And even if the data is stored in an custom table? I am especially thinking about this part of the code:

    if (!empty($author)) {
        $meta_query[] = [
            'key' => 'book_author',
            'value' => $author,
            'compare' => 'LIKE'
        ];
    }
    

    Do you have any suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #31224
    Long Nguyen
    Moderator

    Hi,

    Yes, it can work with MB CPT and custom fields as well. You can read an article of us about the same query https://metabox.io/get-posts-by-custom-fields-in-wordpress/

    #31236
    Bellul
    Participant

    Thanks!

    And it doesn't matter if the data is stored in a "custom table"?

    /Bengt

    #31239
    Long Nguyen
    Moderator

    Hi,

    Create a search form that searches data from the custom table is more complicated. You can use the plugin SearchWP to do that. Please read more here https://metabox.io/plugins/meta-box-searchwp-integrator/

    #31240
    Bellul
    Participant

    Thanks! Are you aware of any guide on internet on how to do it manually (without the need to use a plugin)? (N.B. with "custom table" I mean a custom table created with your extension in MB: "MB Custom Table".)

    #31244
    Long Nguyen
    Moderator

    Hi,

    There is no tutorial on how to do it with coding. I will inform our team to create a blog post for this case.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.