• Resolved ruewa

    (@ruewa)


    Hi, thanks for the great plugin!
    I created a hidden wiki for logged-in members of a research team via the plugin wp-members, which works smoothly with the wiki pages itself. But Yada-Wiki seems to create an non-editable kind of wiki main page if you call the non-existent “my-domain/wiki”. This page generates a kind of search-result-style TOC and shows captions and excerpts of the wiki-posts. I tried to override it by creating a 404-style page with the same address, but this didn’t work.
    Is there a way to suppress this behaviour?

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

    (@dmccan)

    Hi ruewa,

    The wiki is a type of WordPress content called a Custom Post Type. When a Custom Post Type is defined there is an option to have an “archive” or not. Most people want an archive for their post types, so it is set to true. Here is some code to turn it off and you will need to add that to your child theme’s functions.php file, or use a plugin like Code Snippets to add it.

    
    add_filter( 'register_post_type_args', function( $args, $post_type ) {
        if ( 'yada_wiki' !== $post_type ) {
            return $args;
        }
    
        $args['has_archive'] = false;
        $args['rewrite']     = true;
    
        return $args;   
    }, PHP_INT_MAX, 2);

    Is the information you are hiding sensitive information, such that this is a security issue? I ask that because the code above, together with the free plugin wp-members, is not going to lock down the information. For example, if you have added wiki categories to the wiki articles then categories (default WordPress as well as Custom Post Type custom categories — tags too) also have an archive. If you had added a wiki category of “tips” you could go to “my-domain/wiki_cats/tips/” and they would be listed. Custom categories don’t have a setting to turn them on or off. I’m not comfortable trying to lock down your data with some bits of code and you might need some plugin geared to that.

    Best regards,

    David

    Thread Starter ruewa

    (@ruewa)

    Hi David,
    thanks for the speedy reply, but this didn’t work. The ../wiki page showed up anyway, only without the caption “Archive”. It shows a complete list of all wiki pages.
    On the other hand I couldn’t see newly created wiki pages anymore, they became redirected to 404, even though they showed up in the All Wiki Pages list and were accessible in the editor.
    I tried to override the ../wiki page with a post and a page on the same address, but also without success.
    Yes, it’s kind of sensible data – not on a live-or-die-level, but yeah…
    I don’t use categories by now, there’s a clear tree structure of the pages.

    Any way to redirect this ../wiki page to 404?

    Best regards
    Ruediger

    Plugin Author dmccan

    (@dmccan)

    Hi ruewa,

    This works for me, added using the Code Snippets plugin:

    function yada_wiki_disable_cpt_archive_template(){
        if ( is_post_type_archive('yada_wiki') ) {
            global $wp_query;
          $wp_query->set_404();
          status_header( 404 );
          get_template_part( 404 ); exit();
      }
    }
    add_filter( 'archive_template', 'yada_wiki_disable_cpt_archive_template');

    Here is a screenshot with the settings:
    https://share.getcloudapp.com/WnubxEGw

    Settings / Permalinks set to Post Name. Save the permalinks after adding the above code and if you disable it, go save them again to clear it.

    If you add the code to your functions.php or a plugin then you will need to add the priority. I think that would be something like:

    add_filter( ‘archive_template’, ‘yada_wiki_disable_cpt_archive_template’, 10);

    Hope this helps,

    David

    Thread Starter ruewa

    (@ruewa)

    Hi David,

    this works fine and solved my problem.

    Thank you very much!

    Kind regards

    Ruediger

    Plugin Author dmccan

    (@dmccan)

    You are welcome. Glad to hear it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to hide auto-generated wiki-mainpage?’ is closed to new replies.