Articles of custom post types

Shortcode for display posts on home page show only one post

Need to display 3 posts. I created this code: add_shortcode(‘projects’, ‘projects_shortcode’); function projects_shortcode($atts, $content){ extract(shortcode_atts(array( ‘post_type’ => ‘project’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ‘caller_get_posts’ => 1 ), $atts)); $args = array( ‘post_type’ => $post_type, ‘post_status’ => $post_status, ‘posts_per_page’ => $posts_per_page ); global $post; $posts = new WP_Query($args); $out = ”; if ($posts->have_posts()) while ($posts->have_posts()): […]

Create sub single pages

I would like to have the possibility to create “sub single pages” to display detailed content in a custom post type. Is there a way to generate pages, with a specific template with a URL of this type: domain.com/custom-post-type-slug/single-slug/sub-single-slug/ Note : I need multiple sub-single pages for each section of my post (content added via […]

remove permalink “front part” for custom post type

Let’s suppose I have CPT “event”. In register_post_type, I’ve set ‘slug’ => ‘event’ Then, in WordPress settings I’ve set following Permalink structure Custom: http://www.domain.tld/news/%postname%/ The problem is, URL for my “Event” CPT is www.domain.tld/news/event/<event-name> and I want www.domain.tld/event/<event-name> how can I achieve that? Thanks

How can I display an archive of only one category of my custom post type?

This is different from the question: How to display categories of my Custom Post Type? I have a custom post type – podcasts. I have added the taxonomy “category” as I want my ‘podcasts’ to share the ‘category’ taxonomy with my posts. I have an archive page (archive-podcasts.php) that displays the podcasts at the url […]

Display different content on homepage depending on post type

In the home page, I have a custom loop for displaying different post type content. I have this loop on my index.php $loop = new WP_Query( array( ‘post_type’ => array(‘photo’, ‘video’, ‘web’), ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1, ‘posts_per_page’ => -1 ) ); Now it displays correctly but I want to include the title […]

Display Custom Post Type Fields

I’m making a website and want to display Events. Therefore I made a Custom Post Type called ‘event’. I’m querying events to show them in a page. The Events I made also have some custom fields like : ‘Location’, ‘Day’, ‘Month’, ‘Year’ and a category. This is my code now : <?php $args = array( […]

permalink editor doesn't show on custom post types

I’ve created a simple custom post type. In my wordpress site, permalinks are set to Post Name. In the admin screen for posts of my custom post type, no permalink editor is displayed. How do I make this show up, as it does normally for the default post types? This is how I’ve created the […]

How to make a relation between two posts

I’have this structure: News (CPT. A page showing all news) Works (CPT. A page showing all works) Then, inside a single page of works I want to show the news related to this work: Single work title content news related to this single work How can I make a relation between a single post in […]

Custom page type – template under page attributes?

I thought we can apply templates to custom page types: You can’t apply templates to custom post types in this manner. That will show up only if the post type is ‘page’ My code: function keyword_pages_init() { $args = array( ‘label’ => ‘Keywords’, ‘public’ => true, ‘show_ui’ => true, ‘capability_type’ => ‘page’, ‘hierarchical’ => false, […]

Conditional tags don't work

I’m trying to display different templates in archive.php page. I need to load different article display depending on custom post type. Here is my code: <?php if(is_singular(‘libri’)) :?> <?php // WP_Query arguments $args = array ( ‘post_type’ => ‘libri’, ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() […]