Pulling latest uploaded images out of a particular category in Wordpress

Discussion in 'PHP' started by Nima, Aug 29, 2012.

  1. #1
    Is it possible to pull out the thumbnails of the latest added images in a particular category of Wordpress and publish them on an external php page?

    Thanks
     
    Nima, Aug 29, 2012 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    definitely.

    You just need to query the database and get the most recent posts according to your rules (date, post count, category etc) and then use regex to find the <img tags and extract the source of those images.

    Check the RSS - might be quicker to do it that way but I suspect querying the database directly will be more efficient.
     
    sarahk, Aug 29, 2012 IP
    Nima likes this.
  3. Nima

    Nima Well-Known Member

    Messages:
    3,489
    Likes Received:
    243
    Best Answers:
    0
    Trophy Points:
    175
    #3
    I like the first idea. I can write a php code to pull in the complete posts but i dont know how to look for an find the images. Can you help me on that part?
    Thanks
     
    Nima, Aug 30, 2012 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    sarahk, Aug 30, 2012 IP
  5. Nima

    Nima Well-Known Member

    Messages:
    3,489
    Likes Received:
    243
    Best Answers:
    0
    Trophy Points:
    175
    #5
    Nima, Aug 30, 2012 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
  7. Nima

    Nima Well-Known Member

    Messages:
    3,489
    Likes Received:
    243
    Best Answers:
    0
    Trophy Points:
    175
    #7
    Nima, Aug 30, 2012 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #8
    Yes, you just need to update the path.

    This should probably be a plugin if you are going to use the output within the WP site tho
     
    sarahk, Aug 30, 2012 IP
  9. Nima

    Nima Well-Known Member

    Messages:
    3,489
    Likes Received:
    243
    Best Answers:
    0
    Trophy Points:
    175
    #9
    Im going to use it on /index.php where blog blog is in /blog/...
     
    Nima, Aug 30, 2012 IP
  10. afstanislav

    afstanislav Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    16
    #10
    As i think you have 2 options:

    1 - Like said before, you can use MySQL query from WP database and then format your results
    2 - Write external php script which you can integrate inside WP framework and use all functions, options, etc.. which have WP. But this way more difficult.
     
    Last edited: Aug 31, 2012
    afstanislav, Aug 31, 2012 IP