New to PHP.
I have a custom page template that I want to use to show a list of posts. The idea is that each post has a category and I can provide a category to a page. For example let’s say there are 5 posts with category "news" and a page called latest news, where I pass the "news" category as query-args. But then I can also use the same page template for another page, let’s say with category "blog" to receive another category. So I believe the page template should read the category assigned to the page dynamically.
Here is the code I have so far. It’s working for multiple categories as long as I pass them through an array. But then that’s not dynamic, since the categories themselves are static.
The page is not a category page, just a normal page.
'posts_per_page' => 6,'orderby' => 'date')); if(have_posts()) : while(have_posts()) : the_post(); ?> <div class="custom_page"> <div class="latest_news_cont"> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a> <!-- <a href="<?php the_permalink() ?>"><h2><?php the_title(); ?></h2></a> --> <div id ="helloworld" class="portfolio-work"><a href="<?php the_permalink() ?>" '" style="text-decoration:none;">'<h2><?php the_title(); ?></h2></a></div> <?php the_excerpt(); ?> <p style="text-align:left;"><a href="<?php the_permalink() ?>" class="readmore_news">CONTINUE READING </a></p> <br> <div class="clear"></div> </div> </div> <?php endwhile; ?> <?php else : ?>
I found some info about custom taxonomy, but couldn’t figure out how to use it. Would really appreciate any help here.