Support » Plugin: Custom Content Type Manager » get post's category

Viewing 1 replies (of 1 total)
  • Plugin Contributor fireproofsocks


    No, this isn’t possible via the shortcode. You’d have to do it using the PHP equivalent in your template file and use WP’s various functions for getting category and tag info. The reason is that it’s not a 1:1 relationship between a post and a category. A post can be placed into MANY categories, so you’re not longer dealing with a simple string, you’re dealing with a list (i.e. an array). So simple [+placeholders+] are not enough: you’d have to describe your rules and preferences for how to sort and join the items in that array — that’s much better suited to PHP.

    Secondly, although you can filter on taxonomy data using Summarize Posts (e.g. select all posts in category X), the query does not return this data. Summarize Posts deals primarily with data inherent in the post (i.e. the post’s regular and custom fields), not with the ancillary data that classifies posts (i.e. tags and categories). This is a worthy feature request, but the overhead when joining on an unknown number of virtual tables (i.e. categories, tags, custom taxonomies) makes its potential integration problematic.

    To solve your problem here, you could create a dedicated template in your theme directory (copy your current page template), tell your page to use this template, and then add the necessary PHP into that template file.

    Or, another alternative may be to use a simple custom field (e.g. a dropdown field) instead of a category and treat that as your “category”. Since a dropdown field stores a simple string, it WOULD work with the placeholder scenario you described. You wouldn’t get the built-in WP searching and widget support that a full-blown taxonomy would get, but it would solve your immediate problem.

Viewing 1 replies (of 1 total)
  • The topic ‘get post's category’ is closed to new replies.