我认为最好的解决方案是添加一个get属性,在这种情况下,我们不需要像这样的javascript:您的single。php:
<div id="product-information">
<div id="tabs" class="htabs">
<a href="<?php the_permalink(); ?>&tab=description" class="<?php echo !isset($_GET[\'tab\']) || ($_GET[\'tab\'] == \'description\') ? \'selected\':\'\'; ?>">Description</a>
<a href="<?php the_permalink(); ?>&tab=comment" class="<?php echo isset($_GET[\'tab\']) && ($_GET[\'tab\'] == \'comment\') ? \'selected\':\'\'; ?>">Comments</a>
<a href="<?php the_permalink(); ?>&tab=review" class="<?php echo isset($_GET[\'tab\']) && ($_GET[\'tab\'] == \'review\') ? \'selected\':\'\'; ?>">Reviews</a>
</div>
<div id="tab-description" class="tab-content" style="display: <?php echo !isset($_GET[\'tab\']) || ($_GET[\'tab\'] == \'description\') ? \'block;\':\'none;\'; ?>">
<?php the_content(); ?>
</div>
<div id="tab-comment" class="tab-content" style="display: <?php echo isset($_GET[\'tab\']) && ($_GET[\'tab\'] == \'comment\') ? \'block;\':\'none;\'; ?>">
<?php if ( comments_open() || true): ?>
<?php comments_template( \'\', true ); ?>
<?php endif ?>
</div>
<div id="tab-review" class="tab-content" style="display: <?php echo isset($_GET[\'tab\']) && ($_GET[\'tab\'] == \'review\') ? \'block;\':\'none;\'; ?>;">
<h1>REVIEW</h1>
</div>
</div>
在你的功能中。php添加以下内容:
if ( ! function_exists( \'redirect_after_comment\' ) ) {
function redirect_after_comment($location)
{
return get_permalink().\'&tab=comment\';
}
}
add_filter(\'comment_post_redirect\', \'redirect_after_comment\');