Display multiple categories on Block 12

Posted in: Newspaper
Post count: 31

I’d like to display more than one category name/link in the meta info of each post in Block 12, like in the single posts where you can see more than one. Is there some code from the single post loop that can be re-used to do this in td_module_mx11.php? I don’t want to choose a primary category, I want to be able to display at least two.

http://thekineticist.com/2016/04/15/art-dance-collaboration-in-philadelphia/
Single post > Multiple categories displayed here

Thanks.
Rachel

Post count: 22421
Post count: 31

Unfortunately,that’s not quite what I need.

Post count: 22421

Hi
This method will display multiple categories on a module but it will also grab the colors from the category tag. The standard category tag for modules was designed to grab only the primary category of the post, not multiple ones.
Thank you!

Post count: 1

I’ve resolved in this way:
On Newspaper/includes/modules/td-module_numberofyourmodule.php
i’ve added this:


<div class="td-module-meta-info">
<?php if (td_util::get_option('tds_category_module_11') == 'yes') { 
$postid = get_the_ID();                  
$post_categories = wp_get_post_categories( $postid );
$cats = array();
foreach($post_categories as $c){
  $cat = get_category($c);
  $cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug);
  $catid=get_cat_ID($cat->name);
  $category_link = get_category_link($catid);
  echo "<a>$cat->name</a>";} ?>
<?php echo $this->get_author();?>
<?php echo $this->get_date();?>
<?php echo $this->get_comments();                    
/* echo $this->get_category();*/ } ?>
</div>

Istead of:


<div class="td-module-meta-info">
                    <?php if (td_util::get_option('tds_category_module_11') == 'yes') { echo $this->get_category(); }?>
                    <?php echo $this->get_author();?>
                    <?php echo $this->get_date();?>
                    <?php echo $this->get_comments();?>
                </div>

Please, tell me if this can cause any problems on template, and if there is a way to set this for all modules without modifying all the module files.
Thanks.

Gabriele.

Post count: 20688

Hi,


@SerenityStore
If it causes problems remove the code. Make tests to see if it works as you want. Modify the modules you want in a child theme, this way you will not loose the customization after a theme update.

By default the theme modules are created to display only the primary category of the post
https://forum.tagdiv.com/primary-category/
Displaying more is not possible by a theme setting, it may also damage the design of the module. Each module will have to be modified in order to allow this.

Maybe in the future such an option will be available, can’t say for sure. Sorry for any inconvenience.

Thanks

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.