在php中更改链接值
我是wordpress的新手,一直在使用以下代码:在php中更改链接值,php,wordpress,Php,Wordpress,我是wordpress的新手,一直在使用以下代码: div class="hd-box-wrap"> h2> a href=" ?php the_permalink();?>">?php the_title();?></a>/h2> div class=“hd包装盒”> h2>a href=“?php the_permalink();?>”>?php the_title();?>
div class="hd-box-wrap">
h2> a href=" ?php the_permalink();?>">?php the_title();?></a>/h2>
div class=“hd包装盒”>
h2>a href=“?php the_permalink();?>”>?php the_title();?>/h2>
现在假设这个超链接给了我一个值
www.google.com/ankit
但我需要我的页面转到
www.google.com/ankit1
我试过了
div class="hd-box-wrap">
h2> a href=" ?php the_permalink();?1>">?php the_title();?></a>/h2>
div class=“hd包装盒”>
h2>a href=“?php the_permalink();?1>”>?php the_title();?>/h2>
但我不知道剩下的是什么。使用substr_replace()函数将最后一个字符从/更改为1是没有错误的
像这样:
a href=" <?php substr_replace(the_permalink(), "1", -1); ?>"
a href=“”
像这样尝试:
<div class="hd-box-wrap">
<h2>
<a href="<?php the_permalink();?>1"><?php the_title();?></a>
</h2>
</div>
您可以按{}图标将代码包装在一个块中,该块将阻止您使用“sorry its take as instead”执行操作,因此函数返回“ankit/”,您希望它转到“”?不,我希望它转到ankit1。实际上,这是一个指向公文包的公文包页面。我想将它指向另一个页面localhost/wordpress/portfolio/ankit1或localhost/wordpress/ankit或localhost/wordpress/ankit1。任何事情都会成功,因为我会给我的新页面相同的URL更新了我的答案,它给出的输出是/ankit/1而不是ankit1那么1