WordPress.org

Ready to get started?Download WordPress

Forums

probelms with banner images (33 posts)

  1. giec
    Member
    Posted 2 years ago #

    Hi there, I would like to modify the images in the banner section. I was told to change them from the dashboard - appearance - header, but what if I want to change them manually?
    I have created a child theme folder and I have created an image->header folder too. I have added my new image there, but the banner hasn't change. Any suggestion please?
    thanks

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    What theme is this? It might be possible to do it via custom fields but it would take some additional PHP coding.

  3. giec
    Member
    Posted 2 years ago #

    ah sorry, here's the link to it http://andys.antonioborrillo.co.uk/wp/. I am sure there is an easy way just changing the html and css. If not, unfortunately I don't know any php, so if that's the only way then I will have to do it through the dashboard

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Do not edit the Twenty Eleven theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes.

  5. giec
    Member
    Posted 2 years ago #

    yes, as I said in my post, i already have a child theme created and the associated child folders

  6. giec
    Member
    Posted 2 years ago #

    with that in mind, any idea? : - )

  7. esmi
    Forum Moderator
    Posted 2 years ago #

    Do you have an images/headers folder in your child theme with your new banner images?

  8. giec
    Member
    Posted 2 years ago #

    that's correct esmi, I have an image/headers in my child theme. There is only one image in there at the moment but I am planning to add a few more. The thing is though, the banner still has the old images

  9. esmi
    Forum Moderator
    Posted 2 years ago #

    Try adding your new images using register_default_headers in your child theme'#s functions.php file. You can get rid of the default ones from the parent theme by using unregister_default_headers.

  10. giec
    Member
    Posted 2 years ago #

    uhm, thanks but I don't know much about php I am afraid, so I am not entirely sure how to use the function. If I add the new images using the dashboard, is it ok anyway? I mean can I replace the old ones?

  11. esmi
    Forum Moderator
    Posted 2 years ago #

    You can add as many new images as you want via Appearance -> Header. And you don't need a child theme for this either. What you can't do is remove any of the original banners except by unregistering them in a child theme.

  12. giec
    Member
    Posted 2 years ago #

    ah I see, no the thing is I need to remove the original images and replace them with mine in my child theme. If I remove all the current images from the image->headers folder and replace them with mine, wouldn't that be enough - bearing in mind that eventually I will need to move the wordpress site to another domain and probably a different host.
    So, to do that I have to resort to the register_Default_heading I seem to understand. I had a look at the link you sent me but I am not sure how to construct the function

  13. giec
    Member
    Posted 2 years ago #

    I mean I have found this post, so I was wondering if I can do the same thing. I don't mind changing images in the parent folder as long as the change is permanent http://wordpress.org/support/topic/how-to-change-the-headerbanner-image-in-my-theme?replies=7

  14. esmi
    Forum Moderator
    Posted 2 years ago #

    Not if you are using the Twenty Eleven theme or a Twenty Eleven child, no.

  15. giec
    Member
    Posted 2 years ago #

    oh no. Ok then, if I remove the original images from the parent theme and replace them with mine, all this using the dashboard of course, what happens when I then transfer the wordpress site to a different domain and probably a different hosting provider? DO I lose all the images and need to copy them again into the folder? If so, could you possibly give me some advice as to how to use the php function as you mentioned earlier on? I mean if it isn't too difficult maybe I can have a go myself
    thanks

  16. giec
    Member
    Posted 2 years ago #

    ok, maybe it isn't as complicated as I have thought.
    so here's part of the function with the array:

    register_default_headers( array(
    		'wheel' => array(
    			'url' => '%s/images/headers/wheel.jpg',
    			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Wheel', 'twentyeleven' )
    		),
    ...

    Assuming I have copied the images I want to use in the images->headers folder in my child theme /public_html/andys/wp/wp-content/themes/twentyeleven-child/images/headers. Say I have 2 images: image1.jpg and image2.jpg.
    How should I change the function to?
    -in the 'wheel' => array( I guess I don't have to change 'wheel';
    -the url, is the path the same, apart form the file name? 'url' => '%s/images/headers/image1.jpg',
    -Same for the thumbnail?
    -how about the description, does is stay the same?
    thanks

  17. esmi
    Forum Moderator
    Posted 2 years ago #

    You need to use something like:

    register_default_headers( array(
    		'wheel' => array(
    			'url' => '%s/images/headers/image1.jpg',
    			'thumbnail_url' => '%s/images/headers/image1-thumbnail.jpg',
    			'description' => __( 'name_of_image_here', 'twentyeleven' )
    		)
  18. giec
    Member
    Posted 2 years ago #

    uhm, I think something went wrong. I have created another functions.php file in my /public_html/andys/wp/wp-content/themes/twentyeleven-child, and replaced the register_default_headers to the following

    register_default_headers( array(
    		'wheel' => array(
    			'url' => '%s/images/headers/andy_background.jpg',
    			'thumbnail_url' => '%s/images/headers/andy_background.jpg',
    			/* translators: header image description */
    			'description' => __( 'andy_background', 'twentyeleven' )
    		),
    		'shore' => array(
    			'url' => '%s/images/headers/andy_background_1.jpg',
    			'thumbnail_url' => '%s/images/headers/andy_background_1.jpg',
    			/* translators: header image description */
    			'description' => __( 'andy_background_1', 'twentyeleven' )
    		)
    	) );
    }

    If you look at my site now though you nget the following error http://andys.antonioborrillo.co.uk/wp/?page_id=20. It's all gone bananas...

  19. esmi
    Forum Moderator
    Posted 2 years ago #

    Have a look at the Twenty Eleven's functions,php file. See how its register_default_headers() is wrapped inside a function (twentyeleven_setup() ) that is then added to the after_setup_theme action hook? You need to do something similar in the child. Wrap the header banners code inside a function called something like my_headers() and then use add_action( 'after_setup_theme', 'my_headers' ); to get the function to run.

  20. giec
    Member
    Posted 2 years ago #

    But I don't get this. I mean, I thought I could reuse the functions.php file in my own folder (/public_html/andys/wp/wp-content/themes/twentyeleven-child), change the reference to the pictures and the theme and run the function. Is that because my twentyeleven-child folder doestn' have all the necessary php files in it?

  21. esmi
    Forum Moderator
    Posted 2 years ago #

    I thought I could reuse the functions.php file in my own folder

    Nooo! You have to start with a blank functions.php file in the child theme and then just add your new or custom functions to that file.

  22. giec
    Member
    Posted 2 years ago #

    you mean my functions.php to go into /public_html/andys/wp/wp-content/themes/twentyeleven-child should look like this;

    <?php
    
    my_headers ( array(
    		'wheel' => array(
    			'url' => '%s/images/headers/andy_background.jpg',
    			'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Wheel', 'twentyeleven' )
    		),
    		'shore' => array(
    			'url' => '%s/images/headers/andy_background_1.jpg',
    			'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
    			/* translators: header image description */
    			'description' => __( 'Shore', 'twentyeleven' )
    		)
    	) );
    add_action( 'after_setup_theme', 'my_headers' );
    ?>

    As said I don't do php so not sure whether the syntax is correct
    thanks

  23. esmi
    Forum Moderator
    Posted 2 years ago #

    Yes! You've got it!

  24. giec
    Member
    Posted 2 years ago #

    one more thing esmi, I think the syntax is wrong. My header is a function, how about this version then:

    <?php
    
    function my_headers(){
    register_default_headers ( array(
    		'image1' => array(
    			'url' => '%s/images/headers/andy_background.jpg',
    			'thumbnail_url' => '%s/images/headers/andy_background_thumb.jpg',
    			/* translators: header image description */
    			'description' => __( 'Image description', 'twentyeleven-child' )
    		),
    		'image2' => array(
    			'url' => '%s/images/headers/andy_background_1.jpg',
    			'thumbnail_url' => '%s/images/headers/andy_background_1_thumb.jpg',
    			/* translators: header image description */
    			'description' => __( 'Shore', 'twentyeleven-child' )
    		)
    	) );
    }
    add_action( 'after_setup_theme', 'my_headers' );
    ?>
  25. esmi
    Forum Moderator
    Posted 2 years ago #

    Oops - I missed that, You're right. You need to use function my_headers().

  26. giec
    Member
    Posted 2 years ago #

    uhm, it doesn't work. There is actually something peculiar happening. The original images are still all there. I managed to load my images (even if oddly enough I had to use an absolute path in the php script?!)If you refresh a good 7-8 times http://andys.antonioborrillo.co.uk/wp/?page_id=20 you will still see the default images.How do I get rid of them? we are getting there : - )

  27. esmi
    Forum Moderator
    Posted 2 years ago #

    First. can you see the new images in the back end of your site in Admin -> Header?

  28. giec
    Member
    Posted 2 years ago #

    I actually ca, although for some odd reasons they are not thumbnails but full pictures, but they are there yes

  29. esmi
    Forum Moderator
    Posted 2 years ago #

    You need to upload a second set of smaller banner thumbnails that are 230 x 66.

  30. giec
    Member
    Posted 2 years ago #

    well I am not too worried about the thumbnails to be honest, what worries me is the fact that I need to get rid of the default images that are stil there. How do I do that, can I do it from the dashboard or do I have to do it on the php script?
    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.