Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
219 views
in Plugins by
I tested: 

public function post_meta_where($post, $class) {

    if (isset($post['raw']['categoryid'], $post['where']['data'])) {

        $categoryId = $post['raw']['categoryid'];

        $post['where']['data'] = str_replace('class="qa-category-link', 'class="qa-category-link qa-category-link-' . $categoryId,     $post['where']['data']);

    }

    qa_html_theme_base::post_meta_where($post, $class);

}

but it gives me error.
What I want is to do what this image.

by
This question is duplicated: http://www.question2answer.org/qa/39875

1 Answer

+1 vote
by
edited by

what is the error ? the pointers to data are valid , the replace idem ...

did you try the simplest :

$post['where']['prefix'] = '<span class="qa-category-link-' . $categoryId.'">'. $post['where']['prefix'] . '</span>' ;

I tested it, it works if you have the css with the icons specification. ie with SnowFlat and its icons :

.qa-category-link-3 {
    position: relative;
    padding-right: 20px;
}

.qa-category-link-3:after {
    position: absolute;
    top: 0;
    right: 0;
    width: 17px;
    margin-left: 32px;
    height: 100%;
    display: block;
    content: url('images/icons/mail.png');
}

 

and in the theme

    public function post_meta_where($post, $class)
    {
if (isset($post['raw']['categoryid'], $post['where']['data']))
   {

        $post['where']['prefix'] = '<span class="qa-category-link-' . $post['raw']['categoryid'].'">'. $post['where']['prefix'] . '</span>' ;
        parent::post_meta_where($post, $class) ;
      }
 }

 

...