Hi!
Yes, that’s possible.
if(CrellySliderCommon::sliderExists($id)) {
// Do something if slider exists
}
This function was not meant to be used as an API, that’s why it is not documented. But there’s no problem to use it 🙂
Thread Starter
WiSch
(@wisch)
Hi Fabio.
Thanks for the reply, but I didn’t get it working.
My code now looks like this:
global $post;
$alias = get_post_field( 'post_name', get_post() );
if ($alias && function_exists('crellySlider')) {
if(CrellySliderCommon::sliderExists($alias)) {
crellySlider('standardslider');
} else {
crellySlider($alias);
}
}
If exists, the slide for the post_slug comes correct.
If it not exists, nothing happend, even not integrating the slider “standardslider”.
In the page-source I can find the comment “The Slider wasn’t found” (in german)?
But in my dashboard there’s this slider. The shortcode your PlugIn shows: [crellyslider alias=”standardslider”]
Can you see, where’s the problem?
Regards,
Jörg
-
This reply was modified 8 years, 6 months ago by
WiSch.
-
This reply was modified 8 years, 6 months ago by
WiSch.
Are you sure you haven’t swapped the 2 functions?
if(CrellySliderCommon::sliderExists($alias)) {
crellySlider($alias);
} else {
crellySlider('standardslider');
}
Thread Starter
WiSch
(@wisch)
Hi Fabio.
Thanks for the support, but…
If I use your snippet, on every page the ‘standardslide’ comes up.
If I swap the if & else content the right slider comes up, if exists, but not my default if there’s no slider named like the slug.
Any other ideas?
Update:
Maybe your code checks the ID and I come with the slug in my $alias…
if(CrellySliderCommon::sliderExists($id)) {
// Do something if slider exists
}
So I have to find out the ID before? But how?
-
This reply was modified 8 years, 6 months ago by
WiSch.
You’re completely right, I was distracted…
global $wpdb;
$slider = $wpdb->get_row($wpdb->prepare('SELECT id FROM ' . $wpdb->prefix . 'crellyslider_sliders WHERE alias = %s', esc_sql($alias)));
if($slider === null) {
// Slider not found
}
else {
// Slider found!
}
this is the only way to do it with the alias. It’s a direct query to the database, but it should work
Thread Starter
WiSch
(@wisch)
Hello Fabio.
Sorry for the delay… checked it today and your last solution works now!
Thanks for your support.