Modifying a function in a child php file
-
I’m trying to add a function to a functions.php file in my child theme that removes the dates in Posts, and also removes “Posted on” preceding where the dates go.
For the first part, I had success by adding a function from this web site:
http://johnlamansky.com/wordpress/remove-post-dates/
That worked. Then I added the function twentyeleven_posted_on() function from the parent theme functions.php file, removing “Posted on”. This did work, however today when I tried to login to WP, I get a blank screen consistently. When I rename functions.php in the child theme, I’m able to log in. I’m not sure if my commenting is incorrect, or if it is something else.
I’m not even sure my overall approach of bringing in the parent function and modifying it is correct, but that’s what I’ve found so far. Thanks.
functions.php follows:
<!-- comment --> <?php /* This code removes the dates in Posts, but still leaves "Posted on"; so not a complete solution yet. */ function jl_remove_post_dates() { add_filter('the_date', '__return_false'); add_filter('the_time', '__return_false'); add_filter('the_modified_date', '__return_false'); add_filter('get_the_date', '__return_false'); add_filter('get_the_time', '__return_false'); add_filter('get_the_modified_date', '__return_false'); } add_action('loop_start', 'jl_remove_post_dates'); /* Remove "Posted on". Function from parent theme. */ if ( ! function_exists( 'twentyeleven_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. * Create your own twentyeleven_posted_on to override in a child theme * * @since Twenty Eleven 1.0 */ function twentyeleven_posted_on() { printf( __( '<span class="sep"> </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ), get_the_author() ); } endif; ?>
[Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin. As it stands, your code has been permanently damaged/corrupted by the forum’s parser.]
- The topic ‘Modifying a function in a child php file’ is closed to new replies.