I'm using the Astra theme (with the Astra Pro plugin). I'm trying to enqueue some custom editor styles for some block patterns I have created. I tried this first: add_theme_support('editor-styles'); but the moment I did--before even getting to add_editor_style--some unfortunate things happened, e.g. the text in a default paragraph block displayed much smaller. I was able to use the add_editor_style() function, and could then correct the problem with the small font size, but that means a lot of extra work to do to correct any other styles that inadvertently affected by the add_theme_support('editor-styles) function . Any ideas what I'm doing wrong? Please note: I am running WP v6.0.1, Astra theme 3.9.0 (with a child theme), and Astra Pro v3.9.0. I'd be grateful for any suggestions or assistance!
Here's the answer:
wp_enqueue_style( 'tg-pattern-styles', get_theme_file_uri( '/tg-pattern-styles.css' ) );
}
add_action( 'enqueue_block_assets', 'tg_block_styles' );```
It works for front and back end.
Related
I'm trying to disable the mobile formatting in the WP theme Ocean and I have this snip of code that should work. I know it needs to go in the Theme Functions (functions.php) file but I don't know where to place it within that file. I've tried at the end inside of the final braces, the code compiles but doesn't change anything.
//disable mobile responsive
function no_meta_viewport() {
return false;
}
add_filter( 'ocean_meta_viewport', 'no_meta_viewport' );
Thank you!
Ocean themes using widths as percent that mean even if change viewerport still it will act like mobil also the theme not using bootstrap that why you cant do with css.Shortly i dont think solution be easy, it need a lot of edit.
The theme author is loading the Google Maps API but it isn't being used on the site so I want to dequeue it in the child theme's functions.php. They don't offer an option to simply disable it within the theme settings.
Would someone mind helping me out with the wp_dequeue code? Also, is it technically more efficient to comment it out in the parent theme or dequeue it in the child theme? I know the inherent problems with modifying the parent theme code, but I doubt the author is going to update this theme in future. Thanks!
wp_enqueue_script('bazien-google-maps', 'https://maps.googleapis.com/maps/api/js?key='.$bazien_theme_options['google_maps_api'], array(), '1.0', FALSE);
If you want to do it the best WordPress way, you'll need to deregister it in the child theme. to do so, use the following :
wp_deregister_script( 'bazien-google-maps' );
It should make the job. To answer the other question, it's more efficient to comment it in the parent theme, because this way you don't load the script to "unload" it after. But, as you truly said, an update might appear somedays, so it's more secure to disable it in the child theme.
See the cod WordPress for more informations aboubt registering scripts and styles : here
and informations about deregistering : here
I've created child themes before without issue however when I create one using Woocommerce Mystile theme it does not display properly with menu items missing and images resizing to be too large.
I made the child theme by creating a new folder in the wp-content>themes folder called mystile-child and creating style.css with the contents
/*
Theme Name: Mystile Child
Description: Mystile Child Theme
Template: mystile
*/
I then created a functions.php file with the contents
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
this is what the parent theme looks like:
This what the child theme looks like
Just out of curiousity - were the logo and other missing elements set up intially using the theme customizer (reached via the wordpress admin menu Appearance > Customize)?
If that's the case, then those settings are created outside of your theme and need to be reset or imported for your child theme. There are a few ways to accomplish this, the easiest way being with a plugin which imports/exports those Customizer settings.
Hope that helps,
Laura
Okay I fixed the problem following the advice found on Wordpress.org support forum here https://wordpress.org/support/topic/mystile-theme-child-header-problem
Seems more of temporary fix though and something that the people at Woocommerce should investigate.
I am working on a WP plugin that uses bootstrap. However, it seems to be having a very strange affect on the page. You can see it here:
My Test Page
If you go to this page, then go to another, you will see that the page goes back to normal.
How can I prevent bootstrap from affecting the WP elements on the page?
add_action( 'wp_enqueue_scripts', 'bootstrap_css', 150 );
function bootstrap_css(){
// add pages for bootstrap leave out site address, just the path e.g.
$pages= array( '_3_8_0/rentals/','add_page_url' );
$path=$_SERVER['REQUEST_URI'];
if( !in_array($path, $pages) ):
wp_dequeue_style( 'bootstrap_handle' ); // look up handle for stylesheet
endif;
}
You can do something like the above to de_queue the bootstrap css on pages that you dont want it on. The problem is Bootstrap is not really designed for singular page use with a existing theme and will share a lot of common identifers with what your theme uses e.g. "content"
its either that or remove bootstrap altogether (just de-queue it) and style the page yourself. To be honest bootstrap is a heavy load for the use case here.
I have created a wordpress theme and I made it so the background image can easily be changed. The only problem is that currently I have to make the change manually (ie FTP) and Id like to provide my client with a Template options page with an "Upload new background image" option in it.
Im pretty sure this is possible, I just dont know where to start.
Could someone point me out in the right direction?
This will do it for you. Just add the following to your theme's functions.php file:
add_action( 'after_setup_theme', 'add_custom_background' );
This only works in WordPress 3.0 as of now. Of course, you should be running the latest version anyway. It will add a custom background menu in the admin area (under 'Appearance') and will add the styles to the body tag. Also handles uploading, centering/tiling (x, y, or both) images/background colors. Very simple and great functionality.