Shortcodes in excerpt

Forums › Forums › General › Shortcodes in excerpt

Tagged: 

Viewing 10 posts – 1 through 10 (of 20 total)
  • Anonymous
    #205948

    Hello,
    I need to show a shortcode in search results, this shortcode is in an excerpt. It’s an audio player. Now it’s displaying the only text of shortcode.

    How to fix it?

    PS Also where can I find information about creating custom result page? (i am not savvy with web development, PHP codes for title, excerpt etc will be great)

    Anonymous
    #205949

    Also, is it realistic to create a default value for taxonomies?
    For example, I have these checkboxes:

    ( ) Checkbox 1
    ( ) Checkbox 2
    ( ) Checkbox 3
    ( ) Checkbox 4

    Can one of them be ticked by default?

    (*) Checkbox 1
    ( ) Checkbox 2
    ( ) Checkbox 3
    ( ) Checkbox 4

    Trevor
    #205953

    By default, WordPress does not execute shortcodes in excerpts. What Display Results Method are you using in your form?

    At this time, there is no UI option to pre-select a default value in the form, sorry. It is something we are working on for V3 (still some months away).

    Anonymous
    #205957

    By default, WordPress does not execute shortcodes in excerpts. What Display Results Method are you using in your form?

    Display results method: Using a Shortcode

    Trevor
    #205961

    As you are using our shortcode method, the guide for customization is here:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results

    You need to find this line:

    <p><br /><?php the_excerpt(); ?></p>

    and replace it with something like:

    <p><?php echo get_the_content(); ?></p>

    You can edit pretty much anything in this file, but make small changes and test.

    Anonymous
    #205967

    I will edit template thanks.

    But this not quite what I need, now it displays all page content under the title.

    By default, it’s showing the right data in an excerpt, but doesn’t execute shortcode in it.
    Screenshot:
    https://drive.google.com/open?id=1s_uqhkxnolGnRbMRXmivjn0BkyeIClbY

    In my post type (Portfolio) I have a custom field “excerpt” there is one specific shortcode that I need to show on my search result.

    Also, it will be great to use custom field data to show in my result page, how to include it?

    Trevor
    #205969

    The execution of shortcodes in the excerpt is down to your theme and WordPress. If you are using a child theme (you should be), then this might help:

    http://miftyisbored.com/wordpress-executing-shortcode-inside-the_excerpt/

    Are you using ACF to make the custom fields, or something else?

    Anonymous
    #205971

    http://miftyisbored.com/wordpress-executing-shortcode-inside-the_excerpt/

    It helped! Thanks.

    Are you using ACF to make the custom fields, or something else?

    I am using ACF.

    Anonymous
    #205975

    update: it helped but not fully.

    It loads shortcode correctly only on page 1, next page audio loads with default browser player.
    You can check it yourself: https://tunestogo.net/portfolio-test/

    Trevor
    #205978

    Is the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?

    As to ACF fields. Let us assume it is a single value field use key is my_custom_field and the prefix required is My Custom Field Value, then the PHP is this:

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php the_field('cial_secteur'); ?></p>
    <?php endif; ?>
Viewing 10 posts – 1 through 10 (of 20 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.