I am completely new in Wordpress, please forgive me for my stupid question. I want to create menu with all categories. I created such menu but after clicking on specific menu item with category name it links me to my home page. What code should i add to my page to display all posts with specific category?
0
votes
Can you post your category menu code here? Are you getting category URLs correctly?
- Outsource WordPress
Hello, It is already in Wordpress. If i understand your question, then it is already shown the posts when you click a category link. For example Just a create a category and assign some posts. After that, go to the menu and add a category link to the menu. It will give you answer
- Ranjit
Hi I will give you the code below. But you can do it the way the above comment has mentioned.
- EstablishedRebel
Add archive.php on your theme folder. The code for archive.php, you can easily download from any other theme. And then you can set html orientation as according to your theme.
- Shashank Sharma
1 Answers
1
votes
Inside your wordpress theme you must have a page called "content.php" Which will get included through the code below. In that template you can huse the wordpress functions like so... the_title(); And so on.. You will just have to check the Wordpress Codex
$args['tax_query'][] =
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'category slug must go here'
);
<?php $query = new WP_Query($args); ?>
<?php while ( $query->have_posts() ) : the_post(); ?>
<div>
<?php
$query->the_post();
get_template_part( 'content', get_post_format() );
?>
</div>
<?php endwhile; ?>