This topic contains 5 replies, has 2 voices, and was last updated by  Steve 2 months ago.

  • Author
    Posts
  • #9516

    quadricula
    Participant

    I am trying to make a front-end form to filter the list of a type of post but I can not do it, this is the example I use, how can I make it work?

    ———————-

    <?php
    /*
    Title: Person Filter Form
    Method: get
    Logged in: false
    Filter: true
    Action: /person/
    */

    // Search by post_title
    piklist( ‘field’, array(
    ‘type’ => ‘text’, ‘scope’ => ‘post’, ‘field’ => ‘post_title’
    ));

    // Submit button
    piklist( ‘field’, array(
    ‘type’ => ‘submit’, ‘field’ => ‘submit’, ‘value’ => ‘Submit’
    ));

    ——————

    I get this error:
    Warning Invalid argument supplied for foreach() 5
    +
    wp-content/plugins/piklist/includes/class-piklist-cpt.php:967
    Plugin: piklist
    Warning Invalid argument supplied for foreach() 1
    +
    wp-content/plugins/piklist/includes/class-piklist-cpt.php:965
    Plugin: piklist
    Warning Parameter 2 to Piklist_CPT::posts_search() expected to be a reference, value given 2
    +
    wp-includes/class-wp-hook.php:286
    Core
    Warning Invalid argument supplied for foreach() 1
    +
    wp-content/plugins/piklist/includes/class-piklist-cpt.php:1192
    Plugin: piklist

  • #9517

    Steve
    Keymaster
  • #9518

    quadricula
    Participant

    Thanks for fast reply, but wanted to say is to build a simple form to search by post title on custom post type on front-end.

    I only want a textbox and a submit button on form, but i dont know how to use the “Filter” parameter on header

  • #9519

    Steve
    Keymaster

    Piklist doesn’t have a built-in filtering option because we want you to have options. You can easily use CHOSEN or SELECT2:

    https://docs.piklist.com/tutorials/fields/using-chosen/
    https://docs.piklist.com/tutorials/fields/using-select2/

  • #9520

    quadricula
    Participant

    I need only one form field that works as a people search engine like the file attatchment

    Attachments:
    You must be logged in to view attached files.
  • #9522

    Steve
    Keymaster

    That would be using a text box and some type of search functionality. You can either pass the search parameter to the url and use get_posts() to pull the data (similar to what WordPress search does). Or you can use a combination of javascript and the rest api to do this. Piklist helps you create the form, but you would need to build the search.

The topic ‘Front-end custom post type query form’ is closed to new replies.