1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Adding text to all posts of certain category in wordpress using MySQL

Discussion in 'Databases' started by nemanjamax, Feb 10, 2015.

  1. #1
    Hey to all!

    I have some blog. In one of my category i have 500 posts. I need to insert one simply link on the top of all of this posts which are for example cat=5.
    SEMrush
    How can i do it using mysql?

    Thanks in advance!
     
    nemanjamax, Feb 10, 2015 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Why in the world would you do this using mysql? Do it using PHP. Simply check for post-category, and if the posts match the criteria, insert a link before the post (or after, or in, or or or)
     
    PoPSiCLe, Feb 11, 2015 IP
  3. nemanjamax

    nemanjamax Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    I was thinking that its much easier to do with mysql, and i am not that good with PHP.

    If you have some idea how to do this pls post code.

    Thanks man.
     
    nemanjamax, Feb 11, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Uhm. This is not mysql's job. What you'd have to do is something like this:
    
    if (in_category($category_name, $post_name)) {
    //insert the link here
    }
    
    Code (markup):
     
    PoPSiCLe, Feb 11, 2015 IP