Add HTML inside a php function in functions.php
-
Disclaimer: my PHP knowledge is very very basic.
I have a child theme with a functions.php file in it. I don’t edit the parent functions.php at all however I want to override something. I can’t seem to do this w/o error though.
Currently in the parent functions.php (among other things) is this:
/** * Posts Meta Data. Category and Date. **/ function ti_meta_data(){ global $ti_option; // Category Name if ( is_single() ) { if ( $ti_option['single_post_cat_name'] == true ) { echo '<span class="entry-category">'; the_category(', '); echo '</span>'; } } else { echo '<span class="entry-category">'; the_category(', '); echo '</span>'; } // Date $publish_date = '<time class="entry-date updated" datetime="' . get_the_time( 'c' ) . '" itemprop="datePublished">' . get_the_time( get_option( 'date_format' ) ) . '</time>'; if ( is_home() || is_front_page() || is_page() ) { if ( $ti_option['home_post_date'] == 1 ) { echo $publish_date; } } if ( is_category() || is_tag() || is_author() ) { if ( $ti_option['archive_post_date'] == 1 ) { echo $publish_date; } } if ( is_single() ) { if ( $ti_option['single_post_date'] == 1 ) { echo $publish_date; } } }
I’d like to add the comment count before the categories because it’s missing for some reason. The theme does have it at the bottom where the comments are and so I can copy that php and add it to the meta_data function in functions.php:
comments_number(__('No Comments', 'themetext'), __('1 Comment', 'themetext'), __( '% Comments', 'themetext') );
However, how can do these changes in the child theme functions file without getting the error that this code already exists in the parent functions?
Also, I need to add a span around the comment count so i can add a class to it. Not sure where to add that in.
I am using SimpleMag theme
Thanks in advance!
- The topic ‘Add HTML inside a php function in functions.php’ is closed to new replies.