Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.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_Html_Css_Wordpress_Loops - Fatal编程技术网

Php 在特定作者的循环中显示帖子

Php 在特定作者的循环中显示帖子,php,html,css,wordpress,loops,Php,Html,Css,Wordpress,Loops,嗨,伙计们,我在制作一个新的wordpress网站时遇到了一些问题。我有一个名为“authors”的自定义帖子类型,我将所有将在新网站中创建内容的作者放在这里。现在,在用CSS设计了这些单作者网站之后,我想做一个循环,在网站上显示他们的帖子。我怎样才能做到这一点?现在,当我使用标准循环时,它会显示所有用户的帖子,但不会显示我实际所在站点的特定帖子。如果用这种方法无法实现,请告诉我如何用更简单的方法实现?也许我应该删除自定义帖子类型,并基于“用户”。但我如何才能将他们的“信息”放入循环中(例如姓名

嗨,伙计们,我在制作一个新的wordpress网站时遇到了一些问题。我有一个名为“authors”的自定义帖子类型,我将所有将在新网站中创建内容的作者放在这里。现在,在用CSS设计了这些单作者网站之后,我想做一个循环,在网站上显示他们的帖子。我怎样才能做到这一点?现在,当我使用标准循环时,它会显示所有用户的帖子,但不会显示我实际所在站点的特定帖子。如果用这种方法无法实现,请告诉我如何用更简单的方法实现?也许我应该删除自定义帖子类型,并基于“用户”。但我如何才能将他们的“信息”放入循环中(例如姓名、简历以及他们已经写了多少篇文章)。下面是single-authors.php的代码

<?php get_header(); ?>

<main class="author">
<div class="container">
<h1>Author's articles</h1>
<a href="" class="see-all">Meet our team <i class="fa fa-angle-double-right" aria-hidden="true"></i></a>
<div class="breadcrumbs">
<span>You are here:</span>
<ol class="breadcrumb">
<li><a href="#">INFO</a></li>
<li><a href="#">About us</a></li>
</ol>
</div>
<div class="entries-authors">
<div class="single-author row">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
 <img src="<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); print_r($thumb[0]); ?>" alt="">
 </a>
<div class="author-info">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<h3><?php $title = get_the_title(); echo substr($title, 0 , 100); ?>
</h3>
</a>
<h4>
<?php
$terms = get_the_terms( $post->id, 'job' );
if ( !is_wp_error($terms)) {
$album_categories = array();
foreach ($terms as $term) {
$album_categories[] = $term->name;
$albums = join( ", ", $album_categories );
}
?>
<span><?php echo $albums; ?></span>
<?php } ?>
</h4>
<p>Follow me:</p>
<!--
<div class="author-social">
<ul class="nav nav-pills">
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
</ul>
</div>
-->
</div>
<div class="author-bio">
<div class="bio-desc">
<p class="more-toggle">
<?php 
echo get_post_field('post_content', $post_id);
?>
</p>
<button class="toggle">Show more <i class="fa fa-chevron-down" aria-hidden="true"></i></button>
</div>

<div class="genre-list"><img src="<?php echo get_template_directory_uri(); ?>/library/images/gamepad.png" alt="">Favourite genre:
<span class="genre-tags">
 <?php
$terms = get_the_terms( $post->id, 'genre' );
if ( !is_wp_error($terms)) {
$album_categories = array();
foreach ($terms as $term) {
$album_categories[] = $term->name;
$albums = join( ", ", $album_categories );
}
?>
<span><?php echo $albums; ?></span>
<?php } ?>
</div>
</div>
<div class="author-entries-count">
<span>Entries:</span>
<p href="<?php the_permalink(); ?>" class="count">
<?php 
$post_author_id = get_post_field( 'post_author', $post_id );
echo count_user_posts($post_author_id);
 ?>
</p>
</div>
</div>
</div>
<section class="articles">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#news">News (18)</a></li>
<li><a data-toggle="tab" href="#reviews">Reviews (2)</a></li>
<li><a data-toggle="tab" href="#features">Features (6)</a></li>
</ul>

<div class="tab-content">
<div id="news" class="tab-pane fade in active">

<?php $loop = new WP_Query( array( 'posts_per_page' => 7)); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<?php echo the_content(); ?>

<?php endwhile; wp_reset_query(); ?>


<div class="single-post">
<div class="thumb">
<img src="<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); print_r($thumb[0]); ?>" alt="">
<span>nintendo</span>
</div>
<div class="content">
<h2>Nintendo Explains Why Zelda Games Rarely Come Out on Time</h2>
<p>Some of the key designers behind Nintendo's famous Legend of Zelda series have spoken up to explain why new installments in the iconic... <a href="">Read more <i class="fa fa-angle-double-right" aria-hidden="true"></i></a></p>
<div class="news-info">
<div class="time-stamp">
<span>
<i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
</span>
</div>
<div class="comments-stamp">
<span>
<img src="<?php echo get_template_directory_uri(); ?>/library/images/comments-gray.png" alt=""><?php comments_number( '0', '1', '%' ); ?>
</span>
</div>
</div>
</div>
</div>

<?php 
$post_author_id = get_post_field( 'post_author', $post_id );
 count_user_posts($post_author_id);
?>

</div>
<div id="reviews" class="tab-pane fade">

</div>
<div id="features" class="tab-pane fade">

</div>
</div>
</section>
<aside class="sidebar">
<sidebar>
<div class="hot-news">
<h3>hot topics</h3>
<?php $loop = new WP_Query( array( 'post_type' => 'hot_topics', 'posts_per_page' => 5)); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<div class="single-hot-news">
<img src="<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); print_r($thumb[0]); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<h3><?php $title = get_the_title(); echo substr($title, 0 , 40); ?></h3>
</a>
<span><img src="<?php echo get_template_directory_uri(); ?>/library/images/comments.png" alt=""><?php comments_number( '0', '1', '%' ); ?></span>
</div>
<?php endwhile; wp_reset_query(); ?>

<div class="show-more">
<a href="">See more</a>
</div>
</div>
<div class="interesting-news">
<h3>You might be interested in</h3>
<?php $loop = new WP_Query( array('posts_per_page' => 5)); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<div class="single-interesting-news">
<img src="<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); print_r($thumb[0]); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<h3><?php $title = get_the_title(); echo substr($title, 0 , 40); ?></h3>
</a>
<span><img src="<?php echo get_template_directory_uri(); ?>/library/images/author-comments.png" alt=""><?php comments_number( '0', '1', '%' ); ?></span>
</div>
<?php endwhile; wp_reset_query(); ?>

<div class="show-more">
<a href="">See more</a>
</div>
</div>
</sidebar>
</aside>
</div>
</main>


<?php get_footer(); ?>

作者文章
你在这里:
  • 跟我来:

    显示更多 /library/images/gamepad.png“alt=”“>喜爱的流派: 条目: 这就是我需要的

    <?php query_posts('author=' . $post->post_author . '&order=ASC&showposts=7'); ?>