- This topic has 3 replies, 2 voices, and was last updated 9 years, 6 months ago by Theme Horse Support Team.
-
AuthorPosts
-
May 5, 2015 at 2:48 pm #24647aaron1Participant
Hi,
I’ve set up a child theme for the Attitude free version. I don’t wish to use the Google API fonts and don’t want the google_fonts-css stylesheet to load at all.
How can I prevent these fonts from being loaded? It appears they’re being called by \attitude\library\functions\functions.php by the following code:
function attitude_scripts_styles_method() { global $attitude_theme_options_settings; $options = $attitude_theme_options_settings; /** * Loads our main stylesheet. */ wp_enqueue_style( 'attitude_style', get_stylesheet_uri() ); /** * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /** * Register JQuery cycle js file for slider. * Register Jquery fancybox js and css file for fancybox effect. */ wp_register_script( 'jquery_cycle', ATTITUDE_JS_URL . '/jquery.cycle.all.min.js', array( 'jquery' ), '2.9999.5', true ); wp_register_style( 'google_fonts', '//fonts.googleapis.com/css?family=PT+Sans|Philosopher' ); /** * Enqueue Slider setup js file. * Enqueue Fancy Box setup js and css file. */ if( ( is_home() || is_front_page() ) && "0" == $options[ 'disable_slider' ] ) { wp_enqueue_script( 'attitude_slider', ATTITUDE_JS_URL . '/attitude-slider-setting.js', array( 'jquery_cycle' ), false, true ); } wp_enqueue_script( 'tinynav', ATTITUDE_JS_URL . '/tinynav.js', array( 'jquery' ) ); wp_enqueue_script( 'backtotop', ATTITUDE_JS_URL. '/backtotop.js', array( 'jquery' ) ); wp_enqueue_style( 'google_fonts' );
and
function attitude_add_editor_styles() { $font_url = str_replace( ',', '%2C', '//fonts.googleapis.com/css?family=PT+Sans:400,700italic,700,400italic' ); add_editor_style( $font_url ); } add_action( 'after_setup_theme', 'attitude_add_editor_styles' );
I’ve been experimenting with trying to deregister or dequeue ‘google_fonts’ from the child theme’s functions.php file, but I’m not terribly familiar with the syntax of the WordPress hooks, so nothing I’ve tried has worked at all.
Any suggestions?
Thanks!
May 6, 2015 at 5:16 am #24668Theme Horse Support TeamKeymasterHi aaron1,
This is an example how to unhook page 404.php and use your own content.
unhook functions
// Unhook default Thematic functions function unhook_thematic_functions() { // Don't forget the position number if the original function has one remove_action( 'attitude_404_content', 'attitude_display_404_page_content', 10 ); } add_action('init','unhook_thematic_functions'); // removes the header content by using hook attitude_header add_action( 'attitude_404_content', 'attitude_child_display_404_page_content', 10 ); /** * function to show the footer info, copyright information */ function attitude_child_display_404_page_content() { ?> <div id="content"> <header class="entry-header"> <h1 class="entry-title"><?php _e( 'Error 404-Page NOT Found', 'attitude' ); ?></h1> </header> <div class="entry-content clearfix" > <p>Thank you</p> </div><!-- .entry-content --> </div><!-- #content --> <?php }
You need to do the same in your child theme. Create a style.css file and functions.php file and unhook the functions.
http://codex.wordpress.org/Child_ThemesIf you are unable to unhook then you need to hire a developer to fix it.
Thank you!
May 6, 2015 at 5:33 am #24670aaron1ParticipantHi,
I appreciate the suggestions on the 404 page, but that’s not related to the specific problem I’m having.
My child theme has a stylesheet and functions.php. I’ve added several functions to the latter, which are working fine. However, I’m having trouble unhooking the Google fonts function.
I see that the parent theme’s function.php file is running a function called attitude_scripts_styles_method() and that this function is first registering the style ‘google-fonts’ and then enqueuing it. I’ve tried creating a function in the child functions.php file to deregister google-fonts, dequeue, or both, both as separate functions and together, but none of them are working.
I was able to do this successfully on another site with a different theme, but that theme handled the Google fonts hook differently (it had an individual function to register and enqueue that style, rather than doing that as part of another function), so it was easier to unhook. I sort of grasp the basics here, but I’m not a developer, so the structure of this specific function is confounding me.
May 7, 2015 at 4:44 am #24710Theme Horse Support TeamKeymasterHi aaron1,
Use
function unhook_thematic_functions() { add_action( 'wp_enqueue_scripts', 'attitude_scripts_styles_method' ); }
after this
add_action( 'wp_enqueue_scripts', 'attitude_child_scripts_styles_method'); function attitude_child_scripts_styles_method(){ // your stuff }
Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.