如何重定向wordpress中的帖子?

时间:2011-04-28 11:37:34

标签: wordpress

我正在使用wordpress,我的主页上有9个帖子

当有人点击其中一个帖子时,我不希望帖子打开

我想打开一个其他页面(一个特定的类别),所以你能告诉我该怎么做吗?

最好的问候

2 个答案:

答案 0 :(得分:0)

在你的循环中,你需要修改指向该帖子的类别。

您的主页可以在index.php和home.php上设置。我建议改为创建一个模板页面和一个新页面并将该模板链接到它。这样你就可以保留index.php和home.php完整的后备情况。

如果你想要它是动态的,你可以在这里查看类别codex:http://codex.wordpress.org/Function_Reference/get_category_link

答案 1 :(得分:0)

在你的循环中,如果is_sticky为真,则运行条件到类别而不是永久链接。

许多主题包含一个包含所有条件等的loop.php文件。基本前提是:

<?php if (have_posts()) : while (have_posts()) : the_post();  ?>

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
$category_id = get_cat_ID($post->ID);
$category_link = get_category_link($category_id);

if (is_sticky() { ?>

<a href="<?php echo $category_link; ?>" title="<?php the_title();"><?php the_title(); ?></a>

<?php } else { ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title();"><?php the_title(); ?></a>

<?php } ?>