• Resolved Agrajag27

    (@agrajag27)


    Thanks again for the great plugin. We’ve communicated before and you’ve been a great help. We heavily use the plugin in a different way than most where we might call it five times on a single page for different fields (movie review site):

    http://slashcomment.com/movie-reviews/a-bigger-splash-review/

    One thing we’d like to get is the ability to select just two fields for results. In the example above, “Other Similar Films” is driven by our custom “Keywords” field, but it would be much improved if that result could also include our custom “Genre” field as well. However, there’s no UI way to select two fields. It’s either all fields or one field.

    Can this be easily overcome?

    Thanks!

    https://wordpress.org/plugins/related-posts-by-taxonomy/

Viewing 1 replies (of 1 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi agrajag27

    Do you need this for the widget only?
    One way is to add a new format for the widged by using something similar to this in your (child) theme’s functions.php

    
    // Create new format keyword_genre for use in widget and shortcode
    add_action( 'wp_loaded', 'rpbt_add_keyword_genre_format', 11 );
     
    function rpbt_add_keyword_genre_format() {
     
        if ( !class_exists( 'Related_Posts_By_Taxonomy_Defaults' ) ) {
            return;
        }
     
        $defaults = Related_Posts_By_Taxonomy_Defaults::get_instance();
     
        // Add the new format .
        $defaults->formats['keyword_genre'] = __( 'Keyword and Gengre' );
    }

    With this you can select the new format Keyword and Gengre in the widget
    Now we have to let the plugin know what taxonomies to use when we use this format. Put this in your (child) theme’s functions.php

    
    add_filter( 'related_posts_by_taxonomy_widget_args', 'my_widget_filter', 10, 2 );
    function my_widget_filter( $args, $instance ) {
      
        if( 'keyword_genre' === $args['format'] ) {
            $args['taxonomies'] = array( 'keyword', 'genre' );
        }
         
        return $args;
    }

    btw:
    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.

    • This reply was modified 7 years, 7 months ago by keesiemeijer.
Viewing 1 replies (of 1 total)
  • The topic ‘Multi-select Fields?’ is closed to new replies.