2017-05-11 72 views
0

我想自定義我的網址。設爲網址+字段

<a href="/2017/?post_type=issue_number"><?php the_title(); ?></a> 

我希望2017年的網址是<?php the_title(); ?>

一些,因爲這:

<a href="/<?php the_title(); ?>/?post_type=issue_number"><?php the_title(); ?></a> 

這是可能嗎?

+0

Antonio,我想你應該確保「the_title()」提供一個URLEncoded字符串格式,實際上,這對用戶來說並不總是好的。事實上,也許你應該使用不同的功能?無論如何:我認爲你的問題是這樣的事情對你來說是否可能,是的。 – Lepidopteron

回答

0

您需要更改WordPress配置中的URL以使用「Post slugs」。

+0

有沒有辦法自定義網址? –

+0

是的,它可以在wordpress管理器屏幕中全部配置 –

0

解決

有了這個代碼

<a href="/<?php echo the_title(); ?>/?post_type=issue_number" > 
    <?php the_title(); ?></a> 
1

<?php echo basename(get_permalink()); ?>將是一個更好的辦法,我認爲。這基本上輸出了slu portion部分(不是整個URL)......這基本上是標題。