Discussion:
Two loops
hamlet
2013-11-17 00:11:09 UTC
Permalink
Hello, I am the following issue:

I am using a custom post type (it has support for comments)
single-myPostType.php

if ( have_posts() ) {
while ( have_posts() ) {
the_post();

get_template_part('content', 'single-myCustomPostType');

comments_template('', true);
}
}
content-single-myCustomPostType.php

(...)
$loop = wp_get_the_related(get_the_ID());
if ($loop->have_posts())
while ($loop->have_posts()) {
$loop->the_post();
get_template_part('content', 'related');
}
(...)

It is getting comment forms if some related has this options enabled.
Any idea?
Aero Maxx
2013-11-17 17:44:16 UTC
Permalink
Post by hamlet
I am using a custom post type (it has support for comments)
single-myPostType.php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part('content', 'single-myCustomPostType');
comments_template('', true);
}
}
content-single-myCustomPostType.php
(...)
$loop = wp_get_the_related(get_the_ID());
if ($loop->have_posts())
while ($loop->have_posts()) {
$loop->the_post();
get_template_part('content', 'related');
}
(...)
It is getting comment forms if some related has this options enabled.
Any idea?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
I'm happy to try and help you, but I read what you wrote 2-3 times and I
didn't understand what it was you was trying to explain, are you saying
you have a custom post type, and its showing the post but not the
comment form, or that its only showing the comment form when it has a
post that is related to the post being viewed ?
Josh Eaton
2013-11-17 20:41:41 UTC
Permalink
This question is probably better suited for the support forums or WordPress
Answers http://wordpress.stackexchange.com/

Regardless, you're likely missing a wp_reset_postdata() after the related
loop to reset the $post global.
Post by Aero Maxx
Post by hamlet
I am using a custom post type (it has support for comments)
single-myPostType.php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part('content', 'single-myCustomPostType');
comments_template('', true);
}
}
content-single-myCustomPostType.php
(...)
$loop = wp_get_the_related(get_the_ID());
if ($loop->have_posts())
while ($loop->have_posts()) {
$loop->the_post();
get_template_part('content', 'related');
}
(...)
It is getting comment forms if some related has this options enabled. Any
idea?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
I'm happy to try and help you, but I read what you wrote 2-3 times and I
didn't understand what it was you was trying to explain, are you saying you
have a custom post type, and its showing the post but not the comment form,
or that its only showing the comment form when it has a post that is
related to the post being viewed ?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...