drd29
Forum Replies Created
-
Ideally I would prefer
2) Or are you instead trying to remove only the specific word "Category:" or "Tag:" and leave visible the name of the category itself, like "Travel"?For now I’ve added the code you mentioned and that’s half my problem solved, thank you so much Kathryn for taking the time to help me!
Hi Kathryn, thanks for your help! I’ve updated the style sheet and functions.php. The child theme in itself seems to be working, but my original issue of removing the “Category:” and “Tag:” text hasn’t been resolved. Any idea where I’m going wrong?
Here’s what I have for my functions.php now:
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); if ( ! function_exists( 'the_archive_title' ) ) : /** * Shim for <code>the_archive_title()</code>. * * Display the archive title based on the queried object. * * @todo Remove this function when WordPress 4.3 is released. * * @param string $before Optional. Content to prepend to the title. Default empty. * @param string $after Optional. Content to append to the title. Default empty. */ function the_archive_title( $before = '', $after = '' ) { if ( is_category() ) { $title = sprintf( __( '%s', 'canard' ), single_cat_title( '', false ) ); } elseif ( is_tag() ) { $title = sprintf( __( '%s', 'canard' ), single_tag_title( '', false ) ); } elseif ( is_author() ) { $title = sprintf( __( 'Author: %s', 'canard' ), '<span class="vcard">' . get_the_author() . '</span>' ); } elseif ( is_year() ) { $title = sprintf( __( 'Year: %s', 'canard' ), get_the_date( _x( 'Y', 'yearly archives date format', 'canard' ) ) ); } elseif ( is_month() ) { $title = sprintf( __( 'Month: %s', 'canard' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'canard' ) ) ); } elseif ( is_day() ) { $title = sprintf( __( 'Day: %s', 'canard' ), get_the_date( _x( 'F j, Y', 'daily archives date format', 'canard' ) ) ); } elseif ( is_tax( 'post_format' ) ) { if ( is_tax( 'post_format', 'post-format-aside' ) ) { $title = _x( 'Asides', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = _x( 'Galleries', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = _x( 'Images', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = _x( 'Videos', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = _x( 'Quotes', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = _x( 'Links', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = _x( 'Statuses', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = _x( 'Audio', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = _x( 'Chats', 'post format archive title', 'canard' ); } } elseif ( is_post_type_archive() ) { $title = sprintf( __( 'Archives: %s', 'canard' ), post_type_archive_title( '', false ) ); } elseif ( is_tax() ) { $tax = get_taxonomy( get_queried_object()->taxonomy ); /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ $title = sprintf( __( '%1$s: %2$s', 'canard' ), $tax->labels->singular_name, single_term_title( '', false ) ); } else { $title = __( 'Archives', 'canard' ); } /** * Filter the archive title. * * @param string $title Archive title to be displayed. */ $title = apply_filters( 'get_the_archive_title', $title ); if ( ! empty( $title ) ) { echo $before . $title . $after; } } endif; }Thank you, webkong and Siobhan!
I set up the child theme and followed the notes above and from the link you sent (https://codex.ww.wp.xz.cn/Child_Themes), but I seem to have done something wrong because I caused my site to go down when I uploaded the child theme. I had named the child theme folder “canard-child”. I’m not sure what I’ve missed?
I also included the enqueuing for rtl.css – was I supposed to skip that?
Appreciate your help, as always. Thank you.This is the style.css I used:
/* Theme Name: Canard Child Theme URI: http://www.theindiaedition.com/canard-child/ Description: Canard child theme Author: DRD Author URI: http://www.theindiaedition.com Template: canard Version: 1.0.0 Text Domain: canard-child */And this is my functions.php file:
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/rtl.css' ); if ( ! function_exists( 'the_archive_title' ) ) : /** * Shim for <code>the_archive_title()</code>. * * Display the archive title based on the queried object. * * @todo Remove this function when WordPress 4.3 is released. * * @param string $before Optional. Content to prepend to the title. Default empty. * @param string $after Optional. Content to append to the title. Default empty. */ function the_archive_title( $before = '', $after = '' ) { if ( is_category() ) { $title = sprintf( __( '%s', 'canard' ), single_cat_title( '', false ) ); } elseif ( is_tag() ) { $title = sprintf( __( '%s', 'canard' ), single_tag_title( '', false ) ); } elseif ( is_author() ) { $title = sprintf( __( 'Author: %s', 'canard' ), '<span class="vcard">' . get_the_author() . '</span>' ); } elseif ( is_year() ) { $title = sprintf( __( 'Year: %s', 'canard' ), get_the_date( _x( 'Y', 'yearly archives date format', 'canard' ) ) ); } elseif ( is_month() ) { $title = sprintf( __( 'Month: %s', 'canard' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'canard' ) ) ); } elseif ( is_day() ) { $title = sprintf( __( 'Day: %s', 'canard' ), get_the_date( _x( 'F j, Y', 'daily archives date format', 'canard' ) ) ); } elseif ( is_tax( 'post_format' ) ) { if ( is_tax( 'post_format', 'post-format-aside' ) ) { $title = _x( 'Asides', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = _x( 'Galleries', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = _x( 'Images', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = _x( 'Videos', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = _x( 'Quotes', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = _x( 'Links', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = _x( 'Statuses', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = _x( 'Audio', 'post format archive title', 'canard' ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = _x( 'Chats', 'post format archive title', 'canard' ); } } elseif ( is_post_type_archive() ) { $title = sprintf( __( 'Archives: %s', 'canard' ), post_type_archive_title( '', false ) ); } elseif ( is_tax() ) { $tax = get_taxonomy( get_queried_object()->taxonomy ); /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ $title = sprintf( __( '%1$s: %2$s', 'canard' ), $tax->labels->singular_name, single_term_title( '', false ) ); } else { $title = __( 'Archives', 'canard' ); } /** * Filter the archive title. * * @param string $title Archive title to be displayed. */ $title = apply_filters( 'get_the_archive_title', $title ); if ( ! empty( $title ) ) { echo $before . $title . $after; } } endif; } ?>