-
AuthorPosts
-
February 24, 2022 at 11:58 am #1342139
I want to also add shortcodes to my excerpt but don’t see the code. I see this (below) in avia-shortcodes > portfolio > portfolio.php but not from your reply in #1272058 I am using enfold 4.8.2
Many thanks
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>’;February 25, 2022 at 1:53 am #1342204Hey condonpb,
For version 4.9 in avia-shortcodes > portfolio > portfolio.php find this in line 1128:
$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>" : '';
change to this:
$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,
MikeFebruary 25, 2022 at 2:44 pm #1342275Mark
This does not seem to resolve the issue please see https://peter-test3.co.uk/view-our-menus/ the Menu for March 3rd we are trying to have a button here that says “Read The Menu” using shortcodes. Can you help ?February 25, 2022 at 3:10 pm #1342279Hi,
Please include admin login and FTP access in the Private Content area so we can be of more assistance.Best regards,
MikeFebruary 25, 2022 at 3:40 pm #1342284I had added access to WordPress. I need to see about how you get FTP access if this is really needed ?
February 25, 2022 at 4:48 pm #1342302adding ftp credentials now
February 25, 2022 at 4:50 pm #1342303adding ftp credentials now
February 26, 2022 at 12:01 am #1342344Hi,
Thanks for the login, originally I was under the impression that we were talking about a portfolio item, so after testing the solution above was for a portfolio item, but I see that you are using a masonry element to show posts. I couldn’t find a similar solution for this, but I did find a plugin that works Shortcodes Anywhere or Everywhere if the In Post/Page Custom Fields option is used. I first tested this with a simple date shortcode, but using a button shortcode breaks the masonry element.
If you notice the whole masonry block, excerpt and image, is already linked to the item, so you can not add a button to the excerpt that includes a link.
I assume that you understand that this, so I came up with a different solution for you, I replaced your shortcode in the manual excerpt with this:
[buttoncode]
then I added this to your child theme functions.phpfunction custom_masonry_excerpt_button_script() { ?> <script> var masonryExcerpt = document.querySelector(".av-masonry-entry-content.entry-content"); masonryExcerpt.innerHTML = masonryExcerpt.innerHTML.replace("[buttoncode]", '<span class="avia-button avia-icon_select-yes-left-icon avia-size-small avia-position-center avia-color-theme-color"><span class="avia_button_icon avia_button_icon_left" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span><span class="avia_iconbox_title">Click me</span></span>'); </script> <?php } add_action('wp_footer', 'custom_masonry_excerpt_button_script');
and now the button shows.
You can adjust the button html in the script above to suit, if you want help with this please post the button you want to use on a test page so I can copy the html and adjust the script for you.Best regards,
MikeFebruary 26, 2022 at 1:03 pm #1342361Mike,
Thanks for all your work. However the button short-code does not work for all the other events> See https://peter-test3.co.uk/view-our-menus/
Also is it possible to get the button in the middle and slightly larger?
Many thanks for all your help
Pete
February 26, 2022 at 5:45 pm #1342395Hi,
Thanks for the feedback I adjusted the script to this:function custom_masonry_excerpt_button_script() { ?> <script> var elements = new Array(); var elements = document.getElementsByClassName('av-masonry-entry-content'); for (var e = 0; e < elements.length; e++) { var newHTML = elements[e].innerHTML; newHTML = newHTML.replace('[buttoncode]','<span class="center-excerpt-button"><span class="avia-button avia-icon_select-yes-left-icon avia-size-large avia-position-center avia-color-theme-color"><span class="avia_button_icon avia_button_icon_left" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span><span class="avia_iconbox_title">SEE MENU</span></span></span>'); elements[e].innerHTML = newHTML; }; </script> <?php } add_action('wp_footer', 'custom_masonry_excerpt_button_script');
and I added this css to center the buttons:
span.center-excerpt-button { display: flex; justify-content: center; }
Please clear any cache plugin and your browser cache and check.
Best regards,
MikeFebruary 26, 2022 at 9:41 pm #1342422Mike
Many thanks for going the extra mile>
Really appreciate it thanksPete
February 26, 2022 at 10:32 pm #1342425Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Adding Shortcode to Excerpts’ is closed to new replies.