dongye9182 2019-07-14 12:41
浏览 51

如何修复PHP代码不返回所需的页面链接

I am setting up an auction site on WordPress and am trying to change a button that originally leads to the authors profile to lead to a page named after the author

This is the original code:

<a href="<?php echo get_author_posts_url( $post->post_author ); ?>"

This is what is have done so far:

<a href="<?php echo get_page_link( get_page_by_title(author_name)->ID ); ?>"
<div class="col-4">
<a href="<?php echo get_page_link( get_page_by_title(author_name)->ID ); ?>" class="btn btn-primary btn-block text-uppercase"><?php echo __("Visit Profile","premiumpress") ?></a>
</div>

I know i am missing a line that is in getting the authors name which will be used as title for the page id that needs to be echoed, i need help with fixing the code

  • 写回答

1条回答 默认 最新

  • douchuntang2827 2019-07-14 17:01
    关注

    Not really clear what you really want, but :

    First - what is author_name ? is that some placeholder you have put for the question ? is that $author_name as a variable ?

    I am asking this because the syntax get_page_by_title(author_name)->ID is not correct.

    Like I said, I am not sure what you want exactly and what this author really is and how it is created / handled, but Anyhow you should look at the get_the_author_meta() function and could try using any of the related fields like get_the_author_meta( 'ID' ) or get_the_author_meta('user_nicename').

    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助