I have a string in my main index that looks like this:

if (is_sticky()) { echo " id='sticky' "; } echo ">";

What this does is post info like a "Sticky" in a format like the thread of a forum at the very top of the list. It does this for every category that the "Sticky" applies to.

Instead, I want the sticky to be placed in a table that is 1 row with 4 columns. The 1 row and 4 columns are used for data and should look like 4 boxes side by side which contain the data that is called by the "Sticky" string. Then below these 4 boxes is the regular data that looks like forum threads. I just don't want the "Sticky" to be at the TOP of the forum posts, rather I want them separated and on their own.

Here is the entire main index to show you what I am working with:

<?php
require_once dirname( __FILE__ ) . '/form_process.php';
get_header( ); 
include_classified_form( );
?>

    <div class="content">
    
        <ul id="catnav">
            <li<?php if ( is_home() ) { echo " class=\"current-cat\""; } ?>><a href="<?php bloginfo('url'); ?>" ><?php _e('Latest Listings','cp'); ?></a></li>
            <?php wp_list_categories('show_count=0&hide_empty=true&orderby=name&order=asc&title_li='); ?>
            <li><div class="clear"></div></li>
        </ul>
        
        <?php if ( is_category() && function_exists('bcn_display')) { ?>    
            <div class="subnav">
                <small><?php if(function_exists('bcn_display')) { bcn_display(); } ?></small>
            </div>
        <?php } ?>
    <!-- HERE IS WHERE THE 4 BOXES OF INFO WILL START.  THIS IS WHERE I WANT THE "STICKY" DATA TO BE PLACED-->    
        <div class="main">
        
            <div class="listing">
                <div class="head">
                                                       
                    <div class="clear"></div>
                </div>
                <div class="list">
                    <?php 
                    $i = 1; 
                    
                    if(!empty($_GET['sort']))
                    {
                    $orderby=trim($_GET['sort']);
                    $order=trim($_GET['order']);
                    $key=trim($_GET['key']);
                    
                    // create the sort by injection
                    $posts = query_posts($query_string . '&orderby='.$orderby.'&meta_key='.$key.'&order='.$order.'');
                    }
                    
                    if (have_posts()) : ?>
                    
                    <?php while (have_posts()) : the_post(); ?>
                    
                    <?php if ($i % 2 == 0) { $alt = " class=\"alt\""; } else { $alt = " class=\"no\""; } echo "<div" . $alt;

<!-- BELOW IS THE STRING THAT CALLS THE "STICKY" AND PLACES THEM AT THE TOP OF EACH THREAD -->
                    if (is_sticky()) { echo " id='sticky' "; } echo ">"; 
                    ?>
                        
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                    
                    <?php if ( get_option('main_page_img') != "no" ) { ?>

                        <span class="image">    
                            <?php $images = get_post_meta($post->ID, "images", true);
                                if (empty($images)) {?>
                                    <div class="main_page_no_img"><img src="<?php bloginfo('template_url'); ?>/images/no-pic.png" alt="No Photo" border="0" /></div></span>
                                <?php } else { ?>
                                <div class="main_page_img" style="background: #FFF url(<?php echo get_bloginfo('template_url')."/includes/img_resize.php?width=350&height=355&url=";?><?php
                                          if ( strstr($images, ',')) {  
                                            $matches = explode(",", $images);
                                            $img_single = $matches[0];
                                            $img_single = explode(trailingslashit(get_option('siteurl')) . "wp-content/uploads/classipress/", $img_single);
                                            echo $img_single[1];
                                          } else {
                                            $img_single2 = $images;
                                            echo $img_single2;
                                                }?>) center no-repeat"></div></span>
                                <?php 
                                } 
                                    } else {
                                        $ii = 1;
                                        echo "<span class='cat_image'>";
                                        foreach((get_the_category()) as $category) {
                                            if ($ii == "1") {
                                                $cat_image = get_bloginfo('template_url')."/images/category-icons/".get_option("cat$category->cat_ID").".png";
                                                echo "<img src=" . $cat_image . ">";
                                                $ii++;
                                            }
                                        }
                                        echo "</span>";
                                    } ?>
                                
                                <span class="item"><div style="text-decoration:underline; font-weight:bold;"><?php if ( strlen(get_the_title()) > 65 ) { echo substr(get_the_title(), 0, 65)."..."; } else { the_title(); } ?></div>
                                <?php echo substr(strip_tags($post->post_content), 0, 190)."...";?></span>

                                
                            </a>
                            <div class="clear"></div>
                        </div>
                        
                    <?php $i++; unset($alt); ?>
                    
                    <?php endwhile; ?>
                    

                        <div class="navigation1">
                        <div class="navigation2">
                        
                        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else {  ?>
                        
                            <div class="alignleft">
                                <?php next_posts_link('<div class="next_post_link"></div>') ?>
                            </div>
                            <div class="alignright">
                                <?php previous_posts_link('<div class="previous_post_link"></div>') ?>
                            </div>
                            
                        <?php  } ?>
                        
                        </div>
                        <div style="clear:both;"></div>
                        </div>
                    <div style="clear:both;"></div>
                    
                    <?php endif; ?>
                    
                </div>
            </div>
        </div>
    </div>
    
<?php
//code to prune posts.
if (get_option("post_prun") == "yes" && get_option("prun_period") != "" && get_option("post_prun") != "") {
    $prun_period = get_option("prun_period");
    $sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_date`<'".date('Y-m-d h:i:s', strtotime("-$prun_period days"))."' AND `post_status`='publish' AND `post_type`='post' LIMIT 10";
    $sql = mysql_query($sql);
    while ($row=mysql_fetch_array($sql)){
        $post_id = (int)$row['ID'];

        if (get_option("prun_status") == "1") {
            $my_post = array();
            $my_post['ID'] = $post_id;
            $my_post['post_status'] = 'draft';
            wp_update_post( $my_post );
        } else if (get_option("prun_status") == "2") {
            wp_delete_post($post_id);
        }
    }
}
?>    
    
<?php get_footer(); ?>

My thinking is that I should just make another class selector and place the html code where I want the table to appear and when the server reads the "sticky" string, it will just place (echo) the data to the correct location on the web page.

I just can't find any examples on the web to back up my theory and I can't get it to work correctly no matter what I do.

Can anyone here give me some help.

Looks like your dealing with WordPress! I'm not sure how you can get the is_sticky() outside of the have posts loop. The only thing I can think of is using absolute positioning in CSS and creating a table where the is_sticky() is and then position it at the top of your page where you want the sticky to be:

#sticky { position: absolute;  top: 100px; } /* Position it 100px from the top of the page */

Then the only thing you would have to do is add some margin on the element below or above where the sticky would be placed so the absolutely positioned table won't overlap anything.

load the results from is sticky to an array, then output the array.

$sticky_array = array();
if (is_sticky()) 
     {
          $sticky_array[] = $yourid;
     }

You'll have to run your logic at the top of the page. then output the sticky and other stuff where you want it.

load the results from is sticky to an array, then output the array.

$sticky_array = array();
if (is_sticky()) 
     {
          $sticky_array[] = $yourid;
     }

You'll have to run your logic at the top of the page. then output the sticky and other stuff where you want it.

just use foreach loop and get values which is in array

commented: Your well put together answer solved my problem. Thank you! +3

just use foreach loop and get values which is in array

exactly. but you need to load the array first.

exactly. but you need to load the array first.

yaa... i am also saying same like that. first we have to load an array. when we have to use that array then use foreach loop for get each value which is in array.

just use foreach loop and get values which is in array

This worked well. Thank you very much!

This worked well. Thank you very much!

You're welcome, even though you thanked the wrong guy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.