【问题标题】:Customizing wordpress twenty fifteen theme - Basic PHP自定义 wordpress 二十十五主题 - 基础 PHP
【发布时间】:2015-10-28 01:13:29
【问题描述】:

在官方的 Wordpress 主题 25 中,我们在 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('');

【问题讨论】:

  • 你能给我页面链接吗?
  • 主题仅在本地服务器上,如果需要我可以上传主题。但我会先尝试 user2191227 的建议

标签: php css wordpress


【解决方案1】:

您可以使用引号 (the_content('')) 替换 sprint_f 部分,并使用 the_permalink() 将 readmore 链接放置在您想要的任何位置

这是一个例子:

<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 -->

【讨论】:

  • 谢谢。你能举个例子说明你的建议吗?
猜你喜欢
  • 2015-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-24
  • 2013-10-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多