• Resolved tabatha.j22

    (@tabathaj22)


    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 Screenshot

    We 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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Leo

    (@leohsiang)

    Hi there,

    Can you link me to the page in question with the icons added with generate_after_entry_title hook?

    I wonder if we can just use CSS to rearrange it.

    Let me know ??

    Thread Starter tabatha.j22

    (@tabathaj22)

    Hi Leo,

    I’m testing the theme locally. I am able to get the icon next to the title using absolute positioning on the image, but the issue is that I would need to add a left margin on the entry title to offset the image’s width.. We have a lot of posts and we don’t put icons next to all of the titles.

    Most people wouldn’t need a hook like, generate_inside_entry_title, which makes sense why it’s not an available hook.

    Do you think there is another way other to get the images next to the title?

    Thanks!

    Leo

    (@leohsiang)

    I’d think there is a way to use flexbox instead of absolute positioning.

    Can you create a staging environment so I can see?

    Thread Starter tabatha.j22

    (@tabathaj22)

    Using flexbox definitely works. The reason we are trying to get the icon within the title is so that we can call the title in some of our widgets and the icons are automatically pulled.

    If generate_inside_entry_title existed then that would do it, but it’s understandable why the theme doesn’t have it since the need for making changes to the title section would be rare.

    Thanks for taking the time to assist, Leo. Your name comes up a lot. You do good work for GeneratePress.

    I’ll mark this as resolved. Thanks again!

    Leo

    (@leohsiang)

    No problem ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Icon next to the title’ is closed to new replies.