admin管理员组文章数量:1291009
Recently I need Help regarding this permalink shortcode
function my_permalink(){
ob_start();
the_permalink();
return ob_get_flush();}
add_shortcode('my_permalink','my_permalink');
for this, I get a shortcode [my_permalink], it's working fine
But the problem is when I use this shortcode on my WordPress Posts, Pages, CPT, CT or any custom Archive Page it shows me some unnecessary link text which is at top of the loop and also it does not include any HTML tag
I am showing the screenshot and the link appearing position in the posts
Code:
</div>
<div class="entry-content">
/<div class="wprt-container"><p>KFRI Recruitment 2021 for 1 Project Assistant Applications are invited from eligible candidates for the post of one <b>Project Assistant </b>under the project KFRI/RP 823/2021 entitled “Ecological studies on post restoration success of threatened plants in situ.”</p>
/
<p> </p>
Screenshot: The URL appears:
I just paste the shortcode:
Inside inspect Elements:
Recently I need Help regarding this permalink shortcode
function my_permalink(){
ob_start();
the_permalink();
return ob_get_flush();}
add_shortcode('my_permalink','my_permalink');
for this, I get a shortcode [my_permalink], it's working fine
But the problem is when I use this shortcode on my WordPress Posts, Pages, CPT, CT or any custom Archive Page it shows me some unnecessary link text which is at top of the loop and also it does not include any HTML tag
I am showing the screenshot and the link appearing position in the posts
Code:
</div>
<div class="entry-content">
https://careerfeed/jobs/kfri-recruitment-2021-for-1-project-assistant/<div class="wprt-container"><p>KFRI Recruitment 2021 for 1 Project Assistant Applications are invited from eligible candidates for the post of one <b>Project Assistant </b>under the project KFRI/RP 823/2021 entitled “Ecological studies on post restoration success of threatened plants in situ.”</p>
https://careerfeed/jobs/kfri-recruitment-2021-for-1-project-assistant/
<p> </p>
Screenshot: The URL appears:
https://prnt.sc/15jcg6d
I just paste the shortcode:
https://prnt.sc/15jckza
Inside inspect Elements:
https://prnt.sc/15jct1q
Share Improve this question asked Jun 15, 2021 at 21:04 GOSTGOST 11 bronze badge 1 |1 Answer
Reset to default 0ob_get_flush
doesn't do what you think it does. You're assuming that it only ends the output buffer and returns its contents, which is incorrect, it also flushes the output buffer to the browser.
So this:
return ob_get_flush();
Is the same as this:
$content = ob_get_clean();
echo $content;
return $content;
Use ob_get_clean();
instead, which erases the output buffer instead of flushing it.
本文标签: postsPermalink Short code showing unnecessary link text inside the loop
版权声明:本文标题:posts - Permalink Short code showing unnecessary link text inside the loop 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741502037a2382105.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_shortcode( 'my_permalink', 'get_the_permalink' );
Since there's already a function for returning the permalink. – Jacob Peattie Commented Jun 16, 2021 at 6:43