Icon next to the title
-
Greetings,
We are are looking into switching themes and are highly interested in your theme.
However, we ran into an issue while trying to place icons next to the entry/post titles. Our current theme has 2 template files for the titles that we were able to add our code in to accomplish this.
We are using the Advanced Custom Fields Plugin for the icons and this is the code in each of the title template files for our current theme…
// Theme template file (I removed the irrelevant code) // begin Entry Title - Added icon to the title using Advanced Custom Fields Plugin <?php $image = get_field('title_icon'); if( !empty( $image ) ): ?> <img class="post-title-icon" src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" /> <?php endif; ?> <h2 class="entry-title post-title" itemprop="headline"><a href="<?php the_permalink(); ?>" rel="bookmark" <?php responsive_schema_markup( 'url' ); ?>><?php the_title(); ?></a></h2> // end Entry Title - Added icon to the title using Advanced Custom Fields Plugin // begin - I added Ratings under the title <?php if (is_category(array( 3, 5, 14, 15, 17, 18, 19, 20, 21 )) ) : ?> <?php if(function_exists('the_ratings')) { the_ratings(); } ?> <?php endif; ?>
This is a screenshot of the output…
Title ScreenshotWe tried directly editing template files to adding hooks to no avail. The hooks either place the icon before or after the title and using absolute positioning doesn’t work because of the different title parents for the category/archive/post pages.
Now, for the ratings this worked for the categories and I believe we will be able to get working by adding conditional statements.
This is the hook for the ratings…add_action( 'generate_after_entry_title','test' ); function test () { ?> <?php if (is_category(array( 1, 2, 3, 4, 5 )) ) : ?> <?php if(function_exists('the_ratings')) { the_ratings(); } ?> <?php endif; ?> <?php }
I hope I was clear in my explanation. It’s 2 am and my coffee machine isn’t working.
I would greatly appreciate any assistance.
Thanks!
- The topic ‘Icon next to the title’ is closed to new replies.