• Hey all! I’m new to WP and I am trying to build a Plugin. I’m kinda done with it but I dont get how to loop through the custom fields I’ve build.

    If I do a var_dump on my Array it looks like this:

    array(2) {
        [0] => array(3) {
            ["title"] => string(11)
            "First Title" ["content"] => string(13)
            "First Content" ["image"] => string(67)
            "http://localhost/wordpress/wp-content/uploads/2015/09/hotel1-29.jpg"
        }[1] => array(3) {
            ["title"] => string(13)
            "Second title " ["content"] => string(14)
            "Second Content" ["image"] => string(67)
            "http://localhost/wordpress/wp-content/uploads/2015/09/image-29.jpg"
        }
    }

    Appreciate any advice!

    Thanks in Advance

    ners

Viewing 1 replies (of 1 total)
  • Just use a foreach loop on your variable:

    foreach( $myfields as $key => $value ) {
    
        echo $value['title'];  // This is the title of each array item
        echo $value['content'];  // This is the content of each array item
        echo $value['image'];  // This is your image link of each array item
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Loop through custom Fields from self build plugin’ is closed to new replies.