Grow your CSS skills. Land your dream job.

WORDPRESS THEME DEV HELP…

  • # May 9, 2013 at 10:15 pm

    hey guys..

    ok so im creating a wp theme and on the homepage i have a sidebar that i want to display some images like maybe 8 or so and it’s responsive so its in 2 columns then 1 column, that sorta thing. when i built the site it was still static so i just used but now that i moved into wordpress im trying to figure out how i could upload images into the media uploader and then do some sort of function to query and array and spit the images out and be able to specify the size i want the thumbs to be, how many to spit out, that sorta thing. i know there is a way to do this but im looking and i cant find it or maybe i am seeing it but just not getting it. if somebody could help me that would be really amazing! :)

    # May 9, 2013 at 10:29 pm

    Install Advanced Custom Fields plug-in and create custom field group for your images. Set up rules to only be applicable to specific page you are targeting. Create as many fields as you need, name them appropriately, then just write a function to output them where you need them, here is sample code from my recent project, it builds a Lean Slider Markup by Gilbert Pellegrom:

    // Build Lean-Slider HTML and output all custom fields
    function build_slider_using_page_custom_fields(){
    echo ‘

    ‘;
    $all_fields = get_fields();
    $fields = array_slice($all_fields, 1);
    if($fields){
    foreach($fields as $field_name => $value){
    $field = get_field_object($field_name, false, array(‘load_value’ => false));
    $output = “”;
    $output .= ‘
    ‘;
    $output .= ‘

    ‘;
    echo $output;
    }
    }
    echo ‘

    ‘;
    }

    Also check out the plug-in documentation for more.

    # May 9, 2013 at 10:37 pm

    Thanks so much! I’ll check it out!

    # May 9, 2013 at 10:39 pm

    There isn’t any native WordPress function to spit out images though like loop through an array of images? Just curious? I tried to find something explaining something like that in the codex but no luck. Idk if I’m just not typing in the write thing.

    # May 10, 2013 at 3:09 am

    Yes there is a native way and you just have to follow two steps.
    1. Create an option page in admin and give the options to upload images to the admin.
    2. Use the path of those images where you want to display them with the help of ‘for’ or while loop.

    Now how would you do these two steps, let me suggest the best tutorial for it.

    1.For creating options page: http://www.onedesigns.com/tutorials/how-to-create-a-wordpress-theme-options-page
    For adding multiple media uploaders: http://onetarek.com/wordpress/how-to-use-wordpress-media-uploader-in-plugin-or-theme-admin-page/

    2. Once you read the first two tutorials, you would know how to do this second step.

    # May 10, 2013 at 11:50 am

    thanks very much! :) thats why i love the whole css tricks community everybody helps everybody!!!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".