Support » Fixing WordPress » get_permalink returns default link

  • Hi guys, I hope you can help me.

    So i’m using /%postname%/ as permalink structure, and my htaccess is this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /develop/sekai/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /develop/sekai/index.php [L]
    # END WordPress

    Hovewer, get_permalink returns me the default permalink structure (?page_id=x), while menus are fine with their links. What should i do? Thanks for all!! 😀

Viewing 1 replies (of 1 total)
  • I was working on front-end submission form and encounted a similar issue. Then understood how and why it works this way.

    Code looked something like this:

    if ( ... ) { $pstatus = "post"; }
           else { $pstatus = "draft"; }
    $new_post = array( ...
      'post_status' => $pstatus );
    $post_id = wp_insert_post($new_post);
    $link = get_permalink($post_id);
    echo $link;

    Here is the deal.

    When you submit post as a DRAFT,
    admin/editor can change the permalink before it is ever posted.
    The post slug ($post->post_name;) simply does not exist yet.
    So returning “?page_id=” is the only option wordpress has.

    If you submit post as a POST,
    then everything works perfectly as expected.

    Hope it helped.

Viewing 1 replies (of 1 total)
  • The topic ‘get_permalink returns default link’ is closed to new replies.