• I have a loop set up as follows:

    [loop type=gazpost taxonomy=gaztype term=deptintro relation=and taxonomy_2=gazissue term_2=issue-1 relation=and taxonomy_3=gazdept term_3=epd]
    [content]
    [/loop]

    This works no problem. However, each post that matches this criteria may also have assigned to it multiple identical custom fields, e.g. a post may have a custom field “gazettepics”, multiple times, and in each instance, containing a unique URL to an image.

    gazettepics: imgurl1
    gazettepics: imgurl2
    gazettepics: imgurl3

    I’ve tried adding:

    [array gazettepics]
    [field value]
    [/array]

    and

    [array gazettepics]
    [-array inner_array]
    [field value]
    [/-array]
    [/array]

    I’m very clearly not doing this right, but it seems the tools are there to make it work… I’m just not sure how. Any help would be much appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter trevolutionary

    (@jkdsouljah)

    After some playing, the latest I have is

    [array]
    [field image=gazettepics in=url]
    [/array]

    This returns only one result however. When I added the debug=true parameter however, I can see the full array for that custom field, as follows:

    [gazettepics] => Array
    (
    [0] => img_url_1.jpg
    [1] => img_url_2.jpg
    [2] => img_url_3.jpg
    [3] => img_url_4.jpg
    [4] => img_url_4.jpg
    )

    If I were hardcoding this into the template in PHP, it’s simple:

    <?php 
    
    $gazpics = get_post_meta($post->ID, 'gazettepics', false);
    if( count( $gazpics ) != 0 ) { 
    
    foreach($gazpics as $gazpics) {
    echo '<a class="gazpiclink" href="'.$gazpics.'"><img class="gazpicthumb" src='.$gazpics.'></a>';
    }
    } else { 
    
    }
    
    ?>

    But I need to be able to achieve the same thing using the shortcodes from this plugin.

    Any help would be greatly appreciated!!!

    Thread Starter trevolutionary

    (@jkdsouljah)

    So now I am managing to output the array with simply:

    [loop type=gazette taxonomy=gaztype term=deptintro relation=and taxonomy_2=gazissue term_2=issue-1 relation=and taxonomy_3=gazdept term_3=epd]
    [content]
    
    [array]
    [field gazettepics]
    [/array]
    
    [/loop]

    This outputs the array as a comma separated string, like so:

    https://example.com/IMG001.jpg, https://example.com/IMG002.jpg, https://example.com/IMG003.jpg, https://example.com/IMG004.jpg

    I’m not sure how I can turn these into images. If I adjust the [field] as follows,

    [array]
    [field image=gazettepics in=url]
    [/array]

    it works but only retrieves the first image in the array.

    Thread Starter trevolutionary

    (@jkdsouljah)

    Couldn’t work this out, so used

    [array]
    <div class=”pics”>[field gazettepics]</div>
    [/array]

    And split the string and wrapped them in an image tag with JS/JQuery. Works well enough.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy Array’ is closed to new replies.