• Hello people –

    So I’m working with a theme that bases an important part of it’s functionality on custom post types. No issue there – but the URL structure is. The output URLs are (for example) “www.site.com/?service=california” What I’d prefer ideally for several reasons – SEO being one – is “www.site.com/california”

    I tried a plugin ‘custom post type permalinks’ that will change the permalink structure but pages then give a 404. The author is unresponsive to multiple support requests from people having the same issue.

    I’m not requesting help with the plugin but, rather, how to rewrite the custom post type urls to be what I need them to be.

    Any advice or info would be greatly appreciated. Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    From Your example (“www.site.com/?service=california”) i assume that You have default permalinks setting active.

    On Settings -> Permalinks setting ‘Post name’ or ‘Custom Structure’ would be a good start.

    If You do not want to use any SEO plugins, look at WordPress rewrite API.

    Hope that helps at least a little bit.
    M

    Thread Starter joeydav0117

    (@joeydav0117)

    Thanks for replying. Actually, no, I don’t have default permalinks set. I do have custom structure. The only links not custom are the custom post type links.

    I’m using an SEO plugin. That doesn’t help me change the URL structure.

    I don’t know how to use rewrite API – so I came to these forums for help.

    Thanks!

    Ok,

    So how You created that custom post type?
    What SEO plugin are You using?

    M

    Thread Starter joeydav0117

    (@joeydav0117)

    The custom post types were built into the theme. Example here:

    https://logitrans.themesawesome.com/?service=air-freight

    Using Yoast’s SEO plugin.

    Thank you for replying.

    Well,
    Logitrans is a paid theme, and i would recommend to contact theme developer. They should provide You with the solutions.

    You can also try some rewrite plugin.

    M

    Thread Starter joeydav0117

    (@joeydav0117)

    I’ve been that route. It’s a very slow process. No further advice?

    Thanks.

    You can dig into theme code…
    Unfortunately i do not have that theme so from now on i can only guess…

    There should be a function somewhere called ‘register_post_type’ and/or ‘register_taxonomy’. They are responsible for creating custom post type and taxonomy for it. It can be in functions.php, files that are included in it, in some plugin if that theme provide some…

    Both should have in argument array something like ‘rewrite’.
    If there is nothing like it, then it would be the best position to start messing with the code:)

    Try to add 'rewrite' => array( 'slug' => 'someveryprettyslug' ) and see what happen.

    M

    Thread Starter joeydav0117

    (@joeydav0117)

    I found this – just don’t know what to do with it to remove
    “/?service=california” and just make it “california.” Can you tell from this code?

    register_post_type('logitrans-service' , $args);
    
            /*register_taxonomy(
                    "service-category", array("logitrans-service"), array(
                    "hierarchical"   => true,
                    "label"          => "Categories",
                    "singular_label" => "Categories",
                    "rewrite"        => true));
    
            register_taxonomy(
                    "service-tag", array("logitrans-service"), array(
                    "hierarchical"   => false,
                    "label"          => "Tags",
                    "singular_label" => "Tags",
                    "rewrite"        => true));
    
            register_taxonomy_for_object_type('service-category', 'logitrans-service');
            register_taxonomy_for_object_type('service-tag', 'logitrans-service');*/

    We may be closing to something:)
    I need few more lines of code.
    This:
    register_post_type('logitrans-service' , $args);
    is what generates post type.
    Can You paste here args?
    It should look somewhat like this:

    $args = array(
      'labels' => $labels,
      'public' => true,
      'publicly_queryable' => true,
      'show_ui' => true,
      'show_in_menu' => true,
      'show_in_nav_menus' => true,
      'query_var' => true,
      'rewrite' => array( 'slug' => 'service', 'with_front' => false ),
      'capability_type' => 'post',
      'has_archive' => false,
    );

    M

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom post type URL rewrite’ is closed to new replies.