0

I have set all my site urls to the custom structure in Permalink Settings:

/portfolio/%postname%/

But when I try to get a post clean URL in my admin area at http://mywebsite.com/wp-admin/post.php?post=415&action=edit:

// Get post/page ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;

get_permalink($post->ID);

Result:

http://mywebsite.com/?p=415

But it should be:

http://mywebsite.com/portfolio/sample-1/

Why? What have I missed?

Run
  • 54,938
  • 169
  • 450
  • 748
  • Where you try to get this permalink? I think that permalinks are available on the frontend is already checked. So on which admin-page you try to access them, from where you receive the page/post-id and at last: Do this page already exists when you try to access them? (sorry for the dump questions, but that's important) – Sascha Jul 16 '16 at 06:13
  • `Do this page already exists when you try to access them?` yes they do. – Run Jul 16 '16 at 06:26
  • `Where you try to get this permalink?` for instance from `http://mywebsite.com/wp-admin/post.php?post=415&action=edit` – Run Jul 16 '16 at 06:29
  • Are u make sure .htaccess CHMOD 644 or something similar. If now is 444 you will can't use permalink setting. – Quynh Nguyen Jul 16 '16 at 06:38
  • it is already set to 777. – Run Jul 16 '16 at 07:03

1 Answers1

2

The cause of it is that the page has no slug data. Only the slug data is stored then I can get the clean URL.

Run
  • 54,938
  • 169
  • 450
  • 748