How to make URLs look like regular posts?

0

Hi there,

When I create a post from my custom type, it has this kind of url, together with my custom post type.

[attachments are only viewable by logged-in members]

However, I want the URL to be more like my regular posts.

[attachments are only viewable by logged-in members]

How can I change that?

  • UNIIMI
    • The Incredible Code Injector

    I would assume you would use this info

    URLs with Namespaced Custom Post Types

    When you namespace a URL and still want to use a “clean” URL structure, you need to add the “rewrite” element to the array. For example, assuming the “ACME Widgets” example from above:

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
    register_post_type( 'acme_product',
    array(
    'labels' => array(
    'name' => __( 'Products' ),
    'singular_name' => __( 'Product' )
    ),
    'public' => true,
    'has_archive' => true,
    'rewrite' => array('slug' => 'products')
    )
    );
    }

    And change the slug from the post-type to the year and date.

    (From here: http://codex.wordpress.org/Post_Types#Custom_Types)

    The problem with that is then you have to worry about creating a blog entry with the same name on the same day… even though it’s not likely, it’s a bad idea to do anything that could end up like that. Not a “best practice.” (Similar to the warnings they give you on the permalinks page.)

  • flashmech
    • The Incredible Code Injector

    Thanks for the solution @UNIIMI, unfortunately I’m not good with PHP at all, and am clueless about what to do with those codes right now. :slight_frown: I will assume that I will have to go read up a lot of materials from the link you provided before I have a glimmer of hope.

    Hi Phil, I was hoping that the Rewrite section in custom press is able to provide this fix.

    [attachments are only viewable by logged-in members]

    If not, having a separate plugin provided by WPMU DEV will be great as well.

    By the way, you are writing a series of how-tos right? I’ll go ahead and post this there too. :slight_smile:

  • Philip John
    • DEV MAN’s Apprentice

    Sorry, yes, you do have this within CustomPress already. Code-filled day on Friday messing with my head :wink:

    Something like this;

    [attachments are only viewable by logged-in members]

    Will produce this;

    [attachments are only viewable by logged-in members]

    Is that what you were looking for?

    Phil

  • flashmech
    • The Incredible Code Injector

    Hi Phil, I’m opening this thread just to grab your attention.

    I am hoping that since a guy did it previously, am wondering if you guys are able to do it too.

    Which is why I asked previously

    What’s the possibility of adding this functionality into CustomPress?

    Will be really great for my custom type, as I foresee I will have many post and some recurring (with possibly the same title) at different times throughout the years. Having the same title is quite no go for me. :slight_frown: