Community Forums › Forums › Archived Forums › General Discussion › Trying to assign a different css class to blog post headers – Altitude Pro
- This topic has 6 replies, 2 voices, and was last updated 7 years, 9 months ago by Donatello.
-
AuthorPosts
-
July 19, 2016 at 3:18 pm #189813DonatelloMember
Hi.
Right now my blog post headers use a class named "entry-header" found in, of course, style.css.
I have created a separate class in style.css called "custom-header".
I want to tell the blog page to use "custom-header" instead of "entry-header" but I don't know where to go to do this?
Please note that for various reasons I do not want to modify the "entry-header" class itself (that'd be simple enough). Rather, I want to tell the page to use this other class.
What file would I need to modify to tell my blog posts to use "custom-header" instead of "entry-header"?
Thanks Much,
DonJuly 19, 2016 at 3:23 pm #189814Victor FontModeratorSee if this helps: http://victorfont.com/genesis-framework-add-a-custom-css-class-to-elements/
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?July 19, 2016 at 3:42 pm #189818DonatelloMemberVictor,
First of all, awesome name.
Second, thanks so much for your speedy and useful help. Here's how you essentially solved the problem for me:
I'm not a php programmer and so I'm sure exactly what I'm doing when it comes to working with wordpress/php files. Your instructions on that page told me that the way php works is that the element is first named, then it's followed by the class you want to apply to it. Specifically, your example was this:
add_filter( 'genesis_attr_entry-content', 'vmf_my_custom_class' );
With this new understanding, I looked through the various php files located in genesis/lib/structure and found what I was looking for in "post.php":
function genesis_entry_header_markup_open() {
printf( '<header %s>', genesis_attr( 'entry-header' ) );There, I saw the css class that I want to change, "entry-header" and saw to the left of it that it was indeed being applied to the header. Now I can change "entry-header" to something else.
In summary, the answer to my question was: "To tell wordpress to use a different class for blog headers, go to post.php and change 'entry-header' to the name of whatever class you want to use."
Thanks again,
DonJuly 19, 2016 at 3:44 pm #189819DonatelloMemberBefore I mark this as 'resolved', can you tell me if there's a way I can do this in my child theme, Altitude Pro, rather than Genesis?
Thanks again,
DonJuly 19, 2016 at 6:21 pm #189820Victor FontModeratorIn the child theme's functions.php, you can add this:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); add_action( 'genesis_entry_header', 'my_custom_markup_open', 5 ); function my_custom_markup_open() { printf( '<header %s>', genesis_attr( 'my-custom-class' ) ); }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?July 19, 2016 at 6:47 pm #189821DonatelloMemberExcellent, Victor; that did it.
Thanks so much. You were a huge help.
Don
July 19, 2016 at 7:25 pm #189822DonatelloMemberHi Again...
I found that this is editing both my posts and my pages. I only want it to apply to posts on my blog page. I'm using a static home page, which does not house the blog. Instead, I have my blog on a separate page called "blog".
Can you help?
Please note that I've tried piecing together bits of information from various websites but am finding I'm in over my head. For example, I tried adding code to use "if_front_page()" but was just guessing and got it wrong. If you could provide any direct assistance I would be greatly appreciative.
Thanks again,
Don -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.