Viewing 6 replies - 16 through 21 (of 21 total)
  • Nothing strange going on in there either. Can you drop a copy of your header and sidebar into the pastebin?

    Thread Starter Sandro Dzneladze

    (@sandrodz)

    oh sorry I had connection problems so… here we go,

    Sidebar: https://wordpress.pastebin.ca/1406317
    header: https://wordpress.pastebin.ca/1406325

    :S

    Ok – I’m officially stumped. I can’t see anything wrong in the code snippets that you’ve posted. The only thing left to try is deactivating all plugins in case one is interfering.

    Thread Starter Sandro Dzneladze

    (@sandrodz)

    ?? like me… it’s very very interesting / frustrating… I will try ur suggestion and report back.

    Hi, sandrodz!

    I had the same problem (not really the same). I wanted a single random post before my regular posts.

    The problem is that the random post could be seing only when i was logged in, and the post wasn′t a random post (it always displayed the same post)

    I reactivated all my plugins, and deleted the ones I was not using. It didnt work… Then I tried this solution from esmi (I just deleted the tag selection).

    This worked for me! I hope this can help you… Here is the code I′m using:

    <?php
    $taggedposts = get_posts('category_name=Humor&showposts=1&orderby=rand');
    foreach($taggedposts as $post) :
        setup_postdata($post);?>
        [ do stuff ]
    <?php endforeach; ?>

    I had a similar issue where I needed to include the content of custom fields from a random posts in a specific category in my sidebar. In case it helps anyone, here is my hodgepodge of code. — I was rather proud of myself ??

    <?php query_posts('category_name=bonus_benefits&showposts=1&orderby=rand'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
              <?php // check for thumbnail
    $thumb = get_post_meta($post->ID, 'Sidebar Thumbnail', $single = true);
    // check for thumbnail class
    $sidebar_text = get_post_meta($post->ID, 'Sidebar Text', $single = true);
    $thumb_class = get_post_meta($post->ID, 'Thumbnail Class', $single = true);
    // check for thumbnail alt text
    $thumb_alt = get_post_meta($post->ID, 'Thumbnail Alt', $single = true); ?><?php // if there's a thumbnail
    if($thumb !== '') { ?>
    	<p>
    	<a href="<?php the_permalink(); ?>"><img src="<?php echo $thumb; ?>"
    	class="<?php if($thumb_class !== '') { echo $thumb_class; } else { echo "sidebar-thumbnail"; } ?>"
    	alt="<?php if($thumb_alt !== '') { echo $thumb_alt; } else { echo the_title(); } ?>"
    /></a></p><p><h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php echo $sidebar_text; ?>
    	</p>
    <?php } // end if statement
    
    // if there's not a thumbnail
    else { echo ''; } ?>      
    
    <?php endwhile; ?>
    <?php endif; ?>
     <?php wp_reset_query(); ?>
Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘weird problem trying to show random post’ is closed to new replies.