Need help with PHP code

Discussion in 'PHP' started by goal442, Sep 2, 2008.

  1. #1
    Hello Everyone,
    I hope some one here can help me.

    I would like to add a new category to my wordpress blog. But when I'm adding new post to that particular category, I don't want that post to appear on the first page as the post in other categories do.

    Example:
    Let say I have the following categories:
    Category 1
    Category 2
    Category 3

    Every time I add new post to either one of those three categories, you can see the new post on the front page, which is fine for Those 3 categories.

    But now I want to add a fourth Category "Category 4" .
    This is where I need your help. When I add a new post to my blog under "Category 4", I don't want that post to appear on the first page. The only way for the visitor to see the post in "Category 4" is to actually click on the link "Category 4".

    For your reference, here is the URL to my blog - http://www.goal442.com

    I hope to here back to some one......Thank you very much in advance.

    Please PM me to post a comment in this thread if you need any more details.
     
    goal442, Sep 2, 2008 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #2
    You need to change the sql query for this. I don't know which version of Wordpress you are using. The one I have on my pc has these 2 functions which you need to modify:
    (php functions)
    have_posts()
    while (have_posts()
    for example if query is something like:
    " select * from $tablePosts order by date desc"
    you need to do:
    " select * from $tablePosts where category!='category_name' order by date desc"
    This is not actual wordpress code, just an example to show you what will exclude posts from a specific category.
    regards :)
     
    JEET, Sep 2, 2008 IP
  3. goal442

    goal442 Peon

    Messages:
    328
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    JEET Thank you very much for your reply.
    It's very detailed, but unfortunatly I'm not a PHP expert so I was hoping you can (or anybody else) help figure this out with my code.

    Here is my code for displaying the posts on the front page:

    	<?php if (have_posts()) : ?>
    
                   <?php $counter = 0;?>
    		<?php while (have_posts()) : the_post(); ?>
                   <?php $counter = $counter + 1;?>
    
            <div class="post" id="post-<?php the_ID(); ?>">
    		  <div class="date"><span><?php the_time('M') ?></span> <?php the_time('d') ?></div>
    		  <div class="title">
              <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
              <div class="postdata"><SPAN class="category"><?php the_category(', ') ?></SPAN><span class="comments"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></span>
    Code (markup):
    Please let me know what I need to change.
     
    goal442, Sep 3, 2008 IP
  4. goal442

    goal442 Peon

    Messages:
    328
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Anybody?????? HELP
     
    goal442, Sep 9, 2008 IP
  5. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Hi,

    You want home page static ? right ?

    Thanks,
     
    nice.wallpapers, Sep 9, 2008 IP
  6. goal442

    goal442 Peon

    Messages:
    328
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No I don't want it to be static.
    I have category A, B, C, D, E and F
    When I make a post in category A, B, C, D and E then it's OK for the post to show on the front page.
    But when i make a post in category F then I don't want it to show on the front page. The only way to see the post in category F is if the visitor clicks on "Category F" link in the navigation bar.

    Can anybody help me please?
     
    goal442, Sep 26, 2008 IP