Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Gabriel!

    Please, check this answer. While is a slightly different requirement, the solution still applies in your case ??

    Thread Starter gabrieldilaurentis

    (@gabrieldilaurentis)

    Oh I’m afraid I’ll need a little more help with that ??

    I’m not a designer, just a simple user who’s learned a little CSS and html, and a grain of php but nowhere near enough to do this on my own. How do I create a filter for category for instance? Where do I place the code? Please help.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Ah, that’s a different story ??

    Adding the category tag(s) to the posts shouldn’t be too difficult. Same goes for the share buttons (although I don’t see them on the Featured tab).

    Problem is I’m awfully busy with work projects right now. I’m on a tight deadline and until I finish stuff here I have to put WPP (and most of the Internet) away. I’ll only check here occasionally to help people with quick questions and other minor stuff.

    If you’re also on a deadline and can’t wait, you should probably hire a developer to give you a hand with this right away. If that’s not the case, or if you’re willing to wait, I might be able to help you out once I get some spare time.

    Thread Starter gabrieldilaurentis

    (@gabrieldilaurentis)

    I guess I’m gonna have to wait since there isn’t anyone else available to help. Thank you in advance.

    Thread Starter gabrieldilaurentis

    (@gabrieldilaurentis)

    This is the code from the example:

    // Category option checked
        if ($instance['stats_tag']['category']) {
            $post_cat = get_the_category($popular->id);
            $post_cat = (isset($post_cat[0]))
              ? '<a href="' . get_category_link($post_cat[0]->term_id) . '">' . $post_cat[0]->cat_name . '</a>'
              : '';
    
            if ($post_cat != '') {
                $stats[] = '<span class="wpp-category">' . sprintf(__('under %s', 'wordpress-popular-posts'), $post_cat) . '</span>';
            }
        }

    and the code that I need integrated into the one above is

    <?php
    $categories = get_the_category();
    $separator = ' / ';
    $output = '';
    if($categories){
        foreach($categories as $category) {
                $rl_category_color = rl_color($category->cat_ID);
            $output .= '<a href="'.get_category_link( $category->term_id ).'" style="color:'.$rl_category_color.';">'.$category->cat_name.'</a>'.$separator;
        }
    echo trim($output, $separator);
    }
    ?>

    I’m not a developer, I know only a little css, I’m smart but not that smart, what I got is

    // Category option checked
        if ($instance['stats_tag']['category']) {
            $post_cat = get_the_category($popular->id);
            $post_cat = (isset($post_cat[0]))
    
                            ? '<a href="'.get_category_link($post_cat[0]->term_id).'"style="background-color:'.$rl_category_color.';">'.$post_cat[0]->cat_name.'</a>'
              : '';
    
            if ($post_cat != '') {
                $stats[] = '<span class="wpp-category">' . sprintf(__('under %s', 'wordpress-popular-posts'), $post_cat) . '</span>';
            }
        }

    For when you find a little time. Thank you in advance.

    Thread Starter gabrieldilaurentis

    (@gabrieldilaurentis)

    Managed to solve this one on my own. Again. Will open a new thread for a different question.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding custom code’ is closed to new replies.