Show categorie name in "latest articles"

Posted in: Newspaper
Post count: 15

Hello

How can I display the categorie name (next to the date) in the “latest articles” in the homepage.

latest article

Regards
Ewing

website : http://riddimtunup.com
version: V3

Post count: 24

I’m sorry I can’t help with your question, but I have to ask you how did you get your category title to show up on your category pages?

Post count: 854

hi,
overwrite the code from module 6 with this one:


<?php

class td_module_6 extends td_module {

    function __construct($post) {
        //run the parrent constructor
        parent::__construct($post);
    }

    function render() {

        $buffy = '';
        $buffy .= '<div class="td_mod6 td_mod_wrap" ' . $this->get_item_scope() . '>';
        $buffy .= $this->get_image('art-wide');
        $buffy .= $this->get_title(td_util::get_option('tds_mod6_title_excerpt'));

        $buffy .= '<div class="meta-info">';
            //$buffy .= $this->get_author();
            $buffy .= $this->get_date();
            $buffy .= ' - ' . $this->get_category();
            //$buffy .= $this->get_commentsAndViews();
        $buffy .= '</div>';

        $buffy .= $this->get_item_scope_meta();
        $buffy .= '</div>';
        return $buffy;
    }

    function get_category() {
        $buffy = '';

        //read the post meta to get the custom primary category
        $td_post_theme_settings = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
        if (!empty($td_post_theme_settings['td_primary_cat'])) {
            //we have a custom category selected
            $selected_category_obj = get_category($td_post_theme_settings['td_primary_cat']);
        } else {
            //get one auto
            $categories = get_the_category($this->post->ID);
            if (!empty($categories[0])) {
                if ($categories[0]->name === TD_FEATURED_CAT and !empty($categories[1])) {
                    $selected_category_obj = $categories[1];
                } else {
                    $selected_category_obj = $categories[0];
                }
            }
        }

        if (!empty($selected_category_obj)) { //@todo catch error here
            $buffy .= '<a href="' . get_category_link($selected_category_obj->cat_ID) . '">'  . $selected_category_obj->name . '</a>' ;
        }

        //return print_r($post, true);
        return $buffy;
    }
}
?>

like: http://screencast.com/t/Z25pzA862

Thanks for you message.
Radu A.

Post count: 15

Hello Radu
Thank you for your reply.

I use the module 3, could you provide me a code for this module

see my page: http://riddimtunup.com

Best regards

Post count: 854

hi,

class td_module_3 extends td_module {

    function __construct($post) {
        //run the parrent constructor
        parent::__construct($post);
    }

    function render() {
        ob_start();
        ?>

        <div class="td_mod3 td_mod_wrap <?php echo $this->get_no_thumb_class();?>" <?php echo $this->get_item_scope();?>>
        <?php echo $this->get_image('art-thumb');?>
        <div class="item-details">
            <?php echo $this->get_title(td_util::get_option('tds_mod3_title_excerpt'));?>
            <div class="meta-info">
                <?php //echo $this->get_author();?>
                <?php echo $this->get_date();?>

                <?php echo ' - ' . $this->get_category();?>

                <?php //echo $this->get_commentsAndViews();?>
            </div>
        </div>
        <?php echo $this->get_item_scope_meta();?>
        </div>

        <?php return ob_get_clean();
    }

    function get_category() {
        $buffy = '';

        //read the post meta to get the custom primary category
        $td_post_theme_settings = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
        if (!empty($td_post_theme_settings['td_primary_cat'])) {
            //we have a custom category selected
            $selected_category_obj = get_category($td_post_theme_settings['td_primary_cat']);
        } else {
            //get one auto
            $categories = get_the_category($this->post->ID);
            if (!empty($categories[0])) {
                if ($categories[0]->name === TD_FEATURED_CAT and !empty($categories[1])) {
                    $selected_category_obj = $categories[1];
                } else {
                    $selected_category_obj = $categories[0];
                }
            }
        }

        if (!empty($selected_category_obj)) { //@todo catch error here
            $buffy .= '<a href="' . get_category_link($selected_category_obj->cat_ID) . '">'  . $selected_category_obj->name . '</a>' ;
        }

        //return print_r($post, true);
        return $buffy;
    }

}

Thanks for you message.
Radu A.

Post count: 15

Many thanks Radu, Just one more thing

How can I have a no clickable category, I just want the name of the category without the internal link.

Best regards

Post count: 854

hi,

class td_module_3 extends td_module {

function __construct($post) {
//run the parrent constructor
parent::__construct($post);
}

function render() {
ob_start();
?>

<div class="td_mod3 td_mod_wrap <?php echo $this->get_no_thumb_class();?>" <?php echo $this->get_item_scope();?>>
    <?php echo $this->get_image('art-thumb');?>
    <div class="item-details">
        <?php echo $this->get_title(td_util::get_option('tds_mod3_title_excerpt'));?>
        <div class="meta-info">
            <?php //echo $this->get_author();?>
            <?php echo $this->get_date();?>

            <?php echo ' - ' . $this->get_category();?>

            <?php //echo $this->get_commentsAndViews();?>
        </div>
    </div>
    <?php echo $this->get_item_scope_meta();?>
</div>

<?php return ob_get_clean();
}

function get_category() {
    $buffy = '';

    //read the post meta to get the custom primary category
    $td_post_theme_settings = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
    if (!empty($td_post_theme_settings['td_primary_cat'])) {
        //we have a custom category selected
        $selected_category_obj = get_category($td_post_theme_settings['td_primary_cat']);
    } else {
        //get one auto
        $categories = get_the_category($this->post->ID);
        if (!empty($categories[0])) {
            if ($categories[0]->name === TD_FEATURED_CAT and !empty($categories[1])) {
                $selected_category_obj = $categories[1];
            } else {
                $selected_category_obj = $categories[0];
            }
        }
    }

    if (!empty($selected_category_obj)) { //@todo catch error here
        $buffy .= $selected_category_obj->name;
    }

    //return print_r($post, true);
    return $buffy;
}

}

Thanks for you message.
Radu A.

Post count: 15

Many thanks Radu, you’re the best

Post count: 3

What do i have to do to achieve this with module 2 on the frontpage (featured category)?

I copy-pasted the get_category() function and implemented the other function in render() but it doesn’t work.

Sorry for hijacking this Thread. Thanks in advance!

Post count: 854

hi,

take a look how the code from module 3 is done and make the appropriate changes.

Thanks for you message.
Radu A.

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