• Resolved TrishaM

    (@trisham)


    I’m using the Genesis Framework which adds breadcrumbs to all my pages, including my single CPT for FAQs – it all works great except that the parent page to the single FAQ page does not get linked in the breadcrumb trail UNLESS the “has_archive” parameter is set to ‘true’ when you register this CPT during plugin installation.

    SO the breadcrumb looked like this:
    Home >> FAQ >> My cool single FAQ

    When I needed it to look like this:

    Home >> FAQ >> My cool single FAQ

    I hacked the plugin to change that parameter to true so this would work correctly, but I’m requesting that you consider either making it an option, or just set it to “true” on future versions.

    Unless I’m missing something, I can’t see a reason to set it to ‘false’ (?).

    It would definitely bear noting that if it is set to true, the user MUST have a Page setup on which ALL FAQs are displayed (which they likely would anyway, otherwise why have FAQs, right?)…..if there is not a Page setup to display all FAQs, then that archive link would generate a 404 error.

    Thanks!!
    Changing that parameter to true makes

    https://wordpress.org/plugins/arconix-faq/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Gardner

    (@jgardner03)

    Hi Trisha,

    A post type archive isn’t really be a commonly used element with this plugin since in using it you’d lose the jquery toggle/accordion functionality along with FAQ groups and other customization options. Because the archive setting is easy enough to enable via a simple filter I don’t see myself enabling it by default in a future version, but I do really appreciate the feedback.

    The following code in your theme’s functions.php file will set the archive value to true:

    add_filter( 'arconix_faq_defaults', 'my_faq_defaults' );
    function my_faq_defaults( $defaults ) {
        $defaults['post_type']['args']['has_archive'] = true;
    
        return $defaults;
    }

    I recommend the filter route because it is upgrade-safe — you won’t have to re-edit the file when I update the plugin in the future.

    I hope that helps.

    Thread Starter TrishaM

    (@trisham)

    HI John – thank you very much – your solution is perfect! I also would rather add code to my functions to alter a plugin’s behavior rather than hack a plugin, so thank you for this.

    And I agree with you on the post-type archive issue, but my boss insisted that the Breadcrumb trail should have the (parent page) for all FAQs shown when viewing a single FAQ post.

    So while setting has_archive to true does allow Genesis to automatically add the parent (archive) page, as you’ve noted, it directs one to a normal archive page, which does indeed mean losing all the great features of your plugin.

    What I did to get around that was to use a 301 redirect in my .htaccess file to redirect from the Genesis breadcrumb-generated link – which uses the CPT “FAQ” – to a page named “FAQs” that I created and which has the shortcode to display all FAQ posts accordion-style.

    The only other alternative would be to change the Genesis breadcrumb structure to change the CPT ‘faq’ in the trail to ‘faqs’, which means using Genesis hooks and code….ultimately I decided a 301 redirect was much easier.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change has_archive to 'true'’ is closed to new replies.