Sitemap

[insert_php]
$args = array(
‘posts_per_page’ => -1
);

$query = new WP_Query($args);
$q = array();

while ( $query->have_posts() ) {

$query->the_post();

$a = ‘‘ . get_the_title() .’‘;

$categories = get_the_category();

foreach ( $categories as $key=>$category ) {

$b = ‘

‘ . $category->name . ‘

‘;

}

$q[$b][] = $a; // Create an array with the category names and post titles
}

/* Restore original Post Data */
wp_reset_postdata();

foreach ($q as $key=>$values) {
echo $key;

echo ‘

    ‘;
    foreach ($values as $value){
    echo ‘

  • ‘ . $value . ‘
  • ‘;
    }
    echo ‘

‘;
}
[/insert_php]

„Understanding your users is the first step towards defining the exact problem. does just that!“
- Paul