Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WORDPRESS THEME DEV HELP…

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #44675
    dominick1
    Member

    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! :)

    #134632
    Alen
    Participant

    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.

    #134635
    dominick1
    Member

    Thanks so much! I’ll check it out!

    #134636
    dominick1
    Member

    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.

    #134644
    ghafirsayed
    Member

    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.

    #134701
    dominick1
    Member

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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.