[英]Customizing wordpress twenty fifteen theme - Basic PHP
在官方的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()將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 -->
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.