M
M
Minusator2018-08-20 22:15:44
WordPress
Minusator, 2018-08-20 22:15:44

How to change the icon in wordpress child theme?

Hello.
In the main theme on wordpress 4.9.8 there is a theme/includes/functions.php file, which has a post view counter function -

function theme_get_post_views_count_html( $args = array() ) {



  $r = wp_parse_args( $args, array(

    'class'   => '',

    'post_id' => get_the_ID(),

  ) );

  $views_count = theme_get_views_count( absint( $r[ 'post_id' ] ) );


  if( theme_is_view_count_tresholded( $views_count ) ) {

    return;

  }
  $class = 'post-meta-item post-views' . ( $r[ 'class' ] ? sprintf( ' %s', $r[ 'class' ] ) : '' );



  $icon = 'bb-ui-icon-eye';
  
  return sprintf( '<span class="%s"><span class="bb-icon ' . $icon . '"></span><span class="count">%s</span><span class="txt">%s</span></span>', $class, $views, _n( 'view', 'views', $views_count, 'theme' ) );

}

How can I change the output of the counter icon so that I do not change the file in the main theme, but do it from the child? Already broke my head

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Immortal_pony, 2018-08-20
@Minusator

In the child theme, create the function child_theme_get_post_views_count_html . Change it as necessary.
Copy all parent theme files that use the theme_get_post_views_count_html call . Replace with calling child_theme_get_post_views_count_html

S
Sumor, 2015-02-10
@Sumor

For me, it's better to combine everything, and then calculate. Something like this (possible syntax errors):

SELECT COUNT(*) AS count
FROM orders o 
JOIN order_comments oc ON o.id = oc.order_id
JOIN order_comment_views ocv ON ocv.comment_id = oc.id
WHERE o.id =286 AND ocv.user_id =1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question