After creating Wordpress custom post type, how do you display these posts on their respected pages?
-
When using the_permalink(), my custom post type pages do not display? How can this be modified?
-
Answer:
Create a template for your custom post type in your theme. Put this on the top: <?php /** * Template Name: My Custom Post Type Template */ ?> Copy rest of the code from your theme's page.php . Now in the code just before the wordpress loop paste this code <?php query_posts(array('post_type'=>'mycustomposttype')); ?> Name this file archives-mycustomposttype.php Now go to pages and create a new page. In the title, choose something that you would like to appear in your menus. Then in the template metabox choose My Custom Post Type Template. Leave the text area of the page blank, save page and publish. If this page is appearing in your menu then good other wise go to Appearance > Menus and add this page to menu. I hope this helps.
Noumaan Yaqoob at Quora Visit the source
Other answers
Custom Post Types would use the single.php template from the http://codex.wordpress.org/Template_Hierarchy unless you define a template for them. In this case you would copy single.php and save it as single-mycustomtype.php then edit as you wish. This would be the template for individual posts. You don't need a special query for that. If you want a list of those posts to show up on a regular page, then you would need a special query. Since you mentioned the_permalink() I'm guessing this is what you are trying to do. As an example on this demo site - http://www.coolwebdev.com/givecamp/monsters/ - I have a landing page for my custom post type "Monsters." It displays an alphabetical list of monster pages. That uses a variation of page.php with a custom name. Here is the query from page-monsters.php: <ul> <?php $wp_query = new WP_Query(array('showposts' => 50, 'post_type' => array('monsters'),'orderby' => 'title'));?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <?php endif; ?> </ul> This gives us an alpha list, but there are many different queries you could run. (reference the link that Brad shared) The main thing is to define your post type in the query and to make sure the name matches your post type as you have defined it in functions.php or via a plug-in depending on how you created it.
Heidi Cool
You need to setup a wp_query for your custom post type on the custom pages. You can list your custom post type where ever you would like using the wp_query. You can find out how to create your query here: http://codex.wordpress.org/Class_Reference/WP_Query
Brad Williams
Under Admin > Settings > Permalinks Go to that Admin page and (re) save. Try visiting the page again.
Mark Simchock
Related Q & A:
- How do I redirect all posts from the old Wordpress to a subdomain?Best solution by en.support.wordpress.com
- How to add likes to the top Facebook business pages?Best solution by Web Applications
- How to make the first page of a PDF display by itself and the succeeding pages display two-up?Best solution by Super User
- How do I go about creating a custom search engine for my website?Best solution by Stack Overflow
- How to reply to Сraigslist posts?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.