Löste det med efter :
<?php get_header(); ?>
<?php
$thePostID = $post->ID;
?>
.... bla bla resterande kod innan comments_template...
<?php
$id = $thePostID;
comments_template();
?>
Så fick jag rätt ID för kommentarerna. :D
2 svar · 525 visningar · startad av Fredde Mannen
<?php
/*
Template Name: Wedding
*/
?>
<?php get_header(); ?>
<div id="content" class="widecolumn">
<div id="post-<?php the_ID(); ?>" class="post-<?php the_ID(); ?> page">
<h1><?php the_title(); ?></h1>
<div class="postmeta">
<span class="comments"><?php comments_popup_link(__('0 <span>comments</span>', 'notesblog'), __('1 <span>comment</span>', 'notesblog'), __('% <span>comments</span>', 'notesblog'), '', ''); ?></span>
<span class="author"><?php _e("By", "notesblog");?> <a href="<?php the_author_url(); ?>" title="<?php the_author(); ?>" class="author"><?php the_author(); ?></a></span>
</div>
<div class="entry">
<?php the_content(); ?>
<ul>
<?php $recent = new WP_Query("cat=126&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
</div>
</div>
<?php
comments_template();
?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Visst den listade posterna från kategorin, men sedan ville jag funktion att kunna kommentera sidan, så jag lade till det.
Men när man skriver en kommentar så tar den post id från den den sista posten av de som skrivits ut. Och det vill jag ju inte.
Hur undan komma detta?
Löste det med efter :
<?php get_header(); ?>
<?php
$thePostID = $post->ID;
?>
.... bla bla resterande kod innan comments_template...
<?php
$id = $thePostID;
comments_template();
?>
Så fick jag rätt ID för kommentarerna. :D
Fick göra en liten justering för att den skulle skriva ut posterna också..
<?php
$post = get_post($thePostID);
$id = $post->ID;
comments_template('', false);
?>
Sen om det är en korrekt lösning och den bästa.. det vet jag inte!