Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在没有换行符的情况下列出归档中的博客文章标题?_Php_Wordpress_Archive - Fatal编程技术网

Php 如何在没有换行符的情况下列出归档中的博客文章标题?

Php 如何在没有换行符的情况下列出归档中的博客文章标题?,php,wordpress,archive,Php,Wordpress,Archive,我有一个自定义模板,可以让我的归档页面按照日期的顺序显示我的所有博客文章,但出于格式方面的原因,我经常在标题中使用换行符,但我不希望这些换行符在归档页面上起作用 自定义存档页面模板 <?php /** * Put together by Sridhar Katakam using the code linked in StudioPress forum post * @license GPL-2.0+ * @link http://www.studiopress.com/for

我有一个自定义模板,可以让我的归档页面按照日期的顺序显示我的所有博客文章,但出于格式方面的原因,我经常在标题中使用换行符,但我不希望这些换行符在归档页面上起作用

自定义存档页面模板

<?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();

  • :
  • 替换

    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
    
    

    
    
    应该解决它。

    更换

    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
    
    

    
    

    应该解决它。

    更改
  • 此部分

    您尚未使用带标签功能

    <li>
        <span class="the_date"><?php the_time('d') ?>:</span>
        <a href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_title()); ?></a>
    </li>
    
  • :

  • 更改
  • 此部分

    您尚未使用带标签功能

    <li>
        <span class="the_date"><?php the_time('d') ?>:</span>
        <a href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_title()); ?></a>
    </li>
    
  • :