Skip to main content

Questions tagged [permalinks]

A permanent link to an item (a blog post, an attachment, ...). The default structure is "?p=123", but WordPress can handle "pretty permalinks" and will rewrite them internally to the former version. If you have a question about special rewrite structures you should use the [url-rewriting] tag.

Filter by
Sorted by
Tagged with
150 votes
7 answers
216k views

Is it possible to get a page link from its slug?

Is it possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using get_page_link(): <a href="<?php echo get_page_link(40); ?>">...
Sampson's user avatar
  • 2,949
136 votes
14 answers
590k views

How to get URL of current page displayed?

I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use echo get_permalink(), but that does not work on ...
cag8f's user avatar
  • 1,937
66 votes
5 answers
22k views

Custom post types, taxonomies, and permalinks

This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex). I have a custom post type product_listing and a custom ...
RodeoRamsey's user avatar
  • 1,707
64 votes
4 answers
74k views

How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name

I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what this post asks, but I need a hierarchical taxonomy. The answer given in ...
Jeff's user avatar
  • 2,555
58 votes
1 answer
69k views

Need help with add_rewrite_rule

SOLUTION I've gone with Update 3 and have got it working. What I had misunderstood, was that I believed that a rewrite rule would change designers/?designer=some-designer&bid=9 to /designers/...
54 votes
5 answers
80k views

Get the blog page URL set in Options

I have set the blog to be a different page other than the home page. I want to have a link from single.php to this blog page. Is there any function that pulls out URL for the blog ?
Atif's user avatar
  • 1,088
49 votes
1 answer
76k views

Permalinks: custom post type -> custom taxonomy -> post

I am having trouble working with WordPress rewrite rules, and could use some help. I have a custom post type called _shows_. All shows have a single custom taxonomy category _show-category_. A ...
Paul T's user avatar
  • 667
42 votes
6 answers
121k views

After server migration only the homepage works

I have recently changed hosting of my WordPress site to VPS.net. I have moved all of my files and imported the database. Everything appeared to be fine until I clicked a link and noticed that all of ...
mikeyrocks's user avatar
32 votes
8 answers
46k views

Resolve a custom post type name vs. page permalink conflict (same slug)

I have a custom post type called "visningshus", and also a Page with that slug. This is as it should (must) be. Currently, "http://my-site.com/visningshus" lists all posts of that type. I want to ...
Henrik Erlandsson's user avatar
32 votes
2 answers
26k views

Mixing custom post type and taxonomy rewrite structures?

Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that: The main glossary URL: http://example.com/...
maryisdead's user avatar
29 votes
5 answers
62k views

Custom Post Type pages are "not found"

I've created two new Custom Post types using code that I've used successfully on other projects without issue. The first is called top_charts, the other case_studies, and both appear correctly in the ...
Django Reinhardt's user avatar
28 votes
2 answers
111k views

remove "index.php" from permalinks

I have been trying to find a solution. but I can't.. my links are all domain.com/index.php/post_name/ I really want to remove /index.php I have searched and found some... saying I need to add these....
pulla's user avatar
  • 713
26 votes
3 answers
82k views

where is permalink info stored in database?

I see that I can edit permalink information in wp-admin page > settings > permalinks. However, where is that information actually stored in the database?
Alexander Bird's user avatar
25 votes
4 answers
101k views

Change media item permalink

I have an image whose permalink is domain.com/books I would now like a page located at this permalink. Is there a way to change the image's permalink? Thanks
kneidels's user avatar
  • 275
25 votes
7 answers
49k views

Changing permalinks gives me 404 errors on nginx

EDIT It turns out that I was barking up the wrong tree trying to edit .htaccess, as nginx doesn't use it. What I apparently need to do is edit my .conf file. Before I read this, my_app.conf looked ...
ninjachicken1's user avatar
25 votes
2 answers
72k views

How do I add /blog/ as a prefix to permalink structure for blog posts, tag pages, etc.?

I'm using WordPress 3.1.3 as a full CMS, installed in the root directory of a domain. I have it setup using the built in options to have a static page as the home page, and then my blog at http://www....
Preston's user avatar
  • 375
24 votes
9 answers
23k views

Remove taxonomy slug from a custom hierarchical taxonomy permalink

I created a 'forum' taxonomy, using these rules: register_taxonomy( 'forum', array('topic'), array( 'public' => true, 'name' => _a('Forums'), 'singular_name' => _a('Forum'),...
onetrickpony's user avatar
  • 13.6k
23 votes
4 answers
31k views

Adding categories to custom post type in permalink

I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink. The problem is I have 340 existing categories which I would like to continue ...
hash's user avatar
  • 231
20 votes
6 answers
27k views

Remove the blog slug from Wordpress Multisite root node

I have been looking at whether it is possible to remove blog/ from the post & category URLs on the root node in a multisite setup. I have found the multisite sites settings and removed the blog/ ...
David's user avatar
  • 331
20 votes
5 answers
61k views

How do I get the permalink of a custom post type?

I can get the permalink of a specific post tag or category, but what if I want to get the permalink of a custom post type? I can't find anything in the Codex or anywhere else about how to do this.
Industrial Themes's user avatar
19 votes
2 answers
28k views

Wordpress Permalinks not working in Apache2 Ubuntu 14.04

In my local machine, wordpress permalinks not working. After research I found that wordpress not creating .htaccess file. For this I followed below steps. Manually create a ".htaccess" file and ...
Harish Kumar's user avatar
19 votes
1 answer
41k views

Can a custom post type have a Parent Page?

I've seen a lot of posts out there in the Webiverse about assigning a page as a parent of a custom post type. After four hours I can't find a solution and need some help. I've create an "About" page ...
Nick's user avatar
  • 427
18 votes
4 answers
49k views

remove custom post type permalink

I've registered post type with following -- $holidayLabels = array( 'name' => __( 'Holidays'), 'singular_name' => __( 'Holidays'), 'all_items' => __( 'All Holidays'), '...
SachinGutte's user avatar
18 votes
1 answer
2k views

How does WordPress create URLs that Apache knows about?

When you create a page in WordPress, it's just an entry in a database table; there's no actual file at that location. However I can create a file at that location myself and it will steal the page ...
Matt's user avatar
  • 183
18 votes
7 answers
34k views

Strange permalink issue: can't rename /company-2/ to /company/

I created a page titled company. But the permalink turned it into /company-2/, trying to change it to just /company/ doesn't work. The website just has 8 pages and none is called company (don't know ...
alex's user avatar
  • 1,112
17 votes
3 answers
143k views

How to get permalink and title from post ID?

I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if ...
sarytash 's user avatar
  • 1,789
17 votes
1 answer
29k views

How to rewrite URI of custom post type?

The site that I am working on uses the following "pretty" permalink structure: http://example.com/blog/my-special-post But for a custom post type my client would like to avoid having a "pretty" slug:...
Lea Hayes's user avatar
  • 273
17 votes
8 answers
74k views

Get the current page URL (including pagination)

Is there a WP function to automatically get the correct URL of the current page? Meaning if I just opened a single post, the function returns the same as get_permalink(), but if I'm on a paginated ...
René Schubert's user avatar
17 votes
3 answers
48k views

Get Permalink without domain (i.e. get relative permalink) [duplicate]

This is the code I am using: <?php echo str_replace( home_url(), '', get_permalink($post->ID) ); ?> What it does is output the permalink as a relative URL i.e. only the slug. For instance, ...
its_me's user avatar
  • 4,502
17 votes
3 answers
29k views

Add extra parameters after permalink?

How can I add extra parameters after a permalink, specifically if I'm using a custom post type? For example, let's say http://mysite/album/record-name was the permalink. How can I make http://mysite/...
relm's user avatar
  • 333
17 votes
1 answer
26k views

Passing and retrieving query vars in wordpress

I have two authors pages, one displays about 5 posts. Then I'm trying to setup another page that will be all of their posts. I have created a template called moreauthorposts.php and I'm trying to ...
codeisforeva's user avatar
17 votes
1 answer
35k views

Rewriting a custom-post-type permalink with taxonomy term?

I'm trying to rewrite my url for a custom_post_type named wr_events with one of its custom_taxonomy terms from event_type add_action('init', 'wr_events'); function wr_events() { ...
mathiregister's user avatar
16 votes
5 answers
13k views

Getting hierarchical custom post type permalinks to work just like pages

I've dug through every question here on custom post type permalinks, but most seem to be either problems with custom taxonomy rewrites, or the obvious missing of flush_rewrite_rules(). But in my case, ...
somatic's user avatar
  • 3,001
16 votes
8 answers
25k views

Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?

I am having a bit of a strange issue with rewrite rules not flushing properly. I have tried using flush_rewrite_rules(); and flush_rewrite_rules(true);. I have also tried globalizing $wp_rewrite ...
Michael Ecklund's user avatar
15 votes
5 answers
65k views

Why is "/page/2/" not working?

Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work? <?php $temp = $wp_query; $wp_query= null; $...
Dave's user avatar
  • 810
15 votes
2 answers
20k views

Stop Wordpress appending `-2` to the end of my url after i change it

When i try to set the url of a page in wordpress (4.2) it keeps apending -2 to the end of the url, i guess its becuase this ulr already exists, but i checked and it dosnt, although at one time it did ...
sam's user avatar
  • 265
15 votes
2 answers
4k views

Get default permalink structure from pretty URL's

When a single post is clicked on from a category page or for that matter any page, you can get the URL of that referrer and parse it to get the query string. But this only works with the default ...
Pieter Goosen's user avatar
14 votes
3 answers
39k views

Difference between the_permalink() and get_permalink() function

In WordPress I am using both the_permalink() and get_permalink() functions, but I cannot get any difference in the output of both functions. What is the difference between both functions?
AliasgerSW's user avatar
14 votes
3 answers
911 views

Performance of my permalink structure?

I have read the discussion on the performance of different permalinks on the wp hackers mailinglist, THIS forum and around Google. I could however not really deduce if the permalink structure I have ...
edelwater's user avatar
  • 2,574
13 votes
8 answers
47k views

Get current URL (permalink) without /page/{pagenum}/

How can I retrieve the current URL (whether homepage, archive, post type archive, category archive, etc) but always without the /page/{pagenum}/ part if it's present? So, if the real URL is: example....
Ihor Vorotnov's user avatar
13 votes
1 answer
7k views

Change permalinks for posts but not for custom post types

Currently my permalink structure for posts is domain.com/post-title I'm using a static front page and a "blog" page for posts. I'd like to to change the permalink structure for posts, tags and ...
user2019515's user avatar
13 votes
2 answers
12k views

What is the difference between get_post_permalink and get_permalink?

I've read the documentation on get_post_permalink() and get_permalink() and don't understand the difference between the two. It might be because I don't understand the purpose of the $leavename and $...
Michelle's user avatar
  • 3,448
12 votes
2 answers
5k views

Permalink format: singular or plural

The default is singular, e.g. http://example.com/category/apple/ But I am wondering if it is better to use the plural form, e.g. http://example.com/categories/apple/ Are there any guideline on ...
Yoga's user avatar
  • 909
12 votes
7 answers
3k views

Wordpress matching URLs with trailing tildes

I've been handed a vulnerability report(1) that seems to be implying that there may be a security issue in the way Wordpress handles URLs with following tildes. It seems the scanner thinks the website ...
dKen's user avatar
  • 173
12 votes
2 answers
7k views

How can I get the privacy policy page?

After the update regarding the GDPR, WordPress now has an option named "Privacy Policy" under the settings, which you can use a page to be used as your privacy policy page. How can I get the ID or ...
Johansson's user avatar
  • 15.3k
12 votes
4 answers
16k views

Disable Attachment Pages Completely

I would like to disable all attachment pages completely. I Googled it, but there's just information on how to redirect to parent post or homepage. That's not what I would call an elegant solution. Why ...
Maciej Kravchyk's user avatar
12 votes
4 answers
11k views

Can I use REST-API on plain permalink format?

Recently all of my REST-API requests suddenly turned to return a 404 error, Every request (no matter custom endpoint or built-in). Then I figured it's because of permalink's structure. /wp-json/ is ...
Johansson's user avatar
  • 15.3k
12 votes
1 answer
3k views

How to prefix post permalinks with /blog/ - without affecting custom post types?

I have several custom post types, which are properly structured as /%post_type%/%postname%/, however I wish to have the same effect for regular blog entries: /blog/%postname%/ If I prepend the ...
Mythical Fish's user avatar
12 votes
3 answers
16k views

Add .html (dot HTML) extension to custom post types

Is there any way to add the .html extension to custom post types without plugin ? For posts I can use /%postname.html on the permalink settings For pages I can use: add_action('init', '...
user983248's user avatar
  • 1,350
12 votes
3 answers
35k views

How to change permalink structure for custom post type and it's taxonomies?

This is a repost of an earlier question I had, but I like to go into more details now to be able to fully solve this. So again, with (normal) posts changing the permalink is as easy as going to ...
Mark's user avatar
  • 1,029

1
2 3 4 5
64