Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Martel

    (@mike_cowobo)

    Hi again Lewis!

    The exclude_current_post parameter works under 2 conditions:

    1. You must be ‘in the loop’ – so it will only work if the shortcode is in the content of your post. For example, it won’t work in the sidebar or footer.

    2. The id parameter must not be set. If you give a list of ids, it will not take out the current post from that list.

    Apart from that, I have it working good on my test server. Also, you don’t have to specify exclude_current_post, because it is set to true by default!

    If the above doesn’t help.. do you have the page online, so I can see what’s happening?

    Mike

    Thread Starter Lewis Tyler

    (@tylerjfrags)

    Hi Mike, sorry to leave you hanging on this one 🙂

    I’ve come back to this and well, here is my code. I having read your words I think the problem is I am using echo to call the shortcode, when I should be doing php?

    Here it is:

    <div class="single-portfolio <?php echo $class ?>">
    <div class="container">
    
            <div class="portfolio-content">
    
              <?php echo the_content(); ?>
    
            </div>
    <!---
    -->  
    
    </div>
    
    <div class="container" id="more-portfolio">
      <div class="titles " style="margin-top: 45px; margin-bottom: 40px;"><i class="fa fa-search"></i><h1>Other projects</h1></div>
      <?php echo do_shortcode('[wp-tiles post_type="Portfolio" exclude_current_post="true" orderby="date" order="ASC" grids="Portfolio" small_screen_grid="Mobile" breakpoint="800" padding="25" grid_selector_color="#444444" posts_per_page=4]'); ?></div>
    </div>
    
    <?php get_footer(); ?>
    Plugin Author Mike Martel

    (@mike_cowobo)

    Hi Lewis!

    Welcome back 🙂

    The best way to include WP Tiles in a php template, is by using the_wp_tiles(). I haven’t documented this for the new version yet, but this week I have set some time apart to finish the docs for the 1.0 version and finally release it in full. When the release happens, it will all be on http://wp-tiles.com/.

    But the way you’re doing it now is valid, and if it works it works!

    For exclude_current_post, however, the shortcode should be in the loop. In most templates that is between if ( have_posts() ) : while ( have_posts() ) : the_post(); and endwhile; else :.

    But because you are putting the shortcode in a template file directly, you could exclude the current post yourself manually, also outside the loop. To do this, add exclude=' . get_the_ID() . ' to the shortcode. It would then look like this:

    <?php echo do_shortcode('[wp-tiles post_type="Portfolio" orderby="date" order="ASC" grids="Portfolio" small_screen_grid="Mobile" breakpoint="800" padding="25" grid_selector_color="#444444" posts_per_page=4 exclude=' . get_the_ID() . ']'); ?>

    (Oh btw, there seems to be a </div> too many in your example, after the shortcode!)

    Let me know if that worked for you!

    Mike

    Thread Starter Lewis Tyler

    (@tylerjfrags)

    Hey Mike thank you for the help 🙂

    Here’s what I did, it was actually quite simple. I just looked up the standard loop code and stuck the shotcode echo in it.

    <?php
    if ( have_posts() ) {
    	while ( have_posts() ) {
    		the_post();
    		//
    
        echo do_shortcode('[wp-tiles post_type="Portfolio" exclude_current_post="true" orderby="date" order="ASC" grids="Portfolio" small_screen_grid="Mobile" breakpoint="800" padding="25" grid_selector_color="#444444" posts_per_page=4]');
    
    		//
    	} // end while
    } // end if
    
    ?>

    Thanks again – I’m off to codecademy to brush up on my php!

    So there is absolutely no way to get it to exclude the current post from the sidebar? It seems most people use tiles in the sidebar or other widget spot.

    I love the tiles but I don’t want it show the tile for the post they are reading right at the top.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘exclude_current_post="true" not working?’ is closed to new replies.