Custom Page Template for Custom Content Type displaying weird results

Home Forums Iconic One Pro Support Custom Page Template for Custom Content Type displaying weird results

This topic contains 3 replies, has 2 voices, and was last updated by  Themonic-Support 9 years, 12 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2198

    pwcurtis
    Participant

    I have used the plugin Custom Content Type Manager to create a custom content type called “news”. The news content type will be article reposts from other blogs. I would like to keep these separate from my main blog posts as well as being able to tweak how single posts etc. are displayed.

    I have already created a child theme, and made a custom page template for page-news.php. The page is actually displaying news contnet type posts. But the formatting iss off, it is not using an excerpt and instead displays the entire post, comment section and all. See http://petersblog.us/news/

    Below is the code for page-news.php:

    <?php
    /**
    * The template for displaying all pages.
    *
    * This is the template that displays all pages by default.
    * Please note that this is the WordPress construct of pages
    * and that other ‘pages’ on your WordPress site will use a
    * different template.
    *
    * @package Iconic One Pro
    *
    * @since Iconic One Pro 1.0
    */

    get_header(); ?>

    <div id=”primary” class=”site-content”>
    <div id=”content” role=”main”>

    <?php $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 10 ); ?>
    <?php $loop = new WP_Query( $args ); ?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <?php get_template_part( ‘content’, ‘page’ ); ?>
    <?php comments_template( ”, true ); ?>
    <?php endwhile; // end of the loop. ?>

    </div><!– #content –>
    </div><!– #primary –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    #2199

    pwcurtis
    Participant

    With additional testing, I have noticed that the news articles display correctly in this view (I am sharing tags and categories between “post”, and “news” content types, so this works) http://petersblog.us/tag/microsoft/

    I think that rules out how my custom content type is setup. I am guessing it has to do with how my query is setup (I pulled this originally from wordpress codex):

    <?php $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 10 ); ?>
    <?php $loop = new WP_Query( $args ); ?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    I tried removing the “‘posts_per_page’ => 10 ” statement. It had no effect on formatting. I don’t have more than 10 articles published yet either.

    #2200

    pwcurtis
    Participant

    Quick update, I modified the loop in page-news.php to read:

    <?php $args = array( ‘post_type’ => ‘news’); ?>
    <?php $loop = new WP_Query( $args ); ?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <?php get_template_part( ‘content’, ‘page’ ); ?>
    <?php endwhile; // end of the loop. ?>

    Removing this command solved the problem with comments showing up: <?php comments_template( ”, true ); ?>

    Also, I realize I may need a content-news.php
    (based on: <?php get_template_part( ‘content’, ‘page’ ); ?>)
    I copied content.php from the theme folder, into the child theme folder and renamed it content-news.php. That did not solve the formatting issue either.

    At this point I am a bit stuck. I’m sure dev can offer a bit of help during business hours tomorrow. Thanks!

    #2201

    You do not have permission to view this content.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.