estmit
Forum Replies Created
-
The website is officialnightingalemovie.com in case you wanted to take a look at it.
Hi Andrew,
You recommended
.menu ainstead of.menuin your original post so I never used.menuin my code. I tried using.main-navigationinstead but that didn’t work either. In fact, I tried using justh1in the script and that didn’t do anything to the site except for unscrambling the navigation menu.I tried making the following change: creating the folder
/jsinside my child theme (/harmonic-child/js) and pasted the script file in it since the function callget_stylesheet_directory_uri()in myfunctions.phpreturns the stylesheet directory for the current theme and not the parent theme. I cleared my cache everytime I made changes. Any reason why it still doesn’t work?Hello Andrew,
I followed your advice and created a child theme. I made the following changes to my files and I then tried changing the theme to the child theme under Appearance/Themes but it doesn’t seem to work: the Chinese characters are not showing up as red. In fact, the menu becomes unscrambled into just a list of page links :
/harmonic/js/red-zh-char.js
(function($) { $('h1, .menu a').each(function() { var text = $(this).html(); $(this).html(text.replace(/([\u4E00-\u9FFF])/g, '<span lang="zh">$1</span>')); }); })(jQuery);/harmonic-child/style.css
/* Theme Name: Harmonic Child Theme URI: https://wordpress.com/themes/harmonic/ Description: Harmonic makes your content sing. No matter if you are a band looking to get a record deal, a travel blogger wanting to document your trip around the world or just someone that wants to make their home on WordPress. Author: Automattic Author URI: https://wordpress.com/themes/ Template: harmonic Version: 1.0.11 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: black, white, one-column, two-columns, fluid-layout, responsive-layout, custom-colors, custom-header, custom-menu, editor-style, featured-images, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready Text Domain: harmonic */ span[lang="zh"] { color: #dd0c23; }/harmonic-child/functions.php
<?php // Opening PHP tag - nothing should be before this, not even whitespace function theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function red_zh_char_method() { wp_enqueue_script( 'red-zh-char-script', get_stylesheet_directory_uri() . '/js/red-zh-char.js', array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'red_zh_char_method' );Any insight as to why that is the case?
^ I have not, so I shall go straight into setting a child theme. Thanks Andrew! Do you have any insights into how I could perform the same selective color change for the menu bar?
^ I am not sure where I should insert the span code into the style.css but since the code worked for my test case I assume it would work for this too.
^ I’m not sure how to incorporate the span css code so that it could make Chinese characters inside h1 tag red colored.
I tested the script on a html with a css file containing only the span statement and it worked, so I was just wondering how I can make it work on the style.css for harmonic theme