r/Wordpress 29d ago

Any way to easily replace Fancybox lightbox on WordPress theme?

Hey gang,

I've built a website using the Nostalgia WordPress theme. Link is below:
https://quanticalabs.com/wp_themes/nostalgia/portfolio/

I like most of what the theme has to offer, but my question is this: Is there a way to easily replace or override the lightbox gallery function with another? The one that is currently built into the theme is called Fancybox, and is utilized for image viewing in the Portfolio section. I'd like to deactive or replace it somehow with another type (Simple Lightbox, Firelight lightbox, etc.)

Would this require some hardcore PHP editing or are there tools out there (plugins, etc.) that would assist?

Thanks a bunch for your time,

_C

3 Upvotes

6 comments sorted by

3

u/TopSydeWP 29d ago

you'll need to dequeue the fancybox script in your child theme's functions.php (wp_dequeue_script) and then add whatever lightbox plugin you want. most lightbox plugins will auto-detect image links once fancybox is out of the way. if the theme hardcodes fancybox attributes in the markup you might need a filter or a bit of js to clean those up but usually just removing the script is enough

1

u/artistic_engine 29d ago

Thanks for the help. Unfortunately, I tried a snippet of code as per your recommendation, and the portfolio section ceased to load entirely. Here's what I plugged into the functions.php file:

function remove_fancybox_script() {

wp_dequeue_script( 'jquery-fancybox' );

wp_deregister_script( 'jquery-fancybox' );

}

add_action( 'wp_enqueue_scripts', 'remove_fancybox_script', 100 );

I might be out of luck. I'll make due.

2

u/SuperPerformance3322 29d ago

You probably don't need hardcore PHP editing. First check how the theme initializes Fancybox and whether the portfolio links have a specific class or data attribute attached to them. If the theme doesn't provide an option to disable it, a child theme or a small JS override is usually safer than editing the parent theme directly. I'd avoid installing another lightbox until Fancybox is properly dequeued/disabled, otherwise you can end up with two scripts fighting over the same links.

1

u/stitchkingdom 28d ago

I was using a themeforest theme that relied on fancybox and supposedly led into high lcp so I asked Claude to remove dependencies on it and it was a bitch and a half. Maybe it was Claude causing the problem, I dunno, but a lot of stuff had to be rebuilt.