WordPress.org

Ready to get started?Download WordPress

Forums

Most annoying problem. Ever. (5 posts)

  1. abovegrnd
    Member
    Posted 4 years ago #

    I've written a function to capture the number of posts in a given category (my video category) and then display the posts into 3 separate columns.

    The issue is that when I get it to display the correct posts, it ruins the columns! I cannot figure this out!

    Here's the difference:

    To get it to display all of the posts in the correct order I have this:
    <?php query_posts("showposts=$vidsSecond&offset=$vidsFirst&cat=15"); ?>

    But, instead of displaying in three separate columns the way it should, it just stacks them all on top of each other. On the other hand, if I use this code:

    <?php query_posts('showposts=$vidsSecond&offset=$vidsFirst&cat=15'); ?>

    it displays in 3 columns, but only puts the latest video in all of the columns! (notice one uses " and one uses ')

    So, there you have it. The most annoying problem in the world. There is NO reason that I can tell that this would have any effect on the layout of the page. This is driving me bonkers.

    Here's the full code:

    <?php
    /*
    Template Name: Vids
    */
    ?>
    <?php get_header(); ?>
    <?php
    $vidsTotal=get_category(15)->count;
    $vidsFirst=floor($vidsTotal/3);
    $vidsSecond=floor(($vidsTotal-$vidsFirst)/2);
    $vidsThird=ceil($vidsTotal-($vidsFirst+$vidsSecond));
    ?>
    <div id="content">
    <div id="VidsLeft" style="width:600px;margin: 2px 2px 2px 0;float:left;">
                    <div id="LeftLeft" style="float:left;width:275px;">
    		<?php query_posts("showposts=$vidsFirst&offset=0&cat=15"); ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="text" align="center">
    			<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading <?php the_title(); ?>"><?php the_title(); ?></a></h3>
                            <br />
    			<?php
    			$values = get_post_custom_values("vid");
    			if($values != "")
    			{
    			echo "<object width='200'><param name='movie' value='$values[0]'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='$values[0]' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='200'></embed></object>"; }
    			?>
                            <?php $values = get_post_custom_values("vidAlt"); echo $values[0]; ?>
                            <br />
                            <?php the_excerpt(); ?>
                            <?php endwhile; ?>
                            </div>
                    </div>
                    <div id="LeftRight" style="float:right;width:275px;">
    		<?php query_posts("showposts=$vidsSecond&offset=$vidsFirst&cat=15"); ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="text" align="center">
    			<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading <?php the_title(); ?>"><?php the_title(); ?></a></h3>
                            <br />
    			<?php
    			$values = get_post_custom_values("vid");
    			if($values != "")
    			{
    			echo "<object width='200'><param name='movie' value='$values[0]'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='$values[0]' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='200'></embed></object>"; }
    			?>
                            <?php $values = get_post_custom_values("vidAlt"); echo $values[0]; ?>
                            <br />
                            <?php the_excerpt(); ?>
                            <?php endwhile; ?>
                            </div>
                    </div>
    </div>
                    <div id="RightVids" style="float:right;width:300px;">
    		<?php query_posts("showposts=$vidsThird&offset=($vidsFirst+$vidsSecond)&cat=15"); ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="text" align="center">
    			<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading <?php the_title(); ?>"><?php the_title(); ?></a></h3>
                            <br />
    			<?php
    			$values = get_post_custom_values("vid");
    			if($values != "")
    			{
    			echo "<object width='200'><param name='movie' value='$values[0]'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='$values[0]' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='200'></embed></object>"; }
    			?>
                            <?php $values = get_post_custom_values("vidAlt"); echo $values[0]; ?>
                            <br />
                            <?php the_excerpt(); ?>
                            <?php endwhile; ?>
                            </div>
                    </div>
    </div>
    <div class="clearer"></div>
    <?php get_footer(); ?>

    Any help would seriously be GREATLY appreciated.

  2. abovegrnd
    Member
    Posted 4 years ago #

    Still annoyed.

  3. iridiax
    Member
    Posted 4 years ago #

    Maybe the flaky behavior is due to the multiple loops malfunctioning:

    http://codex.wordpress.org/The_Loop#Multiple_Loops

    Another thing to check is that you aren't accidentally getting fancy quotes in your code due to copy and pasting.

  4. abovegrnd
    Member
    Posted 4 years ago #

    Thanks for the insight iridiax. I'm not finding any funky quotes or anything. I looked at the codex you linked, but everything seemed in line according to that site.

  5. abovegrnd
    Member
    Posted 4 years ago #

    Hi.

Topic Closed

This topic has been closed to new replies.

About this Topic