首页 文章

删除Wordpress中特定类别的 Headers 链接

提问于
浏览
0

我正在运行Wordpress 4.1 . 我的网站上有两个博客页面,虽然我真的不知道php,但我已经做了一些修改并弄清楚如何修改页面模板,因此每个页面只显示特定类别的帖子 . 这段代码看起来像这样:

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

这很好 . 页面A显示类别1的帖子,页面B显示类别2的帖子 .

我想要做的是禁用一个特定类别的帖子 Headers 链接 . 换句话说,页面A将显示来自类别1的帖子(具有标准可点击 Headers 链接),而页面B将显示来自类别2的帖子(具有不可点击的 Headers 链接) .

我是一个HTML / CSS的人,所以我真的不在这里,但如果有办法修改循环来达到这个目的,我很乐意学习如何 . 在此先感谢您的帮助 .

1 回答

  • 0

    是的,您可以使用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;
    ?>
    

相关问题