query post by custom field value

Support MB Views query post by custom field value

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #49790
    aryanrajaryanraj
    Participant

    Hi, i have post type book and custom table wp_books. it has column book_type F(free) P(paid)

    I want to create a listing shortcode using mb views to show on singular book based on current book is free or paid. if a book is free, it should list all free books, same if book is paid, list all paid books. the value F/P saved in book type in custom table wp_books

    could you share the code.

    thanks.

    #49793
    PeterPeter
    Moderator

    Hello,

    Thanks for reaching out.

    You can follow the tutorial below to learn to use MB Views and create the query to get posts by custom fields
    https://docs.metabox.io/tutorials/show-posts-specific-criteria-mb-views/

    Follow the tutorials page to get more information https://docs.metabox.io/tutorials/

    #49795
    aryanrajaryanraj
    Participant

    Hi, the tutorial doesn't cover the custom table structure. please provide a relative example and code.

    Thanks

    #49814
    PeterPeter
    Moderator

    Hello,

    To query posts by a field value saved in a custom table, you need to use PHP code and SQL query. It isn't possible to use MB Views to do so. Please follow the documentation to read more about the PHP code
    https://docs.metabox.io/extensions/mb-custom-table/#query-posts-with-wp_query

    Thank you.

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