Display subcategories
-
Hi
the plugin is great but how do I display subcategories with indent on the dropDown? The subcategory is displayed as its parent, also the position doesn’t look like the actual plugin understands hierarchy:- Cat
- Puppy doggy
- Dog
Instead of
- Cat
- Dog
- Puppy doggy
Is there anyway to achieve this? Or peraphs a drop down list of the sub category is displayed once you select parent category?
Also I’ve read you are creating a premium version, any idea of a possible date when this is coming out and what features it may have?
Thanks a lot
-
On another note, Is there a possibility to display authors using wp authors? I understand they are not users but is it there any other way?
Thanks
Hi downFast,
The plugin doesn’t do the category list thing by default, but could be wrangled with some custom code.
I’m not sure what you mean by “wp authors”.. perhaps you could clarify?
What does involve custom coding? Is it a paid support request?
I have kinda solved the categories and sub categories issue with some tags workaround tho.With authors I mean have a page with the list of all people who have wrote a post with perhaps the number of their posts in brackets e.g.
Etc
Using wp default won’t work as the post submitted users are not actual wp users
http://codex.wordpress.org/Function_Reference/list_authorsCustom coding means that somebody has to write/modify the code because the plugin, theme, or whatever requires custom functionality, such as the things you’re asking about here. Whether money is involved depends on the request. For example, if a visitor happens to know the answer, they may share some codes for you on the thread. If no one helps for free, then yes it may be necessary to increase incentive with payment. In this case, the plugin would require custom coding for the items you mention.
Hi Jeff. Thanks.
What about the authors thingy?
Sure. Same answer.
Here it is my solution:
1: In order to get sub catebories, I played around with tags and I was able to create a system where I could show only tags attached to posts within a specific category, this will act as some sort of “sub category”. In the user submit posts plugin, find the file called: submission-form.php, this is the file we’ll edit. Just below
<?php } if ($usp_options['usp_tags'] == 'show') { ?>
we do the following:First: Get the cat id:
$cat=5; $yourcat = get_category($cat); if ($yourcat) { echo '<h3>' . $yourcat->name . '</h3>'; }
Then we loop all tags and we output it in a list and we make sure we don’t have any duplicates:
<ul> query_posts('category_name=Ambiente'); if (have_posts()) { $allTags = array(); while (have_posts()) { the_post(); if( get_the_tag_list() ) { $tags = wp_get_post_tags( get_the_ID()); foreach($tags as $tag) { $allTags[$tag->name] = $tag; } } } foreach($allTags as $tag) { echo '<li><input class="checkTag" type="checkbox" value="' . $tag->name . '" />' . ' ' . $tag->name . '</li>'; } } wp_reset_query(); ?> </ul>
Just repeat this for all your category and change the category id.
Note: I am using:
echo '<li><input class="checkTag" type="checkbox" value="' . $tag->name . '" />' . ' ' . $tag->name . '</li>';
Display a list of tags based on category and have a checkbox next to each tag, this is because I am saying to the user: “Hey look all tags already created for each category, maybe you find one you like, if so, check it and the input field for the tag will be automatically populated.
Using this jQuery in the footer to be able to automatically insert in the tag input field the same as what it is writtent next to the check box:
$('.checkTag').click(function() { $("#user-submitted-tags").val( $('.checkTag:checked').map(function() { return $(this).val(); }).get().join(', ') ); });
With that, the selected checkbox will populate the tag input field, you can select multiple checkboxes too, and the tags will be written in the input field with a comma for multiple tags selection.
Note: There maybe tons of tags (subcategories), so what I did was to insert a link “Check all existing sub-categories => click > a pop up opens with all the lists. In my case I have used bootstrap3 modal
If the user wants to create a new sub-category (a tag), they won’t select any checkbox and can simply write it in the input field as normal:
<input name="user-submitted-tags" required id="user-submitted-tags" data-required="true" type="text" value="" placeholder="Scrivi la sottocategoria" class="form-control input-lg usp-input">
Careful to the classes I have used as these are used in the jQuery bit too.
Done! Now we treates tags as some sort of sub category.
—
The authors:
The plugin is great and you don’t need to register, which means the posts will be written with whatever name you provide but actually wordpress thinks they are written by the admin with just a differnt name. So What I had to do was to get the author name and with the following I am able to:
1: Get the author and display all posts made by it
2: Get the total number of posts the author made
3: Get a link to each posts it made<ul> <?php $args= array( 'posts_per_page' => -1 ); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li> <?php $args = array( 'posts_per_page' => -1, 'meta_key' => 'user_submit_name', 'meta_value' => get_the_author(), 'meta_compare' => '=' ); $myquery = new WP_Query($args); echo '<h3>' . $myquery->found_posts . ' proposte da ' . get_the_author() . '</h3>'; while ( $myquery->have_posts() ) { $myquery->the_post(); echo '</li> <li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li> '; } ?> <?php wp_reset_postdata(); ?> <?php endwhile; ?> <?php endif; ?> </ul>
Done!
The last bit I will do is to ask the user to insert their name and I will attach a random unique string, then tell the user to always use that username when posting in order to not have duplcate username and therefore be able to really show all posts made by 1 author.
e.g.
User 1 says: My name is => Simon, and he writes a post
User 2 says: My name is => Simon, and he writes a post.As we can see they are 2 users using the same name, which makes it impossible di distinguish the 2 different authors.
The solution I am thinking is as I said, create a unique string which will be attached to the Name provided by the user, and just tell them to always use that username when posting. E.g.
simon_uniquexyz
simon_uniquegtdI hope this will help someone.
downFast? Thanks but with the code blocks (which you should use, thank you for that) the code looks totally and completely unreadable. Honest.
Can you share that via pastebin.com links?
Hey I was just about to clean up the code, should be ok now.
or even bettr, in regards of the same name, I could check if the meta value already exists
- The topic ‘Display subcategories’ is closed to new replies.