-
AuthorPosts
-
December 3, 2017 at 2:01 pm #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!
December 6, 2017 at 7:39 am #885401Hey 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,
IsmaelDecember 6, 2017 at 10:18 am #885458Hey Ismael,
thnx for hitting back to me – please see information below
Regards,
AndyDecember 7, 2017 at 5:32 am #885915Hi,
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,
IsmaelDecember 7, 2017 at 10:26 am #886002Hey 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?
December 9, 2017 at 5:28 pm #886909Hi,
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,
IsmaelDecember 11, 2017 at 12:46 am #887172This reply has been marked as private.December 11, 2017 at 6:38 pm #887531I have the same problem and would love to see a solution. Thank you guys for your outstanding support!
December 12, 2017 at 4:34 am #887691Hi,
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,
IsmaelDecember 12, 2017 at 11:31 am #887838Hey Ismael,
thnx again for the fix but still… not showing the acf shortcode in the excerpts wich are shown in the “full portfolio”
December 13, 2017 at 1:23 pm #888315Hi,
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,
IsmaelDecember 13, 2017 at 2:00 pm #888353Hey Ismael,
changed it in parent theme – but still no output….
December 14, 2017 at 2:17 am #888693Hi,
Please post the code of the portfolio.php file on pastebin.com. Did you duplicate the file? Please remove the copy.
Best regards,
IsmaelDecember 14, 2017 at 10:25 am #888803Hey Ismael,
yes i have removed the copy before.Please see portfolio.php code here: https://pastebin.com/iB9EqaUz
Best Regards,
AndyDecember 16, 2017 at 3:40 am #889454Hi,
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,
IsmaelDecember 19, 2017 at 10:56 am #890397Hey 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.
December 22, 2017 at 6:30 am #891467October 29, 2020 at 3:40 pm #1256778hi 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.
November 2, 2020 at 4:01 am #1257491Hi,
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 -
AuthorPosts
- The topic ‘How to add Shortcodes in Portfolio excerpt’ is closed to new replies.