Display a different Post Detail Page Than Post Template

A bit of background:

I’ve build a social media aggregator that pulls in a bunch of different custom post types.

Read More

Based on the post type I’m assigning a template dynamically for the list view. So each post type has a unique look.

                    switch (get_post_type())
                {
                    case twitter:
                        get_template_part( 'content', 'twitter' );break;
                    case flickr:
                        get_template_part( 'content', 'flickr' );break;
                    case facebook:
                        get_template_part( 'content', 'facebook' );break;
                    case youtube:
                        get_template_part( 'content', 'youtube' );break;
                    case instagram:
                        get_template_part( 'content', 'instagram' );break;
                    case googleplus:
                        get_template_part( 'content', 'googleplus' ); break;
                    case facebook:
                        get_template_part( 'content', 'facebook' ); break;
                    case linkedin:
                        get_template_part( 'content', 'linkedin' ); break;
                    case pinterest:
                        get_template_part( 'content', 'pinterest' ); break;

                    default:
                        get_template_part( 'content_blog');
                }?>

What I want to do is to link the “more” button which takes the user to a standardized detail page that looks the same for all post types.

Is there a way to set the “Post Detail” formatting independently of its respective template.

Is there a best practices way to achieve this?

Thanks!

Related posts

Leave a Reply

1 comment

  1. If I understood you correctly, you want for the code below to link to some different URL.

     <?php the_content( 'Read more ...' ); ?> 
    

    If so, then you can check this WordPress Forum Question which shows how to achieve this.

    Also one point about your switch statement:

    Instead of using switch why don’t you just rename content_blog.php to content.php and then use this single line of code:

    get_template_part( 'content', get_post_format() );