WordPress.org

Ready to get started?Download WordPress

Forums

Specific header image for specific category? (87 posts)

  1. Marventus
    Member
    Posted 2 years ago #

    So,
    I tried the script on the Graphene theme directly, and it worked like a charm, both for categories and pages.
    The script, which is basically a filter function, has to be pasted in the functions.php file after the function named graphene_get_header_image (i.e., after the add_action command). By "after" I don't mean right after: the script should work as long as it is placed below the graphene_get_header_image function.
    If you don't want to mix theme functions and custom functions in the same file, you could create a file called user-functions.php in your theme folder, paste the script there, and insert this line of code at the end of functions.php (before the php closing tag):

    include_once (TEMPLATEPATH . '/user-functions.php');

    If that doesn't work, you could try updating WP and Graphene, assuming this is an option for you, of course. If it isn't, there's one more thing you could try, which is disabling all the plugins to make sure they are not interfering with the loading of the images.

  2. Romain51
    Member
    Posted 2 years ago #

    Hi,
    Thanks for the test.
    I tried it both ways (directly in the functions.php after the graphene_get_header_image; and with a separate user-functions.php) and unfortunately without success...
    So I guess I should try to update graphene first and then WordPress if no change.
    But I'm not sure I want to do that, I have to check before all customizations I did...
    So if I decide to do so, I'll let you know what's going on.

    Thx anyway, and if you think of something else, don't hesitate to tell.

    cheers;

  3. raindance
    Member
    Posted 2 years ago #

    Romain-
    Sorry I don't know why it's not working, but for sure you should consider setting up a child theme. Read about it on the Graphene forum. If you search by threads by my raindance name, you'll find a conversation about it. It's easy to set up but you'd have to get all your customizations tied into it. If you can live with that headache once then you'll never not be able to easily update. A child theme is just sort of a sub-set of your theme. It's still Graphene, but you have a functions file which overrides specific bits as you wish to customize. Then when the theme or WP is updated, you don't ever lose your customizations. It really makes a huge difference.

    Check out the Graphene forum threads on it, spend the time to have a child theme and you will be forever glad you did it as updates happen!

  4. Marventus
    Member
    Posted 2 years ago #

    Hi Romain,
    As Laura puts it, making a child-theme is the most recommended approach, specially for themes that are regularly updated.
    You could try to update WP only first and see what happens (always backup your files and your DB before hand): you not even have to update Graphene.
    If that doesn't work, you will have to update the theme as well. In order to do so, you could backup your custom version, update the theme, and then create a child theme containing the modified files.
    However, if that fails too, you could compare your custom files against the new source ones here. The Pastebin also has a feature to compare different versions of the same code, but you will have to create a paste, then a new version of the same paste, and then click on "View differences."

  5. Marventus
    Member
    Posted 2 years ago #

    I turned the script into a downloadable zip file, and it is available here. The zip file contains the script (custom-header-images-script.txt) and a separate txt with the instrucitons (_readme.txt).

  6. raindance
    Member
    Posted 2 years ago #

    You rock! Awesome!

  7. Romain51
    Member
    Posted 2 years ago #

    Hey, thanks for the feedbacks.
    In fact I cannot update WordPress, cause wordpress 3.2.1 requires PHP version 5.2.4 or higher (my provider only provides me with PHP 5.1.3RC4-dev). So I have to stay with WordPress 3.1.2
    So finally I updated Graphene: But same problem. I really checked everything (naming of folders, ID of categories, placement of the script, size of jpegs) and I'm sure I did not forget anything.
    So my guess is that it's not working with my version of wordpress.
    Of course if anyone-else have managed to have the code working on wordpress 3.1.2 (or previous version), please post ! :)

    Thanks,

  8. Marventus
    Member
    Posted 2 years ago #

    Hi Romain,

    I don't think custom images can work on WP 3.1.2, because if I'm not mistaken, header images were introduced in 3.2.
    However, the good news is that I have PHP 5.2.17 running on one of my site's servers, and WP 3.2.1 is working flawlessly on it. Did you use phpinfo to retrieve your PHP version or did you look at your host's site? The most accurate way is to do it through phpinfo. To do so, you just have to paste this code into an empty php file in your site's root folder (public_html). I call the phpinfo.php, but you could call it whatever:

    <?php
    phpinfo();
    ?>

    Then, you would access it like so:

    http://sitename.com/phpinfo.php

    If you're still getting 5.13 as your PHP version, you could try to backup your site and DB, update WP anyway, and see how it goes. Worst case scenario, you can roll back to 3.1.2.
    Personally, I always try to have the latest WP version because the platform keeps improving and it is a shame to me not to take advantage of the new features, such as rotating header images. Of course, don't update just to have custom images, ;-)

  9. Romain51
    Member
    Posted 2 years ago #

    Hi Marventus,

    Thx for the explanation.
    In fact I got my php version from WordPress directly : I clicked on the update link and got this message on my dashboard : "You cannot update because WordPress 3.2.1 requires PHP version 5.2.4 or higher. You are running version 5.1.3RC4-dev."
    I checked with your method (phpinfo file) and got same version: PHP Version 5.1.3RC4-dev

    So I think I'll wait a little before updating...

    Thx,

  10. Marventus
    Member
    Posted 2 years ago #

    Yeah, you are right: if WP gave you that warning you should not update. The potential risks outweigh the potential benefits.
    You could also e-mail your host and let them about the issue you are having, because their PHP version is getting old.
    Good luck!

  11. raindance
    Member
    Posted 2 years ago #

    Msrventus-
    Sorry to hijak this form posting with this request...
    would you be so kind to take a look at
    http://wordpress.org/support/topic/best-way-to-insert-related-pages-sidebar?replies=1#post-2470913
    ?

    Thanks in advance if you have a moment...

  12. Marventus
    Member
    Posted 2 years ago #

    New link to the download folder: http://www.filefactory.com/f/b279dc7479247490/.
    You have to scroll down to the bottom of the page and click on the "Slow Download" button.
    Cheers!

  13. raindance
    Member
    Posted 2 years ago #

    Emmm Marventus....
    I haven't worked with this for awhile and am trying to figure it out again...could you take a moment to help?
    It's working great for random rotating headers for the category "juicy-travels-blog".
    But I just made my first post (I so far have only done pages rather than posts), and set the featured image as the specific header image I wanted (no rotation necessary) and set the category to blog (slug juicy-travels-blog).
    Problem is I want that specific header image for just that blog post but can't remember how...arrrgh :-)
    If I don't assign it to the category of blog, the featured image header image shows up fine. But I need it assigned to the blog category so it shows up on the blog link.
    If I assign it to the blog category then the random rotation images from the juicy-travels-blog folder are what appear for the header image, not the featured image I set.
    The slug for the blog post is suprising-sonora-mexico. I made a folder by that name and put it both in the custom-headers folder and the custom-headers/juicy-travels-blog/ folder but still...only the images for the random rotation for the blog category show up...which I know we worked hard to get working! :-) But how to override it if for particular blog post I want a specific image and NOT the random rotating images for that category folder?

    Thanks so much if you can wrap your head around it again!

  14. raindance
    Member
    Posted 2 years ago #

    For example in a simple logic theory....I'd like for it to go:
    If there is a featured image, use that for that post, but if there is no featured image for a post, then use the images from the folder with the category slug name.

    And maybe it already does this and I just forgot how to do it? I felt sure we'd made it so I could dictate a single specific image for a single post or page and if none, then in pulled from the folder?

    Thanks so much if you can help...

  15. raindance
    Member
    Posted 2 years ago #

    I forgot to post the link to the post example...
    http://juicytravels.com/surprising-sonora-mexico/
    So this is assigned to the category blog as it needs to be to show up on
    http://juicytravels.com/category/juicy-travels-blog/
    (which is pulling from the blog image folder perfectly)

    But how do I set a specific header image then for the individual blog post? Doesn't need to random just needs to be the featured image I choose.

    Thanks...

  16. Marventus
    Member
    Posted 2 years ago #

    Hi Laura,

    You were right: The script was overriding specific featured images for posts and pages despite of many layers preventing just that. I think this has to do with the way in which the graphene_header_image hook is called inside Graphene.

    Anyway, the script should now retrieve specific header images set for posts and pages.

    I also corrected a bug by which post categories where being retrieved alphabetically instead of by ID, which had the potential of retrieving a header image from a higher or lower level category.

    You can download version 1.1 from the link I pasted above.

    Cheers!

  17. raindance
    Member
    Posted 2 years ago #

    It works perfectly! Thanks for creating this flexibility. I really appreciate all of the time and effort you put into this...thank you so much Marventus!

  18. Andrea155
    Member
    Posted 1 year ago #

    Hy to all, sorry my lack of knowledge in theme graphene ..
    Im very interested in obtain something like http://juicytravels.com/travel-type/biking-tours/
    i'm beginner..
    I installed a theme in child (from Prasanna), my funcion.php was empty, and when I tried to past the script, it does not work and I see it in the top of the site ..

    I could not figure out where mistake.
    Can you help me please?
    thanks

  19. Marventus
    Member
    Posted 1 year ago #

    Hi Andrea.

    Could you make a pastebin of your entire child functions.php file?
    Also, I haven't tested this script in a while, so I don't know if it still works with the latest versions of Graphene and WP. Here is a link to the latest version (1.1).
    Laura, could you confirm if this still works? By the looks of your site, it seems it does, but do let us know just in case. Thanks!

    Cheers!

  20. Andrea155
    Member
    Posted 1 year ago #

    Hi Marventus, many thanks for your kindly reply.
    I don't able to reply your question about my child funcntions php, because it is comoletely blank (emty) in child.

    For child thema i applicate Prasanna methode, which consists in uploda two files (CSS: compilated) and function php (completely EMPTY). PRasanna explain here how to create a child portal, and it is work: http://www.prasannasp.net/graphene-child-theme-template/

    I can suppose (in my ignorabce) that funcion php in a child is tehe same that in the father, but i'd like that Laura tell if is correct or not.
    If my idea is correct, in pastebin you can try my function php ORIGINAL, non t child: http://pastebin.com/X3qEpqyA

    Thanks for your interesting and helping me..

  21. Marventus
    Member
    Posted 1 year ago #

    Basically, what you need to do is paste my script into your child functions.php file. You are going to need to modify the $custom_image_ids Array to customize which categories you would like to show custom header images for. You will find a detailed explanation in the readme.txt file that comes with the script.
    Good luck!

  22. Andrea155
    Member
    Posted 1 year ago #

    My Marvenus, thanks for your reply. Problems remains; now my funcions.php file is non emty, but it contains your script. The test of script ios seen in te bottom part of site.. this is first problem
    How is possible that php code is seen in site?
    I dont't understand..
    give you a paste bin about my php file: http://pastebin.com/2qWreMb6

  23. Marventus
    Member
    Posted 1 year ago #

    Hi, Andrea.

    In your pastebin, you are missing the opneing <?php tag. Your code should start like so:

    <?php
    function custom_header_image($random_image) {

    Also, you need to customize the categories that you will be targeting. Based on your pastebin, you are using the exact same number of categories as the sample $custom_image_ids is.
    Please read the documentation that is shipped with the plugin.

    Cheers!

  24. Andrea155
    Member
    Posted 1 year ago #

    Hi Marvenus
    i had inert opening tag, and have removed crashed in child theme php.
    Now i'm studying your documentation and your code.

    I'd like to ask you if there is a simple way to modify your script to realizing a moving (rotation ) effects in header image only in home page.

    This effect will be fantastic, perhaps in Raindance site there isn't this rotation header image in home page.. cheers
    Andrea

  25. Marventus
    Member
    Posted 1 year ago #

    Hi Andrea.

    I don't really have the availability to add that functionality right now. However, if you are interested in animations, you can look into the CSS animation property (http://www.w3schools.com/css3/css3_animations.asp) or into jQuery's (Javascript) .animate() function. There are also many free JS plugins and sliders that support animations and transitions.

    Good luck.

  26. Andrea155
    Member
    Posted 1 year ago #

    Hi Marventus, i'm studying your script's instructions, for customize your code in my site.

    I'd like to ask how to customize my array to use your script, in particular, I did not understand where to put the cat ID, i mean where write the number? id i'd like to crete an HoME PAGE like "HOME PAGE (3) @ *", where can I write ID number 3? in php function? inb css?

    can you help me?
    Thanks a lot
    Andrea

  27. Marventus
    Member
    Posted 1 year ago #

    Hi Andrea. What you need to do is modify this line:

    $custom_image_ids = array(2,8,28,617);

    with your own category numbers.
    For example: imagine that you have 4 categories and that you wish to display custom images for 2 of those. So, you need to retrieve the category ID for each targeted category and add those IDs as comma-separated values. Assuming the IDs of those two categories were 57 and 324, your $custom_image_ids definition should look like this:

    $custom_image_ids = array(57,324);

    Remember to follow the instructions carefully regarding parent and child categories.
    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic