Home › Forums › Iconic One Pro Support › Custom Page Template for Custom Content Type displaying weird results
- This topic has 3 replies, 2 voices, and was last updated 10 years, 5 months ago by Themonic-Support.
- AuthorPosts
- April 28, 2014 at 9:19 pm #2198pwcurtisParticipant
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(); ?>April 28, 2014 at 10:07 pm #2199pwcurtisParticipantWith 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.
April 29, 2014 at 2:42 am #2200pwcurtisParticipantQuick 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!
April 29, 2014 at 6:44 am #2201Themonic-SupportKeymasterYou do not have permission to view this content.
- AuthorPosts
- You must be logged in to reply to this topic.