-
AuthorPosts
-
July 11, 2014 at 3:27 pm #290127
I came across this instruction in this support forum to add this code to functions.php..when enable it removes the Prefix Archives for tax if( is_category( ) )
add_filter(‘avf_which_archive_output’,’avf_remove_which_archive’, 10, 3);
add_filter(‘avf_which_archive_output’,’avf_remove_which_archive’, 10, 3);
function avf_remove_which_archive($output) {
if ( is_category() ) {
$output = __(”,’avia_framework’).” “.single_cat_title(”,false);
}return $output;
}I would like to use this or something similar for other Tax that I have created. Do you know if that is possible with tax label or will only category work in the function.php in this theme. (i.e. other tax are not theme specific and could break site ?)
If so, is there an alternate way to always remove the Archieve prefix
thanks
Ed
July 12, 2014 at 4:53 pm #290534Hi Ed!
You can use the is_tax conditional: http://codex.wordpress.org/Function_Reference/is_tax instead of is_category(). Use it like:
add_filter('avf_which_archive_output', 'avf_remove_which_archive_output', 10, 1); function avf_remove_which_archive_output($output) { $output = ""; if(is_tax('portfolio_entries')) { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $output = $term->name; } return $output; }
The code above will remove the “Archive” prefix from all archive pages of the portfolio taxonomy. You can also use the second parameter to specify a special term/category of this taxonomy – i.e. is_tax(‘portfolio_entries’, ‘Books’) would just affect the term archive page of the portfolio category “Books”.
Best regards,
PeterJuly 12, 2014 at 5:18 pm #290544Thanks,
Can I use this function code that you have provided as written in Enfold without any modifications ?
Ed
July 12, 2014 at 6:46 pm #290581Hi!
Yes, if you just want to remove the “Archive” prefix from all archive pages of the portfolio taxonomy. If you want to use it with another taxonomy replace “portfolio_entries” with your custom taxonomy name. You can also use it for more than one taxonomy like:
if(is_tax('portfolio_entries') || is_tax('my_ustom_taxonomy'))
Best regards,
PeterJuly 12, 2014 at 7:23 pm #290590How would I use this for category and its children ?
if(is_tax(‘category_entries’) or like above if( is_category() )
thanks
July 12, 2014 at 8:33 pm #290619Peter,
This code removes all the info, I set the if(is_tax(‘portfolio_entries’) to if(is_tax(‘category’))
The banner originally reads:
Archive for category: Wildlife ImagesUsing your code it reads:
nullI want it to read:
Wildlife ImagesJuly 12, 2014 at 8:42 pm #290623Your code also wipes out all different tax in the banner, The code is not selective for a unique tax. It wipes out 12 different tax that I have set up.. Whihc is okay, as I don’t want archive at all, but I’l like to have the Tax Description visible
This is without the function code enabled:
http://fritzimages.com/blog/category/photography/wildlife-image/Archive for category: Wildlife Images
Archive for :RecommendationJuly 13, 2014 at 1:12 am #290657this is where I want to remove “Archive for category;” but still keep Wildlife Images
http://prntscr.com/4230yjJuly 13, 2014 at 6:59 am #290737I have tried for the pst few hours the function.pho code you provided.
it does not work at all.
if(is_tax(‘category”)) does not work, on category or any other tax.I start out with this: and I want to remove, “archive for categories” and have only “wildlife images”
http://prntscr.com/425obqusing this function code provided
http://prntscr.com/425no4all I get is for output:
http://prntscr.com/425nulInteresting enough, this code provided by a support participant
http://prntscr.com/425obqmakes the correct output
http://prntscr.com/425pjtthe problems is that it only works on category……
I don’t know how to modify it for other taxDo you ?
July 13, 2014 at 7:26 am #290738I found this function code, it however does not work for category
add_filter(‘avf_which_archive_output’, ‘avf_remove_which_archive_output’, 10, 1);function avf_remove_which_archive_output($output) {
$output = “”;if(is_tax())
{
$term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );
$output = __(”,’avia_framework’).” “.$term->name;
}return $output;
}I tried to various changes to the if(is_tax()) but could not get it to work for category
What I need is a code that is a combination, one for tax f(is_tax()) and one for if ( is_category() )
any suggestions ??
thanks
July 13, 2014 at 9:42 am #290753Hi!
is_tax() will not work on standard category archive pages. In your first post you asked how you can use this code with a custom taxonomy and I thought you don’t want to use it with post categories. If you want to use it with taxonomies/terms and post categories use it like:
add_filter('avf_which_archive_output', 'avf_remove_which_archive_output', 10, 1); function avf_remove_which_archive_output($output) { $output = ""; if(is_tax('portfolio_entries') || is_category()) { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $output = $term->name; } return $output; }
The code will affect all archives of the taxonomy “portfolio_entries” and all post category archives.
Cheers!
PeterJuly 13, 2014 at 1:11 pm #290782Thanks, I tried your code and it did not work
code used
http://prntscr.com/427nm3result
http://prntscr.com/427oxdJuly 13, 2014 at 1:19 pm #290784I also modified code just for category and it did not work
code used
http://prntscr.com/427pksresults
http://prntscr.com/427qs5July 13, 2014 at 1:22 pm #290785I modified code just for tax
code used
http://prntscr.com/427r8fresults: it works
http://prntscr.com/427r8fJuly 13, 2014 at 1:42 pm #290786Any ideas why this code does not work for category ?
July 14, 2014 at 5:28 pm #291167Hey!
Because is_tax() will not work for standard post categories. You must use is_category() for post archives. The documentation: http://codex.wordpress.org/Function_Reference/is_tax mentions this limitation: “Note that is_tax() returns false on category archives and tag archives. You should use is_category() and is_tag() respectively when checking for category and tag archives.”
Cheers!
Peter -
AuthorPosts
- The topic ‘Remove "Archive" in Theme for all Tax not just category’ is closed to new replies.