so yoast posted one interesting thing about html sitemaps here and i decided to try. i modified it a bit to match my needs:
$cats = get_categories('exclude=156');
foreach ($cats as $cat) {
echo '<ul></ul>';
echo '<span style="color:#8B0000"><strong><FONT size=2>'.$cat->cat_name.'</FONT></strong></span>';
query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
while(have_posts()) {
the_post();
$category = get_the_category();
if ($category[0]->cat_ID == $cat->cat_ID) {
echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
}
}
}
it could be called ok with
<?php get_template_part('/partials/anime_list');?>, but i want it to be called with shortcode from for example created page with address anime4psp.org/anime-list . How do i create shortcode? i tried like
<?php
function anime_list() {
$cats = get_categories('exclude=156');
foreach ($cats as $cat) {
echo '';
echo ''.$cat->cat_name.'';
query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
while(have_posts()) {
the_post();
$category = get_the_category();
if ($category[0]->cat_ID == $cat->cat_ID) {
echo ''.get_the_title().'';
}
}
}
}
add_shortcode('anime-list', 'anime_list');
?>
and
<?php
add_shortcode('anime_list', 'anime_list');
function anime_list()
{
$cats = get_categories('exclude=156');
foreach ($cats as $cat) {
echo '<ul></ul>';
echo '<span style="color:#8B0000"><strong><FONT size=2>'.$cat->cat_name.'</FONT></strong></span>';
query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
while(have_posts()) {
the_post();
$category = get_the_category();
if ($category[0]->cat_ID == $cat->cat_ID) {
echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
}
}
}
}
?>
but none of it worked. can you help me to make it work please?