Questions tagged [custom-post-types]
Custom Post Types extend WordPress to support additional content.
3,234
questions with no upvoted or accepted answers
7
votes
0
answers
3k
views
add_rewrite_endpoint() not working for custom post type archives
i'm working on somekind of wiki/encyclopedia system based on wordpress.
there are two custom post types. i'll show my configuration for one of them:
$labels = array(
'name' => _x('Objects', '...
6
votes
1
answer
2k
views
Add category to custom post URL
I am trying to create custom post with custom taxonomy and categories. Structure is like:
Product:
Has categories
Has taxonomy
Custom post type create:
function create_alco_custom_post() {
$...
6
votes
1
answer
1k
views
How do I display two separate taxonomy archives for two post types that share a single taxonomy?
I have a custom content type, "products", which shares the category taxonomy with posts. We're using posts to discuss and review products. The idea is to have two separate URLs:
/discussion/...
6
votes
2
answers
2k
views
Admin Area Custom Type Search By Meta Fields Without Title & Content
I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code:
...
5
votes
0
answers
2k
views
Fetching private posts or custom post types via WP-API with basic authentication
I've installed WP-API along with Basic Auth. I'm able to fetch cpt posts using
curl http://siteurl.com/posts?type={post-type}
However, if I change a post to private, it is no longer returned. This ...
4
votes
0
answers
271
views
Custom post type capabilities require "create_posts" to access the edit posts list page
I have a custom post type and a custom user role that I want to be able to do everything but delete and create this post type. However, this user role can't view the dashboard's list of posts for ...
4
votes
0
answers
230
views
Lock post meta block at the bottom of a custom post type
I'm using the template feature of Gutenberg to add a post meta block (with a couple of input fields) at the bottom of a custom post type:
$args = array(
'show_ui' => true,
'show_in_rest' =&...
4
votes
0
answers
530
views
How to add button to post page WordPress 5.x
How can I add a button to a posts page? what hook can be used to add a custom button
I'd like to place it next to, or near, the "Publish/update" button, or modify the publish button for triggering ...
4
votes
2
answers
3k
views
Enabled Revisions to existing custom post type not working Wordpress
I am trying to enable revisions for an existing custom post type. As the post type was already created about 2 years ago so where the post type was register I added revisions to the supports array.
...
4
votes
1
answer
662
views
Custom taxonomy query for a custom post type
I have a custom post type called news with a custom taxonomy called news category. Right now I have a template called taxonomy-news_category-press.php where press is one of the news_categories. The ...
4
votes
1
answer
1k
views
has_term or in_category for Custom Post Types
I have property as a custom post type. I want to display a specific message if the property is in the sold category. To do that, I'm using the function below:
if ( has_term('sold', 'category')) {
?&...
3
votes
0
answers
54
views
WordPress Rest API only returns content when posttype has editor capability
I am trying to request my post via the WordPress V2 Rest API in the backend. For whatever reason the post content is only returned when my custom post type has the editor support enabled. Is there a ...
3
votes
0
answers
1k
views
ACF Upload Image in repeater from front-end with custom form? - add_post_meta()
I want to upload images in the ACF repeater. That repeater means the gallery of page.
Point is to create post in custom post type using add_post_meta() method.
Here I have the form :
<input type=...
3
votes
1
answer
1k
views
How to delete all posts from a custom post type?
I want to delete all posts from a custom post type "TV-Serie". The number of all posts in this post type are 150,000.
Moreover, when I try to delete them all manually while selecting more than 500 ...
3
votes
1
answer
893
views
Bulk 301 redirect for custom post type
I've amended the URLs for my custom post type from:
url.com/jobs/job-name to url.com/jobs/job-location/job-name
Problem is, because this isn't a standard rewrite wordpress doesn't do the 301 ...
3
votes
0
answers
378
views
Linking three taxonomies with ACF
I'm creating a product finder using a CPT called "Products", which is already used for displaying products separately on the site. The product finder is based on a answer and question idea, where the ...
3
votes
1
answer
111
views
Adding a span when custom post type is updated
What I'm trying to do is have a span tag appear on the top of the post type whenever the post is updated.
The way the page is setup, there is a query of different post types that list jobs currently ...
3
votes
1
answer
132
views
Remove "-2" from a Toolset Types URL with the same post name
I'm using Toolset Types to create a custom post type, and within that post type there is a taxonomy. I have created two posts with the same name, but in a different taxonomy.
For the purposes of ...
3
votes
1
answer
215
views
Page to display an archive of taxonomies
My website needs to have two custom post types and each of these has two custom taxonomies with several terms each. These terms also have to be hierarchical.
My problem is, that I don't know how to ...
3
votes
0
answers
3k
views
Adding description to archive of Custom Post Type
Im battling to add a description / introduction field to the top of the archive of my custom post type. I manage easy with with ACF's option page, but I would like to do without ACF.
I have managed, ...
3
votes
0
answers
388
views
No checkbox in wordpress posts list table for CPT
I have added a Custom Post Type as follows
add_action( 'init', 'codex_book_init' );
function codex_book_init() {
$args = array(
'description' => __( 'Description.', 'your-plugin-...
3
votes
0
answers
70
views
Select menu should display categories and the item's depth
I have a select menu of a custom post type in the header.php:
<?php
$selectloop = new WP_Query( array( 'post_type' => 'products', 'posts_per_page' => -1 ) );
echo '<form>&...
3
votes
0
answers
656
views
Custom Post Type relationship with hierarchical parent and child permalinks
Trying to get my permalink and url structures to behave nicely.
I have a Custom Post Type called Diseases.
This post type is hierarchical with parent and child relationships.
I have another CPT ...
3
votes
0
answers
2k
views
Category base to url in custom post type/taxonomy
I'm building a recipe site that uses custom post types for recipes.
So I searched for including the custom post type categories in the url and found a solution below by Milo. It rewrites the url and ...
3
votes
1
answer
713
views
Custom Taxonomy and tax_query Issue?
I am working on Plugin development and my plugin name is plugindev.I have a custom post type called team.I have a custom taxonomy Team_Category which is being registered by this code
/****************...
3
votes
0
answers
59
views
How to show custom taxonomy in the permalink?
I used the Portfolio Post Type Plugin to create custom tax and post type.
I would like to show the custom taxonomy on the portfolio projects.
portfolio/customtaxonomy/project
while now is
...
3
votes
1
answer
3k
views
How to set custom post type as post title to avoid 'Auto Draft'
I am using a mixture of Advanced custom fields plugin and Custom post type UI to give my users some extra functionality. The problem I have is that I have serup a testimonials menu and in the list ...
3
votes
0
answers
189
views
How to create a repeatable / reusable divs in the metabox?
I have a meta box:
<?php
function custom_meta_box_markup() {
global $post;
$meta_box_text = get_post_meta( $post->ID, 'meta-box-text', true );
$meta_box_text_day = get_post_meta( $...
3
votes
0
answers
1k
views
Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
I have 8 custom post types (which are actually for 8 different blogs and used as "blog landing pages"). Each custom post type is also a Blog Category and each has several sub categories to it. For ...
3
votes
0
answers
2k
views
How to add meta boxes(repeater fields) from WordPress back end?
I have a custom post type 'service'. Each service will have items. For each item there would be 'name of item' and 'price'. Earlier i created meta boxes for 5 items i.e 10 meta boxes in total, which i ...
3
votes
1
answer
726
views
register_post_type - rewrite / feeds, what's it for?
The codex page for register_post_type seems to suggest that it should be possible to disable feed generation for custom post types:
rewrite
(boolean or array) (optional) Triggers the handling of ...
3
votes
1
answer
1k
views
Get list of terms of current taxonomy archive for another taxonomy
I have a Custom Post Type named 'Real estate' which has (amongst others) two different taxonomies:
'Purpose' (hierarchical; terms used are 'Living', 'Working' and 'Holidays') and
'Location' (non-...
3
votes
2
answers
1k
views
Parent page for CPT
Alright, there's been numerous topics about this, but it doesn't seem to work for me.
I have one normal page, called "Resources".
Then I have several Custom Post Types. One of which is "...
3
votes
2
answers
6k
views
Displaying Meta Box Image
I have some problems displaying info from my custom meta box in my custom post type single. I'm using Reusable Custom Wordpress Meta Boxes by Tammy Hart.
I'm able to display the textfields using this:...
3
votes
3
answers
912
views
Unable to get wp_redirect() working after adding a CPT via the front end
I am attempting to learn PHP by creating a relatively simple application built on wordpress, it is a basic CRM and I've made decent progress but have been stuck on some of the finer points.
I've been ...
3
votes
1
answer
2k
views
WordPress import not importing custom taxonomy
I've posted this already in the WP Support Forum hoping to have more luck here.
I'm trying to import a custom post type from one blog to another. (126 posts in the custom post type).
I've exported ...
3
votes
2
answers
2k
views
save_post custom post type ? $_POST not working?
i have this code.
<?php
add_action('add_meta_boxes', 'ct_meta_add');
add_action('save_post','ct_meta_save');
add_action('save_post','ct_parent');
// add meta functions
function ct_meta_add() {
...
3
votes
2
answers
227
views
Page as a child of a Custom Post Type
I have a custom post type called "Professions", it contains different professions and info about them. To show them I simply use a content-profession.php -file.
The thing is that I need subpages (...
2
votes
1
answer
39
views
How to include Font Awesome icons into 'menu_icon' from register_post_type() function - wp admin?
I would like to use font awesome icons instead of dashicons inside menu_icons argument of register_post_type() function or for add_menu_page() icon argument.
I have found another page that suggest to ...
2
votes
1
answer
40
views
Is it possible to use a post name in a custom post slug?
So I have custom post type called Lessons and I am using something like this for the slug
register_post_type( 'Lessons',
// CPT Options
array(
'labels' => array(
...
2
votes
0
answers
212
views
Query custom post type and group by taxonomy
I struggle a bit with my piece of code - it's main goal is to show list of custom post type (called "career") childs grouped by custom taxonomy.
How it should work?
A user see default list ...
2
votes
0
answers
86
views
Child post with numeric only slug keeps redirecting to parent
I modified the allow-numeric-stubs plugin code to work with CPTs. You can view my forked repository here: https://github.com/akshatkedia/allow-numeric-stubs
WordPress is now allowing numeric slugs for ...
2
votes
0
answers
205
views
Clone wp-admin/users.php (Users Admin Page)
I have created a new page in admin. I need to show all the users in this page(like Users admin page).
The reason for this is because i want to show certain custom user roles only on this page.
I tried ...
2
votes
0
answers
42
views
Custom Post Type not appearing in website search
I've built a custom theme from scratch for a client and have a few custom post types. For one in particular, FAQ, I wanted to hide it from showing individual posts (posts would only appear on its ...
2
votes
2
answers
54
views
Permalinks without post type
I use norebo theme
I use it when I open a Portfolio the link is in this format
https://www.hshnorm.com/project/fruit-flavored-powder-juice/
How can I remove the word project
To be the link in this ...
2
votes
0
answers
563
views
Show Post Count of a Category
I've been stuck on this for a little while now, and have tried multiple ways to achieve this with no luck. I've been looking for two ways to display the total posts found on a specific, and non-...
2
votes
0
answers
51
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 ...
2
votes
0
answers
835
views
A better way to add a meta box to custom post types
Id like to customize the UI for adding and editing a custom post type such that each custom field is included as a separate input field on the "new post" and "edit post" forms (as ...
2
votes
0
answers
127
views
Registration and Custom Post Types - How to synchronize information?
I am building a platform where service providers can offer their services to potential customers. Therefore, I have two user roles, one "customer" who can only create an account and read; ...
2
votes
0
answers
600
views
Gutenberg Featured-Image-panel missing when user with custom role edits Custom Post Type
For a Wordpress project I made a Custom Post Type in the usual manner. Also i made a custom role. I want users with that role to be able to make, edit and delete this CPT. I added the apropriate ...