Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1404383
    JfantasyBooks
    Participant

    Hi there,

    Details:

    Name: JFantasyBooks
    Site: Fantasy-Books
    Site Url: https://fantasy-books.live
    WordPress Version: 4.7.1
    X Version: 4.6.4
    Cornerstone Plugin Version: 1.33

    Problem:

    I want to call a css file. I just don’t know how in the x theme and where I should call it.

    Can you help?

    #1404440
    Rupok
    Member

    Hi there,

    Do you want to add an external CSS file? You can follow this – https://community.theme.co/forums/topic/external-style-sheet-question/#post-702014

    I’d suggest to use Child Theme and use your CSS within Child Theme’s style.css.

    Cheers!

    #1405857
    JfantasyBooks
    Participant

    Thanks.

    Can you explain it a bit more?

    So, in my theme folder, I made a file called css-genre and placed a css file named romance.css

    function load_demandforce_style() {
    
      wp_enqueue_style( 'demandforce-style', '//fantasy-books.live/wp-content/themes/css_genre/romance.css');
    
    }
    add_action( 'wp_enqueue_scripts', 'load_demandforce_style', 50

    This works if I don’t have that same css called in the file under customizer -> css.

    I am trying to override that css file so that it would do something different under a certain condition. Problem is, this won’t override x theme’s css files.

    Can you help?

    #1406009
    Rupok
    Member

    Hi there,

    As it’s external CSS so it might not override the X theme’s CSS as you have set the priority (that means it will load earlier). You can try taking off the priority (50).

    Thanks!

    #1406403
    JfantasyBooks
    Participant

    I tried that as well, unfortunately, that did not work either.

    #1406516
    Thai
    Moderator

    Please try with this code:

    function load_demandforce_style() {
    
      wp_enqueue_style( 'demandforce-style', '//fantasy-books.live/wp-content/themes/css_genre/romance.css');
    
    }
    add_action( 'wp_enqueue_scripts', 'load_demandforce_style', 9999);

    Let us know how it goes!

    #1406612
    JfantasyBooks
    Participant

    I tried it. It didn’t work either.

    Any other ideas?

    #1406704
    Thai
    Moderator

    How about this code?

    function load_demandforce_style() {
    	?>
    	<link rel='stylesheet' id='dashicons-css'  href='//fantasy-books.live/wp-content/themes/css_genre/romance.css' type='text/css' media='all' />
    	<?php
    
    }
    add_action( 'wp_head', 'load_demandforce_style', 9999);

    Hope it helps 🙂

    #1406943
    JfantasyBooks
    Participant

    It worked.

    Only, now with this new set up, I am unsure of how to do an if, else if, and else conditions in php.

    Can you show me where you’d place them?

    Trying to load stylesheet for specific categories.

    #1407553
    Rupok
    Member

    Hi there,

    If you want to load for specific category then you can follow this – https://developer.wordpress.org/reference/functions/is_category/

    All conditional tags could be found here – https://codex.wordpress.org/Conditional_Tags

    Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.

  • <script> jQuery(function($){ $("#no-reply-1404383 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>