*

pietkei

  • ***
  • 69 posts
How to exclude a sub category from mainpage?
« on: July 28, 2021, 04:17:58 PM »
Hello,

Is it possible to exclude a sub category from showing on the mainpage?

Thanks!

*

MB Themes

Re: How to exclude a sub category from mainpage?
« Reply #1 on: July 29, 2021, 01:59:23 PM »
@pietkei
You can update inc-search.php / inc.category.php and put there restriction on IDs.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pietkei

  • ***
  • 69 posts
Re: How to exclude a sub category from mainpage?
« Reply #2 on: July 29, 2021, 06:41:01 PM »
@pietkei
You can update inc-search.php / inc.category.php and put there restriction on IDs.

Thanks, i looked into the files, but it's to technical for me. :-[

I want to exclude this subcatecory: https://marktplaats24.nl/te-koop/dieren

All help is appreciated!

Pieter

*

MB Themes

Re: How to exclude a sub category from mainpage?
« Reply #3 on: July 30, 2021, 08:03:28 AM »
@pietkei
Go to inc.category.php of theme and find this code:
Code: [Select]
          <div class="line" style="width:<?php echo osc_count_categories()*($width 4) - 2?>px;">
            <?php osc_goto_first_category(); ?>
            <?php while(osc_has_categories()) { ?>
              <?php 
                $search_params
['sCategory'] = osc_category_id(); 
                
$color gam_get_cat_color(osc_category_id());
              
?>



and bellow line with $color add following:
Code: [Select]
if(osc_category_id() == 5) {
  continue;
}

Whole code will be :
Code: [Select]
          <div class="line" style="width:<?php echo osc_count_categories()*($width 4) - 2?>px;">
            <?php osc_goto_first_category(); ?>
            <?php while(osc_has_categories()) { ?>
              <?php 
                $search_params
['sCategory'] = osc_category_id(); 
                
$color gam_get_cat_color(osc_category_id());

                if(
osc_category_id() == 5) {
                  continue;
                }
              
?>


Number 5 should be replaced with ID of your category.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pietkei

  • ***
  • 69 posts
Re: How to exclude a sub category from mainpage?
« Reply #4 on: July 30, 2021, 12:37:57 PM »
Thanks!

I changed the code as you suggested:

Code: [Select]
<div class="line" style="width:<?php echo osc_count_categories()*($width 4) - 2?>px;">
            <?php osc_goto_first_category(); ?>
            <?php while(osc_has_categories()) { ?>
              <?php 
                $search_params
['sCategory'] = osc_category_id(); 
                
$color gam_get_cat_color(osc_category_id());
                
                if(
osc_category_id() == 9) {
                  continue;
                }                         
              
?>

When showing the mainpage the subcategory is still there.

I doubt if i have the right subcategory ID.
I found the subcategory ID using the ID i found under category icons.

Thanks!
Pieter