Questions tagged [post-type]
The post-type tag has no usage guidance.
200
questions
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 ...
16
votes
3
answers
20k
views
How do i know the current post type when on post.php in admin?
Im trying to do something with an admin_init hook if - and only if - the user is editing a post (post.php) with post type "event". My problem is that, even though wordpress points to a global variable ...
10
votes
4
answers
31k
views
Custom post type pagination 404 fix?
Been trying to get this working all day but haven't had any luck...
I have a custom post type called 'news' and an archive template (archive-news.php), here I'd like to show 2 posts with pagination, ...
10
votes
1
answer
4k
views
What are custom_css and customize_changeset used for?
A fresh wordpress install has the following post types:
Post (Post Type: 'post')
Page (Post Type: 'page')
Attachment (Post Type: 'attachment')
Revision (Post Type: 'revision')
Navigation Menu (Post ...
8
votes
3
answers
480
views
Per Post Type Revision Numbers
In wp-config.php you're able to change how WordPress deals with post revisions. Specifically you're able to turn them off or specify a max number of revisions.
I'd like to be able to set a max number ...
7
votes
2
answers
3k
views
Are captions stored anywhere?
In regards to my previous question about shortcode captions, it doesn't appear to me that the actual text of a caption is stored anywhere other than in the post content within the shortcode itself.
I ...
6
votes
4
answers
20k
views
Get list of all registered post types slugs
I'd like to get a list (array) of all the post types I registered.
Precisely I would like to retrieve their slugs.
Could someone help me?
thanks!
5
votes
2
answers
2k
views
WP_Query ignores post_type in category view
I have following query to select posts by my custom post-type. This works fine while being on the frontpage (the snippet is included in the sidebar). As soon it gets executed on a category page the ...
4
votes
4
answers
4k
views
Disable block from editor based on post type
I've made a Gutenberg block which is only appropriate to show on hierarchical post types, so I want to disable it from the block inserter for non-hierarchical post types.
I thought about how to ...
4
votes
2
answers
2k
views
How do I create a link that will always show the latest post?
If I want to create a link that will always show the latest post how can i do that?
Lets say I have three post types and there are three links with posts names (like a nav list) to those post types. ...
4
votes
2
answers
931
views
How to get only posts, pages and custom post types in WordPress
I am trying to get Pages, Posts and Custom Post Types In WordPress website but it is showing some other things in the list.
My Code:
<?php $types = get_post_types( ['public' => true ], '...
4
votes
3
answers
9k
views
Overwrite rewrite-slug of built in post-type 'post'
I need to change the rewrite-slug of the built in post-type 'post' to 'example.com/magazine/news/any-nice-news-item'.
When I re-register the post-type 'post' and set the rewrite-slug to 'magazine/...
4
votes
1
answer
226
views
Exclude top-level pages from search results
With the following code I can exclude all posts and pages that are top-level, but I would like to apply this only to pages, not to posts (but I still want all posts in the results):
function ...
4
votes
2
answers
3k
views
How to get attachments for a specific post type?
I have this page where I am showing all post's attachments.
This is the code:
<?php
$args = array(
'post_type' => 'attachment',
'post_status' => 'published',
'posts_per_page' =&...
3
votes
2
answers
23k
views
How do I implement custom fields without using any plugins?
I am trying to create a member directory and using a custom post type members. I am familiar on how to use the ACF plugin but is there any methods on how to associate a custom field for a specific ...
3
votes
2
answers
5k
views
Get All IDs Of A Post Type Using WP_Query
I am trying to get a list of a custom post type's IDs using WP_Query, but it is returning undesired result, which is a memory leak and stuck browser.
Here is the code I use:
$the_query = new ...
3
votes
2
answers
4k
views
List All Post Types in Admin view using /wp-admin/edit.php?post_type=
I have successfully created a custom post type. I'm trying to construct a URL which points to a combined listing of posts of all post types on the view all posts page in the admin view.
I can ...
3
votes
1
answer
956
views
custom post types don't appear in RSS
I created custom post-types in my site but these posts are not shown in the RSS. Only the regular posts appear there.
What could be preventing them from showing up there
3
votes
2
answers
397
views
What is the difference between "post" and "page" in WordPress?
I understood that both post and page are coming under the same post-type but I noticed that both are showing the almost same layout and behavior. could anyone explain in short words?
Advance Thanks
3
votes
2
answers
522
views
Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
I am building a theme in which I have a post type, which will have an archive in a grid layout. You're probably thinking, "Just use the CPT archive!" Well, there are some cons to that method that I'd ...
3
votes
1
answer
1k
views
Search through custom post type and custom fields takes 5 minutes
I got strange problem and I'm stuck. I have custom post type with around 15 custom fields.
I moved data from old db (not WP) by using wp_insert_post ,update_post_meta and wp_set_object_terms.
All ...
3
votes
0
answers
106
views
How can I filter block registration based on post-type? (Block alignment settings)
I want to disable the .alignwide and .alignfull block alignment options (remove them from the editor UI) on the 'post' post-type only.
I have tried using this block registration filter to modify the '...
3
votes
0
answers
1k
views
Show all parents and children in custom post type in right order
I would like to show all posts from a custom post type on one page with the ordering exactly like in the backend. I get the right ordering with wp_list_pages, but of course without the content.
...
2
votes
1
answer
3k
views
Including post_type = 'wiki' in author archives
For a user with wiki-update permission only, I want to list their wiki articles in the author archive page. Currently, it comes back with "NOT FOUND Apologies, but ...".
I am using the Twenty-ten ...
2
votes
1
answer
2k
views
Custom Post Type causes Page Not Found
I found a basic tutorial online which gave the rundown on how to create a plugin from scratch and sets up a new custom post type. I could not find any basic coupon plugins that accomplished what I ...
2
votes
2
answers
2k
views
Remove "Comment" column in all post-types
I just want to remove Comment's column in all post-types and in a single function
My current function , Have to do each post-type like this :
function remove_post_columns($columns) {
unset($...
2
votes
2
answers
2k
views
How do I make search results include ONLY pages, no posts?
I'm trying to return only pages in search results.
This is working:
/?s=term&post_type=post
It returns only posts, no pages.
But the opposite is not working:
/?s=term&post_type=page
This ...
2
votes
3
answers
1k
views
Is It Possible To Have Shared Wordpress Custom Post Types?
I am developing a website for a record label and the basically it uses quite a few custom post types for various pieces of information. My problem is that I feel the same bits of information are being ...
2
votes
1
answer
37
views
What is the meaning of the various post messages?
I'm confused about some of the messages that can appear on a post entry/edit screen in the admin area:
$messages['post'] = array(
0 => '', // Unused. Messages start at index 1.
1 ...
2
votes
1
answer
1k
views
Resolved - category-slug.php not working after wordpress migration
I have one issue I'm trying to resolve hours ago searching around the web but can't by now. Any Idea or clue is welcome...
I'm trying to migrate a WordPress site that use a plugin (CCTM (that have no ...
2
votes
1
answer
829
views
Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
I have registered a custom post type "Animals" and also two custom taxonomies ("Vertebrate" and "Type") assigned to it, which have their own specific terms, for "...
2
votes
1
answer
4k
views
wp_query for displaying attachments with a tag
So I am running the following query:
<?php
$args = new WP_Query(array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'oderby' => 'title',
'order'...
2
votes
2
answers
379
views
How to output content based on same custom taxonomy?
I have been trying to output content of all post-types (Posts, Pages and CPTs) based on a term of a custom taxonomy that they must share (meaning if they don't share that particular term, the output ...
2
votes
1
answer
302
views
Is it possible to request several post types from a feed?
If so, how should the query URL be formatted? I've tried:
post_type=cat1&post_type=cat2
post_type=cat1,cat2
post_type=cat1+cat2
This bug report says you could use post_type[]=cat1&post_type[]...
2
votes
0
answers
41
views
How do I set default meta value by post type?
I'm trying to set a meta variable depending on what custom post type is set but can't get my code to work. This is the function in the plugin that sets the metabox after the plugin has added it to ...
1
vote
1
answer
124
views
How can I pick a single post from the latest 3?
I'm looking to display a single featured post from my latest 3 posts at random. I've managed to get it up and running picking any post at random just fine, but I want to filter it down to only the ...
1
vote
1
answer
6k
views
Undefined property: WP_Post_Type::$ID
Using the Query Monitor Plugin - I'm getting this Error Undefined property: WP_Post_Type::$ID for this function:
public function add_form_modal() {
$button_group = get_post_meta( ...
1
vote
1
answer
770
views
How to retrieve a custom post's capability?
When you register a custom post type, you can specify it's capability:
'capability_type' => 'page',
Is there away to retrieve the capability_type within a page (based on the post object provided)?...
1
vote
1
answer
3k
views
save_post not working with attachments
I've made a Meta Box for Posts and Pages, and while testing added Attachments too. But, curiously, the hook save_post does not fire.
$cpts = apply_filters( 'my_filter', array( 'post', 'page' ) ); // ...
1
vote
2
answers
2k
views
Custom dashboard menu does not stay open for the custom Taxonomy within it
Short Version:
Custom menu with a custom post type that supports a custom taxonomy. The custom post type works, the menu for it works and stays open. The custom taxonomy works, but the sidebar menu ...
1
vote
1
answer
26k
views
Multiple post type queries (with specific arguments for each)
So i know how to combine post types into 1 loop and out put the loop. Below is what i have:
<?php
$args = array(
'post_type' => array('post','movie','actor'),
...
1
vote
2
answers
3k
views
How do I search inside specific taxonomies in Wordpress
I am trying to search for posts in specific taxonomies but any time I search, I get results from all the other pages instead of Wordpress searching within the selected category in the taxonomy.
I ...
1
vote
1
answer
497
views
get_post_types - exclude multiple post types by name
I am trying to get an array of all the post types except for attachments and pages. I've been able to do this with one exclusion like this:
get_post_types(
array(
'name' => 'page',
...
1
vote
2
answers
472
views
wp_list_filter() and supports
I'm testing the function wp_list_filter(), basically I want to know if post_type has some specific feature before making stuffs.
So I end up with this:
public static function ...
1
vote
1
answer
5k
views
Use get_post_types to query only custom posts types
I need to query only custom posts types - that is all post types in my WP install excluding posts and pages. I have used get_post_types to build a string of all custom post types which I want to query:...
1
vote
4
answers
9k
views
Move value from one meta key to another
Migrating question:
How would I structure a MySQL query to move the value from one meta_key to another meta_key?
eg: I have an old meta_key of "guest_sort" associated with "posts" to "...
1
vote
1
answer
42
views
Understand post type
I am a bit lost, even after searching answers qutie everywhere..
I am creating a theme for Wordpress, and I would like to have three custom post types (gallery, audio and video). So I added the ...
1
vote
1
answer
69
views
Should I be using custom post types for this or terms and taxonomies?
So for the past week or so, I've been developing a plugin that lets users manage a restaurant menu. I've learned a lot about the process of making plugins as far as adding custom post types, creating ...
1
vote
1
answer
1k
views
get_post_type() in in_array doesn't work for some reason
I am trying to create some function for metaboxes and some reason i can't get get_post_type to work in in_array.
Everything else seems to work in testing but in_array nope.
This is the function that ...
1
vote
1
answer
603
views
WP_Query | 'post_type' doesn't work
I'm new to WP theme development and I've an issue.
I've created a custom post type 'portfolio' via CPT UI plug-in.
Now I want to create a custom query to show all the posts with the post_type = '...