• In our use-case, we have a category like this:

    /parent-category/second-level/third-level/

    For some categories, we’ll have a themed top-level page on /parent-category/

    We want this page to have the same slug, so when someone removes a part of the URL, they’ll visit the themed page (instead of the top level category page).

    In our case, WordPress Pages Slugs have prior to Woocommerce Categories Slugs.

    To achieve this, we’ve added these lines of codes to the plugin on row 485:

    
    // Check if slug exists for a page
    global $wpdb;
    $slug_exists = $wpdb->get_var("SELECT count(ID) FROM <code>$wpdb->posts</code> WHERE <code>post_name</code> = '" . $slug . "' AND <code>post_type</code> = 'page'");
    if($slug_exists > 0){
        continue;
    }
    

    When the permalinks are being rebuild, it checks if the slug is used by a page. If so, he’ll skip the slug to be used by the Woocommerce Category.

    @dholovnia Is it possible to implement this feature in the plugin (ideally with an option the user can activate in the settings?)

Viewing 1 replies (of 1 total)
  • Plugin Author Dmytro Holovnia

    (@dholovnia)

    Hi,

    Sorry for the late reply.

    Did you try page builder for this?
    For example Divi builder has option Theme+Builder. There you can add custom header/body/footer for the chosen pages. You can rewrite body content of some page without doing any fancy changes.
    I’m sure that most of the modern builder have this option.

    What you are trying to do has many ways to be done. The one with 2 pages and same slug can provide you headache in the future.

    I don’t think this is a good feature.

    Regards,
    Dmytro

Viewing 1 replies (of 1 total)
  • The topic ‘Use same slug for both category and page (prior to page)’ is closed to new replies.