Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1301755

    Hi
    I would like to change “Archive for” by “Search for” for my custom post.
    I find this code :

    add_filter('avf_which_archive_output','avf_change_which_archive', 10, 3);
    function avf_change_which_archive($output)
    {
        $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
        if(is_tax('portfolio_entries')){
            $output = __('Our Work:','avia_framework')." ".$term->name; 
        } else {
            $output = __('Archive for:','avia_framework')." ".$term->name; 
        }
    
    	return $output;
    }

    I think I must change this part :

    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
        if(is_tax('portfolio_entries')){

    But by what ?
    My custom post slug : publication_post
    Thanks
    Seb

    #1301761

    when you hover on dashboard your CPT “Categories” what is shown on your browser for taxonomie as you can see here by portfolio:

    this is the analogon in your code above – if it is as you suspect: publication_post
    try:

    function avf_change_which_archive($output){
    	$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    		if(is_tax('publication_post')){
    			$output = __('Search for:','avia_framework')." ".$term->name; 
    		} 
    		else {
    			$output = __('Archive for:','avia_framework')." ".$term->name; 
    		}
    	return $output;
    }
    add_filter('avf_which_archive_output','avf_change_which_archive', 10, 3);
    #1301768

    Thanks but I already try this… not work…

    Over my publication_post I have only this : http://andre-revil/wp-admin/edit.php?post_type=publication_post

    • This reply was modified 3 years, 7 months ago by Astaryne.
    #1301848

    in fact the solution is very simple: it is not the slug of the custom post but the slug of the taxonomies… of course.
    small misunderstanding with the answer obtained

    add_filter('avf_which_archive_output','avf_change_which_archive', 10, 3);
    function avf_change_which_archive($output)
    {
    	$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    	if(is_tax('publi_categories') || is_tax('publi_revues')){
            $output = __('Search for:','avia_framework')." ".$term->name; 
        } else {
            $output = __('Archive for:','avia_framework')." ".$term->name; 
        }
    	return $output;
    }
    #1301930

    That was exactly what I suspected, that you had not correctly determined the taxonomy of your CPT, hence why I wrote: if it is as you suspect: publication_post.
    on post-type : portfolio it is portfolio_entries

    #1301943

    I was focused on my type of custom post! :) not the way
    Thanks for your help
    Regards
    Seb
    > subject resolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Change "Archive For: " for custom type’ is closed to new replies.