-
AuthorPosts
-
September 22, 2018 at 3:28 pm #1013079
I’m sorry. I thought I found the solution yesterday and since there was no reply I assumed it was better to remove the post.
I followed your instructions but the the changes affect the blog pages too.
This is what I got so far:
I created a file ‘front-page.php’ in the theme directory.
<?php if ( !defined('ABSPATH') ){ die(); } global $avia_config, $more; wp_head(); get_template_part( 'includes/loop', 'index' ); wp_footer(); ?>
The reason I did this was because the normal Enfold frontpage came with a lot of html, the <div class=”container”> was one to many for example.
Second I combined all the custom JS into one script, but this one only works if its loaded in the footer
So this is how the config.php looks like
add_action( 'wp_footer', 'my_custom_scripts' ); function my_custom_scripts() { wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/scripts.js', array( 'jquery' )); } add_action( 'wp_enqueue_scripts', 'edit_css', 20 ); function edit_css() { wp_dequeue_style( 'avia-base' ); wp_deregister_style( 'avia-base' ); wp_dequeue_style( 'avia-dynamic' ); wp_deregister_style( 'avia-dynamic' ); wp_dequeue_style( 'avia-grid' ); wp_deregister_style( 'avia-grid' ); //Added some css needed for the homepage to work wp_register_style( 'bootstrap', get_stylesheet_directory_uri() .'/css/bootstrap.min.css'); wp_enqueue_style( 'bootstrap' ); wp_register_style( 'animate', get_stylesheet_directory_uri() .'/css/animate.css','style'); wp_enqueue_style( 'animate' ); wp_enqueue_style( 'style', get_stylesheet_uri() ); } add_action( 'wp_head', 'remove_my_action' ); function remove_my_action(){ //One of them removed some unwanted html remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'adjacent_posts_rel_link'); }
The homepage is a static page. So I was hoping if I add this to the script above it would only influence the homepage
if ( is_front_page() && is_home() ) { ... }
Unfortunately, the code above including the
if ( is_front_page() && is_home() ) { ... }
is also affecting a normal blog post. I want the blog posts to render normal (enfold config).You suggest to add if ( !is_front_page() && !is_home() ) { … } around it. I tried that too, but it doesn’t render the normal blog posts in Enfold style.
- This topic was modified 6 years, 3 months ago by tijshensen.
September 22, 2018 at 6:18 pm #1013108Hey tijshensen,
I assume that you would like to remove all the CSS & jQuery of the theme for the homepage only, you can do this by adding:if ( !is_front_page() && !is_home() ) {
before the “register js” & “register styles” in the functions.php, please go to line 358 and fine this code block:
//register js wp_enqueue_script( 'avia-compat', $template_url.'/js/avia-compat.js' , array(), $vn, false ); //needs to be loaded at the top to prevent bugs wp_enqueue_script( 'avia-default', $template_url.'/js/avia.js', array('jquery'), $vn, true ); wp_enqueue_script( 'avia-shortcodes', $template_url.'/js/shortcodes.js', array('jquery','avia-default'), $vn, true ); wp_enqueue_script( 'jquery' ); //register styles wp_register_style( 'avia-style' , $child_theme_url."/style.css", array(), $vn, 'all' ); //only include in childthemes. has no purpose in main theme wp_register_style( 'avia-custom', $template_url."/css/custom.css", array(), $vn, 'all' ); wp_enqueue_style( 'avia-grid' , $template_url."/css/grid.css", array(), $vn, 'all' ); wp_enqueue_style( 'avia-base' , $template_url."/css/base.css", array('avia-grid'), $vn, 'all' ); wp_enqueue_style( 'avia-layout', $template_url."/css/layout.css", array('avia-base'), $vn, 'all' ); wp_enqueue_style( 'avia-scs', $template_url."/css/shortcodes.css", array('avia-layout'), $vn, 'all' );
and add the condition before and a single bracket after, like this:
if ( !is_front_page() && !is_home() ) { //register js wp_enqueue_script( 'avia-compat', $template_url.'/js/avia-compat.js' , array(), $vn, false ); //needs to be loaded at the top to prevent bugs wp_enqueue_script( 'avia-default', $template_url.'/js/avia.js', array('jquery'), $vn, true ); wp_enqueue_script( 'avia-shortcodes', $template_url.'/js/shortcodes.js', array('jquery','avia-default'), $vn, true ); wp_enqueue_script( 'jquery' ); //register styles wp_register_style( 'avia-style' , $child_theme_url."/style.css", array(), $vn, 'all' ); //only include in childthemes. has no purpose in main theme wp_register_style( 'avia-custom', $template_url."/css/custom.css", array(), $vn, 'all' ); wp_enqueue_style( 'avia-grid' , $template_url."/css/grid.css", array(), $vn, 'all' ); wp_enqueue_style( 'avia-base' , $template_url."/css/base.css", array('avia-grid'), $vn, 'all' ); wp_enqueue_style( 'avia-layout', $template_url."/css/layout.css", array('avia-base'), $vn, 'all' ); wp_enqueue_style( 'avia-scs', $template_url."/css/shortcodes.css", array('avia-layout'), $vn, 'all' ); }
Best regards,
MikeSeptember 23, 2018 at 8:55 pm #1013417Finally I came up with this solution:
// Register and enqueue scripts add_action( 'wp_footer', 'my_custom_scripts' ); function my_custom_scripts() { if( is_home() || is_front_page() ){ wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/scripts.js', array( 'jquery' )); } } add_action( 'wp_enqueue_scripts', 'edit_css', 9999 ); function edit_css() { if( is_home() || is_front_page() ){ wp_dequeue_style( 'avia-base' ); wp_deregister_style( 'avia-base' ); wp_dequeue_style( 'avia-dynamic' ); wp_deregister_style( 'avia-dynamic' ); wp_dequeue_style( 'avia-grid' ); wp_deregister_style( 'avia-grid' ); wp_register_style( 'bootstrap', get_stylesheet_directory_uri() .'/css/bootstrap.min.css'); wp_enqueue_style( 'bootstrap' ); wp_register_style( 'animate', get_stylesheet_directory_uri() .'/css/animate.css','style'); wp_enqueue_style( 'animate' ); wp_register_style( 'homepage', get_stylesheet_directory_uri() .'/css/homepage.css','style'); wp_enqueue_style( 'homepage' ); } }
September 24, 2018 at 4:55 am #1013469Hi,
Great, glad you managed to get a working solution and thanks for sharing. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardSeptember 24, 2018 at 10:00 am #1013531Thanks for the great support! You can close the topic.
September 24, 2018 at 10:04 am #1013532Hi!
You are welcome! :)
For your information, you can take a look at Enfold documentation here – https://kriesi.at/documentation/enfold/
If you have any other questions or issues, feel free to start a new thread under Enfold sub forum and we will gladly try to help you :)Best regards,
Yigit -
AuthorPosts
- The topic ‘Remove Theme css’ is closed to new replies.