Can I use echo to place data in a certain spot

Sundace60

Registered Member
Joined
Jun 22, 2009
Messages
53
Reaction score
18
I have a string in my main index that looks like this:

Code:
if (is_sticky()) { echo " id='sticky' "; } echo ">";
What this does is post info like a "Sticky" on a forum at the very top of the list. It does this for every category that the "Sticky" applies to.

I want the sticky to be placed in a table that is 1 row with 4 columns that will apply to the respective categories.

Here is how the code looks on the main index page:

Code:
<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 1 ROW AND 4 COLUMNS WILL START -->    
        

<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;

<!-- HERE IS WHERE THE STICKY IS CALLED AND I WANT IT PLACED IN THE AREA ABOVE THIS -->
                    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>
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.

(I won't divulge my site, but the code above is from a classified ad script called "ClassiPress" which is a theme you can use in Wordpress). I just modified the hell out of it to suit my purpose.)
 
Something like this?

Code:
echo "<table border=\"1\"  background=\"http://www.autogatesandfencing.com.au/images/bottom_color_border.gif\">
<tr>
<td>This Should Say Sticky</td>
<td>This should say categorie 1</td>
<td>This should say categorie 2</td>
<td>This should say categorie 3</td>
</tr>

</table>"
 
No, the 1 row and 4 columns are used for data and should look like 4 boxes side by side which contain the data the 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.


The original code places all data like a forum sticky at the top of each thread. I don't want the info placed like a sticky. I want them separated into their own area above the regular list of information.

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

Code:
<?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;
                    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(); ?>
 
Back
Top