Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post meta display issue in search template #558

Open
tomusborne opened this issue Jul 19, 2023 · 0 comments
Open

Post meta display issue in search template #558

tomusborne opened this issue Jul 19, 2023 · 0 comments
Labels
bug Bugs, unexpected and weird behaviors triage Awaiting review
Milestone

Comments

@tomusborne
Copy link
Owner

tomusborne commented Jul 19, 2023

Description

The post meta is displaying (or not) based on the first post in the loop.

Steps to reproduce

  1. Search for something that will show results from multiple post types.
  2. Depending on the post type of the first post, the post meta will show or not

Actual behavior

  1. The post meta display is based on the post type of the first post in the loop.

Expected behavior

The post meta display should always be based on the individual post type.

This is happening because we're checking get_post_type() in the wp hook, which will grab the post type of the first post only.

A potential solution:

add_action( 'generate_before_content', function() {
	if ( is_search() ) {
		$header_items = generate_get_header_entry_meta_items();

		$header_post_types = apply_filters(
			'generate_entry_meta_post_types',
			array(
				'post',
			)
		);

		if ( ! in_array( get_post_type(), $header_post_types ) && ! empty( $header_items ) ) {
			remove_action( 'generate_after_entry_title', 'generate_post_meta' );
		}
	}
} );

References

https://generate.support/topic/last-updated-date-in-internal-search-results/#post-28191
https://generate.support/topic/last-updated-date-in-internal-search-results/page/2/#post-28405

@tomusborne tomusborne added the bug Bugs, unexpected and weird behaviors label Jul 19, 2023
@tomusborne tomusborne added this to the 3.4.0 milestone Jul 19, 2023
@github-actions github-actions bot added the triage Awaiting review label Jul 19, 2023
@tomusborne tomusborne modified the milestones: 3.4.0, 3.5.0 Nov 8, 2023
@tomusborne tomusborne modified the milestones: 3.5.0, 3.6.0 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs, unexpected and weird behaviors triage Awaiting review
Projects
None yet
Development

No branches or pull requests

1 participant