Excluding categories in the_category

Excluding categories in the_category

Excluding categories in the_category

<?php the_category() ?>
<?php
wp_list_categories('orderby=name&include=3,5,9,16'); ?>

<?php foreach((get_the_category()) as $cat) {
if (!($cat->cat_ID=='37')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', ';
} ?>



Hide / Exclude Categories From Posts Page

<?php if (is_front_page() && !is_paged() )
$posts = query_posts($query_string . '&cat=-35'); ?>

<?php
$cat_to_exclude = 35;
query_posts($query_string . '&cat=-'.$cat_to_exclude');
?>

<?php if (in_category('35')) continue; ?>


or



function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-5, -34' );
}
return $query;
}

add_filter( 'pre_get_posts', 'exclude_category_home' );


Exclude Category from Homepage

Placing this code in your index.php file will cause your home page to display posts from all categories except category ID 3.

<?php
if (is_home()) {
query_posts("cat=-3");
}
?>


You can also add some more categories to the exclude-list(tested with WP 2.1.2):

<?php
if (is_home()) {
query_posts("cat=-1,-2,-3");
}
?>


or

function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-3,-5,-23');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');


ID=2685,MSG=3331
Re: Excluding categories in the_category

Re: Excluding categories in the_category

<?php query_posts("cat=-25,35"); ?>

Look for this on your main theme index page:
<?php if (have_posts()) : ?>

Insert this right before (or above) it:
<?php query_posts('cat=-49'); ?>

Change the category ID to whatever it is you want to exclude.

<?php if (is_home()) {
  query_posts($query_string . "&cat=-33");
} ?>
<?php if(is_home()) {query_post("cat=-39");}?php>


<?php
$excluded_cats = array( 44, 55 );  // ids to exclude
$args = array(
  'caller_get_posts' => 1,  // Don't show stickies at top
  'posts_per_page' => 5,    // The number of latest to show
  'category__not_in' => $excluded_cats,
);
query_posts($args);



ID=2685,MSG=3332
Re: Excluding categories in the_category

Re: Excluding categories in the_category

Display all of a post's categories except the current category

if(is_category()):// only run this on category page
    $cc = get_queried_object();
    $exclude = $cc->cat_name; //get the name of current category page
endif;


<?php
if(is_category()):// only run this on category page
    $cc = get_queried_object();
    $exclude = $cc->cat_name; //get the name of current category page
endif;

$categories = get_the_category();
foreach($categories as $category) :

    if(is_category() && $category->name==$exclude)
        continue; //skip current category from being displayed only on category pages

    $category_link = get_category_link( $category->cat_ID );
    echo '<li><a href="'.$category_link.'">'.$category->cat_name.'</a></li>';
endforeach;
?>


ID=2685,MSG=3333
Re: Excluding categories in the_category

Re: Excluding categories in the_category

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

<!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
<?php if (in_category('3')) continue; ?>

<div class="post">

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

  <small><?php the_time('F jS, Y'); ?></small>

  <div class="entry">
    <?php the_content(); ?>
  </div>

  <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->

<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>


ID=2685,MSG=3334
ลูกค้าเราโทรได้ 24hr


⭐️ เราให้คำแนะนำปรึกษา รักษาผลประโยชน์ให้ลูกค้า ของเรา
⭐️ เราอยู่เคียงข้างลูกค้าของเรา ช่วยเหลือ ดูแลบริการ
⭐️ เรารองรับช่องทางติดต่อมากมาย สะดวก เข้าถึงง่าย
⭐️ เราดำเนินธุรกิจยาวนานกว่า20 ปี คุณจึงมั่นใจได้
⭐️ คุณมีสามารถรับบริการทั้งจากบริษัทประกันเจ้าของสินค้า และ เรา (ตัวกลาง)

ไทย มีราว 80 บริษัทประกันภัย สินค้าที่แตกต่าง ทั้ง เงื่อนไข ราคา เคลม ความมั่นคง นโยบาย ฯลฯ
ขายผ่านตัวกลาง กว่า 500,000 ราย : ตัวแทน นายหน้า ธนาคาร บิ๊กซี โลตัส ค่ายรถยนต์ เฮ้าส์แบรนด์ ของประกันภัย หรือ ซื้อตรงกับบริษัทเจ้าของสินค้า
⭐️ ตัวอย่าง การบริการ กดดูที่ลิงค์นี้

"สิ่งที่ต้องคำนึงอันดับแรกในการซื้อประกัน คือ ตัวกลางประกันภัย ซึ่งจะเป็นที่ปรึกษา ช่วยเหลือ ดูแลเรา ตลอดอายุกรมธรรม์"

โปรดรอ

display:inline-block; position:relative;
ลูกค้าเราโทรได้ 24hr



โทร.(จ-ศ : 9-16) เว้นวันหยุดฯ , ลูกค้าเรา บริการ 24/7/365 , Sunday เวลา 04:17:48am... กรุณาติดต่อ ช่องทางข้อความ
Copyright © 2018 Cymiz.com., All rights reserved.นโยบาย,ข้อตกลงcymiz.com