php - 自定义 wordpress 25 主题 - 基本 PHP

标签 php css wordpress

在官方 Wordpress 主题二十十五中,我们在 content.php 文件中有以下代码:

<div class="entry-content">
    <?php
        /* translators: %s: Name of current post */
        the_content( sprintf(
            __( 'Continue reading %s', 'twentyfifteen' ),
            the_title( '<span class="screen-reader-text">', '</span>', false )
        ) );

        wp_link_pages( array(
            'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
            'after'       => '</div>',
            'link_before' => '<span>',
            'link_after'  => '</span>',
            'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
            'separator'   => '<span class="screen-reader-text">, </span>',
        ) );
    ?>
</div><!-- .entry-content -->

我正在尝试将自定义样式应用于“继续阅读”链接(并且仅链接),但问题是“继续阅读”已经是具有“条目内容”样式的 div 的一部分。

最好我希望在其他地方有“继续阅读”,但我很困惑该怎么做。

我不太熟悉 PHP,老实说,这可能是这里的主要问题。我花了大约一个小时试图研究如何做到这一点,但我可能没有经验来理解我正在阅读的内容。

已解决:编辑/更新:

以下代码对我有用。这将插入阅读更多链接:

<div class="more-link">
<a href="<?php the_permalink(); ?>">Read more</a>
</div>

我也改了:

the_content( sprintf(
        __( 'Continue reading %s', 'twentyfifteen' ),
        the_title( '<span class="screen-reader-text">', '</span>', false )

为此:

the_content('');

最佳答案

您可以用引号 (the_content('')) 替换 sprint_f 部分,并使用 the_permalink() 将阅读更多链接放在任何您想要的地方

这是一个例子:

<div class="entry-content">
<?php
    /* translators: %s: Name of current post */
    the_content('');

?>
<a href="<?php the_permalink(); ?>">Read more</a>
<?php
    wp_link_pages( array(
        'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
        'after'       => '</div>',
        'link_before' => '<span>',
        'link_after'  => '</span>',
        'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
        'separator'   => '<span class="screen-reader-text">, </span>',
    ) );
?>
</div><!-- .entry-content -->

关于php - 自定义 wordpress 25 主题 - 基本 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33368004/

相关文章:

html - css table td 三重对 Angular 分割

以页面为父级的 Wordpress 自定义帖子类型?

javascript - 在 wordpress 上使用自定义 CSS 制作动画

php - 发现Python代码转换为PHP时的逻辑错误

php - 循环并显示 php 列中的所有数据库条目

html - 相对于 previous() div 的位置 div

php - WordPress 覆盖私有(private)页面的 404

PHP : Fatal error: Uncaught Error: Class 'abc\abc' not found in demo. PHP

php - IntlDateFormatter::Parse 返回日期解析失败:U_PARSE_ERROR

css - 将 float 元素与图像和文本对齐