Create a custom search form

Support General Create a custom search formResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31207
    BellulBellul
    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?

    #31224
    Long NguyenLong 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
    BellulBellul
    Participant

    Thanks!

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

    /Bengt

    #31239
    Long NguyenLong 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
    BellulBellul
    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 NguyenLong 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 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.