删除 Wordpress 中特定类别的标题 Link

Remove Title Link for Specific Category in Wordpress

我是 运行 Wordpress 4.1。我的网站上有两个博客页面,虽然我真的不知道 php,但我做了一些修补并弄清楚了如何修改页面模板,所以每个页面只显示 posts特定类别。这段代码看起来像这样:

<?php query_posts('cat=2'); ?>

效果很好。页面 A 显示来自类别 1 的 post 秒,页面 B 显示来自类别 2 的 post 秒。

我想做的是禁用 post 一个特定类别的标题链接。换句话说,页面 A 将显示来自类别 1 的 posts(带有标准的可点击标题链接),而页面 B 将显示来自类别 2 的 posts(带有 non-clickable 标题链接) .

我是一个 HTML/CSS 的人,所以真的超出了我的理解范围,但是如果有办法修改循环来实现这一点,我很乐意学习。在此先感谢您的帮助。

是的,您可以使用 category.php 主题文件来完成此操作。点击此页面时,它会加载请求的特定类别以及属于该类别的帖子。

您的主题和循环可能如下所示:

<?php single_cat_title(); ?>
<?php echo category_description(); ?>
if (have_posts()) : while (have_posts()) : the_post();
/// display posts from specific category
endwhile; endif;

或者,如果您不想使用专为此设计的页面,您可以创建自己的循环:

query_posts( array ( 'category_name' => 'my-category-slug', 'posts_per_page' => 50 ) );

像这样在一起:

<?php
/* retrieve unlimited # of posts with an category slug of music */

query_posts(  array ( 'category_name' => 'music', 'posts_per_page' => -1 )  );

// set $more to 0 in order to only get the first part of the post
global $more;
$more = 0;

// the Loop
while (have_posts()) : the_post();
    the_content( 'Read the full post »' );
endwhile;
?>