• Hello,

    I am trying to use either the shortcode option or the random pet widget to show random pets on my homepage. If I use the shortcode option the pets shown stay the same (the only thing I tried to change was pet.get to pet.getRandom in the php file). If I use the random pet widget I can’t figure out how to show more than 1 random pet (I’m not sure how to edit the php file to show another random pet, the best I could do was have it show the same one again). Any help?

    https://www.ads-software.com/plugins/petfinder-listings/

Viewing 5 replies - 1 through 5 (of 5 total)
  • rawrzors

    (@rawrzors)

    Hi there! You were almost there with the getRandom, but the getRandom function returns a different XML structure than shelter.get.

    In petfinder-listings.php:

    1. Change the API Call URL https://api.petfinder.com/shelter.getPets?key=
    to https://api.petfinder.com/pet.getRandom?key=

    2. Change if( count( $xml->pets->pet ) > 0 ){
    to if( count( $xml->pet ) > 0 ){

    3. Change foreach( $xml->pets->pet as $dog ){
    to foreach( $xml->pet as $dog ){

    Let me know how it goes! Please note that this will cause site-wide changes.

    Thread Starter burnadette02

    (@burnadette02)

    Hello rawrzors,

    Thanks for the reply. I tried that out and then it gave the output “No pets are listed for this shelter at this time. Please check back soon.”

    rawrzors

    (@rawrzors)

    Hi,

    Please copy and paste your .php file into pastebin so I can take a look.

    Thread Starter burnadette02

    (@burnadette02)

    Hi,

    https://pastebin.com/egXGMcyB

    I edited lines 348, 352, and 354

    rawrzors

    (@rawrzors)

    It shows that you changed lines 194, 199, and 201. I changed the same lines on mine.

    Try using shortcode: [shelter_list]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multiple Random Pets’ is closed to new replies.