I used a shortcode to include my own customized archive on a WordPress page.
Currently it looks like this:
- Here is title number 1
- Title 2
What I know want to achieve is something like this:
H:
- Here is title number 1
T:
- Title 2
Does somebody know if a function for that already exists somewhere? My code is currently pretty straight forward:
//[show_archive]
function create_archive( $atts ){
$args = array(
'post_type' => 'post',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1,
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li><a href="'.get_the_permalink().'" title="'.get_the_title().'">' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
_e("Es sind keine beiträge gefunden worden.");
}
/* Restore original Post Data */
wp_reset_postdata();
}//function
add_shortcode( 'show_archive', 'create_archive' );
Thanks!
1 comment
Comments are closed.