• Resolved OthelloBloke

    (@othellobloke)


    Hello…

    On my blog I use one of those fake loops to display a post of Youtube video from a ‘Hot Video’ category in the sidebar.

    When I’m on the single post view… it shows the video in the main area (where it’s supposed to) AND in the sidebar (where I don’t want it to show).

    If you go to the following URL you’ll see what I mean:
    https://www.ryanpaul.ca/hot-video/griffin-house-the-guy-that-says-goodbye-to-you-is-out-of-his-mind/

    Anyone have an idea how I can stop the sidebar vid showing when on that post’s single post view?

    I tried assigning the post id to a global variable in the main loop, then assigning the post id to a different variable in the sidebar, and then doing <? if($mainid == $sideid) { ?> in the sidebar but none of that worked.

Viewing 15 replies - 1 through 15 (of 15 total)
  • $post->ID would typically be holding the current post. Might need global $post in your sidebar.php.

    Thread Starter OthelloBloke

    (@othellobloke)

    In sidebar.php I have this:

    <?
    global $post;
    $sideid == $post->ID;
    if ($sideid != $mainid) {
    ?>Fake Loop & Video Here<?php } ?>

    and then at the bottom of single.php I have:

    <?php
    global $post;
    $mainid == $post->ID;
    ?>

    I’ve tried putting both these inside and outside the loops… but it still shows the video in the sidebar when viewing the main single post.

    Sorry, don’t understand what you are trying to accomplish.

    Thread Starter OthelloBloke

    (@othellobloke)

    On this page for instance…

    https://www.ryanpaul.ca/hot-video/griffin-house-the-guy-that-says-goodbye-to-you-is-out-of-his-mind/

    I don’t want that video to show in the sidebar when I’m viewing that page, but DO want it to show when I am NOT on that page.

    The aim is to not have two of the same video showing on screen.

    So you always want the SAME post/video in the sidebar unless it is the post being show in the single.php view?

    Thread Starter OthelloBloke

    (@othellobloke)

    I want the latest post from the Hot Video category to show in the sidebar…

    But I don’t want it to show if the post on the side is the same as the post in single.php view ??

    So I can avoid having the same post / video show twice.

    It will be something in what you call your fake loop:

    if (is_single()) && $post->ID != $id_of_post_in_your_fake_loop {
    //display your post
    }

    If necessary paste that sidebar code in a pastebin and report the link back here.

    Thread Starter OthelloBloke

    (@othellobloke)

    The problem is I can’t get the id of the side post to cross over into the main loop…

    Thread Starter OthelloBloke

    (@othellobloke)

    The problem is I can’t get the id of the side post to cross over into the main loop and vice versa… even with using global.

    Thread Starter OthelloBloke

    (@othellobloke)

    The code I have in the sidebar that shows 1 post from the video category is as follows:

    <?php query_posts($query_string); query_posts("showposts=1&cat=21"); ?><?php while (have_posts()) : the_post(); ?>
    
    <div class="right-margin">
    <?php the_content();  ?><?php edit_post_link('Edit', '<p>[ ', ' ]</p>'); ?>
    
    </div>
    <?php endwhile; ?>

    I want something like this:

    <?php if($fakeloop-postid != $mainloop-postid) { ?>
    
    <?php query_posts($query_string); query_posts("showposts=1&cat=21"); ?><?php while (have_posts()) : the_post(); ?><div class="right-margin"><?php the_content();  ?><?php edit_post_link('Edit', '<p>[ ', ' ]</p>'); ?></div><?php endwhile; ?> 
    
    <?php } ?>

    Then just exclude the post in single with

    $args = array(
    	'showposts' => 1,
    	'post__not_in' => array($post->ID),
    	'cat' => '21'
      );
    query_posts($args);

    Thread Starter OthelloBloke

    (@othellobloke)

    DUDE YOU ROCKKKKKKKK!

    That worked – nearly. But now it ignores the ‘more’ tag I’ve inserted into the post… so when I view ANY page or post on my website, it shows the entire text of the sidebar video.

    ??

    See the note about the more
    Template_Tags/the_content

    Thread Starter OthelloBloke

    (@othellobloke)

    That’s weird because it DOES work if I don’t use the code you gave me.

    At the moment I’m hiding the overflow on the div with css.

    This sucks because I want a more link below the side vid and can’t now ??

    Thread Starter OthelloBloke

    (@othellobloke)

    Actually I think this way worked out better… check it out

    https://www.ryanpaul.ca/

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Stop sidebar content from showing when on that post’ is closed to new replies.