Skip to content

Commit

Permalink
PLANET-7027: Fix tag listing page (#1884)
Browse files Browse the repository at this point in the history
Fix tag listing page

- This issue has been reported by GP Nordics

Co-authored-by: Dan Tovbein <[email protected]>
  • Loading branch information
GP-Dan-Tovbein and dantovbein authored Jan 25, 2023
1 parent 5f4d803 commit bc808a7
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,10 @@

$templates = [ 'tag.twig', 'archive.twig', 'index.twig' ];

// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$posts = get_posts(
[
'posts_per_page' => 1,
'offset' => 0,
'post_parent' => $explore_page_id,
'post_type' => 'page',
'post_status' => 'publish',
'suppress_filters' => false,
'tag_slug__in' => [ $context['tag']->slug ],
]
);

$context['custom_body_classes'] = 'white-bg page-issue-page';
$context['category_name'] = $posts[0]->post_title ?? '';
$context['category_link'] = isset( $posts[0] ) ? get_permalink( $posts[0] ) : '';
$context['tag_name'] = single_tag_title( '', false );
$context['tag_description'] = wpautop( $context['tag']->description );
$context['tag_image'] = get_term_meta( $context['tag']->term_id, 'tag_attachment', true );
$tag_image_id = get_term_meta( $context['tag']->term_id, 'tag_attachment_id', true );
$context['tag_name'] = single_tag_title( '', false );
$context['tag_description'] = wpautop( $context['tag']->description );
$context['tag_image'] = get_term_meta( $context['tag']->term_id, 'tag_attachment', true );
$tag_image_id = get_term_meta( $context['tag']->term_id, 'tag_attachment_id', true );

$context['og_description'] = $context['tag_description'];
if ( $tag_image_id ) {
Expand All @@ -81,6 +65,23 @@
exit();
}

// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$posts = get_posts(
[
'posts_per_page' => 1,
'offset' => 0,
'post_parent' => $explore_page_id,
'post_type' => 'page',
'post_status' => 'publish',
'suppress_filters' => false,
'tag_slug__in' => [ $context['tag']->slug ],
]
);

$context['custom_body_classes'] = 'white-bg page-issue-page';
$context['category_name'] = $posts[0]->post_title ?? '';
$context['category_link'] = isset( $posts[0] ) ? get_permalink( $posts[0] ) : '';

$campaign = new TaxonomyCampaign( $templates, $context );

$campaign->add_block(
Expand Down

0 comments on commit bc808a7

Please sign in to comment.