Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post

    help with my script

    PHP Code:
    <?php get_header() ?>
        <div id="center">
    <?php get_sidebar() ?>
    <div id="ads">
    here are some adsthis is the ad space yo
    </div>

    <div id="content">

    <?php $posts get_posts"category=1&numberposts=6" ); ?>
    <?php 
    if( $posts ) : ?>
      
    <div id="chat" class="post">
    <h2><?php the_category(', '); ?> &raquo;</h2>
    <?php foreach( $posts as $num => $post ):
        
    setup_postdata($post);
        if ( 
    $num == ) {// this is the first post ?>
        <div class="pleft">
        <h3 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h3>  
            <div class="entry-content">
                <?php the_content('[Read the rest of this entry]'); ?>
            </div>
          </div>  
        <div class="pright">
        <p>Previous Posts in <?php the_category(', '); ?></p>
        <ul>    
    <?php // these are the rest ?>
        <li><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></li>
    <?php endforeach; ?>
        </ul>
        </div>
        <hr />
    </div>
      
    <?php endif; ?>

    <?php $posts get_posts"category=4&numberposts=6" ); ?>
    <?php 
    if( $posts ) : ?>
      
    <div id="chat" class="post">
    <h2><?php the_category(', '); ?> &raquo;</h2>
    <?php foreach( $posts as $num => $post ):
        
    setup_postdata($post);
        if ( 
    $num == ) {// this is the first post ?>
        <div class="pleft">
        <h3 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h3>  
            <div class="entry-content">
                <?php the_content('[Read the rest of this entry]'); ?>
            </div>
          </div>  
        <div class="pright">
        <p>Previous Posts in <?php the_category(', '); ?></p>
        <ul>    
    <?php // these are the rest ?>
        <li><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></li>
    <?php endforeach; ?>
        </ul>
        </div>
        <hr />
    </div>
      
    <?php endif; ?>
      
    <?php $posts get_posts"category=3&numberposts=6" ); ?>
    <?php 
    if( $posts ) : ?>
      
    <div id="chat" class="post">
    <h2><?php the_category(', '); ?> &raquo;</h2>
    <?php foreach( $posts as $num => $post ):
        
    setup_postdata($post);
        if ( 
    $num == ) {// this is the first post ?>
        <div class="pleft">
        <h3 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h3>  
            <div class="entry-content">
                <?php the_content('[Read the rest of this entry]'); ?>
            </div>
          </div>  
        <div class="pright">
        <p>Previous Posts in <?php the_category(', '); ?></p>
        <ul>    
    <?php // these are the rest ?>
        <li><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></li>
    <?php endforeach; ?>
        </ul>
        </div>
        <hr />
    </div>
      
    <?php endif; ?>

    </div>
        </div>
    <?php get_footer() ?>
    hi i made this for wordpress however im getting some problems
    each post i make has one category
    however when i run this script, it shows
    <h2>cat 1</h2> with posts listed under cat 1
    <h2>cat 1</h2> with posts listed under cat 2
    <h2>cat 2</h2> with posts listed under cat 3

    however its suppose to be
    <h2>cat 1</h2> with posts listed under cat 1
    <h2>cat 2</h2> with posts listed under cat 2
    <h2>cat 3</h2> with posts listed under cat 3
    even if you dont use wordpress, can u check the script?

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    first of all, when you post here, you should really clean up your code to show only what needs to be seen for the issue.

    Now you have a script here from just a quick browse that includes a lot. Like where is the function "get_posts" made (post that code). Is this something being pulled from a database? and your get_posts on here are for cat1 3 & 4


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •