get_sidebar()
accepts a parameter $name
. Then will look for a file sidebar-{$name}.php
.
So what you can do is:
get_sidebar( get_post_type() ); // search for sidebar-post.php or sidebar-page.php
or:
if ( in_category( array( 'featured-listing', 'listing-post' ) ) )
get_sidebar( 'listing' ); // sidebar-listing.php
else
get_sidebar();
Related Posts:
- Removing sidebar on category pages
- How to list categories by page id in wordpress
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- selected option if current category is the value
- get_template_part based upon post’s category
- Child page menu in sidebar
- Theme developement – incative sidebars
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- How to show only subcategories in parent category not parent category?
- Generate sidebar depending on height of post
- how to show only specific category for a template
- Dilemma of Populating all the categories in a drop down list
- if statement with is_active_sidebar()
- Display most popular posts of category
- How to determine if the sidebar is empty? Or not active?
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to array only one key from another array
- Sidebar not appearing in footer, but it appears everywhere else!
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Get all categories post is not in
- Get latest post from all categories except one
- Displaying posts based on category
- Styling the second sidebar
- How do I remove a category from a wordpress loop>
- Get categories names as an array to use it in theme settings
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to get the last category name of a child category?
- How to remove sidebar primary widget on Mobile on category page [closed]
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- How to get category name or ID by post?
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- How to separate categories with commas?
- How to hide posts of a specific custom category in WordPress?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- How to change logo by category
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- random display categories – change url
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Alphabetically Ordered Category in WordPress
- Output category list inside array
- Do not duplicate posts with multiple categories in multiple loops
- Loading Posts & Category with Ajax
- How to get current category
- WooCommerce: Display product categories to make IF statement
- Trying To Get Child Categories To Show, Issue With foreach Loop
- Define category ID using get_post_meta
- Why the dynamic_sidebar() call is putted into an ul tag?
- Show parent categories of the current category
- is user member of a group, show them categories [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- How to check if a category has a parent and child categories?
- WordPress custom taxonomy
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Add a select-option to the default widgets
- go to home page when i select default in select-box
- Finding and removing duplicates within WP Arrays
- Display Custom Field in Sidebar if Value is Present
- Adding wp_list_categories to a specific div that was appended using jQuery
- Stuck with sidebar registering
- Using multiple variables to assign categories to an array
- Compare current post Category in select menu
- Get category id when SEO URL is turned on
- Don’t display a sidebar widget when on a specific page
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Get the list of post categories
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- Display Sibling WooCommerce Product Categories on Archive Page
- Pagination at category doesnt work with same name of page
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Counting number of posts in multiple (sub)categories using shortcode
- Wrong Number of Products When Hiding Subcategory Products From Showing In Parent Category
- How to show categories and date on posts
- display the months of a specific category
- I need to display posts in subcategory beside posts in main category
- Add Custom Category Description When Empty
- Order category posts by last word of custom field