Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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
    Thanks

    #890173

    Hey schmu2013,

    Can you please explain why you need to do that? Maybe there is another way to achieve what you need?

    Best regards,
    Victoria

    #890373

    Hi 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 Christoph

    #890455

    Hi 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,
    Victoria

    #890465

    Hi 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
    Christoph

    #890528

    Hi 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,
    Victoria

    #890567

    solution 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

    #890658

    Hi,

    I’m glad you were able to get this corrected. Did you need additional help, or shall we close this topic?

    Best regards,
    Jordan Shannon

    #890709

    Hi Jordan,
    thanks – topic can be closed.

    Have a good day!
    Chris

    #890977

    Hi Chris,

    Thanks for that :-)

    Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘template modification – query if shortcode is used’ is closed to new replies.