admin管理员组文章数量:1332873
So I'm running into issues retrieving the get_author_posts_url()
- I'm still in the learning process and want to know why this might be happening:
Here is the code:
<!-- Locate the header.php file under /templates/ -->
<?php include(locate_template('templates/header.php')); ?>
<!-- This is the posts loop, grabs the permalink, the title attributes and the title -->
<?php if (have_posts()) { ?>
<?php while (have_posts()) { ?>
<?php the_post(); ?>
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?></a>
</h2>
<div>
Posted on
<a href="<?php echo get_permalink(); ?>">
<!-- Grab the date: .date.php -->
<time datetime="<?php echo get_the_date('c') ?>" itemprop="datePublished"><?php echo the_date(); ?></time>
</a>
By <a href="<?php get_author_posts_url(get_the_author_meta('ID')) ?>"><?php echo get_the_author(); ?></a>
</div>
<?php } ?>
<?php } else { ?>
<p>Sorry, no posts match your criteria.</p>
<?php } ?>
<!-- Locate the footer.php file under /templates/ -->
<?php include(locate_template('templates/footer.php')); ?>
This is the result:
So I'm running into issues retrieving the get_author_posts_url()
- I'm still in the learning process and want to know why this might be happening:
Here is the code:
<!-- Locate the header.php file under /templates/ -->
<?php include(locate_template('templates/header.php')); ?>
<!-- This is the posts loop, grabs the permalink, the title attributes and the title -->
<?php if (have_posts()) { ?>
<?php while (have_posts()) { ?>
<?php the_post(); ?>
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?></a>
</h2>
<div>
Posted on
<a href="<?php echo get_permalink(); ?>">
<!-- Grab the date: https://www.php/manual/en/function.date.php -->
<time datetime="<?php echo get_the_date('c') ?>" itemprop="datePublished"><?php echo the_date(); ?></time>
</a>
By <a href="<?php get_author_posts_url(get_the_author_meta('ID')) ?>"><?php echo get_the_author(); ?></a>
</div>
<?php } ?>
<?php } else { ?>
<p>Sorry, no posts match your criteria.</p>
<?php } ?>
<!-- Locate the footer.php file under /templates/ -->
<?php include(locate_template('templates/footer.php')); ?>
This is the result:
- Are you sure that code is what generated that result? There is a " in between </a> and By that isn't in the code, so it seems like maybe you fixed/corrected something? – mozboz Commented Jun 27, 2020 at 11:59
- @mozboz, looks like I forgot a echo facepalm – Swe Commented Jun 27, 2020 at 12:01
- hah, well spotted, i was looking and didn't notice :D – mozboz Commented Jun 27, 2020 at 12:03
1 Answer
Reset to default 0Adding answer for reference:
get_author_posts_url(get_the_author_meta('ID'))
retrieves the value into the PHP code, it doesn't automatically output it, so you need:
echo get_author_posts_url(get_the_author_meta('ID'));
To output it into the HTML
本文标签: phpUnable to retrieve getauthorpostsurl
版权声明:本文标题:php - Unable to retrieve get_author_posts_url 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742314292a2451503.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论