Deseja criar taxonomias personalizadas no WordPress?
Por padrão, o WordPress permite que você organize seu conteúdo com categorias e tags. Mas, com as taxonomias personalizadas, você pode personalizar ainda mais a maneira de classificar seu conteúdo.
Neste artigo, mostraremos como criar facilmente taxonomias personalizadas no WordPress com ou sem o uso de um plugin.
O que é uma taxonomia do WordPress?
Uma taxonomia do WordPress é uma forma de organizar grupos de posts e tipos de posts personalizados.
Por padrão, o WordPress vem com duas taxonomias chamadas categorias e tags. Você pode usá-las para organizar as publicações do seu blog.
No entanto, se você estiver usando um tipo de post personalizado, as categorias e tags podem não parecer adequadas para todo o conteúdo.
Por exemplo, você pode criar um tipo de post personalizado chamado “Livros” e classificá-lo usando uma taxonomia personalizada chamada “tópicos”.
Você pode adicionar termos de tópicos como Aventura, Romance, Terror e outros tópicos de livros que desejar. Isso permitiria que você e seus leitores classificassem e filtrassem facilmente os livros por tópico.
As taxonomias também podem ser hierárquicas, o que significa que você pode ter tópicos principais, ou pais, como Ficção e Não ficção. Em seguida, você teria subtópicos, ou filhos, em cada categoria.
Por exemplo, a categoria principal Fiction (Ficção) poderia ter Adventure (Aventura), Romance (Romance) e Horror (Horror) como filhos.
Agora que você já sabe o que é uma taxonomia personalizada, vamos aprender a criar taxonomias personalizadas no WordPress.
Embora a criação de taxonomias personalizadas seja poderosa, há muito a ser abordado. Para ajudá-lo a configurar isso corretamente, criamos uma tabela de conteúdo simples abaixo:
Criar taxonomias personalizadas no WordPress (tutorial em vídeo)
Se você preferir instruções escritas, continue lendo.
Criação de taxonomias personalizadas com um plug-in (a maneira mais fácil)
A primeira coisa que você precisa fazer é instalar e ativar o plug-in Custom Post Type UI. Para obter detalhes, consulte nosso guia sobre como instalar um plug-in do WordPress.
Neste tutorial, já criamos um tipo de post personalizado e o chamamos de “Books”. Portanto, certifique-se de que você tenha criado um tipo de post personalizado antes de começar a criar suas taxonomias.
Em seguida, acesse o item de menu CPT UI ” Add/Edit Taxonomies (Adicionar/Editar taxonomias ) na área de administração do WordPress para criar sua primeira taxonomia.
Nessa tela, você precisará fazer o seguinte:
- Crie o slug de sua taxonomia (isso será incluído em seu URL)
- Criar o rótulo plural
- Criar o rótulo singular
- Preenchimento automático de rótulos
Sua primeira etapa é criar um slug para a taxonomia. Esse slug é usado no URL e nas consultas de pesquisa do WordPress.
Ele só pode conter letras e números, e será automaticamente convertido em letras minúsculas.
Em seguida, você preencherá os nomes no plural e no singular da sua taxonomia personalizada.
A partir daí, você tem a opção de clicar no link ‘Populate additional labels based on chosen labels’ (Preencher rótulos adicionais com base nos rótulos escolhidos). Se você fizer isso, o plug-in preencherá automaticamente o restante dos campos de rótulo para você.
Agora, role a tela para baixo até a seção “Additional Labels” (Rótulos adicionais). Nessa área, você pode fornecer uma descrição do seu tipo de postagem.
Esses rótulos são usados no painel do WordPress quando você está editando e gerenciando conteúdo para essa taxonomia personalizada específica.
Em seguida, temos a opção de configurações. Nessa área, você pode configurar diferentes atributos para cada taxonomia que criar. Cada opção tem uma descrição detalhada do que faz.
Na captura de tela acima, você verá que optamos por tornar essa taxonomia hierárquica. Isso significa que os “Assuntos” da nossa taxonomia podem ter subtópicos. Por exemplo, um assunto chamado Ficção pode ter subtópicos como Fantasia, Suspense, Mistério e outros.
Há muitas outras configurações mais abaixo na tela do painel do WordPress, mas você pode deixá-las como estão para este tutorial.
Agora você pode clicar no botão “Add Taxonomy” (Adicionar taxonomia) na parte inferior para salvar sua taxonomia personalizada.
Depois disso, vá em frente e edite o tipo de postagem associado a essa taxonomia no editor de conteúdo do WordPress para começar a usá-la.
Criação manual de taxonomias personalizadas (com código)
Esse método requer que você adicione código ao seu site WordPress. Se você nunca fez isso antes, recomendamos que leia nosso guia sobre como adicionar facilmente trechos de código no WordPress.
Não recomendamos a edição direta dos arquivos do WordPress porque qualquer pequeno erro pode danificar todo o seu site. É por isso que recomendamos que todos usem o WPCode, o plug-in de snippet de código mais fácil e seguro disponível.
Para começar, você precisará instalar e ativar o plug-in gratuito WPCode. Para obter instruções detalhadas, consulte nosso guia passo a passo sobre como instalar um plug-in do WordPress.
1. Criação de uma taxonomia hierárquica
Vamos começar com uma taxonomia hierárquica que funciona como categorias e pode ter termos pai e filho.
Depois de instalar e ativar o WPCode, você pode navegar até Code Snippets ” Add Snippet no painel do WordPress.
Passe o mouse sobre ‘Add Your Custom Code (New Snippet)’ e clique em ‘Use Snippet’.
Em seguida, você será levado à página “Create Custom Snippet” (Criar snippet personalizado). Basta nomear seu novo snippet de código e colar o seguinte código na área de texto.
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_subjects_hierarchical_taxonomy', 0 );
//create a custom taxonomy name it subjects for your posts
function create_subjects_hierarchical_taxonomy() {
// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI
$labels = array(
'name' => _x( 'Subjects', 'taxonomy general name' ),
'singular_name' => _x( 'Subject', 'taxonomy singular name' ),
'search_items' => __( 'Search Subjects' ),
'all_items' => __( 'All Subjects' ),
'parent_item' => __( 'Parent Subject' ),
'parent_item_colon' => __( 'Parent Subject:' ),
'edit_item' => __( 'Edit Subject' ),
'update_item' => __( 'Update Subject' ),
'add_new_item' => __( 'Add New Subject' ),
'new_item_name' => __( 'New Subject Name' ),
'menu_name' => __( 'Subjects' ),
);
// Now register the taxonomy
register_taxonomy('subjects',array('books'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'subject' ),
));
}
Não se esqueça de alterar o tipo de código para “PHP Snippet” e alternar a opção para “Active”.
Não se esqueça de substituir o nome da taxonomia e os rótulos no snippet por seus próprios rótulos de taxonomia. Você também notará que essa taxonomia está associada ao tipo de postagem Books (Livros). Você precisará alterar isso para o tipo de postagem com o qual deseja usá-la.
Em seguida, role para baixo e certifique-se de que “Auto Insert” e “Run Everywhere” estejam selecionados na caixa de inserção.
Depois disso, você pode rolar de volta para a parte superior e clicar no botão “Update” (Atualizar) para ativar suas alterações.
2. Criação de uma taxonomia não hierárquica
Para criar uma taxonomia personalizada não hierárquica, como Tags, você usará o WPCode e seguirá exatamente as mesmas etapas acima, só que, em vez disso, usará este código:
//hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires
add_action( 'init', 'create_topics_nonhierarchical_taxonomy', 0 );
function create_topics_nonhierarchical_taxonomy() {
// Labels part for the GUI
$labels = array(
'name' => _x( 'Topics', 'taxonomy general name' ),
'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
'search_items' => __( 'Search Topics' ),
'popular_items' => __( 'Popular Topics' ),
'all_items' => __( 'All Topics' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Topic' ),
'update_item' => __( 'Update Topic' ),
'add_new_item' => __( 'Add New Topic' ),
'new_item_name' => __( 'New Topic Name' ),
'separate_items_with_commas' => __( 'Separate topics with commas' ),
'add_or_remove_items' => __( 'Add or remove topics' ),
'choose_from_most_used' => __( 'Choose from the most used topics' ),
'menu_name' => __( 'Topics' ),
);
// Now register the non-hierarchical taxonomy like tag
register_taxonomy('topics','books',array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
}
Observe a diferença entre os dois trechos de código. Na função register_taxonomy()
, o valor do argumento hierárquico
é definido como true
para a taxonomia do tipo categoria e false
para taxonomias do tipo tags.
Além disso, na matriz de rótulos para taxonomias não hierárquicas, adicionamos null
para os argumentos parent_item
e parent_item_colon
, o que significa que nada será mostrado na interface do usuário para criar um item pai ou uma taxonomia que possa ter subtópicos.
Novamente, não se esqueça de editar o código para incluir seus próprios rótulos de taxonomia personalizados.
Exibição de taxonomias personalizadas
Agora que criamos taxonomias personalizadas e adicionamos alguns termos, seu tema do WordPress ainda não os exibirá.
Para exibi-los, você precisará adicionar algum código ao seu tema ou tema filho do WordPress.
Esse código precisará ser adicionado aos arquivos de modelos em que você deseja exibir os termos.
Você pode adicionar manualmente esse snippet aos arquivos do seu tema, como single.php, content.php, archive.php ou index.php. Para descobrir qual arquivo você precisa editar, consulte nosso guia de hierarquia de modelos do WordPress para obter detalhes.
No entanto, isso pode danificar seu site se não for feito corretamente, por isso recomendamos mais uma vez o uso do plug-in gratuito WPCode.
Você precisará adicionar o seguinte código onde deseja exibir os termos.
<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>
Siga as etapas acima para colar o snippet no WPCode.
Mas, em Inserção, você deve clicar no menu suspenso ao lado de “Localização” e selecionar onde deseja exibir a taxonomia, como antes da postagem, depois dela ou até mesmo entre parágrafos.
Para este tutorial, selecionaremos “Insert After Post” (Inserir após a postagem).
Você pode ver na imagem abaixo como ela aparecerá em seu site ativo.
Adição de taxonomias para posts personalizados
Agora que você sabe como criar taxonomias personalizadas, vamos colocá-las em prática com um exemplo.
Vamos criar uma taxonomia e chamá-la de Não ficção.
Como temos um tipo de post personalizado chamado ‘Books’, é semelhante à maneira como você cria um post de blog comum.
No painel do WordPress, vá para Books ” Subjects para adicionar um termo ou assunto.
Nessa tela, você verá 4 áreas:
- Nome
- Lesma
- Pais
- Descrição
No nome, você escreverá o termo que deseja adicionar. Você pode pular a parte do slug e fornecer uma descrição para esse termo específico (opcional).
Por fim, clique no botão “Add New Subject” (Adicionar novo assunto) para criar sua nova taxonomia.
Seu termo recém-adicionado aparecerá na coluna da direita.
Agora você tem um novo termo que pode usar em suas postagens de blog.
Você também pode adicionar termos diretamente ao editar ou escrever conteúdo nesse tipo específico de postagem.
Basta acessar a página Books ” Add New para criar uma postagem. No editor de postagens, você encontrará a opção de selecionar ou criar novos termos na coluna da direita.
Depois de adicionar os termos, você pode ir em frente e publicar o conteúdo.
Todas as suas postagens arquivadas sob esse termo poderão ser acessadas em seu site em seu próprio URL. Por exemplo, as postagens arquivadas sob o assunto Ficção apareceriam no seguinte URL:
https://example.com/subject/fiction/
Adição de taxonomias personalizadas ao menu de navegação
Agora que você criou taxonomias personalizadas, talvez queira exibi-las no menu de navegação do seu site.
Vá para Appearance ” Menus e selecione os termos que deseja adicionar na guia de taxonomia personalizada que aparece no lado esquerdo da tela.
Não se esqueça de clicar no botão “Save Menu” para salvar suas configurações.
Agora você pode visitar seu site para ver o menu em ação.
Para obter mais detalhes, consulte nosso guia passo a passo sobre como criar um menu suspenso no WordPress.
Levar as taxonomias do WordPress mais longe
Há uma infinidade de coisas que você pode fazer com taxonomias personalizadas. Por exemplo, você pode exibi-las em um widget da barra lateral ou adicionar ícones de imagem para cada termo.
Você também pode adicionar um feed RSS habilitado para taxonomias personalizadas no WordPress e permitir que os usuários se inscrevam em termos individuais. Dessa forma, seus leitores só receberão atualizações sobre o conteúdo específico que interessa a eles.
Se quiser personalizar o layout de suas páginas de taxonomia personalizada, você pode consultar o SeedProd. Ele é um construtor de páginas e temas do WordPress do tipo arrastar e soltar que permite criar layouts personalizados sem qualquer codificação.
Esperamos que este artigo tenha ajudado você a aprender como criar taxonomias personalizadas no WordPress. Talvez você também queira ver nosso guia sobre como rastrear os visitantes do site e como criar um tema personalizado do WordPress sem escrever nenhum código.
Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Jiří Vaněk says
Thank you for the clear instructions. I would like to make my own taxonomy for tutorials on the site. This tutorial is great and clear, thanks.
WPBeginner Support says
Glad it was helpful
Administrador
Kira says
Hello.
I don’t understand this part:
ID, ‘topics’, ‘Topics: ‘, ‘, ‘, ‘ ‘ ); ?>
I mean, should I paste exactly that part into my loop-single.php?
I’m using a taxonomy called “writer”
WPBeginner Support says
It would depend on where you want to display the terms, normally it would be added to the single.php.
Administrador
Wolfgang says
Hi,
I used your article to create a CPT with a hierarchical and a non-hierarchical taxonomy attached to it. I created a few entries and it all seems to be working fine. Both taxonomies display fine in their respective archive pages. One thing I noticed though when I tried to add the taxonomies to the menu was that the non-hierarchical taxonomy was available in the “Add menu item” column but the hierarchical taxonomy was NOT.
Is that an expected behavior? If not what could be going wrong?
Thanks
WPBeginner Support says
The most common issues you could check would be that you have published content in the taxonomy and you may want to test adding a different content type to test if it is an issue with the taxonomy or something else.
Administrador
mb says
what does this line do
‘menu_name’ => __( ‘Subjects’ ),
is this in order to add taxonomies to the menu
aditya says
hii i try everything but i taxonomy not showing in product. please help me.
WPBeginner Support says
You would want to check under your preferences to ensure it is not hidden for your user.
Administrador
Gina Wilson says
This tutorial and specifically the part of how to display the custom taxonomy was a lifesaver! I’m very much a beginner and this was very helpful in understanding where I went wrong in my coding.
Thank you!!!
WPBeginner Support says
Glad our guide was helpful
Administrador
fengquanli says
this is very confident with the custom post ui, thanks very much ,it’s very useful for get them.
WPBeginner Support says
Glad our guide was helpful
Administrador
Bruno Oliveira says
Awesome tutorial! i have one question. how do i use my new taxonomy slug as permalink like category (/%category%/%year%/%monthnum%/%day%/%postname%/)
I want something like /%custom_taxonomy%/%year%/%monthnum%/%day%/%postname%/
i keep getting 404 error
WPBeginner Support says
That is not something WordPress would allow by default and would require some custom coding to set up.
Administrador
vikas says
i tried the plugin method , it sucessfully created a new category in custom post type but it is not showing on my posts like tags and other categoties. can you help me with that?
WPBeginner Support says
You would want to reach out to the support for your specific theme for customizing the display to include your taxonomy.
Administrador
Richard says
I am creating a podcast network where I have multiple podcasts on a single site with episodes under each individual podcast. Would something like this work for that? I really don’t want to go the multi site route.
WPBeginner Support says
You can certainly use this should you want or another option would be to create a custom post type depending on your preference.
Administrador
Maria says
Hello is possible add the custom taxonomies to a custom product type?
I create a custom product call drinks and i have several taxonomies like country, material and etc
I want when the user click in drinks then only apperas those taxonomies, is this posiible?
WPBeginner Support says
You should be able to using the plugin method.
Administrador
Parveen Kaushik says
Hi,
Thanks for this article, I am getting 404 page after using this code, can you help me
WPBeginner Support says
If you haven’t done so yet, resave your permalinks for the most common solution
Administrador
Mike Smith says
this code works great on my site for work. Can you tell me how to add the custom taxonomy into the site’s rss feed?
WPBeginner Support says
It would depend on what you are looking for, for a starting point you would want to take a look at our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-make-a-separate-rss-feed-for-each-custom-post-type-in-wordpress/
Administrador
angela says
thank you for taking the time to post this, this was the first site that actually explained this and it made sense, haha. im a happy camper now
WPBeginner Support says
You’re welcome, glad our guide could help simplify the process
Administrador
Jem says
How to show custom taxonomy (checkbox list) in Post editor page like category and tag?
WPBeginner Support says
It would depend on which method you used to create the custom taxonomy, if you’re using the plugin you would want to reach out to the plugin’s support to make sure they have show_in_rest set to true for seeing it in the block editor.
Administrador
Jem says
No, I am not using any plugin. I have just copy paste your snippet. Its create new taxonomy. But it is not display in post editor page like category, tags display on rightside panel.
Can you please guide me how can I show custom taxonomy in post editor page?
WPBeginner Support says
In the register_taxonomy array, you would want to first try adding a new line with the code below:
‘show_in_rest’ => true,
Jim Gersetich says
The first half of this post is completely useless. the Simple Taxonomy plugin doesn’t work with the current WordPress version, and it hasn’t been updated in four years.
Please try to find another plugin and change that section to go with the new one.
WPBeginner Support says
Thank you for letting us know, we’ll certainly take a look at updating this article.
Administrador
joe barrett says
Don’t forget to add ‘show_in_rest’ => true,
if you want to use your custom items in rest api to $args
WPBeginner Support says
Thanks for sharing this for those wanting to add this functionality.
Administrador
Michael Morad-McCoy says
I tried putting this in a site-specfic plug-in and get the following in a box at the top:
y() expects parameter 1 to be a valid callback, function ‘create_topics_hierarchical_taxonomy’ not found or invalid function name in /home2/kaibabpr/public_html/wp-includes/class-wp-hook.php on line 286
Warning: Cannot modify header information – headers already sent by (output started at /home2/kaibabpr/public_html/wp-includes/class-wp-hook.php:286) in /home2/kaibabpr/public_html/wp-admin/includes/misc.php on line 1198
as this is the first time I tried this, I’m at a loss.
WPBeginner Support says
You may want to ensure your site-specific plugin is a php file after you added the code as sometimes your operating system can try to edit the file type.
Administrador
Naji Boutros says
Do you have a different plugin to recommend?
Ajeet singh says
this is very helpful tutorial …..thnks a lot.
Suresh says
Thanks for sharing this code. I used non-hierarchy code, and admin part is working fine. I have created a separate template as well like taxonomy-[taxoName]-.php But while trying to access the URL, giving HTTP error 500. I have tried multiple things, like new cache starts, permalink re-save, new .htaccess and memory increase. even then page is not working. kindly help
Rabby says
WOW, Amazing and helpful details. I’ve created my custom taxonomy using manual rules. Thanks
Joseph Peter says
Hi,
than you for this useful information, iam new to wordpress and i wanted to know the meaning thats i landed here, it was actually helpful.
Best Regards
Joseph Peter
Cindi Gay says
I used the code for adding a tag to a custom post type. Luckily Topics is exactly the label I needed so all I needed to change was post to lesson (I am modifying the LifterLMS lesson post type).
Now I want to display the tags. I tried using the default WordPress Tag Cloud but it does not change to the newly added tag. It continues to show all my post tags even when I choose Topics
Is there a step I am missing? How do I display the new tag: Topics?
Ero says
Taxonomies don’t behave exactly like default posts’ categories. They don’t appear in the URL (especially for nested taxonomies). Is there any way to set a custom taxonomy associated to a custom post type to behave like posts’ categories ?
Rangan Roy says
I have used this code in my gallery custom post type for category support. It shows the name of the category but when i click on the category name it shows 404:error not found. Please help me to solve it. I want the category posts to show on my archive.php page.
Utshab Roy says
I got this same problem that you are facing. The way I solved it is very easy. Go to your permalink settings and click the save button. Refresh the page. This simple step will save the issue.
Carol says
This worked! Thank you so much.
Russell says
Hi, I created custom meta box with new category. I can also show it to the post page. But when I click to the newly created category item it gives a 404 page. I wan it to work like tags, default category or author. So that If I click it shows all the post under that category.
Olivier says
Hello,
I am new to WordPress and coding in general. This tutorial is very well explained, thank you.
However I don’t understand how to display the terms of my taxonomy on my pages.
Where do I have to go to “Add this single line of code in your single.php file within the loop” ?
Thank you for your help
Best,
Olivier
Azamat says
Thank you so much for this great tutorial!
I created custom taxanomy on my website dedicated to books and now I’m able to filter books by authors!
James Angel says
The trouble with some plugins is that they may not be compatible with all themes. I have found that it pays to have a qualified developer do his/her part and test and troubleshoot any Web site alteration after adding a plugin or updating WordPress to a newer version to ensure everything works as it should.
paul says
Man you are a legend,
i struggled 3 days to get this, which i found in many websites, but not as clear as this.
Thanks!
WPBeginner Support says
Hey Paul, glad you found it helpful. Don’t forget to follow us on Facebook for more WordPress tips and tutorials.
Administrador
Rangan Roy says
I have used this code in my gallery custom post type for category support. It shows the name of the category but when i click on the category name it shows 404.php page. Please help me to solve it. I want the category posts to show on my archive.php page.
Ayla says
I’ve created a custom post type and a taxonomy to go with it, but when I create a custom post and add tags to it they don’t show up like normal tags do on normal posts. How do I get them to display at the bottom of the post like normal so people can click on them and find more like it?
Thank you!
-Ayla
WPBeginner Support says
You will need to create a new template to display your custom post type and edit that template to show your custom taxonomy.
Administrador
Giulia says
Hi everybody! First of all thank you for this article!
I’ve found that “Simple Taxonomies” plugin is kind of out of date, since it hasn’t been updated since 2 years…. do you have any other plugin to suggest to create custom taxonomies?
thanks
Giulia
Mario says
I’m not the author of this post, but I use “Custom Post Type UI” to create custom taxonomies. With 300k installs, I’m pretty sure this plugin is as close as you can get to industry standard.
Hope this helps!
Ryan Hall says
Amazing. thank you!
Ryan says
How do you disassociate the posts with the “regular” categories?
WPBeginner Support says
Please see our guide on how to merge and bulk edit categories and tags in WordPress.
Administrador
Sunny says
Hello,
The description is not prominent by default; however, some themes may show it. But still show on front.
How to hide taxonomy description from front ?
I want to add description on taxonomy but i don’t want they show on front .
Please tell me about what i can do.
Thank You
ajax says
How do one automate the population of the taxonomy value with the value in a custom field.
Charles Hall says
The article is OK, but the video is very poor. The sound quality is bad, she talks way too fast, obvious things are elaborated on but the explanation of what you’re doing and why is missing, as is the other content in the lower portion of the article.
Jennifer says
I am working on a WordPress website. I created categories using a plugin called “Categories Images”. One of the categories is named “Videos” so there is one folder/category that is supposed to show videos but images. The problem is, because the plugin is designed to upload images only, the YouTube videos do not show up. How can I edit the PHP files (create a custom taxonomy, edit single.php, edit taxonomy-{taxonomy-slug}.php, etc.) so that the post can show and play YouTube videos??
Jamie Wallace says
If you want more control over how things are pulled from the backend to the frontend look into using the Advanced Custom Fields plugin. This is a plugin for developers (so some code is involved) but its very powerful for things like what you ask
Muhammad says
Hi I have followed the manual way of creating custom taxonomy and i just used Ads/Ad instead of Topics/Topic . But i don’t see any custom taxonomy in post editor though i checked the custom taxonomy form Screen Options.
though the custom taxonomy(Ads) is showing in admin submenu under Posts.
Muhammad says
Here is my code snipped in functions.php file
_x( ‘Ads’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘Ad’, ‘taxonomy singular name’ ),
‘search_items’ => __( ‘Search Ads’ ),
‘all_items’ => __( ‘All Ads’ ),
‘parent_item’ => __( ‘Parent Ad’ ),
‘parent_item_colon’ => __( ‘Parent Ad:’ ),
‘edit_item’ => __( ‘Edit Ad’ ),
‘update_item’ => __( ‘Update Ad’ ),
‘add_new_item’ => __( ‘Add New Ad’ ),
‘new_item_name’ => __( ‘New Ad Name’ ),
‘menu_name’ => __( ‘Ads’ ),
);
// Now register the taxonomy
register_taxonomy(‘ads’,array(‘post’), array(
‘hierarchical’ => true,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘ad’ ),
));
}
?>
Robert Herold says
How to show the number of posts on taxonomy-{taxonomy-slug}.php?
Robert Herold says
How can I display my custom taxonomies list like the category list
WPBeginner Support says
Please see our guide How to display custom taxonomy terms in WordPress sidebar widgets.
Administrador
Robert Herold says
Wow! Thanx! Superb!!!!!! :))
Abdul Rauf Bhatti says
Hy Dear WPBEGINNER SUPPORT,
I have learned many things in this tutorial next time will you please elaborate functions parameter which you have used some time i got in trouble or confused with parameters.
Thanks a lot Nice tutorial 5 rating
WPBeginner Support says
Thanks for the feedback, we will try to improve our code explanation in the future.
Administrador
lee says
Is there a way to get multiple custom taxonomy to use the same slug or same url? Please show us how if you or anyone knows.
pdepmcp says
It may sound obvious, but…remember to refresh the permalink cache or you can waste some hours trying to figure out why archive pages don’t work…
Ilya says
Thank you very much!!!
I wasted hours in debug mode, but cannot determine why my permalink redirects to 404 page! But after flushing “permalink cache” all works fine.
Thank you again!
winson says
Hello.
How can I get a different Posts Link? I mean I want to get 2 different links after I published a New Post.
E.G:
Category Name – > Facebook (theme template A)
Topic Name – > Twitter (theme template B)
Then I submit a post to these 2 Categories. I want get 1 link for “Facebook” and 1 Link for “Twitter”.
Best Regards
foolish coder says
how to create single pages / templates for taxonomies?
I mean like single.php not like category.php
Alex says
Try taxonomy.php ()
WPBeginner Staff says
Yes, you can do that.
fatima says
what if we want to create more than 2 taxonomies, categories style (hierarchy true)
Aalaap Ghag says
I’m building a site which has multiple item thumbnails, each of which leads to a page with multiple images for that item (i.e. product). Are taxonomies the way to go or should I be looking at something else?