[ask]putting certain post on the top for each category

Discussion in 'WordPress' started by metronome, Apr 26, 2010.

  1. #1
    Ok, I will get to my point directly:

    Let's say I have 7 categories in my blog, and then I want it so that when the visitor clicks on one of the category, he/she will see the same post on the top. Each category will have different post on the top permanently. How do you do this(easily)?

    So far we know that all new post will be put on the top instead the old one. I could change the date of the post that I want to be put on the top, that it will be nicer if I just have to install plugin or something like that

    thanks for reading.
     
    metronome, Apr 26, 2010 IP
  2. rilwis

    rilwis Peon

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use the custom fields for this. For ex. if you want a post stay at top of its category, create a custom fields name "cat_top" with value "true".

    And then, in the category.php file, use the query_posts('meta_key="cat_top"') to get them.
     
    rilwis, Apr 27, 2010 IP
  3. metronome

    metronome Active Member

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    @rilwis

    hi, thanks for the answer
    so ok, what u mean is actually go to mysql, and then edit the database and add a custom field?
    I am not good in sql could you please tell me how to add new field like you say.
    and then in category.php, i will just have to paste query_posts('meta_key="cat_top"') anywhere?
     
    metronome, Apr 27, 2010 IP
  4. rilwis

    rilwis Peon

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No, you don't need to go to mysql to add custom field. You can see the box for custom field under post editor, and can enter it here.

    The query_posts() function should be placed in top of your Loop. It's a bit complicated, you can read the guide at Codex.
     
    rilwis, Apr 28, 2010 IP
    metronome likes this.
  5. Indiego

    Indiego Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks to open this topic bro..i think i will need this for some of my site.
     
    Indiego, Apr 28, 2010 IP
  6. njadric

    njadric Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is good for stickys :)
     
    njadric, Apr 29, 2010 IP
  7. metronome

    metronome Active Member

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    @rilwis

    ah ok, now I understand, basically in the end of the post that I want to "stick", I just have to put "cat_top" with value "true" in custom field~~thanks man.

    added u a rep point, I havent tried it(not now, for future project) but I am sure it is helpful for people that needed it now
     
    metronome, Apr 29, 2010 IP