Questions tagged [post-type]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
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
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 ...
Malibur's user avatar
  • 579
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, ...
Dale-Anthony's user avatar
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 ...
rob-gordon's user avatar
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 ...
chrisguitarguy's user avatar
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 ...
Dan Gayle's user avatar
  • 6,116
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!
unfulvio's user avatar
  • 1,814
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 ...
david's user avatar
  • 153
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 ...
Sean's user avatar
  • 647
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. ...
user1355485's user avatar
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 ], '...
Rahul Kumar's user avatar
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/...
Matthias Lohscheidt's user avatar
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 ...
Nicolas's user avatar
  • 141
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' =&...
user1341839's user avatar
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 ...
Mac organo's user avatar
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 ...
Ari's user avatar
  • 1,177
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 ...
HamJam's user avatar
  • 33
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
zina's user avatar
  • 338
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
Abdul Samad's user avatar
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 ...
Peter Andrews's user avatar
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 ...
Charles Kłyciński's user avatar
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 '...
ChemicalSailor's user avatar
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. ...
Christopher Murphy's user avatar
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 ...
Stevarino's user avatar
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 ...
Aidan Knight's user avatar
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($...
l2aelba's user avatar
  • 857
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 ...
Corey's user avatar
  • 311
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 ...
Dwayne Charrington's user avatar
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 ...
eljefejb's user avatar
  • 621
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 ...
Tuux's user avatar
  • 23
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 "...
Sm00k's user avatar
  • 21
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'...
Danny's user avatar
  • 112
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 ...
user avatar
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[]...
Emre's user avatar
  • 123
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 ...
Rosbiffer's user avatar
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 ...
adamdanw's user avatar
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( ...
Demonix's user avatar
  • 41
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)?...
gdaniel's user avatar
  • 3,251
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' ) ); // ...
brasofilo's user avatar
  • 22.1k
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 ...
Radley Sustaire's user avatar
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'), ...
Carpy's user avatar
  • 310
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 ...
Sosthenes Kwame Boame's user avatar
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', ...
user19103974's user avatar
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 ...
JMau's user avatar
  • 2,913
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:...
Bassscape's user avatar
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 "...
Nadine's user avatar
  • 377
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 ...
user3415011's user avatar
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 ...
ShoeLace1291's user avatar
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 ...
lonerunner's user avatar
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 = '...
Frelseren's user avatar
  • 123