-
AuthorPosts
-
December 18, 2017 at 10:03 am #889947
Hi,
I would like to echo something (eg text or slider) (hardcoded in template-builder.php) in my post template in case no layerslider has been used in the template builder. So what I would need is to query in the template-builder.php if the layerslider shortcode has been used.
I am looking for something like:if ( shortcode_exists( '[layerslider]' ) ) { echo 'something'; }
Can you help please
ThanksDecember 18, 2017 at 6:37 pm #890173Hey schmu2013,
Can you please explain why you need to do that? Maybe there is another way to achieve what you need?
Best regards,
VictoriaDecember 19, 2017 at 9:12 am #890373Hi Victoria,
in particular this is to promote events which are organised in a category. Depending on the type of event 2 scenarios can occur: 1. default layerslider (which is implemented in the template-builder.php via do_shortcode) 2. for some events an own slider set shall be used. 90% of the events posts are using the default slider so it makes sense to hardcode it for usabuility reasons for my customer – however, there should be the option to override this by using a slider page builder for some special events posts.
Thanks ChristophDecember 19, 2017 at 1:09 pm #890455Hi Christoph,
Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
VictoriaDecember 19, 2017 at 1:25 pm #890465Hi Victoria,
I really enjoyed the quality of support in the past for some technical questions (especially Isamel is very capable to lead into the right direction or provide a straight solution right away).
My question is a bit linked to this post: https://kriesi.at/support/topic/using-shortcode-in-template/
the only difference is that instead of echoing a shortcode in the template I would like to check if the shortcode is used.
There is already a WordPress function:
`<?php
$content = ‘This is some text, (perhaps pulled via $post->post_content). It has a [gallery] shortcode.’;if( has_shortcode( $content, ‘gallery’ ) ) {
// The content has a [gallery] short code, so this check returned true.
}
?>
What I need to know is how to query the use of the layerslider (is it just [avia_layerslider] or with ID etc.). Anything else I mentioned in my previous post can be managed by myself.
So I don´t think it´s that complicated to answer and I am not asking for a customization of the theme.
Thanks for your help!
Best regards
ChristophDecember 19, 2017 at 3:16 pm #890528Hi Christoph,
SO why don’t you try this function checking for the Layer Slider shortcode? Or try to debug the query and see what content has?
Best regards,
VictoriaDecember 19, 2017 at 5:26 pm #890567solution for anyone with same challenge (better solution might be available). It seems the avia shortcode is not treated as wordpress shortcode….
//check if we got a layerslider global $wpdb; // Table name $table_name = $wpdb->prefix . "layerslider"; // Get slider $slider = $wpdb->get_row("SELECT * FROM $table_name WHERE id = ".(int)$atts['id']." AND flag_hidden = '0' AND flag_deleted = '0' ORDER BY date_c DESC LIMIT 1" , ARRAY_A); and then you can make your query: if ( in_category('yourcategory') && !empty($slider)) {do something}
Best Christoph
December 20, 2017 at 12:53 am #890658Hi,
I’m glad you were able to get this corrected. Did you need additional help, or shall we close this topic?
Best regards,
Jordan ShannonDecember 20, 2017 at 9:06 am #890709Hi Jordan,
thanks – topic can be closed.Have a good day!
ChrisDecember 21, 2017 at 4:19 am #890977 -
AuthorPosts
- The topic ‘template modification – query if shortcode is used’ is closed to new replies.