Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #884343

    Hey guys,

    how can i make shortcodes in portfolio excerpt working and not only showing the “code” :) ?
    Unfortunatelly I could not get any given solution on forums or the web working…

    Thnx in advance!

    #885401

    Hey Andreas,

    Thank you for using Enfold.

    Where can we find the shortcodes? The portfolio items’ content look ok. Please provide the login details in the private field so that we can check this further.

    Best regards,
    Ismael

    #885458

    Hey Ismael,

    thnx for hitting back to me – please see information below

    Regards,
    Andy

    #885915

    Hi,

    Thank you for the info.

    The portfolio grid excerpt doesn’t render shortcodes by default so you have to modify the config-templatebuilder > avia-shortcodes > portfolio.php file. Look for the following code around line 594.

    $output .= "<div class='grid-entry-excerpt entry-content' $markup>".$excerpt."</div>";
    

    You have to add the do_shortcode function.

    $output .= "<div class='grid-entry-excerpt entry-content' $markup>".do_shortcode($excerpt)."</div>";
    

    // https://developer.wordpress.org/reference/functions/do_shortcode/

    Best regards,
    Ismael

    #886002

    Hey Ismael,

    thank you for the fix – it seems to work but surpresses the output right now…

    do I have to change the code anywhere else too?

    #886909

    Hi,

    Did you remove the shortcodes in the “Test” portfolio item? Please re-create a test page so that we can inspect it again.

    Best regards,
    Ismael

    #887172
    This reply has been marked as private.
    #887531

    I have the same problem and would love to see a solution. Thank you guys for your outstanding support!

    #887691

    Hi,

    Thank you for the update.

    Please look for another code around line 638.

    $output .= !empty($excerpt) ? "<div class='grid-entry-excerpt entry-content' ".avia_markup_helper(array('context'=>'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)).">".$excerpt."</div>" : '';
    

    Wrap the $excerpt variable inside do_shortcode function again.

    $output .= !empty($excerpt) ? "<div class='grid-entry-excerpt entry-content' ".avia_markup_helper(array('context'=>'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)).">".do_shortcode($excerpt)."</div>" : '';
    

    Best regards,
    Ismael

    #887838

    Hey Ismael,

    thnx again for the fix but still… not showing the acf shortcode in the excerpts wich are shown in the “full portfolio”

    #888315

    Hi,

    I’m sorry but you can’t modify the shortcodes in the child theme. You have to do this modification in the parent theme folder.

    Best regards,
    Ismael

    #888353

    Hey Ismael,

    changed it in parent theme – but still no output….

    #888693

    Hi,

    Please post the code of the portfolio.php file on pastebin.com. Did you duplicate the file? Please remove the copy.

    Best regards,
    Ismael

    #888803

    Hey Ismael,
    yes i have removed the copy before.

    Please see portfolio.php code here: https://pastebin.com/iB9EqaUz

    Best Regards,
    Andy

    #889454

    Hi,

    The theme shortcodes are rendered properly in the excerpt. According to the ACF documentation, you have to use the get_field function in order to render the ACF shortcodes in a template. You may have to fetch the acf shortcodes manually in the template. Please contact the plugin author for more info.

    One workaround is to use placeholders in the excerpt instead of the actual acf shortcode.

    Test
    %ACF_FIELD_NAME_AP%
    Test
    %ACF_FIELD_NAME_AP%
    

    We will replace the placeholder “%ACF_FIELD_NAME_AP%” with the actual “name_ap” shortcode value. Place the following code above line 594:

    $acf_nameap = get_field("name_ap");
    $excerpt = str_replace("%ACF_FIELD_NAME_AP%", $acf_nameap, $excerpt);
    

    Best regards,
    Ismael

    #890397

    Hey Ismael,

    thanx for sharing your solution… unfortunatelly id didn’t work out for me… I found an solution now wich I guess is the neatest ways of all.
    Since someone else is having that problem i will share it here:

    1) Make the ALB editable in Child Theme with this Code from your Documentation: https://kriesi.at/documentation/enfold/add-new-or-replace-advanced-layout-builder-elements-from-child-theme/

    2) Copy the portfolio.php from enfold>config-templatebuilder>avia-shortcodes into it

    3) Jump to line 589 where the excerpt starts:

    if(!empty($excerpt))
                        {
                            $markup = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
    
                            $output .= "<div class='entry-content-wrapper'>";
                            $output .= "<div class='grid-entry-excerpt entry-content' $markup>".$excerpt."</div>";
                            $output .= "</div>";
                        }
                        $output .= '<div class="avia-arrow"></div>';
                        $output .= "</div>";
    
                        $image = get_the_post_thumbnail( $the_id, $image_size, $image_attrs );

    4) Get the ACF Information
    $varbiable1 = get_field('ACF_VALUE_NAME', $the_id);

    • You can name $varbiable1 what ever you want to make it more easy for you.
    • ACF_VALUE_NAME should be the name of the ACF information you are regarding to
    • $the_id is an enfold function and calls the portfolio ID, so that the information from the right portfolio entry is beeing called
    • If you want to, you can repeat that line with another variable and value

    5) Now to show the information in the excerpt you just add something like this:
    $output .= " . $varbiable1 . ";

    or when you want to make it as an list use:

    $output .= "<ul><li class='CLASS_NAME'>" . $varbiable1 . "</li>";
    $output .= "<li class='CLASS_NAME'>" . $varbiable2 . "</li>";
    $output .= "</ul>

    When you have different text posibillities like singular or plural spelling regarding to the value you can add:

    if($varbiable1 == 1)
    {
    $output .= "<ul><li class='CLASS_NAME'>" . $varbiable1 . " dog</li>";
    }
    else
    {
    $output .= "<ul><li class='CLASS_NAME'>" . $varbiable1 . " dogs</li>";
    }

    And the output is either “1 dog” or “2 dogs” regarding the ACF value.

    6) This gives us the “new” modified code:

    if(!empty($excerpt))
    {
        $markup = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup));
    
        $variable1 = get_field('meeting_raume', $the_id);
        $variable2 = get_field('flache_bis', $the_id);
        
    
        $output .= "<div class='entry-content-wrapper'>";
        $output .= "<div class='grid-entry-excerpt entry-content' $markup>";
    
        if($variable1 == 1){
        $output .= "<ul><li class='CLASS_NAME'>".$variable1." dog/li>";
        }
        else{
        $output .= "<ul><li class='CLASS_NAME'>".$variable1." dogs</li>";
        }
        $output .= "<li class='CLASS_NAME'>" . $variable2 . "</li>";
        $output .= "</ul></div>";
        $output .= "</div>";
    }
    $output .= "</div>";
    
    $image = get_the_post_thumbnail( $the_id, $image_size, $image_attrs );
    • This reply was modified 6 years, 11 months ago by Andreas.
    #891467

    Hi,

    Awesome! Thanks for sharing. :)

    Best regards,
    Ismael

    #1256778

    hi ismael,

    this post here, point to a good direction, but ist is to old.
    is actually there a way to push enfold and parse shortcodes
    in the the excerpts?

    i’m struggling with shortcodes in the excerpts from masonry and portfolio.

    bis dann, marco.

    #1257491

    Hi,

    Have you tried using the do_shortcode function? The masonry template is in the enfold\config-templatebuilder\avia-shortcodes\av-helper-masonry.php file.

    // https://developer.wordpress.org/reference/functions/do_shortcode/

    If you need further assistance, please do not hesitate to open a new thread. We will close this one for now.

    Best regards,
    Ismael

Viewing 19 posts - 1 through 19 (of 19 total)
  • The topic ‘How to add Shortcodes in Portfolio excerpt’ is closed to new replies.