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
- Display current category title on category page
- Inject post (from specific category) between posts in Loop
- Allow authors to post only in categories they create in WordPress
- List all categories but exclude current post category on single post page
- Categories Template Assistance
- Edit category output
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Custom Loop through category menu to include sub categories
- Different background-image by category
- Get posts with at least one category in common with current post?
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- Custom category code not showing all posts
- Missing sidebar parameter “fix” – before_content
- hover image appears below placeholder instead of overlayed
- get current product name in functions.php
- Filter Select results based on selection
- Dynamic Sidebars & Echo
- What is an equivalent of single_cat_title for getting the slug of the category?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Setting default category base on theme activation
- Hide subcategories (widget)
- Let Users Choose Post Categories
- How to show only subcategories in parent category not parent category?
- Generate sidebar depending on height of post
- if statement with is_active_sidebar()
- Display most popular posts of category
- get taxonomy thumbnail and use it as a variable in code
- Sidebar not appearing in footer, but it appears everywhere else!
- Get latest post from all categories except one
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- 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
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Why the dynamic_sidebar() call is putted into an ul tag?
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- Add a select-option to the default widgets
- Finding and removing duplicates within WP Arrays
- Compare current post Category in select menu
- Get the list of post categories
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- 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
- How to show categories and date on posts
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Retrieve the whole widget sidebar and pass it inside an html
- Child-Theme Category View with modified permalinks (%category% removed)
- Category Page Displaying all Pages
- How to move a post from one category to another
- How to enable HTML tags in category description without breaking the category page
- Force Sidebar on Full Width page
- Trying to show the category of a post in the post display
- Link to index.php from home.php?
- Hide a specific category title from displaying on site
- Return to the beginning of the results of a for loop
- Blog Image and Title in Right Sidebar
- Populate Posts based on category selected using AJAX that means without page refresh
- random woocommerce categories are not showing when count enabled?
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- How to Retrieve All Category Images on Front-End
- Displaying 3 Category Posts differently
- Code works on page-example.php by not category-example.php
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- get_category display only 1
- Showing the project type in HREF
- Front end post submissions do not get submitted in the category
- if conditional in sidebar plugin Password content shortcode
- Make an array listing custom taxonomy
- Get category id for a custom category and display it in a class
- Trying to exclude posts from a category on the home page
- Is there a way to randomize and connect a background and header image?
- wp_get_archive for category returning different URLs on different but similar sites
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- dynamically filter by category via sub-menu
- Listing current pages subp page in list items in the sidebar
- How to display different widgets on specific pages, hide from other pages
- Get unique post in parent category
- Sidebar doesnt get updated?
- Incomplete term slugs output from a foreach loop with get_the_terms
- How to insert the first letter in uppercase [closed]
- How to limit number of posts in the certain category and exclude the oldest post automatically