Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ajay

    (@ajay)

    Hi,

    You might want to try using this in conjunction with the addon:
    https://www.ads-software.com/plugins/crp-taxonomy/

    This allows you to restrict related posts to the same category / custom taxonomy.

    Thread Starter dama503

    (@dama503)

    Hi,

    Thanks for the quick reply, I did try that addon, again works well but as the players custom post type I am using only has 1 tag/category, I have to use it for more than 1 team type, i.e. Golf, Mens. Because you can also have Tennis, Mens. The addon will catch both team types, in this case, all players linked to Mens with show.

    Thanks.

    Plugin Author Ajay

    (@ajay)

    Would it be possible to explain and illustration / example how your site is structured. I don’t think I’ve fully understood how your teams and members are structured.

    Thread Starter dama503

    (@dama503)

    Hi,

    I am using the Team Rosters Plugin, the plugin allows me to enter players names etc and a Team Category. You may have multiple Team Categories per Player, i.e.

    Player 1 – Football, Ladies
    Player 2 – Football, Gents
    Player 3 – Tennis, Gents

    Based on the above, if I use CRP without the Haddon, and selected Player1, I would get related posts for all because they share a common name in the title. If I install the addon, and select Teams as the Category to match on, and view Player 3, I would get Player 2 showing as a related post on the basis he is in the Gents Team Category, in reality, there should be no matches for Player 3.

    The reason I have to have “Football”, “Gents” instead of say, “Gents Football” is for use within another plugin.

    Hope this makes sense.

    Thanks.

    Plugin Author WebberZone

    (@webberzone)

    Hi,

    I think it’s clear now. Matching on the excerpt isn’t possible, but you could potentially try adding this piece of code into your theme’s functions.php file to match only with content.

    function filter_crp_posts_match( $match, $stuff ) {
    
       /* Optional: Only first word */
       $stuff = wp_trim_words( $stuff, 1 );
    
       $match = $wpdb->prepare( " AND MATCH (post_content) AGAINST ('%s') ", $stuff );
    
       return $match;
    }
    add_filter( 'crp_posts_match', 'filter_crp_posts_match', 10, 2 );
    Thread Starter dama503

    (@dama503)

    Hi,

    Thanks for that but my theme doesn’t seem to like it. I play around with it a little more, it did make a difference on the output but it still included records matched by Title and lost the images.

    Plugin Author Ajay

    (@ajay)

    Hi,

    The issue is that the related posts are usually pulled based on their word relevance and it isn’t the ideal solution when you have very limited words.

    Thread Starter dama503

    (@dama503)

    OK, Managed to sort this using a combination of the Taxonomy Add-on and messing around with the numbers of words matched and the filter priority.

    This was after trying several other plugins that claim to do the same thing.

    CRP is the best I’ve tried and with some tweaking it works just the way I need it too. Patience, that’s all that was required, quite a lot of patience, but got there in the end.

    Thanks all who helped or responded, really appreciate it.

    Plugin Author Ajay

    (@ajay)

    Glad to know that it worked for you ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Match on specific field.’ is closed to new replies.