WordPress.org

Ready to get started?Download WordPress

Forums

File Gallery
CSS include? (9 posts)

  1. Hubert Nguyen
    Member
    Posted 3 years ago #

    Hi,

    I'm using a custom template and I would like to know what your recommended way of including the template CSS in the page is? Right now, I don't see the CSS being included in the page automatically, and I would rather not hardcode it. Thx!

  2. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @Hubert: the CSS file should be included in the page automatically if it's in the same folder as the gallery.php file and is named gallery.css.

    If this is not working for you, please e-mail me your custom template (aesqe@skyphe.org) and I'll get back to you asap.

    Thanks :)

  3. felixSchl
    Member
    Posted 3 years ago #

    Sorry to revive this old thread, but after hours of searching this is the closest to my problem that I could find.

    For me, the CSS gets included just fine when having the shortcode in a post, however when I try to use either the do_shortcode() or your file_gallery_shortcode() in a template file, the CSS just won't get loaded.

    Cheers

  4. felixSchl
    Member
    Posted 3 years ago #

    I also cannot get it to load the CSS when using my own template (just copied the "file-gallery" template to my "themes/file-gallery-templates" directory as per help file. I can see it loads the right php file by messing with it, however it won't load the CSS. Not even when putting the shortcode into the post itself this time.

  5. Aesqe
    Member
    Plugin Author

    Posted 3 years ago #

    @felixSchl: yes, unless you use a shortcode within your post content, the CSS files will not be included. They simply cannot be included because they need to be placed in the head of the document. Shortcodes within post content are processed way before those included in your template files and allow File Gallery to enqueue all the needed files. If you call do_shortcode() from a template file, that means that the call will be received _after_ the page head has been processed.

    As for the second question: did you rename the template folder to something else, and modified the CSS file accordingly?

  6. felixSchl
    Member
    Posted 3 years ago #

    Thanks for your prompt reply! This is really cool.

    I got the custom template to work, didn't come to mind I had to change the actual css content, because I though it was generated by the gallery.php but nevermind.

    As to loading the CSS -- how would you solve this? wp_enqueue_style() or just always load it or something else maybe?

  7. Francesco Canovi
    Member
    Posted 2 years ago #

    Same problem here about the loading of the css... Any solutions?

  8. Francesco Canovi
    Member
    Posted 2 years ago #

    I resolved importing the desired CSS via import in the main css, but it means that in case the shortcode is used, the css is imported 2 times. This is not so elegant...

  9. Aesqe
    Member
    Plugin Author

    Posted 2 years ago #

    I'd definitely recommend using wp_enqueue_style() to avoid duplicate inclusion.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic