Php 如何插入“;作者;Wordpress所需主题中的代码?
一直试图在Wordpress主题上插入“作者”Php 如何插入“;作者;Wordpress所需主题中的代码?,php,wordpress,Php,Wordpress,一直试图在Wordpress主题上插入“作者”Bycode(8Bit要求)。请求帮助。需要在文章/页面标题之后和日期之前插入 代码如下: <header> <?php if ( 0 < strlen( get_the_title() ) ) { ?> <h1 class="entry-title"> <a href="<?php the_permalink(); ?>">
By
code(8Bit要求)。请求帮助。需要在文章/页面标题之后和日期之前插入
代码如下:
<header>
<?php if ( 0 < strlen( get_the_title() ) ) { ?>
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h1><!-- /.entry-title -->
<?php } // end if ?>
<div class="post-meta">
<span class="post-date">
<?php if ( 0 < strlen( get_the_title() ) ) { ?>
<?php the_time( get_option( 'date_format' ) ); ?>
<?php } else { ?>
<a href="<?php the_permalink(); ?>">
<?php the_time( get_option( 'date_format' ));?>
</a>
<?php } // end if/else ?>
</span><!-- /.post-date -->
<?php _e( ' | ', 'required' ); ?>
<span class="comment-link">
<?php
comments_popup_link( 'Comment', '1 comment', '% comments',
'comments-link', '');
?>
</span><!-- /.comment-link -->
<?php edit_post_link( '- edit ', '<span>', '</span>'); ?>
</div><!-- /.post-meta -->
</header>
谢谢:)
这是循环代码:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'content', get_post_format() );
} // end while
下面是一个例子,在标题和日期之间:
<header>
<?php if ( 0 < strlen( get_the_title() ) ) { ?>
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h1><!-- /.entry-title -->
<?php } // end if ?>
<div class="post-meta">
<?php the_author(); ?>
<span class="post-date">
<?php if ( 0 < strlen( get_the_title() ) ) { ?>
<?php the_time( get_option( 'date_format' ) ); ?>
<?php } else { ?>
<a href="<?php the_permalink(); ?>">
<?php the_time( get_option( 'date_format' ));?>
</a>
<?php } // end if/else ?>
</span><!-- /.post-date -->
<?php _e( ' | ', 'required' ); ?>
<span class="comment-link">
<?php
comments_popup_link( 'Comment', '1 comment', '% comments',
'comments-link', '');
?>
</span><!-- /.comment-link -->
<?php edit_post_link( '- edit ', '<span>', '</span>'); ?>
</div><!-- /.post-meta -->
</header>
您能否更具体地说明您尝试了什么以及出现了什么问题?从我的观点来看,这可能很简单,只需在标题栏和post meta之间插入
,并添加一些HTML进行格式化……代码中的在哪里?@AlexanderVogt感谢您的回复。是的,我试过了,没用。如果可能的话,你能在下次回复时插入代码并注释掉吗?@wordpresser代码中没有。我想在给定的代码之间插入它。“作者代码”应介于标题和日期之间。你能帮忙吗?感谢您的回复。u Author()
函数只能在循环中使用,如果您正在使用它?。。另一件事是,你可以发布你的全部帖子,包括loopThank you@Jerdigit。代码中有许多if/else语句。我只关注代码的一部分,这就是为什么它在早期不起作用的原因。在得到你的确认后,我在每个条件下逐一测试了它。它奏效了:)我真的搜索了很多如何在标题中发布作者姓名,但除了你的解决方案外,从未找到一个简单有效的解决方案: