• Services
    • Website Design & Development
    • E-Commerce Shopping Cart Development
    • Website Management
    • Web app & website integration
    • School Website Design
    • Competition Website Design
  • Portfolio
  • Testimonials
  • Contact
  • Blog
  • 01298 816080
  • Menu Menu
You are here: Home1 / Code Snippets2 / How to override the default wordpress gallery embedded css styles in W...

How to override the default wordpress gallery embedded css styles in WP.

Code Snippets, Wordpress

We all know how good Wordpress is as blog and decent level CMS system. One of the annoying traits of the gallery script in WordPress is that it embeds a <style> tag in your page overriding all your CSS styles for the gallery. Making it difficult to style the WordPress gallery.

Here is a guide so you can override the default gallery.

  1. Navigate through the root of your website to wp-includes/media.php
  2. Copy the entire function gallery_shortcode($attr){…}
  3. Now navigate over to your current theme folder in /wp-content/themes
  4. Locate the file called functions.php
  5. Paste in the original function and amend the function name to say gallery_shortcode_sk23($attr){…}
  6. Above your newly renamed function add the code:
    remove_shortcode(‘gallery’, ‘gallery_shortcode’);
    add_shortcode(‘gallery’, ‘gallery_shortcode_sk23’);
  7. This will in effect utilise your local function for all gallery short codes.
  8. Now you can amend your version of the gallery shortcode script to your hearts content.
  • Share:
  • Facebook
  • Twitter
  • Pinterest
  • Linkedin
  • Google+
February 27, 2013/4 Comments/by Martin Toner Web Designer Developer
Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail
0 0 Martin Toner Web Designer Developer https://sk23.co.uk/wp-content/uploads/2019/09/sk23logo.svg Martin Toner Web Designer Developer2013-02-27 16:57:462013-06-23 20:00:32How to override the default wordpress gallery embedded css styles in WP.
4 replies
  1. Calvin Williams
    Calvin Williams says:
    August 10, 2013 at 10:13 pm

    Thank you so much for this! You have helped me tremendously! I was ready to pull my hair out trying to figure out workarounds until I came across this. Your override fix is genius, thank you again!

  2. Alex
    Alex says:
    October 16, 2013 at 12:13 pm

    This is totaly the wrong way, you should never ever alter core files.

    • Martin Toner Web Designer Developer
      Martin Toner Web Designer Developer says:
      October 16, 2013 at 12:20 pm

      I agree, however with this method you aren’t modifying the core files just over-riding the existing function to one you have created yourself in your theme. So you can update the WordPress core files without this function being affected.

  3. Karen Bennett
    Karen Bennett says:
    June 16, 2014 at 12:58 am

    Thank you very much for this. It was just the right amount of information, clearly presented. I used it and it worked.

Comments are closed.

Pages

  • About
  • Blog
  • Competition Website Design
  • Contact
  • E-Commerce Shopping Cart Development
  • Home
  • Magento CE E-Commerce Shopping Cart Web Development
  • Payment Confirmation
  • Payment Failed
  • School Website Design
  • Serious Coding
  • Simple Unlimited Page Website
  • Testimonials
  • Thanks
  • Web app & website integration
  • Website Management
  • Website Design & Development
  • Buxton Web Designer + Developer
  • High Peak Web Designer
  • Recent Web Design Projects Portfolio

Categories

  • Code Snippets
  • Design
  • Fun Stuff
  • Latest Work
  • Magento
  • Magento Guides
  • Magento Modules
  • MySql
  • Our Work
  • PHP
  • PHP Development Work
  • Website work.
  • Wordpress

Archive

  • February 2024
  • February 2023
  • October 2022
  • June 2022
  • August 2019
  • December 2016
  • July 2014
  • April 2014
  • September 2013
  • June 2013
  • March 2013
  • February 2013
  • October 2012
  • May 2012
  • February 2012
  • January 2012
  • October 2011
  • September 2011
  • February 2011
  • January 2011
  • October 2010

Contact Us

If you are looking for a new website , e-commerce store, web application or just some advice please get in touch.

info@sk23.co.uk 01298 816080

Address

SK23Design
Suite 1,
4 Market St,
Chapel-en-le-Frith,
High Peak SK23 0HH

Partners

Recent

  • Magento 2.4 – Why Your Custom Theme’s Css Is Not Being Compiled
  • Magento 2.4 – Change Product Details From Tabs to Accordion On Desktop
  • Magento 2.4 Bulk Updates Not Working Or Appearing In The Action Log
  • Magento 2.4 Disable Page Builder For Category Description
  • Magento 2 UK Shipping

Categories

  • Code Snippets
  • Design
  • Fun Stuff
  • Latest Work
  • Magento
  • Magento Guides
  • Magento Modules
  • MySql
  • Our Work
  • PHP
  • PHP Development Work
  • Website work.
  • Wordpress
  • Web Design High Peak
  • Web Design Buxton
  • Web Designer Chapel-en-le-Frith
  • Loqate
2026 © Copyright - SK23 Design IT - Websites and Web Development Services | Website by SK23Design
Magento Code Snippets – Get Base Url In Phtml FileCheshire Kitchens & Bathrooms – New Website For Bathroom Company Scroll to top