Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi there,

    You can try using the generate_before_archive_title hook to hook in your post tag texts.

    Here’s an example PHP snippet:

    add_action('generate_before_archive_title',function(){
      echo strip_tags( get_the_term_list( get_the_ID(), 'post_tag', '', ', ') );
    });

    Here’s how to add PHP snippets – https://docs.generatepress.com/article/adding-php/

    Thread Starter tolddsm

    (@tolddsm)

    hi,

    tried another hook, it works, thank you!

    Thread Starter tolddsm

    (@tolddsm)

    Hi,

    @ejcabquina

    How can I make this snippet NOT affecting search result page?

    I see tags show on search result page before entry titles too.

    Thanks!

    You can set an if rule that checks if the page is NOT search page.

    Example:

    add_action('generate_before_archive_title',function(){
    if(!is_search()){
      echo strip_tags( get_the_term_list( get_the_ID(), 'post_tag', '', ', ') );
    }
    });
    Thread Starter tolddsm

    (@tolddsm)

    cool!

    Have you sorted it out? Let us know if you need further help.:D

    Thread Starter tolddsm

    (@tolddsm)

    Yes, it works!

    Great support as usual.

    Nice one. Glad you got it sorted. ??

    Thread Starter tolddsm

    (@tolddsm)

    Hi,

    @ejcabquina

    A small issue update.

    The tag shows on all post page and archive page. It makes sense as the filter only rules out search page.

    Can you update the filter to make it not display on post page too? It should only display on post archive page.

    A simple design to show tags before title on a regular card-style post archive page is what we want.

    Thanks, I’m not familiar with php.

    • This reply was modified 3 years, 10 months ago by tolddsm.

    Try this one.

    add_action('generate_before_archive_title',function(){
    if(!is_search() || is_single()){
      echo strip_tags( get_the_term_list( get_the_ID(), 'post_tag', '', ', ') );
    }
    });

    Or better yet, if you only want this on the Blog index page or archive pages, try this:

    add_action('generate_before_archive_title',function(){
    if(is_home() || is_archive()){
      echo strip_tags( get_the_term_list( get_the_ID(), 'post_tag', '', ', ') );
    }
    });
    Thread Starter tolddsm

    (@tolddsm)

    Hi,

    thanks for the great support. It works!

    Gotta learn some PHP now. ??

    Gotta learn some PHP now.

    Or any programming language. The principles in construction of conditions are the same. ??

    No problem. Glad to be of any help. ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Show tags above title’ is closed to new replies.