-
AuthorPosts
-
May 22, 2021 at 5:05 pm #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
SebMay 22, 2021 at 6:20 pm #1301761when 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);
May 22, 2021 at 7:53 pm #1301768Thanks 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, 6 months ago by Astaryne.
May 23, 2021 at 5:41 pm #1301848in 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 obtainedadd_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; }
May 24, 2021 at 8:14 am #1301930That 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_entriesMay 24, 2021 at 9:55 am #1301943I was focused on my type of custom post! :) not the way
Thanks for your help
Regards
Seb
> subject resolved -
AuthorPosts
- The topic ‘Change "Archive For: " for custom type’ is closed to new replies.