Support » Theme: Blocksy » Archive view customization for custom post type

  • Resolved anandaravind

    (@anandaravind)


    @creativethemeshq Maybe something related to my previous query: Are custom post type more than 2 not supported to create an archive page from the theme? I have 3 custom post type; When I look at the customizer, 2 custom post type along with the default post type are available for customization. The third one does not show up in the customizer for archive customization. Is this by design? Please clarify.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author creativethemeshq

    (@creativethemeshq)

    Hello @anandaravind,
    What is the slug name of your third CPT?

    Thread Starter anandaravind

    (@anandaravind)

    Hi @creativethemeshq, Here is the slug list of CPTs: books / news / courses. All three are non-hierarchical. books and news comes up, while courses does not come up.

    Except for name, all post types have the same configuration:

    name: courses
    label: courses
    singular_label: course
    description: ""
    public: true
    publicly_queryable: true
    show_ui: true
    show_in_nav_menus: true
    delete_with_user: false
    show_in_rest: true
    rest_base: ""
    rest_controller_class: ""
    has_archive: true
    has_archive_string: ""
    exclude_from_search: false
    capability_type: post
    hierarchical: false
    rewrite: true
    rewrite_slug: ""
    rewrite_withfront: true
    query_var: true
    query_var_slug: ""
    menu_position: ""
    show_in_menu: true
    show_in_menu_string: ""
    menu_icon: ""
    custom_supports: ""
    • This reply was modified 6 months, 1 week ago by anandaravind.
    Theme Author creativethemeshq

    (@creativethemeshq)

    Hello @anandaravind,
    Thanks for providing this info.

    The thing is that some CPT’s slugs are used by popular LMS plugins which we provide integration for.

    That is why we are hiding that CPT from the customizer in order to show it only for those LMS plugins and not conflict with other custom made CPT’s.

    But if you don’t use an LMS plugin there is a filter that could bring back the support for your CPT.

    Simply add this code in your child theme’s functions.php file or add this code through a snippets plugin like this one.

    
    add_filter('blocksy:custom_post_types:supported_list', function ($cpts) {
        if (get_post_type('course')) {
            $cpts[] = 'course';
        }
    ​
        return $cpts;
    });
    

    Let us know if this helps.

    Thread Starter anandaravind

    (@anandaravind)

    Thanks @creativethemeshq for sharing the background. The code snippet did not help in bringing out the course post type in the customizer. I tested by adding another post type with a different name, and it worked fine. All the three post type were visible on customizer for customization. Looks like the slug, course, is cause of the issue as it is being used for integration with LMS. Maybe it will help if the documentation captures such dependency and lists slugs/terms to be avoided. Thanks again for your support!

    Theme Author creativethemeshq

    (@creativethemeshq)

    @anandaravind Sad to hear that the above code snippet didn’t helped you.

    I re-did the test on our end like this:

    1. Declared a CPT with the slug course using the “Custom Post Type UI” plugin
    2. Added the above code in the functions.php file of my child theme
    3. Result: Courses showed up in the customizer

    Now, it’s possible that the get_post_type('course') check could fail on your end , because our filter could be called slightly earlier than the moment when your plugin declares the CPT itself.

    What you can try is whitelisting this CPT without the check at all, like this:

    
    add_filter('blocksy:custom_post_types:supported_list', function ($cpts) {
        $cpts[] = 'course';
    ​
        return $cpts;
    });
    

    I believe with this code it should work properly in your case too.

    Can you please give it a go and let us know how it performs for you?

    Thanks and waiting for your reply.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Archive view customization for custom post type’ is closed to new replies.