Showing specific categories - php

I'd like to show only specific wordpress categories (with their sub-categories nested), so for example:
Main Category 1
Sub Category 1.1
Sub Category 1.2
Main Category 5
Sub Category 2.1
Sub Category 2.2
... I can hardcode it inside the sidebar template, but I'd like to know if there's any existing plugin/widget that allows this so I can easily manage category selection/update via admin panel.
Many thanks

You can accomplish this using the wp-list-categories tag. I'm assuming you're customising your template and this came up?
The function has enough parameters to customise it as you need.

Related

Use a single wordpress category.php file for every category registered

As the title suggests, I'm trying to use one category.php file for every category registered by a user in the back-end. I've always created category-[specific category].php files in the past but this feels very messy as the design usually remains the same.
Without being specific in the query I return all posts in all categories however, I want to be able to show the custom posts for only the category selected from the nav. The problem is, I can't seem to find a way to pass the category the user selected into the query in order to only return posts attributed to it.
Thanks in advance for any help.
You don't need to do anything specific to show a list of posts from a specific category. Take a look at this article on the WordPress Codex. Here is an excerpt from that page:
In the case of categories, the hierarchy is fairly simple. For
instance, suppose the slug of the Category in question is news and the
Category ID is 6. The Template Hierarchy specifies that WordPress will
use the first Template file it finds in your current Theme's directory
from the following list:
category-slug.php
category-ID.php
category.php
archive.php
index.php
So all you need to do is create category.php in your theme and then view any category and it'll use that template. You can then use is_category() to check which category is currently being used if you want to do custom things depending on the category.

Wordpress breadcrumb with Custom post Type category and children in the category

I'm trying to create custom breadcrumbs on my Wordpress project.
I searched around and found satisfactory examples, like Dimox Breadcrumbs.
The problem is that I have custom post types that are recalled on a page with a parent.
The various CPTs are associated with categories, daughters of other categories.
When I print the breadcrumbs, however, in the CPT I find only the path from Home> Subcategory> CPT but not all the fathers pages I have served to get there.
Do you have any idea how to structure it?
O example ??
Thank you

Wordpress: display posts in menu

There is an issue with wordpress menu, I'll be very grateful if you help me.
See please screenshot.
Menu item "Destinations" is a category. "Elbrus 5642", "Baikal lake", is sub categories for 'Destinations'. And in every sub category I need to show posts for that sub category.
I thought to do it manually in code, e.g. call posts in sub category "Elbrus 5642" with query posts. But that way I need to every time change my code when I add or remove sub categories. Is there any method, which allow to automate this process, e.g. I adding some sub category in menu admin panel, creating some posts for that sub category and they are automatically added in menu?
Thanks for any advice.
Try this plugin, I think it's what you need.

I want to sort my posts in my wordpress theme with two categories

I am creating a wordpress theme, and as a beginner, I am having difficulties. The website will be a products portfolio, but not e commerce. It has a main menu of categories, and another menu on the sidebar with categories. The posts will be sorted by two categories. First of all, by the main category in the header, and then, those posts will be sorted by the other categories in the sidebar. I have no idea how to do this. Tried a lot to think of something, but I can't come up with anything. I hope you can help me how to sort it out.
I had an idea to use TAGS as sidebar categories, but I couldn't get it to work.
Thanks.
Take a look at wp_nav_menu()
The wordpress backend has a menu making system where you can make menus based on pages/posts/categories. These menu items will take you to a page with a list of all the posts existing in those categories.
So:
make your categories
go to the menu maker
create the 1st menu and assign categories
create your 2nd menu and assign categories
Use wp_nav_menu() to pull the specific menu in. The docs that I linked give you a good overview of how to get the menu you want.
You will have to style these menus appropriately.
Good luck and happy coding! If you have any specific questions, feel free to ask and I can expand on it further.

Wordpress: Mingle page with category navigation

I'm having this situation:
In a Wordpress blog I have my main navigation persisting of categories. The navigation is being created with wp_list_categories().
Now I'd like to mingle just one link to a page at a certain position within this navigation built of only categories.
Any ideas how I could accomplish this?
Thanks a lot!
sprain
Use http://codex.wordpress.org/Function_Reference/wp_list_pages and exclude the pages you don't want in the menu:
<php wp_list_pages(title_li&exclude=X;);?>
where 'X' is the id number of the page you want to exclude. Or use a plugin like Exclude Pages.
Do the same with http://codex.wordpress.org/Template_Tags/wp_list_categories to split the category listings and put the page listings within the category menu.
Use Reveal IDs for WP Admin « WordPress Plugins to find page IDs.

Categories