Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking to set up 2 custom post types - Publicity & Management

What I would like to do is display the featured thumbnail for each post from the custom post type on the Publicity page. These will then link though to each post using a custom template.

I would like to do the exact same for the Management section. I have created the post type, but when I click on the thumbnails I am being taken to a page that doesn't contain any of the relevant info.

I am using a child theme of Twenty Twelve.

Can someone please help with this?

Code used for cpt registration

add_action('init', 'publicity_register');  

function publicity_register() {    
  $labels = array(
    //the (probably plural) name for our new post type
    'name' => _x('Publicity', 'post type general name'),
    //how you’d refer to this in the singular (such as ‘Add new ****’) 
    'singular_name' => _x('Publicity', 'post type singular name'),
    'add_new' => _x('Add New', 'publicity'),
    'add_new_item' => __('Add New Publicity Artist'),
    'edit_item' => __('Edit Publicity Artist'),
    'new_item' => __('New Publicity Artist '),
    'view_item' => __('View Publicity Artist'),
    'search_items' => __('Search Publicity'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
  );
  $args = array(    
    'labels' => $labels,      
    'public' => true,    
    'show_ui' => true,    
    'capability_type' => 'post',    
    'hierarchical' => false,    
    'rewrite' => true,    
    'supports' => array('title', 'editor', 'thumbnail'),
    'has_archive' => true,
  );
  register_post_type( 'publicity' , $args );    
}

Code used for loop

$args = array( 'post_type' => 'publicity', 'posts_per_page' => 20 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
  echo '<div class="col-md-3 portfolio-item">';
  echo '<a href="' . get_permalink() . '" title="' . get_the_title() . '">';
  echo get_the_post_thumbnail() . ' </a>';
  echo '<div class="artist-name"><a href="' . get_permalink() . '"'; 
  echo ' title="' . get_the_title() . '">' . get_the_title() . '</a></div>';
  echo '</div>';
endwhile;
?>
share|improve this question
1  
What have you tried so far. Your question doesn't show any effort or research. Please edit your question and add some code that is relevant to your question –  Pieter Goosen Apr 9 at 19:51
    
Pieter, I have updated my question. –  David McKinlay Apr 9 at 20:01
1  
This is the code to register the custom post type, do you have any code from your attempts to display the thumbnail on the publicity page? –  Stephen S. Apr 9 at 20:26
2  
@PieterGoosen Please don't use backticks for highlighting those are for code, I saw this on your suggested edit, using them for other things then code messes up the search functionality. –  ialocin Apr 9 at 20:50
1  
@PieterGoosen Sure, my pleasure, it is not like I knew that in the beginning, I got pretty much the same remark. –  ialocin Apr 9 at 21:27

1 Answer 1

It sounds like you're wanting the page you are redirected to to display the CPT's information in a certain way or format, in which case you'll want to create a single page template for the custom post types you've created.

You can use the single.php file as an example for the layout and customize it as necessary, but the name of the file should be single-publicity.php and single-management.php.

I hope that helps!

Edit

I forgot to mention, I don't know what the name of the page is that you're looping the CPTs through, but make sure the permalinks don't conflict (e.g. a page called Publicity with a slug of publicity).

share|improve this answer
    
Thanks Oturia, I will give this a go later this evening. –  David McKinlay Apr 10 at 11:39
    
Thanks for the help, works a charm! –  David McKinlay Apr 10 at 16:39
    
You're most welcome, sir! –  Oturia Apr 12 at 22:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.