I am using a newspaper style WordPress theme and the PublishPress Authors plugin. No issues there. ✅
The theme has a post-meta.php file which defines, obviously, how the post-meta is displayed on the page. I am trying to modify the author block of the post-meta to use the PublishPress Authors shortcode, dependent on the active page. For instance, on the home or front page, it should be using one style, but on the single-posts it should be using another.
I have tried a few different ways that I found browsing through StackOverflow, including an echo, but that seemed to cause the PublishPress Authors shortcode to show up in a weird and large overlapping position, over the existing post-meta.
My final attempt has been the following code:
$author_link = '';
if (is_home() || is_front_page()) {
$author_link = $author_img . $label . (!is_home() || !is_front_page() ? get_the_author_posts_link() :
do_shortcode('[publishpress_authors_box layout="ppma_boxes_1011" author_categories="author,co-author"]'));
}
elseif (is_single()) {
$author_link = $author_img . $label . (!is_single() ? get_the_author_posts_link() :
do_shortcode('[publishpress_authors_box layout="ppma_boxes_1567"]'));
}
else {
$author_link = $author_img . $label . (!is_home() || !is_front_page() || !is_single() ? get_the_author_posts_link() :
do_shortcode('[publishpress_authors_box layout="ppma_boxes_1011" author_categories="author,co-author"]'));
}
$output = sprintf(
'<span class="%1$s">%2$s</span>',
esc_attr(join(' ', $classes)),
$author_link
);
I added the third else statement because I was not sure how to properly address all of the remaining categorized archive pages, so thought this might be a good approach.
What’s strange, is the elseif statement seems to be working, but not the other two. I see the correct change on single-posts. I know I am missing something obvious and hope someone can point it out to me.
Thank you!