Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [custom-post-types]

Custom Post Types extend the WordPress back-end to support additional, non-Post content.

1
vote
4answers
4k views

Make future posts visible to the public—not just within WP_Query

I know I can publicly show future posts in a loop using 'post_status' => 'future' in WP_Query. But clicking on a future post's permalink will result in a 404 if you are not a logged-in user. ...
28
votes
3answers
56k 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 ...
0
votes
3answers
477 views

Get Post Terms of Current Post (selected taxonomy term) - How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?

I use the get_post_term code from https://codex.wordpress.org/Function_Reference/wp_get_post_terms. I can retrieve the selected taxonomy term from the current post but the displayed value looks like ...
0
votes
1answer
44 views
+50

How To Import CPT With Only Few TEXT ACF Fields From Front End?

I have registered CPT "Contacts" and I have created 3 text fields: name, phone and address. All those fields are set as text fields, and now I want to allow admins to import CPT with those fields from ...
0
votes
1answer
467 views

Add word limit in wordpress posts editor

hey guys complete newbie over here and I wand to add an character limit in wordpress default text editor for posts. P.S I don't want an excerpt limit I want a word limit in posts. please give step by ...
0
votes
1answer
17 views

get_post_type is always post

Sorry to bother you all with this, but it's driving me nuts and I know I've missed something obvious. I want to display different post types, differently, within the loop. I'm trying to get the post ...
6
votes
4answers
3k views

Creating “static” taxonomies to choose from, inside custom post type?

Alright, so i have a custom post type called Blurbs (translated, sort of). I want to add a static set of categories for the posts within Blurbs (i don't want the user to be able to create custom ...
0
votes
0answers
9 views

Callback to custom field is not working in Wordpress REST API

I'm pretty new to the REST API so please excuse any stupid questions. I'm currently trying to develop a plugin and therefore I need to register a custom post type including a custom field. This is all ...
0
votes
1answer
9 views

Custom user role not working as expected

I've defined a custom user role in functions.php called "Dashboard Admin" with the capabilities defined below. The site has a number of custom post types- all with capability post- and I'd basically ...
4
votes
1answer
392 views
+50

wp_get_object_terms(): count relative to passed IDs?

I know when you wp_get_object_terms() you get a "count" member variable for each term object returned, but that "count" is what's in the $wpdb->term_taxonomy table in the database, it's not ...
0
votes
1answer
464 views

Commas not displaying in implode

I'm trying to separate some taxonomy terms with a comma, but I can't see to get the commas to show correctly. Here's what I got: <?php $terms = get_the_terms($post->ID,'type'); foreach ( $...
3
votes
2answers
2k views

“Edit” option for custom post types archive page

I have a custom post type archive page but I also need the user to be able to insert a bit of page text. I thought I could just use the_content() of the page but the edit link is gone from the admin ...
0
votes
1answer
15 views

How to get the custom post list to admin user edit page?

I want to list out some post types in the admin panel admin user section to allow the users to access from the front end. How can i get the post list in admin user edit profile section?
0
votes
1answer
463 views

Creating custom post type with custom taxonomy and custom fields programatically

I need to create a custom post type. This post type will have a custom taxonomy. Also this post type will have custom fields. I dont want to use any plugins to do it, i want to include the creation ...
0
votes
2answers
25 views

Where paramaters of a custom function are coming from inside the loop?

I have this piece of code and, although it works, I do not understand how. First, I created a custom post type into my mu-plugins folder: function actor_init() { $args = array( 'label' => '...
0
votes
1answer
342 views

Custom nav menu current item custom link problem

Because I want to add <span class="dashicons [class]"></span> inside each link of my menu I needed to create a custom made nav menu. I did this by the code below which works great, but ...
0
votes
2answers
16 views

Archive for custom taxonomy

I have a custom post type movies that I have defined in function.php function create_post_type() { register_post_type( 'movies', array( 'supports' => array('title', 'editor' , 'excerpt' , '...
3
votes
2answers
3k views

Remove current_page_parent nav class from blog index when in CPT

I'm trying to remove current_page_parent class from the blog index menu item (I got a custom page to display all blog posts and it is in the menu) when navigating custom post type archive page and ...
0
votes
1answer
15 views

assign array of category to custom post type

I tried to assign array of categories to custom post type on creation, so I wrote the following code: $post_id = wp_insert_post( array( 'post_content' => '', 'post_name' => $...
0
votes
0answers
21 views

Can I manage current & past editions of an annual event with a single WordPress install?

I want to use a single WP install to build a site that will present curent and pasts editions of an annual event. From one year to the next the list of participants and the daily program change ...
0
votes
1answer
21 views

Topic won't save for a custom post type — how to debug?

In two of my site's custom post types, the topic (in the Topics meta box -- see screenshot below) won't save. This is not a custom meta box, I don't think. At least, I think it comes standard with ...
0
votes
0answers
21 views

Ho to display author image dynamically as a background image?

On my puzzle website I would like to display author image on the post area as shown in the image below. The author image would be a background image. May I know how is this possible? Theme is using ...
0
votes
0answers
15 views

Count posts associated with another post type

I have two custom post types in Wordpress: Events and Venues. I need to count the number of Events associated with the individual venues and have the counts displayed in a column on the Venues page in ...
3
votes
1answer
497 views

Show custom post type endpoint in REST API just if user has capability

I created a custom post type for WP, that should just be visitable for user that have a custom capability read_cpt. Within templates and pre_get_posts I can run checks to include or exclude the CPT by ...
126
votes
13answers
86k 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 ...
0
votes
1answer
38 views

Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?

I have a custom post type called "equipment". I would like the permalink structure to be: example.com/equipment/%post_id%-slug I specifically want it to use a dash and not a slash (i.e. - "id-slug" ...
0
votes
1answer
474 views

Work and Display a Custom Post Type as a normal Post

I've created some Custom Posts for my Wordpress page and I can work fine with them. I can create a new one, edit it and display it in "archive-custom_post_type_name.php" and many more things. I can ...
1
vote
1answer
491 views

re-register custom post type with custom capabilities

I have created custom post type as below. register_post_type( 'connector', array( 'labels' => array( 'name' => __( 'Connectors' ), 'singular_name' => __( '...
0
votes
0answers
13 views

Woo commerce hide category descriptions

i am currently building a site on my localhost, i have descriptions of product categories but on the category product page, it shows it twice. I have tried messing with my theme and custom css to hide ...
1
vote
2answers
15 views

list taxonomies from a custom post type

I registered a Taxonomy for a custom post type called events. // Register Custom Taxonomy function events_categories() { $labels = array( 'name' => _x( '...
0
votes
2answers
21 views

How can we display full post on home page rather than excerpt

I have a puzzle website where i am looking for the option to display full question on the home page rather than excerp. Just a note that questions are custom posts. Is there any way. Thanks
0
votes
0answers
9 views

Hidden Form Custom Post Meta Field for Storing Post_id using PHP and save_post hook

In order to send email notifications to registered users when a new listing matches their breed and location preference, need the post_id stored in a meta field to have post_id parameter available for ...
0
votes
0answers
16 views

Adding specific custom fields (images) to post excerpt

I am working on a simple user profile archive, using the theme "Atomic Blocks" as a starter theme. I am using one custom post type and several custom post fields to create these user profiles. The ...
0
votes
1answer
474 views

Admin: Get all user for Custom Role

I made a custom post type evenement with these capabilities. Here, I just put the capabilities parameters. 'capability_type' => 'evenement', 'map_meta_cap' => true, 'capabilities' => array( ...
0
votes
0answers
12 views

link user to post, when its submitted via online form

Users can submit Events via a Custom Post Type (Form is made with the qform Plugin) - If the user does not have an account, an account is created during submitting the form. If he is logged-in already,...
0
votes
0answers
18 views

Translation in Plugin doesn't work

Hello my fellow WordPress Devs, i'm new in WordPress coding and try to code a free plugin for animal shelters. I want to create a new post type "Pets" this works absolute fine. But when i want to ...
0
votes
0answers
11 views

wp-query: order by a custom-field and get one random item of another custom-field

I have a "brand" page (ex. Nike). When I click on "Nike" page I would like to show a list of all categories of their products (ex. shoes, thirts ecc). Each category of their products is listed by a ...
0
votes
1answer
16 views

Custom post type suddenly stoped working after WordPress 5 update

I build a simple plugin that has a CPT and 1 metabox section that collect extra information from admin. It was working fine in the old version but when i just updated it to WordPress 5 it stopped ...
0
votes
1answer
483 views

Add featured image programatically to custom post type

I am trying to automatically add a video thumbnail from Vimeo or YouTube as the featured image when a new custom post type video is add/updated. The video ID is an advanced custom field. Here's my non-...
1
vote
2answers
37 views

Custom post type archive sorted and grouped by date in post meta field

I am trying to build an Custom Post Type for showing information about events. The Custom Post Type has name 'Event', with the following meta fields: event_startdate (date in format YYYY-MM-DD) ...
0
votes
1answer
16 views

update custom taxonomy with Ajax in edit.php file [duplicate]

I created Custom Psot Type and Custom Taxonomy. I recover, for each CPT element its custom taxonomy. here is a screenshot: now , i want update the coustom taxonomy for the CPT element with ajax ...
3
votes
3answers
18k views

Simple way to search custom-post types only

I'm just trying to find a way to narrow my current search bar so that it only searches within my 'events' custom post-type. I do not want the search to index any other post type, only 'events'. Here'...
51
votes
3answers
31k 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 ...
-1
votes
1answer
23 views

is it possible to keep the custom posts even users deleted from the frontend? Is there any code for function.php? [on hold]

Is it possible to keep the custom posts even users deleted from the frontend? Is there any code for function.php? I want to keep the properties listings even the users from the dashboard (frontend) ...
0
votes
0answers
31 views

filter using custom fields

I am working on a job search page. I have created job category, job location, job description and posted date using Advanced Custom Fields. I want to display the job location and category in a select ...
0
votes
1answer
485 views

Custom post type rewrite with_front

What I'm setting up, I thought would be quite simple. In fact, I'm sort of amazed that the answer didn't just pop up after a half hour of searching here. Here is the code to create my CPT: ...
1
vote
1answer
28 views

Display a grid of taxonomy terms at root taxonomy page

I’ve used WordPress for years as a content admin but I am new to PHP development (am fine with HTML/CSS). From Googling about and experimenting I believe that what I want to achieve isn’t standard ...
0
votes
1answer
484 views

shortcode order for event custom post type

ok im working on a website using post type event with post_meta event_start_date, i created a shortcode and everything is displaying fine except for it displaying in order, it seems as its not ...
0
votes
1answer
21 views

Batch Extract Date from post title and put into ACF custom field

I have a custom post type called 'events' with around 700 posts, the titles are consistently formatted like this: Event Title - January 1st 2019 I need to isolate the date in another field. I am ...
1
vote
1answer
18 views

Custom meta box not saving

I've created a custom meta box for a custom theme. The metabox appears but does not save any inputed values <?php /* @ PACKAGE 3KTECHS THEME ========================= CUSTOM POST TYPE PAGE =======...