The good basic technique to go from specifics to more general context is to look at the calls you already have.
You already call single_cat_title()
, which somehow knows current category, right? If you look inside you will see it passes call to single_term_title()
. And how does that one in turn knows?
$term = get_queried_object();
So there is your way to get to the full category object when on category archive page.
Still it’s a little unclear from your code example what do you want to do with “all” posts. If you want to display all posts, in a context that already does appropriate query, you should be properly modifying main query via pre_get_post
or such. It shouldn’t be done in template for performance and compatibility reasons.
Related Posts:
- Custom Post Types on Category Pages
- Setting a custom sub-path for blog without using pages?
- Setting Default Category for Custom Post Type Upon Autosave
- Creating “static” taxonomies to choose from, inside custom post type?
- Add Content to Page without shortcodes
- Loading custom page template via plugin
- How to quickly switch custom post type singular template?
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- Assign Page Template Within A Custom Post Type
- Template tags to display custom post type posts in category template?
- Restrict categories to a custom post type
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Create second custom 404 page for selected post type
- is_page_template not working as expected
- Help with CPT template pagination
- Weird problem happening with custom taxonmy when creating/updating posts
- Create Template for Custom Post Type same like for Page
- Group posts by custom post type
- Custom Page that comes with preloaded content for the user
- 2 Templates 1 custom post type according url
- Hide parent categories when clicked, and show it’s childs
- Adding the_content() in custom template email
- Filter widget outputs
- Migrating a taxonomy’s tags to the native category
- How do you create a custom template to display a category with an image and related posts below?
- Custom templates for a specific category
- Categorise Custom Post Types
- Custom post type pages return 404 page?
- Custom URL redirect in WP
- How can I have different content for different countries?
- Creating Sections for Post Types
- Custom post types with categories in template
- Displaying a list of Contacts
- Custom permalink structure for remote content pages
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Get terms for a specfic post from multiple taxonomies in custom post type
- Archive Template being used instead of Category Template for Custom Post Type
- cannot achieve this structure (custom posts VS categories VS ??)
- How can I allow users to edit text that will be displayed on a custom post type archive page?
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Multiple categories assigned to a single product breaking the breadcrumb
- A certain theme is forcing it’s singular post layout
- Custom post type defaults to index.php for archive page
- Set a Default CPT taxonomy by taxonomy id
- Displaying posts inside table having issues
- Automatic Set Category For A Custom Post Type
- Question on templates
- Custom post type option page template
- How can I load Template file from wordpress plugin
- How can I find out what template is my custom post type using?
- Help with Travel Guide Setup
- Loading a template for a URL pattern
- Custom Homepage As Single Page or Custom Post Type?
- Display all post types together
- Using get_terms() as shortcode attribute
- Having some trouble properly displaying Custom Post Types in templates
- Using custom post types within a section of a template
- Custom Post Type order Title ASC
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Custom Post Type Template Based on Page Slug?
- How to make a template for a specific post of a custom post type?
- Choose custom post type template by category
- using a template for more then 1 page
- Troubles with making a custom template for posts
- Setting posts per page in query_posts
- How to insert content from another Custom Post type into Post?
- For custom templates, is it better to use `template_include` or `type_template`?
- Get rewrite slug of custom post type in template
- Get Post Primary Category
- How to show the archive / post type description on Single templates
- Placeholder in HTML editor text area?
- Add category in post type dynamically
- Filter categories of posts with checkboxes
- Deleting Custom Post type data using mySQL command
- Pagination is not working on single-{slug}.php but works fine on page-{slug}.php
- How can I create a custom meta box to add an mp4 video to a page?
- Use post as category
- How to get the post type from a category id?
- How to add custom post types to normal category pages
- Plugin templates in which directory
- Pagination on category page with custom post types
- Insert HTML inside link in a walker
- Delete link on single-custom.php with redirection
- How to structure a site with product variations pages?
- Custom Post Types and independent Categories – complex Taxonomy
- Call custom post type by category
- Add category attribute to custom shortcode
- CPT: if more than X images are in post, use pagination
- Use regular category with custom post types
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Getting rid of /my_custom_post_type/ in the single view URL
- Should I use custom taxonomy or custom post type
- Custom post type menu missing after 3.0b2 -> 3.1.2 upgrade
- Custom Post Type – List all attachments on Edit Screen
- Creating a Page to View the List of Posts for a Custom Post Type?
- How to detect filter in URL in Category page?
- How to load a template without it being assigned to a page/post?
- Set menu active state for custom posttype and category, given custom taxonomy term
- Using wordpress template tags within an array