Questions tagged [custom-post-types]
Custom Post Types extend WordPress to support additional content.
10,290
questions
142
votes
9
answers
23k
views
Tips for using WordPress as a CMS? [closed]
I want to use WordPress as a CMS for a reasonably basic site rather than a blog. I have several pages and at the moment, I don't intend to have a "news" page.
While there are ways to make this work, ...
136
votes
8
answers
382k
views
How do test if a post is a custom post type?
I am looking for a way to test if a post is a custom post type. For example, in, say, the sidebar I can put in code like this:
if ( is_single() ) {
// Code here
}
I want code testing for only ...
135
votes
17
answers
105k
views
Adding a Taxonomy Filter to Admin List for a Custom Post Type?
I have created a Custom Post Type called 'listing' and added a Custom Taxonomy called 'businesses'. I would like to add a dropdown list of Businesses to the admin list for the Listings.
Here is what ...
99
votes
7
answers
18k
views
Where to put my code: plugin or functions.php?
Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php?
There are many cases and many debates about that topic, mostly because there are ...
81
votes
14
answers
147k
views
Remove slug from custom post type post URLs
It seems that all web resources based on the subject of removing a custom post type slug ie
yourdomain.com/CPT-SLUG/post-name
are now very outdated solutions often referencing pre WP version 3.5 ...
78
votes
8
answers
52k
views
Custom Post Type Templates from Plugin Folder?
I'd like to offer my custom post type as a Plugin, so that people can use it without touching their theme folder. But custom post type templates -- such as single-movies.php -- reside in the theme ...
75
votes
9
answers
113k
views
How to disable the single view for a custom post type?
Given this custom post type:
register_post_type(
'sample_post_type',
[
'labels' => [
'name' => _x('Sample Posts', 'post type general name'),
'...
69
votes
3
answers
102k
views
Query all posts where a meta key does not exist
I am trying to get a query to retrieve all the posts where a specific meta_key does not exist and then create it.
I am having problems finding those posts as the query I am testing does not seem to ...
66
votes
5
answers
22k
views
Custom post types, taxonomies, and permalinks
This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex).
I have a custom post type product_listing and a custom ...
63
votes
4
answers
73k
views
How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what this post asks, but I need a hierarchical taxonomy. The answer given in ...
59
votes
7
answers
96k
views
How to get all taxonomies of a post type?
How can i get taxonomies of a post type?
If I have a post type event and i need to find out the list of taxonomies that are attached to that post type. How do I find them?
58
votes
8
answers
172k
views
Can I assign a template to a custom post type?
Can I assign a template file to a custom post type?
I have created a custom post type called items, and I would like to assign templates to the items like you can do with pages.
55
votes
3
answers
36k
views
How to sort the admin area of a WordPress custom post type by a custom field
When editing one of my custom post types I want to be able to list all entries by a custom field instead of the date they are published (which, for a custom post type probably isn't relevant). I got a ...
54
votes
8
answers
232k
views
How to create a custom search for custom post type?
I have a search field for the blog posts, but I need an other for a custom post type. How can I create this custom search form with a different search result layout?
50
votes
5
answers
65k
views
Deregister custom post types
Anyone know of a way to deregister custom post types?
Is there an equivalent to register_post_type()?
49
votes
1
answer
75k
views
Permalinks: custom post type -> custom taxonomy -> post
I am having trouble working with WordPress rewrite rules, and could use some help.
I have a custom post type called _shows_.
All shows have a single custom taxonomy category _show-category_. A ...
49
votes
1
answer
44k
views
Enable revisions for custom post type
I have created a custom Post Type, and Registered it.
Can someone help me how to enable revisions to Custom Post type?
49
votes
6
answers
38k
views
Extending the search context in the admin list post screen
I have created a custom post type and have attached some custom fields to it. Now I would like to the search that authors can perform on the custom post list screen (in the admin backend) to also be ...
48
votes
5
answers
248k
views
How do I query a custom post type with a custom taxonomy?
I need to grab any posts using a custom taxonomy.
$args = array(
'post_type' => 'adverts',
'advert_tag' => 'politics' // Doesn't seem to work.
);
query_posts($args);
while ( ...
46
votes
3
answers
67k
views
Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
I currently developing a wordpress plugin that is using two custom post types. What I want to know here: is it possible to add a custom post type menu as another custom post type's sub menu?
45
votes
1
answer
11k
views
Should I use custom post types or a custom database tables for plugin development?
I'm fairly new to writing wordpress plugins, but I've jumped in the deep end already and I want to make sure I'm doing it "right" on my upcoming big project.
I'm going to be heavily extending ...
44
votes
9
answers
115k
views
How to Add Tags to Custom Post Type?
I have a custom post type called portfolio and I'm trying to add the tags taxonomy to it, how do I do this?
44
votes
2
answers
71k
views
Adding a Custom Post Type into the menu screen
I need a way of adding custom post types to the "Appearance-->Menus" option in Wordpress. i have created a custom post type with:
register_post_type('produksjoner',$args);
All examples I find just ...
43
votes
9
answers
119k
views
Add category base to URL in custom post type/taxonomy
I am building an LMS type system in WordPress, controlled by Custom Post types.
The post type is called Lessons (with a slug of courses) and it has one custom taxonomy (category) called courses.
The ...
43
votes
5
answers
33k
views
Pagination not working with custom loop
I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function:
<?php
$sixtydays = date('Y/m/d', ...
42
votes
3
answers
77k
views
How come Featured Image isn't showing up in my Custom Post Type?
I have thumbnail support added with the following in my functions.php
// Add Thumbnail Support
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 140, 140, true );
And I create the ...
41
votes
2
answers
158k
views
Custom Post Type URL Rewriting?
I setup a custom post type for my portfolio projects. The main URL for this is located at /projects/
Now I've also setup my blog posts permalink to /articles/*/ for the permalink structure. This ...
39
votes
12
answers
27k
views
Can the Next/Prev Post links be ordered by menu order or by a meta key?
I have a series of posts that are ordered by a meta_key value. They could also be arranged by menu order, if necessary.
The next/prev post links (generated by next_post_link, previous_post_link, or ...
39
votes
6
answers
59k
views
Include custom taxonomy term in search
I have two custom taxonomies applied to two custom post types. the terms list on the sidebar just fine and will list all posts associated with it. However, if you search one of the terms in specific, ...
38
votes
4
answers
70k
views
Adding 'menu order' column to custom post type admin screen
I want to use the menu order attribute to control ordering for a custom post type that's going to be used for a specific purpose.
It's easy enough to add this to the CPT via supports => array('...
38
votes
4
answers
75k
views
Capabilities and Custom Post Types
I have a custom post type that I'd like to restrict access to certain roles however, I've already added content using the custom post type and now I have to make them restricted. The capability_type ...
38
votes
4
answers
81k
views
what is the correct way to compare dates in a WP query_posts meta_query
I have a query_posts call in a WP template. Through the use of the More Fields Plugin I can give the site admin the ability to create an event (custom post type) and then enter a date which is ...
37
votes
6
answers
30k
views
Use register_post_type() to modify an existing post type
There are lots of situations where a theme or plugin registers a post type and you want to modify it. There is of course add_post_type_support() and remove_post_type_support(), but those don't give ...
35
votes
2
answers
129k
views
Custom Taxonomy specific to a Custom Post type
I want to create a custom taxonomy which behaves similar to the post type as a category behaves to a the default posts (on the grounds of /%category%/%postname%/ permalink structure) so that the posts ...
34
votes
3
answers
26k
views
Renaming Custom Post Types and Taxonomies
I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just ...
34
votes
5
answers
66k
views
Allow member to have access to custom post type only. Permission to only edit their own posts
OK I'm looking for the best way to attack this.
I'm very comfortable with PHP and making custom post types with custom meta fields in WordPress.
Here is what I'm looking at doing:
User registers ...
33
votes
5
answers
133k
views
List all posts in custom post type by taxonomy
Is there a way I can list all posts in a specific custom post type and arrange them by the custom taxonomy term attached to them?
For example;
Taxonmy Term #1
Post Type
Post Type
Post Type
Taxonomy ...
32
votes
4
answers
63k
views
Redeclare/Change Slug of a Plugin's Custom Post Type
Is it possible to redeclare/change the slug of a plugin's existing custom post type (without simply editing the plugin)?
That is, if Plugin X creates a custom post type with the slug /uncookedtoast/, ...
32
votes
7
answers
31k
views
Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?
(Moderators note: Was originally titled "wp_nav_menu Ancestor class without children in navigation structure")
I have a wp_nav_menu in my header which had three pages in it. When I am on one of those ...
32
votes
2
answers
26k
views
Mixing custom post type and taxonomy rewrite structures?
Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that:
The main glossary URL:
http://example.com/...
32
votes
4
answers
71k
views
Advanced search form with filters for custom taxonomies and custom fields
I'd like to build an advanced search form for a specific custom post type, having filters for the custom post types custom fields, custom taxonomies, and for a separate custom post types properties (...
31
votes
2
answers
34k
views
Enable Gutenberg on custom post type
I have this custom post type:
function create_posttype() {
register_post_type( 'companies',
array(
'labels' => array(
'name' => __( 'شرکتهای عضو' ),
'singular_name' =...
31
votes
8
answers
44k
views
Resolve a custom post type name vs. page permalink conflict (same slug)
I have a custom post type called "visningshus", and also a Page with that slug. This is as it should (must) be.
Currently, "http://my-site.com/visningshus" lists all posts of that type. I want to ...
30
votes
8
answers
148k
views
How to Add Custom Fields to a Custom Post Type?
Ok, so I have registered a few custom post types and a few taxonomies. Now, for the life of me, I cannot figure out the code I need to add a Custom Field to my Custom Post Type.
I need a drop down ...
30
votes
3
answers
112k
views
Hook for post and page load
I need to run a function when a particular post or page is loaded. Is there any hook that lets me check whether a post is being displayed during page load ?
29
votes
2
answers
42k
views
Get custom post_type's archive URL
It seems like stupid question. But, I can't figure it out :(.
I need to display button at home that goes to custom post_type's archive URL (archive-{post_type}.php). How do I do that?
29
votes
3
answers
24k
views
Can multiple custom post types share a custom taxonomy?
I'm considering rebuilding a drupal site in wordpress and am still wrapping my head around the differences between the systems - particularly cck/fields and custom content types and the different ways ...
28
votes
5
answers
59k
views
Custom Post Type pages are "not found"
I've created two new Custom Post types using code that I've used successfully on other projects without issue. The first is called top_charts, the other case_studies, and both appear correctly in the ...
28
votes
5
answers
11k
views
Is there a way to get N number of WYSIWYG editors in a custom post type?
Is there way to have multiple WYSIWYG editors for a custom post type? For example, if I had a 2 column layout I wanted to have one editor for one column and another editor for the other.
27
votes
4
answers
54k
views
Custom post type single page returns 404 error
I have a custom post type called slide. It has content and some custom fields. I want WP to show the single.php theme or single-slide.php theme when the user clicks the slide single page link. the ...