admin管理员组文章数量:1122846
I have this code I'm using to create a custom author.php, which is working great to show that users posts and it's children etc:
<?php get_header(); ?>
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
<div class="auth-name">
<?php if ( '' != get_the_author_meta( 'user_description' ) ) echo apply_filters( 'archive_meta', get_the_author_meta( 'display_name' )); ? >
</div>
<div class="auth-desc">
<?php if ( '' != get_the_author_meta( 'user_description' ) ) echo apply_filters( 'archive_meta', get_the_author_meta( 'user_description' )); ?>
</div>
<div class="header">
<h1>Buckets made (<?php $children = get_posts( array( 'author' => $curauth->ID, 'category_name' => 'Bucket', ) ); echo count($children);?>) </h1>
<a href="/add-a-bucket"><span class="big-bucket"> Add a new bucket</span></a>
</div>
</div>
<div class="content">
<ul class="stash-container">
<?php
$args = array( 'post_type' => 'bucket','post_parent' => 0 ,'author' => $curauth->ID,'posts_per_page' => -1 ); ?>
<?php $loop = new WP_Query( $args ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li class="buckets">
<a href="<?php echo get_the_permalink($site->ID); ?>">
<div class="rollover-bucket">
</div>
</a>
<div class="r-text">
<?php do_action('gform_update_post/edit_link', array(
'post_id' => $post->ID,
'url' => '/',
'text' => 'edit',
) ); ?>
<?php echo delete_post_bucket($post->ID); ?>
</div>
<div class="empty-state-thumb">
This bucket is empty!
</div>
<div class="display-block">
<?php
global $authordata, $post;
$parent = array( 'post_type' => 'bucket','post_parent' => $post->ID, 'post_status' => 'publish' ,'author' => $curauth->ID,'posts_per_page' => -1 );
$my_meta = get_post_meta( $post->ID, 'connect', true);
$portfolio_sections = array(
'post_type' => 'bucket',
'author' => $curauth->ID,
'category_name' => 'drop',
'orderby' => 'rand',
'posts_per_page' => 4,
'post_parent' => $parent,
'sort_order' => 'ASC',
'meta_query' => array(
array(
'key' => 'connect',
'value' => $my_meta,
'compare' => '=' )
)
);
$sections = get_posts($portfolio_sections);
foreach ($sections as $section) { ?>
<img src="/? key=8d5e59&size=M&format=png&url=<?php echo get_post_meta($section->ID, 'the_url', true);?>">
<?php } ?>
</div>
<div class="botsy">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
<div class="botsy-det">
<?php
$cc = get_the_content();
if($cc != '') { ?>
<?php $content = get_the_content(); echo mb_strimwidth($content, 0, 96, '...');?>
<?php } else { ?>
<div class="empty-lines"></div>
<div class="empty-lines"></div>
<div class="empty-lines"></div>
<?php } ?>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php get_footer(); ?>
But for some reason the username and bio are not showing at the top, I'm pretty sure at some point during the dev process it was working fine, could it be a conflicting plugin or am I just being dumb?
Thanks!
I have this code I'm using to create a custom author.php, which is working great to show that users posts and it's children etc:
<?php get_header(); ?>
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
<div class="auth-name">
<?php if ( '' != get_the_author_meta( 'user_description' ) ) echo apply_filters( 'archive_meta', get_the_author_meta( 'display_name' )); ? >
</div>
<div class="auth-desc">
<?php if ( '' != get_the_author_meta( 'user_description' ) ) echo apply_filters( 'archive_meta', get_the_author_meta( 'user_description' )); ?>
</div>
<div class="header">
<h1>Buckets made (<?php $children = get_posts( array( 'author' => $curauth->ID, 'category_name' => 'Bucket', ) ); echo count($children);?>) </h1>
<a href="/add-a-bucket"><span class="big-bucket"> Add a new bucket</span></a>
</div>
</div>
<div class="content">
<ul class="stash-container">
<?php
$args = array( 'post_type' => 'bucket','post_parent' => 0 ,'author' => $curauth->ID,'posts_per_page' => -1 ); ?>
<?php $loop = new WP_Query( $args ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li class="buckets">
<a href="<?php echo get_the_permalink($site->ID); ?>">
<div class="rollover-bucket">
</div>
</a>
<div class="r-text">
<?php do_action('gform_update_post/edit_link', array(
'post_id' => $post->ID,
'url' => 'http://buckets.me/edit-bucket/',
'text' => 'edit',
) ); ?>
<?php echo delete_post_bucket($post->ID); ?>
</div>
<div class="empty-state-thumb">
This bucket is empty!
</div>
<div class="display-block">
<?php
global $authordata, $post;
$parent = array( 'post_type' => 'bucket','post_parent' => $post->ID, 'post_status' => 'publish' ,'author' => $curauth->ID,'posts_per_page' => -1 );
$my_meta = get_post_meta( $post->ID, 'connect', true);
$portfolio_sections = array(
'post_type' => 'bucket',
'author' => $curauth->ID,
'category_name' => 'drop',
'orderby' => 'rand',
'posts_per_page' => 4,
'post_parent' => $parent,
'sort_order' => 'ASC',
'meta_query' => array(
array(
'key' => 'connect',
'value' => $my_meta,
'compare' => '=' )
)
);
$sections = get_posts($portfolio_sections);
foreach ($sections as $section) { ?>
<img src="http://api.screenshotmachine.com/? key=8d5e59&size=M&format=png&url=<?php echo get_post_meta($section->ID, 'the_url', true);?>">
<?php } ?>
</div>
<div class="botsy">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
<div class="botsy-det">
<?php
$cc = get_the_content();
if($cc != '') { ?>
<?php $content = get_the_content(); echo mb_strimwidth($content, 0, 96, '...');?>
<?php } else { ?>
<div class="empty-lines"></div>
<div class="empty-lines"></div>
<div class="empty-lines"></div>
<?php } ?>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php get_footer(); ?>
But for some reason the username and bio are not showing at the top, I'm pretty sure at some point during the dev process it was working fine, could it be a conflicting plugin or am I just being dumb?
Thanks!
Share Improve this question asked Mar 9, 2017 at 22:00 joelybristoljoelybristol 1432 silver badges12 bronze badges1 Answer
Reset to default 1Sorted as follows:
<div class="auth-name">
<?php echo $curauth->nickname; ?>
</div>
<div class="auth-desc">
<?php echo $curauth->description; ?>
</div>
本文标签: Showing the authors username and bio on custom authorphp
版权声明:本文标题:Showing the authors username and bio on custom author.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736286644a1927712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论