Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1277028
    JfantasyBooks
    Participant

    Hey there, Themeco Team!

    Name: JFantasyBooks
    Site: Fantasy-Books
    Site Url: https://fantasy-books.live
    WordPress Version: 4.6.1
    X Version: 4.6.4
    Cornerstone Plugin Version: 1.3.3

    Problem:

    Is it possible to add a shortcode or a text at the bottom of each excerpt on the latest updates page?

    #1277030
    Rupok
    Member

    Hi there,

    Thanks for writing in! Excerpt supposed to be plain text so shortcode/HTML won’t work there.

    Cheers!

    #1277140
    JfantasyBooks
    Participant

    I don’t mean to insert a shortcode in the excerpt itself, but below the excerpts.

    #1277152
    Paul R
    Moderator

    Hi,

    To add a shortcode in excerpts, you can add this in your child theme’s functions.php file

    
    function x_excerpt_string( $more ) {
        
        $stack = x_get_stack();
    
        if ( $stack == 'integrity' ) {
          return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>';
        } else if ( $stack == 'renew' ) {
          return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a>';
        } else if ( $stack == 'icon' ) {
          return ' ...';
        } else if ( $stack == 'ethos' ) {
          return ' ... <div class="my_shortcode">'.do_shortcode('[x_icon type="adjust"]').'</div>';
        }
    
      }
      
      add_filter( 'excerpt_more', 'x_excerpt_string' );
    

    Change [x_icon type="adjust"] with your shortcode.

    Hope that helps

    #1278406
    JfantasyBooks
    Participant

    So I actually did not want to add a shortcode at the end of the excerpt or as a part of the excerpt, but below it.

    Strictly below it. As in if I disabled the excerpt, you would see the shortcode below the title instead.

    #1278447
    Paul R
    Moderator

    In that case, please replace the code with this.

    
    function add_my_shortcode( ) {  
       
          echo ' <div class="my_shortcode">'.do_shortcode('[x_icon type="adjust"]').'</div>';   
    
      }
      
      add_action( 'x_after_the_excerpt_end', 'add_my_shortcode' );
    

    Hope that helps

    #1278451
    JfantasyBooks
    Participant

    Great! Thanks

    #1278459
    Friech
    Moderator

    Glad we could help, Cheers!

    #1278460
    Lely
    Moderator

    You’re welcome!

    Cheers!

    #1278487
    JfantasyBooks
    Participant

    I’m back.

    1. Is there a way to make it so that it’s not after the excerpt end, but before that line you see between each latest post begins?

    2. For the latest post at the very top. For some reason there is a gap, making the appearance different from the other posts. Anyway to change that?

    #1278495
    Paul R
    Moderator

    Hi,

    1. Can you provide us a screenshot with indication where exactly you want it to appear.

    2. You can add this under Custom > Edit Global CSS in the Customizer.

    
    .entry-content.excerpt p {
        margin-bottom:0 !important.
    }
    

    Hope that helps.

    #1278504
    JfantasyBooks
    Participant

    Well, It’s appearing where I want it. Only, I realized there was an issue with excerpt word count. More characters, the larger the space.

    This makes the shortcode a bit nonuniform in comparison to the other latest posts. I figured if the shortcode was set before the <hr> line after every post, it may provide a more uniform look.

    #1278524
    JfantasyBooks
    Participant

    Ok. So the code

    
    .entry-content.excerpt p {
        margin-bottom:0 !important.
    }

    Actually fixed .1, my uniniform problem.

    But .2 still remains a problem. The very top post has a gap between the excerpt and the shortcode. This gap is not the same for the other posts, making it look weird.

    #1278533
    Paul R
    Moderator

    Hi,

    You can try this in your custom css.

    
    .blog .my_shortcode {
       position: absolute;   
       width: 80%;
       bottom: 0;
    }
    
    .blog .x-main .hentry {
       position:relative;
    }
    

    Hope that helps.

    #1278544
    JfantasyBooks
    Participant

    Well, it helped a lot. Only now the very last one shows a gap, pushing the shortcode to touch the bottom line.

  • <script> jQuery(function($){ $("#no-reply-1277028 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>