Site logo

[Support request] Custom Post Type Archive in Columns

Home Forums Support [Support request] Custom Post Type Archive in Columns

Home Forums Support Custom Post Type Archive in Columns

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #1651276
    Johan

    Hello David 🙂
    The ideal for this site would be that “our-formations” as well as all the children categories are in columns (3 col if possible?):
    – securite-incendie
    – sante-et-prevention
    – securite
    – vtc
    – hygiene
    In addition, I would like to have for each card a button with the text “Discover this training”
    Is it possible ?
    Thank you

    #1651409
    David
    Staff
    Customer Support

    So you should be able to check if the category is an ancestor. So this line:

    if ( is_category( 'nos-formations' ) ) {

    becomes:

    if ( is_category( 'nos-formations' ) || cat_is_ancestor_of( 'nos-formations' ) ) {

    #1651447
    Johan
    #1652073
    Tom
    Lead Developer
    Lead Developer

    What’s the error? Can you check your error_log file for something specific?

    Let us know 🙂

    #1652762
    Johan

    Hello,
    Nothing is displayed in debug mode (wp-config = define (‘WP_DEBUG’, true);), the page is blank (ex. : https://dev1.directsolutions.fr/offres/nos-formations/securite-incendie/)…
    Here is what Query monitor indicates: “Fatal error: Uncaught Error: Too few arguments for the cat_is_ancestor_of () function, 1 passed in /home/directl/dev1/wp-content/themes/generatepress_child/functions.php on the line 88 and exactly 2 expected
    in /home/directl/dev1/wp-includes/category.php at line 246 “

    #1653388
    Tom
    Lead Developer
    Lead Developer

    Ah, try this:

    $category = get_queried_object();
    
    if ( is_category( 'nos-formations' ) || cat_is_ancestor_of( $category->term_id, 'nos-formations' ) ) {
    #1653444
    Johan

    Hello Tom and thank you 🙂
    Indeed with this code I have no more errors however I have no columns either 🙁

    I put the current full code below for verification:

    add_filter( ‘generate_blog_columns’,’tu_formation_columns’ );
    function tu_formation_columns( $columns ) {
    $category = get_queried_object();
    if ( is_category( ‘nos-formations’ ) || cat_is_ancestor_of( $category->term_id, ‘nos-formations’ ) ) {
    return true;
    }
    return $columns;
    }

    #1654740
    Tom
    Lead Developer
    Lead Developer

    Is this code doing anything on the nos-formations category page?

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