WordPress.org

Ready to get started?Download WordPress

Forums

Childtheme of twenty eleven - Header image slider (5 posts)

  1. cocoonfxmedia
    Member
    Posted 3 years ago #

    be created i,e /wp-content/uploads/2012/01 then 02,03 etc.. etc...

    I currently have in the theme folder an image/ folder and then get PHP to call the images through. I can I change it so that I can point to the uploads or to this directory as my client wants to change the image every month?

    <?php
    $u= '/images/banner'; // this is the directory in the theme //
    $p= get_template_directory_uri();
    $f='.jpg';
    $i=0;
    do
    {
    $i++;
    echo  "<img src=".$p."".$u."".$i."".$f.">\n";
    }
    while ($i<8);
    ?>
  2. cocoonfxmedia
    Member
    Posted 3 years ago #

    anyone?

  3. try to replace get_template_directory_uri() with a suitable get_bloginfo()

    http://codex.wordpress.org/Function_Reference/get_bloginfo

    or:

    http://codex.wordpress.org/Function_Reference/wp_upload_dir

    on second thoughts - might be more complex, as you also might need to adapt the month of the upload directory and the title of the images (?)

  4. RichMacDonald
    Member
    Posted 2 years ago #

    http://wordpress.org/extend/plugins/wp-random-header

    Upload your images to wp-content/header-images and it takes care of randomly selecting a file. You just need to make sure they're the right size. Every month, just replace the contents of the folder.

  5. Digital Raindrops
    Member
    Posted 2 years ago #

    Hi,
    Firstly this will point to the twenty eleven themes folders and not the child themes folders!

    get_template_directory_uri();

    You should add the images in the child themes folder and use:

    $path = get_stylesheet_directory_uri() .'/images/banner/';

    No Code Solution (preffered option)

    as my client wants to change the image every month?

    It looks like this is not a slider as you client want to change the image monthly, as RichMacDonald has said you could just upload headers and these will change on each page load but they will not 'slide', or your client can upload and set the active header themself from admin.

    Using Header Images in a Slider Script:
    To return the headers to use in a slider, there is a function that will return the header images in an array so you can use them in your slider!

    // Get an array of uploaded headers
    $headers = get_uploaded_header_images();
    if( $headers ) {
    	foreach( $headers as $header ) {
    		echo  '<img src="' .$header['url'] .'" />\n"';
    	}
    }

    Slider Plugin
    There are a number of slider plugins out there that could also be used.

    HTH

    David

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.