Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Use meta field for taxonomy value display

Viewing 10 posts - 1 through 10 (of 37 total)
  • Leo Joskowicz
    #31507

    I would appreciate an answer regarding this, even it is a negative answer.

    Ross Moderator
    #31520

    Hey Leo

    I was just looking into something which might help you.

    So it sounds like the plugin is using Taxonomies in the regular way, but to store addition info about authors its saving that across into Post Meta.

    At the moment linking the two is not possible, but I’ve been looking at adding in a filter to html output of all the fields.

    Its a bit tricky at the moment but I need to investigate further how this can be done effectively, so you get access to the values as well as the html – in and organised manner that can be applied to every field type.

    Will take a little while before I get to develop something robust but its definitely on the todo list.

    Thanks

    Leo Joskowicz
    #32014

    Thanks Ross, appreciate the prompt reply. Looking forward!

    Ross Moderator
    #32024

    Turns out this feature is almost done 😉 Want to try the dev version when its ready tonight/tomorrow?

    davide notarantonio
    #48585

    Hi, i have the same problem, use co-authors plus and nedd to list authors by taxonomy but make them view by display name and not by slug. Are there any news about this?
    Thanks

    Ross Moderator
    #48626

    Hey Davide

    I think this will be possible – there is a filter that allows you to modify any field

    http://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Filter_Input_Object

    There is a really extensive example here:
    https://gist.github.com/rmorse/7b59b45a14b1ca179868

    To see how to change the labels of the options this one is probably your best starting point
    https://support.searchandfilter.com/forums/topic/change-post-type-labels/#post-40004

    🙂

    davide notarantonio
    #48787

    Hi, thanks, in your example it’s explained how to change a single label (from Media to Photos), but in this case, as the case of the user that began this thread, i need to print the displayname instead of slugs, so i need to change all the labels, obviously by code, while searching taxonomy auhtor fields. Is there a way to do this (or the way is in the docs you posted me?).

    Jon Watson
    #48857

    I’m struggling with this one, as well. I’ve been playing around with it for a couple of hours but have yet to come up with a solution. Will keep you posted if I do!

    Here’s what I’ve figured out thus far:

    Co-Authors Plus stores its data in terms under the custom taxonomy of ‘author’.

    Search & Filter Pro retrieves the ‘name’ field of each author:

    Term Meta

    But we don’t want this field, we want the display name.

    Co-Authors Plus itself doesn’t seem to store the display name, so we’ll need to use the value of the meta “name” field to retrieve it using a process along the lines of:

    	$author = 'corrado.poli'; // This is the value we're returning at the moment (user login) via $input_object['name']
    
    	$user = get_user_by( 'login', $author ); // Uses user login (the value that Search & Filter Pro is returning) to fetch user meta
    
    	echo 'User is ' . $user->display_name; // Returns the display name (e.g. Corrado Poli) from the user meta

    Thus far I figure we need to use if ($sfid == 123 && $input_object[‘taxonomy’] == ‘author’) {} and find some way of filtering the name field and replacing it with the display name.

    I’ll keep playing, but any advice from the coding wizards at Search & Filter Pro would be MUCH appreciated! 🙂

    Cheers me dears!

    Jon Watson
    #48858

    Whoops! Nope, being an idiot. Ignore what I said about input taxonomy. That was a load of old hogswash. Would help if slowed down for a second to realise just how the filter (and the plugin) worked!

    Getting closer:

    function filter_function_name($input_object, $sfid) {
    
    	if ($input_object['name'] == '_sft_author') {
    
    		global $coauthors_plus;
    		
    		//udpate this field before rendering
    
    			foreach($input_object['options'] as $key => $option) {
    
    				$user = $coauthors_plus->get_coauthor_by( 'user_nicename', $option );
    
        			$input_object['options'][$key]->label = $user->display_name;
    
            	}
    
    	}
    	
    	return $input_object;
    
    }
    
    add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
Viewing 10 posts - 1 through 10 (of 37 total)

The topic ‘Use meta field for taxonomy value display’ is closed to new replies.