0

wordpress 3.3.2 hi. so i have this custom post type and i use a page to show just one post. url.td/page/

the page renders the post but now i want to include comments. if i allow comments for the page, the comments get assigned to the page, but i want it to get assigned to the post, for example url.td/page/my-post

if i disallow comments, the comments form is hidden.

this is my page

get_header(); ?>

<div id="primary">
    <div id="content" role="main">
        <?php
            $args = array( 'post_type' => 'charts', 'posts_per_page' => 1 );
            $loop = new WP_Query( $args );
            while ( $loop->have_posts() ) : $loop->the_post();
                get_template_part( 'content', 'charts' );
            endwhile;
        ?>
    </div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>

and here comes my content-charts.php

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

lots of stuff here...

<?php 
    wp_reset_query();
    comments_template( '', true );
?>
</article><!-- #post-<?php the_ID(); ?> -->

so i thought, if the comments form is inside the post, it will be related to it, but it aint..

0

untested - try and remove the wp_reset_query(); from content-charts.php; add wp_reset_postdata(); after the endwhile; into your page template.

  • nope, that didnt work. have a solution now, thanks!! – honk31 Jun 5 '12 at 17:30
0

trail and error, right?

here is my dirty solution. in my content file i just recall the whole loop.

$args = array( 'post_type' => 'charts', 'posts_per_page' => 1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    comments_template( '', true );
endwhile;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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