Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1276924
    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 on top of the thumbnail of the latest posts on the front page?

    #1276944
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! To add a shortcode on top of the thumbnail of the latest posts in your front page, Since you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file;

    // Add a shortcode before the blog post items
    // =============================================================================
    function add_custom_shortcode(){ ?>
      <?php if ( is_home() ) : ?>
        <?php echo do_shortcode('[the_shortcode_here]'); ?>
      <?php endif; ?>
    <?php }
    add_action('x_before_view_global__index', 'add_custom_shortcode');
    // =============================================================================

    Just make sure that you properly add your [the_shortcode_here] in the code above.

    Please let us know how it goes.

    #1276946
    JfantasyBooks
    Participant

    Thanks! I’ll try it out.

    #1276949
    Rue Nel
    Moderator

    You’re most welcome.
    We would loved to know if this has work for you.

    #1276993
    JfantasyBooks
    Participant

    Unfortunately it doesn’t work. The shortcode pops up above it at the very top, but I would like for it to appear above every thumbnail for every latest post.

    #1276999
    Lely
    Moderator

    Hi There,

    Unfortunately, I am not sure exactly where you want it to appear. Can you give us screenshot pointing us the exact position? This way we can give you more tailored suggestion.

    #1277016
    JfantasyBooks
    Participant

    Ok. So I made a dummy page that imitates the outlook of this site’s frontpage. https://fantasy-books.live/cornerstone-draft/

    As you can see, the right side has the title/excerpt and the left has the thumbnail. This represents the latest posts simlarly structured as the front page.

    Only, on top of each latest post, I would like a particular shortcode to appear. The [Enter Shortcode Here] represents where I want it to appear.

    #1277035
    Lely
    Moderator

    Hi There,

    Thank you for the clarification.
    Please copy content.php file from \wp-content\themes\x\framework\views\global to your child theme here: \wp-content\themes\x-child\framework\views\global.
    Open the copied file and then add the following code:

    <?php if ( is_home() ) : ?>
        <?php echo do_shortcode('[the_shortcode_here]'); ?>
    <?php endif; ?>

    After the following lines:

        <?php if ( has_post_thumbnail() ) : ?>
          <div class="entry-featured">

    Hope this helps.

    #1277038
    JfantasyBooks
    Participant

    Is there an alternative using the child theme?

    Edit: Nvm I see it. I will check it out.

    #1277044
    Lely
    Moderator

    Ok then. Do let us know how this goes.

    #1277047
    JfantasyBooks
    Participant

    Unfortunately, I don’t see :

      <?php if ( has_post_thumbnail() ) : ?>
          <div class="entry-featured">

    in that directory path

    What I get int he content.php is:

    $stack                     = x_get_stack();
    $is_full_post_content_blog = is_home() && x_get_option( 'x_blog_enable_full_post_content' ) == '1';
    
    ?>
    
    <?php
    
    if ( is_singular() || $is_full_post_content_blog ) :
      x_get_view( 'global', '_content', 'the-content' );
      if ( $stack == 'renew' ) :
        x_get_view( 'renew', '_content', 'post-footer' );
      endif;
    else :
      x_get_view( 'global', '_content', 'the-excerpt' );
    endif;
    
    ?>
    #1277055
    Paul R
    Moderator

    Hi,

    Sorry for the confusion.

    You can add the code on top of this line.

    
    if ( is_singular() || $is_full_post_content_blog ) :
    

    The code wll read.

    
    <?php if ( is_home() ) : ?>
        <?php echo do_shortcode('[the_shortcode_here]'); ?>
    <?php endif; ?>
    if ( is_singular() || $is_full_post_content_blog ) :
    

    Hope that helps.

    #1277064
    JfantasyBooks
    Participant

    Ok! Thank You. Just to let you know, the global did not work and crashed the site. But the code you provided me earlier:

      <?php if ( has_post_thumbnail() ) : ?>
          <div class="entry-featured">

    Was actually from the ethos. When I put it in my child theme following your instructions on where to put the shortcode, it worked. Thank You.

    #1277065
    Friech
    Moderator

    We’re delighted to assist you with this.

    Cheers!

    #1277271
    JfantasyBooks
    Participant

    SO, I was able to add the shortcode. But it cuased major problems. It ate away at my resources, significantly slowing down my site.

    Are the shortcodes not built to work like this?

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