Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Support request] Show posts on static frontpage + use static pages as Category Archives

Home Forums Support [Support request] Show posts on static frontpage + use static pages as Category Archives

Home Forums Support Show posts on static frontpage + use static pages as Category Archives

Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #1193688
    David
    Staff
    Customer Support

    Not sure – i have asked Tom to take a look at the issue.

    #1193696
    Patryk

    That’s good because i think that there will be more people interested in.

    #1194043
    Tom
    Lead Developer
    Lead Developer

    Strange, haven’t seen people have this issue with the code before. There’s likely something up with your rewrite rules.

    You might be able to prevent it with this:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() ) {
            return $query_vars;
        }
    
        if ( isset( $query_vars['category_name'] ) && is_archive() ) {
            $pagename = $query_vars['category_name'];
    
            $query_vars = array( 'pagename' => "$pagename" );
        }
    
        return $query_vars;
    } );
    #1194072
    Patryk

    It works! Thank you so much.

    #1194099
    Patryk

    Oh no. Just realize that im wrong. Now it use the categorie archives instead of static pages…

    Any other idea?

    #1194291
    Tom
    Lead Developer
    Lead Developer

    Must be something weird going on with your setup. What do you have set for permalinks in “Settings > Permalinks”?

    #1194412
    Patryk

    Hi,

    my permalink setup:
    /%category%/%postname%/

    And my menu setup:
    individual link as main menu item and category as sub menu item.

    Thanks.

    #1194787
    Tom
    Lead Developer
    Lead Developer

    What if you just use the standard %postname% permalinks? Any difference?

    #1194932
    Patryk

    Hi Tom, that‘s it!
    Any ideas to get it with the other permalink structure? Thanks again.

    #1195048
    Tom
    Lead Developer
    Lead Developer

    Hmm, we could try debugging in the code.

    For example:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() ) {
            return $query_vars;
        }
    
        var_dump($query_vars['category_name']);
    
        return $query_vars;
    } );

    What does that output above the header when viewing category pages?

    #1195194
    Patryk

    Hi Tom,

    i switch permalinks to /%category%/%postname%/

    The output for the category page is the same as in the post:
    – string(6) “rezept“ in the category Rezept
    – string(8) “hausarzt“ in the category Hausarzt

    #1195587
    Tom
    Lead Developer
    Lead Developer

    Can we try this now?:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() ) {
            return $query_vars;
        }
    
        if ( isset( $query_vars['category_name'] ) && is_archive() ) {
            $pagename = $query_vars['category_name'];
    
            var_dump($pagename);
    
            //$query_vars = array( 'pagename' => "$pagename" );
        }
    
        return $query_vars;
    } );

    Does it output anything?

    #1195658
    Patryk

    Hi Tom,

    no nothing.

    #1195907
    Tom
    Lead Developer
    Lead Developer

    I’m assuming the action runs too early for is_archive() to work, that’s a shame.

    I’m not really sure what to do here, unfortunately.

    My last guess would be to do this, but it’s just a guess:

    add_filter('request', function( array $query_vars ) {
        if ( is_admin() ) {
            return $query_vars;
        }
    
        if ( isset( $query_vars['category_name'] ) && ! isset( $query_vars['p'] ) ) {
            $pagename = $query_vars['category_name'];
    
            $query_vars = array( 'pagename' => "$pagename" );
        }
    
        return $query_vars;
    } );

    category_name should only be set when viewing a category, but I guess having it in your permalinks makes it so it’s always true.

    #1195983
    Patryk

    Ok it does not work. But no problem. I switch back to the other permalink and than its fine for me. But thank you very much for your assistance.

Viewing 15 posts - 16 through 30 (of 31 total)
  • You must be logged in to reply to this topic.