WordPress.org

Ready to get started?Download WordPress

Forums

Pods - Custom Content Types and Fields
[resolved] Filters dropdown not showing (4 posts)

  1. senyoraangelica
    Member
    Posted 11 months ago #

    I tried this code

    <?php
    
    $pod = pods( 'books' ); 
    
    echo $pod->filters( array(
     'fields' => array( 'book_title', 'book_author', 'book_genre' )
    ) ); 
    
    $pod->find(); 
    
    while ( $pod->fetch() ) {
        echo "<li>" . $pod->display( 'book_title' ) . '</li>';
    }
    
    echo '<ul>'; 
    
    echo $pod->pagination();
    
    ?>

    It shows the search form with the search button but it is missing the filter dropdown for my custom fields. Is my code wrong?

    The following code should display a dropdown menu containing my custom fields, right?

    echo $pod->filters( array(
     'fields' => array( 'book_title', 'book_author', 'book_genre' )
    ) );

    http://wordpress.org/plugins/pods/

  2. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 11 months ago #

    Filters currently only supports relationship fields (drop-downs). Are Book Title / Book Author / Book Genre relationship fields or are they single line text fields?

  3. senyoraangelica
    Member
    Posted 11 months ago #

    They are plain text fields. Reading through the forums, if I understand correctly, a Relationship field type is for linking different pods together?

    Is there a shortcode or something in the pods codex that would let me display my custom fields as tick boxes or dropdowns right beside the search form? Or is writing my own custom code the only way I can do this?

    I want to let visitors search my pod items through a custom field of their choice. Using the code above, the search form doesn't find texts from my other custom fields. It only finds texts on my pods item title.

  4. Scott Kingsley Clark
    Member
    Plugin Author

    Posted 11 months ago #

    Pods doesn't allow for any other filters than relationships right now, beyond that, there's a single text field that will do a basic text search.

    You can always build your own filter form that can do anything your heart desires with PHP, and during processing, pass your search directly into a find() call, or you can use WP_Query meta_query if you're using Post Types.

Reply

You must log in to post.

About this Plugin

About this Topic