I am loading a category list in wordpress by using this function:
<?php wp_list_cats($args = array( 'current_category' => 0, 'hide_empty' => 1) );?>
Can anyone tell me how I can make the category links link to the category first post?
ie:
At the moment Category A links to url…/category/category-a
I would like Category A to link to its first post instead so url…/category-a/first-post
I tried chaning the taxonomy template which worked witht he following:
<?php
/*
Redirect To First Child
*/
if (have_posts()) {
while (have_posts()) {
the_post();
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$firstchild = $pagekids[0];
wp_redirect(get_permalink($firstchild->ID));
}
}
?>
I just need a neater solution where i dont need to modify the actual wordpress files.
Thanks
Best that i can come up with,
$posts
array now contains links to first post in each category. Put this code in functions.php:In template file to just show the links use:
Or, if you want to wrap links within HTML use something like:
Hope it helps.