Questions tagged [custom-post-types]

Custom Post Types extend WordPress to support additional content.

Filter by
Sorted by
Tagged with
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, ...
139 votes
8 answers
392k 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 ...
Adam Thompson's user avatar
139 votes
17 answers
106k 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 ...
Taras Mankovski's user avatar
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 ...
fuxia's user avatar
  • 107k
82 votes
15 answers
155k 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 ...
Ben Racicot's user avatar
  • 1,406
80 votes
8 answers
53k 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 ...
nathanbweb's user avatar
75 votes
9 answers
119k 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'), '...
passatgt's user avatar
  • 3,338
69 votes
3 answers
105k 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 ...
JordanBel's user avatar
  • 837
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 ...
RodeoRamsey's user avatar
  • 1,707
63 votes
4 answers
74k 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 ...
Jeff's user avatar
  • 2,535
60 votes
8 answers
179k 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.
Odyss3us's user avatar
  • 885
59 votes
7 answers
100k 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?
Sisir's user avatar
  • 7,782
55 votes
3 answers
37k 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 ...
tooshel's user avatar
  • 1,427
54 votes
8 answers
237k 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?
robert's user avatar
  • 557
51 votes
1 answer
46k 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?
Bhanu Prakash Ryaga's user avatar
51 votes
6 answers
39k 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 ...
Stefano's user avatar
  • 1,251
50 votes
5 answers
66k views

Deregister custom post types

Anyone know of a way to deregister custom post types? Is there an equivalent to register_post_type()?
anu's user avatar
  • 9,552
49 votes
5 answers
258k 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 ( ...
Stephen's user avatar
  • 593
49 votes
1 answer
76k 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 ...
Paul T's user avatar
  • 667
47 votes
1 answer
12k 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 ...
Jeff's user avatar
  • 2,535
46 votes
3 answers
68k 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?
Ari's user avatar
  • 1,177
45 votes
9 answers
119k 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?
Joe Bobby's user avatar
  • 739
44 votes
2 answers
73k 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 ...
Ole Henrik Skogstrøm's user avatar
43 votes
9 answers
123k 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 ...
Zach Russell's user avatar
  • 1,043
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', ...
nurain's user avatar
  • 557
42 votes
3 answers
78k 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 ...
Ryan's user avatar
  • 686
41 votes
2 answers
163k 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 ...
Jake's user avatar
  • 540
39 votes
13 answers
28k 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 ...
Jodi Warren's user avatar
39 votes
6 answers
60k 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, ...
Norcross's user avatar
  • 3,077
38 votes
6 answers
31k 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 ...
mrwweb's user avatar
  • 10.2k
38 votes
4 answers
72k 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('...
anu's user avatar
  • 9,552
38 votes
4 answers
77k 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 ...
erichmond's user avatar
  • 1,313
38 votes
4 answers
84k 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 ...
tjsherrill's user avatar
36 votes
2 answers
133k 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 ...
Saurabh Goel's user avatar
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 ...
Derek Perkins's user avatar
34 votes
5 answers
67k 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 ...
Scott's user avatar
  • 12.2k
33 votes
5 answers
135k 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 ...
Dean Elliott's user avatar
  • 1,185
32 votes
2 answers
36k 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' =...
ehsan's user avatar
  • 453
32 votes
8 answers
152k 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 ...
xLRDxREVENGEx's user avatar
32 votes
8 answers
45k 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 ...
Henrik Erlandsson's user avatar
32 votes
4 answers
66k 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/, ...
Edbury's user avatar
  • 445
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 ...
Gavin's user avatar
  • 537
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/...
maryisdead's user avatar
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 (...
pax's user avatar
  • 633
30 votes
3 answers
116k 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 ?
Poulomi Nag's user avatar
30 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?
ariefbayu's user avatar
  • 1,461
29 votes
5 answers
61k 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 ...
Django Reinhardt's user avatar
29 votes
3 answers
25k 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 ...
ChadD's user avatar
  • 393
28 votes
4 answers
56k 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 ...
Ramin Omrani's user avatar
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.
Paul Sheldrake's user avatar

1
2 3 4 5
207