WordPress.org

Forums

Multi Image Metabox
Custom template help (2 posts)

  1. Samuel
    Member
    Posted 1 year ago #

    Great plugin, but I'm having a bit of trouble with my output.

    In my functions.php I have -

    add_filter('images_cpt','my_image_cpt');
        function my_image_cpt(){
            $cpts = array('page');
            return $cpts;
        }
    
    add_filter('list_images','my_list_images');
        function my_list_images(){
            $picts = array(
                'image1' => '_image1',
                'image2' => '_image2',
                'image3' => '_image3',
                'image4' => '_image4',
            );
            return $picts;
        }

    I want to print the 4 images in each page automatically. So I put this into my template.php -

    <?php
    get_images_ids(false,id);
    array(
        [0]  => 45,
        'image1' => '_image1',
        'image2' => '_image2',
        'image3' => '_image3',
        'image4' => '_image4'
    );
    ?>

    On the frontend, I get this error - Error while parsing PHP: syntax error, unexpected '[', expecting ')'

    Could anyone point me in the right direction?

    thanks.

    http://wordpress.org/extend/plugins/multi-image-metabox/

  2. Willy Bahuaud
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,

    You can retrieve your liked pictures using, inside of the WordPress loop :

    $imgs  = get_images_src('your-custom-size');
    foreach( $imgs as $i )
    echo '<img src="' . $i[0] . '">';

    If you want to retrive this images outside of a loop, or for another post, you can ad other parameters to get_images_src(). More information here.

    Thanks for using my plugin !

    :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic