Questions tagged [custom-post-types]
Custom Post Types extend WordPress to support additional content.
1,042
questions
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 ...
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 ...
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', ...
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 ...
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 ...
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, ...
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 ...
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 ...
24
votes
7
answers
19k
views
Change the text on the Publish button
Is there a way to change the text of the publish button on a custom post type to say some different? For example, Save instead of Publish. And also remove the draft button?
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 ...
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, ...
6
votes
1
answer
18k
views
Updating custom post meta with ajax
This AJAX function gets called on a click:
$.ajax({
url: 'site/ajax.php',
data: {id: $('section#single article input:last-of-type').attr('value'), cote: 'like'}
})....
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/...
21
votes
3
answers
7k
views
Implementing a CrunchBase.com Clone using WordPress?
I wish to create something like CrunchBase.com
with WordPress.org (So to have one website that is a "database", and another one, which is a blog, that connects to it).
Is it possible? and how?
...
17
votes
1
answer
35k
views
Rewriting a custom-post-type permalink with taxonomy term?
I'm trying to rewrite my url for a custom_post_type named wr_events with one of its custom_taxonomy terms from event_type
add_action('init', 'wr_events');
function wr_events() {
...
13
votes
4
answers
18k
views
don't publish custom post type post if a meta data field isn't valid
I have a custom post type (CPT) called event. I have a meta box for the type with several fields. I would like to validate some fields before publishing an event. For example, if an event's date is ...
8
votes
1
answer
2k
views
CPT Template Not Showing - Getting 404
I'm developing a Custom Post Type plugin, which works fine in dev. Now that I've moved it to production, I'm getting a 404 when I try to display the template for the CPT.
So, two questions:
1- Is ...
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'),
'...
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 ...
24
votes
9
answers
23k
views
Remove taxonomy slug from a custom hierarchical taxonomy permalink
I created a 'forum' taxonomy, using these rules:
register_taxonomy(
'forum',
array('topic'),
array(
'public' => true,
'name' => _a('Forums'),
'singular_name' => _a('Forum'),...
21
votes
5
answers
25k
views
Prevent post from being published if custom fields not filled
I have a custom post type Event that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen).
I would like to make sure that an Event cannot get published (or ...
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 ...
19
votes
5
answers
19k
views
How to use a custom post type archive as front page?
I'd like to use a custom post type archive as a site's front page, so that
http://the_site.com/
is a custom post type archive displayed according to my archive-{post-type}.php file.
Ideally I ...
17
votes
3
answers
28k
views
Add extra parameters after permalink?
How can I add extra parameters after a permalink, specifically if I'm using a custom post type?
For example, let's say http://mysite/album/record-name was the permalink. How can I make http://mysite/...
16
votes
2
answers
31k
views
Combining queries with different arguments per post type
I am building a section on a site where I am merging two different post types into one loop, and then displaying them randomly. The problem is, I'm having a hard time finding a way to limit the amount ...
13
votes
2
answers
61k
views
Creating a search form for custom fields
I have built a theme for a car dealership. Each car is a custom post type ("vehicle"), and has about 12 custom fields with things such as Make, Model, Mileage, Fuel Type etc. etc.
So basically on the ...
9
votes
4
answers
3k
views
Custom post type - posts list - white screen of death
i am getting a weird error - white screen in the list of posts
for a specific Custom post type (just for that one)
tried deactivating all the plugins
tried checking for error (debugging = true)
...
1
vote
1
answer
3k
views
How to check if last uri segment is a custom post type or taxonomy term?
After following Jeffs suggestion on this thread to create nested parent and child taxonomy terms within a permalink like...
url.com/custom-post-type/taxonomy-parent/taxonomy-child/cpt-entry
It ...
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 ...
22
votes
7
answers
62k
views
Display all posts in a custom post type, grouped by a custom taxonomy
I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called member and my custom taxonomy is called member_groups.
I want to list all the members ...
17
votes
3
answers
10k
views
Custom bulk_action
I would like to add a custom bulk action to a custom post type. I came across the filter bulk_actions-screenid, which according to its documentation, would do exactly as I wish. However, after about ...
15
votes
3
answers
15k
views
Have different number of posts on first page
I need to have a different amount of posts per page on the first page that on the other pages.
For example, this is what I need
Total posts: 6
First page: showing 3 posts
Following page: showing 2 ...
3
votes
2
answers
5k
views
Show related posts on single page by custom taxonomy on custom post
I am trying to build a villa rentals website. To achieve that, I have created two custom post types. The one is named "villa" and is used to show the villas for rent, and the other one is named "...
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?
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 ...
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 ...
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 ...
23
votes
4
answers
31k
views
Adding categories to custom post type in permalink
I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink.
The problem is I have 340 existing categories which I would like to continue ...
12
votes
3
answers
35k
views
How to change permalink structure for custom post type and it's taxonomies?
This is a repost of an earlier question I had, but I like to go into more details now to be able to fully solve this.
So again, with (normal) posts changing the permalink is as easy as going to ...
7
votes
1
answer
2k
views
Truncating custom fields
I'm using custom fields to pull a secondary description. I'd like to use the built in WordPress truncate but can't seem to figure it out.
$desc = get_post_meta($post->ID, "youtube-desc", true);
...
5
votes
1
answer
2k
views
How to show Y number of custom posts after every X normal posts?
I have a loop within a loop.
I figured out how to show all or X number of custom posts after Y number of normal posts.
I also figured out how to show 1 custom post after every Y normal posts.
How do I ...
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 ...
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 ...
22
votes
5
answers
8k
views
How do you use a CPT as the default home page?
I have a client who's site will be making heavy use of custom post types to configure their site. But I'm between a rock and a hard place for their requested home page.
In reality, the home page ...
16
votes
1
answer
13k
views
Saving Taxonomy Terms
I have an interesting problem which I hope someone can quickly answer.
I have created my own metabox which, based on "MY METABOX CODE" (list below) is correctly displaying a dropdown list of all my ...
8
votes
1
answer
9k
views
Sort search results by post type
I need to sort my search results by custom post type. the problem: the order is custom.
I do have 5 different post types and i got the order like so:
artist
artwork
page
post
publication
I'd like ...
2
votes
1
answer
5k
views
Adding Categories across posts, and custom post types
I currently have a list of categories that go with my 'posts'
I want the same categories to go with my custom post types 'services' and 'work'
The following code, adds the tags and categories to the ...
1
vote
1
answer
2k
views
WordPress custom post type category pagination 404 Error
This problem is giving me a headache and I was wondering if anyone knew how to fix it.
I have a custom post type called Review. Here is how it is defined:
function codex_custom_init() {
$args =...
0
votes
1
answer
698
views
Pass parameter to custom post type single while keeping clean url
I'm working on passing a get parameter to a single custom post type in a clean url. So for instance there would be the custom post type 'services' which would have the single post 'gardening'.
/...
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.