Site logo

[Resolved] Category archive pages, URL

Home Forums Support [Resolved] Category archive pages, URL

Home Forums Support Category archive pages, URL

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2452869
    Ted

    Greetings,

    I’ve changed my archive pages to static pages with the PHP at the bottom here. (as suggested in this forum)

    I’ve changed the canonical links to static URLs without the word ‘category’ in them, but they keep showing up as something like https://thegreatestsong.com/category/audio-gear-reviews/
    What I would like is:
    https://thegreatestsong.com/audio-gear-reviews/

    I’ve obviously missed some key step here which removes category from the URL. Your help would be most appreciated.

    Kind Regards

    PHP snippet I’m using:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() ) {
            return $query_vars;
        }
    
        if ( isset( $query_vars['category_name'] ) ) {
            $pagename = $query_vars['category_name'];
    
            $query_vars = array( 'pagename' => "$pagename" );
        }
    
        return $query_vars;
    } );
    #2453554
    Ying
    Staff
    Customer Support

    Hi there,

    Can you go to admin > settings > permalinks, in the Category base field, enter a ., then save the changes?

    Let me know if this works.

    #2454231
    Ted

    Worked! Many thanks!

    #2454989
    Ying
    Staff
    Customer Support

    No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.