我想在wordpress中链接主页上的一些标题。我有这个代码:
<?php
@preg_match("/link='"(.*?)'"/is", $post->post_content, $_tmp);
<h3><a href="<?php echo $_tmp[1]; ?>"><?php the_title(); ?></a></h3>
?>
因此,链接看起来像:http://example.com/2016/03/16/tsar-ivan-terrible-vodka/
我想改变模式,从链接中删除日期。因此,最终链接将是:http://example.com/tsar-ivan-terrible-vodka/
有人能帮忙吗?感谢
您不需要任何preg_match函数来执行此
转到管理员>>设置>>公共设置上的永久链接选择"Post name"而不是"day and name"
然后你会得到你需要的网址http://example.com/tsar-ivan-terrible-vodka/
获取张贴url
<?php get_post_permalink(post_id); ?>