• Resolved Alan

    (@arr)


    Hi

    First of all, thanks for the awesome plug-in!

    Secondly, I was wondering if it is possible to change the default slug used for individual posts? My main FAQ page is located under support/faq and I would like the permalink for individual faq posts (as returned by search etc) to be of the format support/faq/my-test-faq.

    As a first stab I tried adding the following function to re-write the slug from just faq to faqtest…

    add_filter( 'arconix_faq_defaults', 'my_faqslug_rewrite' );
    function my_faqslug_rewrite( $defaults ) {
      $defaults['post_type']['args']['rewrite']['slug'] = 'faqtest';
      return $defaults;
    }

    A search now returns the expected URL for faqs e.g. faqtest/my-test-faq instead of faq/my-test-faq but if I click on the link I get a 404 Page Not Found error. I have tried creating new faxes to see if it was an issue with existing links but still get the 404 error.

    I’m a novice to WordPress so any advice would be greatly appreciated!

    Thanks

    Alan

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

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

    (@jgardner03)

    Hi Alan,

    Thanks for using my plugin and for the kind words. I also have to apologize for incomplete documentation for editing the rewrite slug. Your code for the slug is accurate, but incomplete. The 'has_archive' argument must also be set to true.

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

    Then you go to Settings -> Permalinks and scroll to the bottom and click ‘Save Changes’. That will cause WordPress to refresh your permalinks and the slug should start working. If you change the slug, you have to re-save the permalinks to see the changes.

    Thread Starter Alan

    (@arr)

    Nice one John! Thanks for the prompt reply (it seems so easy when you know how) and thanks again for a great plugin!

    Alan

    Thread Starter Alan

    (@arr)

    One slight quirk to this…

    My site originally had my custom FAQ page (using your shortcodes) located at domain.com/support/faq. I wanted the single page versions of faqs to show up as domain.com/support/faq/my-faq-1 etc. I edited teh rewrite you kindly posted above to make the new slug “support/faq”. That works great in that the single faqs are now seen as domain.com/support/faq/my-faq-1 just as I wanted. The problem now is that if I go to my original FAQ URL at domain.com/support/faq I now see what I resume is the archives page rather than my custom FAQ page. Is there some way to overcome this?

    Thanks again

    Alan

    Plugin Author John Gardner

    (@jgardner03)

    You are correct in that you’ll see the post_type archive instead of your FAQ page. As far as I’m aware of there’s no way around this because it’s what you’ve told WordPress to do. In order to get the rewrite working you had to enable the post_type archive, and you’ve established the post_type archive is located at support/faq.

    Thread Starter Alan

    (@arr)

    Ah OK thanks John. I’ll tinker away and see if I can come up with any ideas. Maybe there is a way to design a custom archive page or some-such.

    Thanks anyway

    Alan

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Slug Change’ is closed to new replies.