Reputation: 2866
I have this custom template to make my archives page show all my blog posts in order of their date, but for formatting reasons I often use line-breaks in the title, but I don't want those line-breaks to work here on the archives page.
custom_archive_page_template
<?php
/**
* Put together by Sridhar Katakam using the code linked in StudioPress forum post
* @license GPL-2.0+
* @link http://www.studiopress.com/forums/topic/creating-custom-page-templates/#post-82959
*/
//* Template Name: Custom Archive
//* Remove standard post content output
remove_action( 'genesis_post_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_entry_content', 'sk_page_archive_content' );
add_action( 'genesis_post_content', 'sk_page_archive_content' );
/**
* This function outputs posts grouped by year and then by months in descending order.
*
*/
function sk_page_archive_content() {
global $post;
echo '<ul class="archives">';
$lastposts = get_posts('numberposts=-1');
$year = '';
$month = '';
foreach($lastposts as $post) :
setup_postdata($post);
if(ucfirst(get_the_time('F')) != $month && $month != ''){
echo '</ul></li>';
}
if(get_the_time('Y') != $year && $year != ''){
echo '</ul></li>';
}
if(get_the_time('Y') != $year){
$year = get_the_time('Y');
echo '<li><h2>' . $year . '</h2><ul class="monthly-archives">';
}
if(ucfirst(get_the_time('F')) != $month){
$month = ucfirst(get_the_time('F'));
echo '<li><h3>' . $month . '</h3><ul>';
}
?>
<li>
<span class="the_date"><?php the_time('d') ?>:</span>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php
}
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
genesis();
You can see the problem here: www.AnthonyGalli.com
Upvotes: 0
Views: 60
Reputation: 81
Change <li></li>
This Part
you have not used strip_tags function.
<li>
<span class="the_date"><?php the_time('d') ?>:</span>
<a href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_title()); ?></a>
</li>
Upvotes: 3
Reputation: 1328
Replacing
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
with
<a href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_title()); ?></a>
Should solve it.
Upvotes: 1