1

On the post page I display the author of the article. But I have two types of authors.

I have at the one hand " the xxx Team" and on the other "from xxx" but my problem is the pre word.

Now it displays "the xxx team" and "the xxx". This is the part from the code:

                    <a href="<?php echo get_author_posts_url( get_the_author_meta('ID'), get_the_author_meta( 'user_nicename' ) ); ?>" class="m-article-author">
                        <?php
                        $author_bio_avatar_size = apply_filters( 'tierisch_wohnen_author_bio_avatar_size', 49 );
                        echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );
                        ?>

                        The <span class="m-article-author-name"><?php the_author(); ?></span>
                    </a>

I hope someone can help me with a if else function or some search and replace. If anyone have an idea please let me know.

4
  • btw the xxx team is every time the same author
    – hendrik-eg
    Commented Apr 21, 2021 at 12:14
  • So you only want to display “the” if the authors name contains the word “team”? Is that right? If not the it’s not clear from your question what you actually want. Commented Apr 21, 2021 at 12:22
  • I need to display "the" if the author is "team" and else the word "from"
    – hendrik-eg
    Commented Apr 21, 2021 at 12:41
  • i need help with the condition for the if else (if the author is team)
    – hendrik-eg
    Commented Apr 21, 2021 at 13:08

1 Answer 1

0

This code is my answer:

                    <a href="<?php echo get_author_posts_url( get_the_author_meta('ID'), get_the_author_meta( 'user_nicename' ) ); ?>" class="m-article-author">
                        <?php
                        $author_bio_avatar_size = apply_filters( 'tierisch_wohnen_author_bio_avatar_size', 49 );
                        echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );
                        ?>


                    <?php 
                    
                    if (get_the_author_meta('display_name') === 'xxx Team') {
                        echo"The";
                    }
                    else {
                        echo"From";
                    }
                    ?>

                    
                    <span class="m-article-author-name"><?php the_author(); ?></span>
                    </a>
                    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.