Trying to 'chain' wikis within categories

Hi,

My boss has requested that I create a method to 'chain' topics in the wiki by category, and/or sub-category. Example:
once a user goes to category RW History and views the first topic (wiki) under that, provide a button or arrow to the NEXT topic in that category. Also have a button or arrow to go to the previous topic (wiki).

I have learned how to make a button, and/or can use a graphic to make an arrow, but don't know how to do the code for the button or arrow to work.

Thanks VERY much in advance!!

Mary :o)

  • Michelle Shull

    Hey there, Mary!

    By "chaining" you're talking about pagination, which is actually built in to WordPress itself (and picked up by Wiki), as long as your theme supports it. You can test this by temporarily switching to a default WP theme (I'm using twenty fifteen in my screenshot below) that supports pagination. Scroll down, you'll see previous and next links at the bottom of the wiki entry.

    So I'm guessing the theme you're using on your boss's site does not support pagination out of the box. (Personally, I think all themes should support this, but I can see why some don't.) We can usually add pagination support to a theme fairly easily, but it ultimately depends on the theme code itself. Which theme are you using here? If it's one we've got on hand, I can take a look and see how it's put together. Do you happen to see previous/next links on regular old blog posts?

    There is a plugin that might help, here, as well: https://wordpress.org/plugins/wp-paginate/

  • Mary

    Hi Michelle,

    The MOST important part of my question above is my reference to CATEGORIES and SUB-CATEGORIES.

    Yes, the wiki pro does have arrows at the bottom, and even says the name of the previous and next topic (wiki) page. BUT, I have observed that the next and previous wiki to come up is based upon WHEN the wiki was created in the database, NOT the CATEGORY OR PARENT. I have never seen any 'front-end' method of sorting the wiki database. IF I could sort it, I would sort it by Parent or Category and possibly it would have the wikis in the correct order and it would accomplish what my boss wants. But, as I said, I've never seen a method to sort the database in the front end, and heaven forbid if I was to try to do this in the back-end. Not within my experience yet.

    In reference to Support Access, it was still valid when I just went in and checked it, but I extended it so now it's till the 16th.
    "Support access is ACTIVE until March 16, 2015 12:55 PM

    I am using Minimaze theme, as a result of the Menu Category problem I had the last time I had a Support question that you answered. (I think it was the last time, LOL).

    Thanks, and I look forward to getting your reply.

    Mary :o)

  • Mary

    Hi Michelle,

    The MOST important part of my question above is my reference to CATEGORIES and SUB-CATEGORIES.

    Yes, the wiki pro does have arrows at the bottom, and even says the name of the previous and next topic (wiki) page. BUT, I have observed that the next and previous wiki to come up is based upon WHEN the wiki was created in the database, NOT the CATEGORY OR PARENT. I have never seen any 'front-end' method of sorting the wiki database. IF I could sort it, I would sort it by Parent or Category and possibly it would have the wikis in the correct order and it would accomplish what my boss wants. But, as I said, I've never seen a method to sort the database in the front end, and heaven forbid if I was to try to do this in the back-end. Not within my experience yet.

    In reference to Support Access, it was still valid when I just went in and checked it, but I extended it so now it's till the 16th.
    "Support access is ACTIVE until March 16, 2015 12:55 PM

    I am using Minimaze theme, as a result of the Menu Category problem I had the last time I had a Support question that you answered. (I think it was the last time, LOL).

    Thanks, and I look forward to getting your reply.

    Mary :o)

  • Michelle Shull

    Hi, Mary, thanks for your replies.

    So sorry for the misunderstanding, thanks for explaining it to me here.

    Okay, going by category and sub-category is going to be much trickier here. I've installed minimize and wiki on my own site, and I've spent several hours trying to get this just right.

    Here are the facts so far:
    1. It is possible to tell previous and next links to use the taxonomy (in this case, a wiki category) rather than chronological order. It's built right in on the WP level. This is good news!
    2. There are several different ways to insert the previous/next links in a theme. Your theme uses a method called get_adjacent_post, and get_adjacent_post has four parameters. Is it in the same taxonomy? (True/False) Are there any excluded taxonomies? (An array of ID numbers, if categories are being excluded, or blank if they aren't. Should the previous post show? (True/False) and the taxonomy slug (default 'category', here 'incsub_wiki_category') This all probably sounds like Greek to you, and it did to me a few hours ago, too. :slight_smile: Cliff's notes: This is what your theme does to make the previous and next links show up.
    3. So, I can make your entire site's previous and next links depend on category rather than chronological order by changing two FALSEs to TRUEs. But, this isn't the goal, we want this to apply only to Wikis.
    4. To make this apply only to Wikis, we're going to need a little more help here, so I'm going to ask for some help from our second level team. The results won't be instant - this is a bit of a noodle bender because of how Wiki works and how your theme handles the links, and our second level guys are really busy handling our more complex issues - but they'll swing by for feedback here as soon as they can. I'll also send a message internally, because after all this time I really want to find the secret sauce to take us from where I got us to the finished project.

    Thanks, Mary!

  • Mary

    Michelle,

    Visualize this like viewing a thread in a blog. After all, WP started out as just a way to create blogs, right?

    So there is an Index of blog 'categories'. User picks the category. Then a sub-index shows 'threads' within the category, to me this is 'sub-categories'. Within those sub-categories are posts (in my case wikis, sub-wikis, and sub-sub-wikis). Each wiki is part of that thread.

    Now since WP started out as a blog site, it certainly would NOT make sense that every single user post would show up in the chronological order of the posts, without regard to what he was posting about, correct? Please see Dropzone.com and click on the forums. Their forums are set up to VIEW like we need our wikis to be set up to VIEW.

    This isn't as complicated as it seems. The mechanics of it already exist in a well-ordered blog. Also, I re-read all the above posts. I will REVOKE then ALLOW Support Access.

    Mary :o)

  • Michelle Shull

    Hi, Mary!

    I see your thought process here, but it is actually more complicated than it looks. The default for previous and next links is to go the the next and previous chronological posts. The option to use those within the same taxonomy (category) is baked in, and as I said, it should have been as simple as changing a few boolean values from FALSE to TRUE. I made this work with Minimaze, but it applies to ALL posts, not just the wiki custom post type. What I need help from second level support on is to create a previous/next system for ONLY wiki posts that depends solely on category rather than on chronological order.

    You're welcome to play with it. The file you need to edit is template-tags.php within the Minimaze theme. If you've got a better idea for making this work with only Wiki posts, I'm definitely listening!

    Thanks Mary!

  • Mary

    Michelle,
    The more I think about this the more I realize that this is a Wiki-Pro problem. It is set up like a blog, in that all wikis default to chronological order of creation date when the user views it using the arrows at the bottom of the page. Changing the sort sequence for ALL pages will affect the blog once people start using it. This would be a real mess if blogs were sorted like Wikis.
    I was using 2012 theme for a while, and it did the same thing, so I think you can't 'point-the finger' at Minimaze, since it's developers did the same thing WPMU Dev developers did. IS THERE a WPMU Dev developed theme that allows the admin to designate the sort order, down at least three levels, when the user views it using the arrows at the bottom of the page for Wikis, and have a separate sort order for blogs?

    It still seems like there should be a simple solution to this, like adding an input field to a sortable wiki list (see Dashboard --> Wikis --> Wikis). Allow the admin to designate the priority order of all wiki pages under categories and sub-categories that will override the chronological order if there is something entered in that field. But that is incredibly time consuming, given how large a wiki can be. We have about 400 wikis right now, and will have at least a thousand more in several months.

    Probably the simplest solution is to enable the Admin to input the sort sequence of the wikis down at least 3 levels of categories, and that governs how the arrows at the bottom of the page display the wikis.

    Mary

  • Michelle Shull

    Hi, Mary.

    I'm not pointing a finger anywhere. I like Minamaze, it's a great free theme, it works well with most custom post types, and it's a nice looking skin for a blog.

    Here is why I called second level:
    *The default WordPress behavior is to move between posts chronologically on the previous and next links. (Your theme uses the "get adjacent posts method" - source)

    Parameters
    $in_same_term
    (boolean) (optional) Whether post should be in a same taxonomy term.
    Default: false
    $excluded_terms
    (array or string) (optional) Array or comma-separated list of excluded term IDs.
    Default: ''
    $previous
    (boolean) (optional) Whether to retrieve previous post.
    Default: true
    $taxonomy
    (string) (optional) Taxonomy name, if $in_same_term is true.
    Default: 'category'

    *It is possible to change this behavior to move between posts in the same category.
    *I can make this work with Minamaze, but only for all posts, not JUST Wiki posts, which is what you want.
    *I need help to keep the previous and next links moving between categories instead of chronologically to only occur on your wiki posts, and not all other post types. I believe it's a matter of creating an if/else statement in your template-tags.php, but I need guidance as to the exact structure of those lines of code.

    Sorting the Wikis first will not change how you move between posts, that has to be done with template-tags.php, which determines the behavior of the previous and next links. Even if you can sort the Wikis/posts/other custom post types, the previous and next links would still move chronologically unless you specifically changed the template-tags.php code to use taxonomy instead, as that parameter is almost always set to FALSE by default. Most blogs display content chronologically, so this makes sense as the default for most bloggers. It's not necessarily the best choice for all users or all cases, obviously, but I think most users are going to expect to move through blog posts chronologically.

    I don't want to argue with you about how complicated it is, I've tried to explain the components we're dealing with, but clearly I've done a poor job. Hopefully second level support, who I flagged the other day, will be able to explain this to you better and provide a Wiki-specific solution for your needs here.

    Thank you.

  • Michelle Shull

    For a little more context, here's the code from your template-tags.php file:

    if ( is_single() ) {
    		$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
    		$next = get_adjacent_post( false, '', false );
    
    		if ( ! $next && ! $previous )
    			return;
    	}

    The places you see true and false here correlate with the properties I quoted from the WordPress Codex in my post above. Thought seeing the code itself might reveal more of what we're trying to do here.

    Thanks, Mary

  • Hoang Ngo

    Hi @Mary,

    I hope you are well today.

    Can you please download the attachment and copy it to the current theme folder, let see if it work for you. The idea is we will base on the category that's the wiki assigned to, and find the categories tree, index the wikis and let user navigate through that.

    If you have any issues please don't hesitate to let us know so we can assist.

    Best regards,
    Hoang

  • Mary

    Hoang,

    This works GREAT for ALL level 2 Wiki Categories. These Wiki Categories are numbered 1., 2., 3., etc. It DOES NOT work for level 3 Wiki Categories and the Wikis themselves. We still get random (no doubt chronological) Wiki level 3 Categories numbered 1.1, 1.2, . . 2.1, etc. and wikis.

    Support access is enabled. Please go to skydiving-encyclopedia.com/wiki/skydiving (Do NOT go to skydiving-encyclopedia.com, as I have a redirect for our users that will take them, and you, to our OLD site that skydiving-encyclopedia.com is replacing WHEN we get this last MAJOR issue resolved). Once you are at that wiki (Skydiving), click any category on the sidebar and then select a sub-Wiki Category (numbered 1.1, 1.2, . . 2.1, etc). Scroll down to the previous and next arrows. It SHOULD show the previous sub-wiki category (level 3 wiki category). THEN click on a wiki shown on the page. It SHOULD show the previous or next wiki within that wiki sub-category (level 3 sub-category). Instead it shows a previous or next wiki based upon when they were created.

    Is there additional code that can be added to the theme file that will make the Previous and Next arrows to go to the correct previous and next level 3 Wiki Category and the correct previous and next wiki within that wiki level 3 category?

    THANK YOU SO VERY MUCH for your help. This change is the LAST hurdle to overcome then I can make our NEW site live for our users.

    Mary :o)

  • Hoang Ngo

    @Mary,
    I hope you are well today, and I do apologise for the delay.
    I have done some code for you, but I will need to update it on your site, so we can quickly apply the changes without re-modify the theme file (my file based on 2013 theme), so when upload that to your site, the look will not really fit.

    Can you please send in:
    - Mark to my attention - ATTN: Hoang Ngo
    - Link back to this thread
    - Include admin/network access
    - Include FTP
    - Include any relevant URLS for your site
    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.
    Thanks!
    Best regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.