Wordpress custom post type single as parent for archive - wordpress

For a new project i like to have a single of my custom post type 'teams' as a parent of a custom post type archive and singles 'report' so i would like to have "Teams/{team-name}/reports/{report}".
I've tried to create a custom slug with the 'save_post' action/hook but it didn't work. On the editor page of a report i do have a custom field to select a team but ik look likes this is not usable on the save_post function yet. Does anyone have a suggestion?

Based on what you've indicated in the comments above, I'd be inclined to do away with the http://{website}/Teams/{team-name}/reports/{report} pretty URL and have a more simple http://{website}/Teams/{team-name} URL. It will be more intuitive to remember for visitors.
In the single for the Team CPT, you would include a loop for the archive type associated with the particular team. You COULD create a hierarchy of CPT where Reports are a child of Team but you will be heading down a slippery road that the parent/child relationship creates a lot of overhang when the types become populated.
There are a lot of threads about this, this is just one guys report on what happens when there are many hierarchical CPTs: https://wordpress.org/support/topic/hierarchical-post-type-w-heavy-data-set-fails-lots-of-custom-fields?replies=1
If you could create them as individual (non related) CPTs, and have a common category or taxonomy you could then in the single.php of your CPT include a loop for the archive, or alternatively in the archive for the reports, you could include a team header section. You could link the two on that taxonomy.
On a slightly different tact, if it is just some basic info you want to have about the team on the archive page, you could include a description in the reports taxonomy and depending on your theme (or custom coding) you could display that at the top of the reports archive.

Related

Multiple Part Wordpress Post

I want to create a blog with stories. Where each story may have multiple chapters. I want to publish chapter wise. Is there any plugin to handle this in WordPress?
You could use core functionalities like categories or even tags as the root of your stories and publish each chapter as new post in this category or with the assigned tag.
Then you could display your stories on an archive page with a custom loop, depending on how/what you want to display (eg. title, content, excerpt...).
You can do this with the Custom Post Type. Here is the plugin you may use.
https://wordpress.org/plugins/custom-post-type-ui/
You can set your Stories as Custom post type and Chapter as a Custom taxonomy. You can also call them on any page, sort them as your chapter vise, you can also show limited chapters stories, etc. with the WP_Query.
https://developer.wordpress.org/reference/classes/wp_query/

WordPress Custom Post Logic

I'm a newbie here, but I've been trying to understand and research this for the past couple of days to no avail.
I created a custom post type (video) with a taxonomy associated with it (industries). The taxonomy "industries" has multiple categories (I'm not sure if in this case they are called terms rather than categories; correct me if I'm wrong!) such as IT, Construction, etc. For arguments sake, let's say under the category IT there is a single post named Web Developer.
First question: With the logic above, how would I manage to reach the single post (web developer) with the URL: .../video/IT/web developer?
Second question: If on the video page I would like to display all posts in all categories, what template page should I create? Is it archive-video.php? The same question goes for the category (IT in this case): Which template page should I create in order to display all posts under a specific category?
I'll answer your second question first:
Yes, the template you should use for displaying all the custom post types would be the CPT archive, so archive-video.php sounds right.
For the categories (the exact way to say it would be "taxonomy terms" indeed), you would use taxonomy-{taxonomy}.php or even taxonomy-{taxonomy}-{term}.php if you need to get more specific.
About your first question, there is currently no core functionality to use custom taxonomies in your permalinks, but this might help you.

Wordpress: Assign Blog Posts to Locations for Location-Based Blog Archive Landing Pages

I need to make it easy for Wordpress blog posts to be assigned to specific locations of a business so they can be grouped into their own collections for display on blog article archive landing pages for each location. Some articles my be relevant to multiple locations as well.
I cannot use categories for this. Ideally I want something similar to categories, but we're already using 70 other categories on this site for actual post categories. Category blog post archive landing pages will have a wildly different look and feel than the location based landing pages, so categories will not work for this.
I need an alternate approach flexible enough to where it's as easy to assign posts to locations as it is to click a check box for assigning categories to a post, and robust enough that I can indeed create those location-based landing pages that can filter out entries from all other locations.
I'll also need to filter posts by category within a location's entries, if possible.
How can I pull this off successfully?
My initial thought on this would be to use a custom Taxonomy for your blog posts. They function just like Categories (can have archive pages, posts can have multiple taxonomies assigned, etc). We generally use the plugin, Types - Complete Solution for Custom Fields and Types, to manage our Taxonomies. (wordpress.org/plugins/types) If you are already familiar with working with Categories and their archive pages, it's not much different to work with Taxonomies.
The interface works with a checkbox list just like Categories. You set a name, slug, and optional description in the admin side of things. You then assign any number of Taxonomy terms to an individual post. Taxonomies, just like Categories, are just alternate ways to categorize posts. You can use the built-in archive file formats (taxonomy-{taxonomy_name}.php or taxonomy-{taxonomy_name}-{taxonomy_term_slug}.php) to built your template files. So if you had a taxonomy with the slug "locations" and your looking at posts with the term "nort_pole" you could make taxonomy-locations.php or taxonomy-locations-north_pole.php to serve as your templates for the archive pages. You can also use custom wp_queries to sort/filter your posts based on what taxonomy terms are applied to the posts you're looking for.
Here is a good article in the Wordpress Codex that talks about Taxonomies. http://codex.wordpress.org/Taxonomies

Wordpress: Using Custom Post Type for image list of Product

I have a Wordpress-blog with gift ideas where I write text based articles. I recently discovered Custom Post types which I believe is the solution to an feature I want to create.
What I want:
Be able to tag each custom post using the normal "Categories" and "Tags".
Create a 3x3 matrix with product images (custom posts) to be shown on top of each Category-view or Tag-view (followed by the typical article list in the category or tag).
Example:
Lets say I have a category "Gifts for mom" and tags "Pink", "Cheap"
In the category "Gifts for mom" I have 10 text articles (normal posts) discussing the difficulties of buying gifts for your mom
I create nine custom posts, each is a specific gift (e.g. A pink hairbrush). I want to place them in the Category "Gifts for mom" and tag them with "Pink".
When I view myrandomgiftblogname.com/category/gifts-for-mom I want to be able to get a view:
Gifts for mom
Product Product Product
Product Product Product
Product Product Product
Articles:
- This awesome article
- That awesome article
- Etc
I assume this is possible but don't really know where to begin. Could you point me in the right direction? Which Plugins do I need? Do I need to do any programming myself (or just plugin configuration)? Is this even possible?
The description is a bit broad, hence a bit broad answer.
Two things are needed:
1) A plugin to create the Custom Post Type.
It is considered best practice to let CPT's in Plugin territory. So you can swap designs and preserve your CPT functionality. In reality, you are asking for future problems letting this be handled by the theme.
Create your own plugin, which would contain a register_post_type and any extra configs.
Use an existent plugin, like Custom Content Type Manager.
Its Custom Fields features are quite handy as well.
Allows users to create custom content types (also known as post types) and standardized custom fields for each, including dropdowns, checkboxes, and images.
2) Learn how to use and customize WordPress Templates
http://codex.wordpress.org/Templates
Templates are the files which control how your WordPress site will be displayed on the Web. These files draw information from your WordPress MySQL database and generate the HTML code which is sent to the web browser. Through its powerful Theme system, WordPress allows you to define as few or as many Templates as you like all under one Theme. Each of these Template files can be configured for use under specific situations.
You can try the following:
Add a new Page for each category with the exact same name as the category.
In the Images menu attach to each of those pages the images you want.
In your script query for a page with a name identical to the current category, and pull all of its attachments

Using WordPress Content Item as a Taxonomy

Is there a way (or a plugin) to make a given content type in WordPress (i.e. posts, pages, media, custom post types) act as a taxonomy? I basically want to setup a one-to-many relationship of one item in a given post type to many items of a different type.
So basically, I have a custom post type, call it Authors. I want to use a Post Type rather than a taxonomy because I need a lot more meta data than a taxonomy allows.
I then have another custom post type called Books.
Is there a way to put a box similar to the Categories or Tags metaboxes on the Author write page that display a list of all the books. I can then choose from a list of all the books, thus creating a relationship.
If this doesn't already exist, I guess I'll write a plugin for it. I thought I'd give this a try first, just in case.
Have you considered adding new meta fields to a custom taxonomy? Unfortunately, you ned to either create a new table for the meta storage or use wp_options, but it does work and is relatively future-friendly. Remember to start your option names with an underscore, though.
http://www.strangework.com/2010/07/01/how-to-save-taxonomy-meta-data-as-an-options-array-in-wordpress/

Resources