Display only parent category

Posted in: Newsmag
Post count: 16

I am looking for a quick way to display only the top parent category within part of the theme’s template. i.e. is there a function where I can use something like ‘<?php echo $this->get_parent_category(); ?>’ within one of the ‘td_module_#.php’ files?

This would be a very beneficial feature.

Post count: 6535

Hi

I am not sure where you want to display the parent category but there are two situations:
– if you want to display it on posts then you will need a new function in td_module_single_base.php file: http://screencast.com/t/0gBPfJtP7 then call the function in loop file corresponding with the post template used: http://screencast.com/t/N9ZTjVYB The result will be like here: http://screencast.com/t/mIh5zDfdE

<?php echo $td_mod_single->get_parent_category(); ?>

– if you want to display it on modules the file that must be edited is td_module.php: http://screencast.com/t/5oCbVAjEc then call the function on each module where you want to display the parent category: http://screencast.com/t/ZmCrrUDeNY6http://screencast.com/t/jgJDfRbaS

<?php echo $this->get_parent_category(); ?>

Here is the code of the function used as example: http://pastebin.com/1vHDfyJq
Note that this is just a basic example but can be used in many different way depending by the desired result. I didn’t applied any style on it, but this can also e done using css class in side php code. You can use others functions from the theme as example but please consider that this customizations require good coding skills and also many tests in order to work fine. Unfortunately time does not allow us to provide any custom services at the moment so if you still need guidance on this or you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you.

Thanks!

  • This reply was modified 10 years by Andrei L..
Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.