• I am creating a custom content type by ‘coding’. I don’t like the CMS Press plugin because it limits me from editing these ‘dynamic’ post types. I want to add new features and not just pick a couple of ‘standard’ features.

    What i liked about the CMS Press plugin was the way it created the permalinks. Just like it should.

    http://www.example.com/post-type/post-id/post-name/

    I have been searching the web for 48 hours but without result.

    add_filter('post_type_link', 'webspot_type_link', 1, 3);
    function webspot_type_link($post_link, $id = 0, $leavename = false)
        {
          if (strpos('%webspot_id%', $post_link) < 0)
          {
            return $post_link;
          }
          $post = get_post($id);
    
          if (!is_object($post) || $post->post_type != 'webspot')
          {
            return $post_link;
          }
          return str_replace('%webspot_id%', $post->ID, $post_link);
        }

    Gives me the right link for the content type ‘webspot’.

    But, i know i miss a step. But whát is that step? It is not been explained anywhere? How do i let this url make it work.

    I do not want wordpress to ‘search’ on the post-name, but just on the post-ID. In the pretty url i want the post-slug-name as wel, but it should be meaningless so i can edit it at all times, because the post is being retrieved by getting the post-id.

    How to accomplish this. when i only add this wordpress_type_link, it results in correct urls, but when i click on the posts, i get a 404 error.

    What do i have to do to make this work? The final url should be:
    http://www.example.com/webspot/39/this-is-a-webspot-post/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ne0que

    (@ne0que)

    Eating my hat here

    Lee Wallis

    (@fatwombat)

    Yep, I’m in the same boat!

    I have posted a question about this and have been searching forums (including this one) for about a week now. It seems no one has any idea how to do it.

    I thought it would be easy… until I started trying… hahaha. Hopefully a reply comes soon, and if it does on mine, i’ll post it in here as well.

    Lee Wallis

    (@fatwombat)

    I put my reply in here, I finally worked it out:
    Custom Post Type – Permalinks

    Hopefully this helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom post type with post_id in permalink structure’ is closed to new replies.