Skip to content

Fix error in post page when no featured image is set #37

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

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

lacruzwebdev
Copy link
Contributor

@lacruzwebdev lacruzwebdev commented Jan 28, 2025

When accessing a post page without a featured image set, we're getting the following error:

2025-01-28 at 13 55 27

WP Rest API returns a 0 whenever there's no featured image set, so we need to make sure that post.featured_media is not falsy before invoking getFeaturedMediaById because there's no media with an id of 0, hence the error.

Copy link

vercel bot commented Jan 28, 2025

@lacruzwebdev is attempting to deploy a commit to the 9d8 Team on Vercel.

A member of the Team first needs to authorize it.

@lacruzwebdev
Copy link
Contributor Author

It's probably a good idea to include this bit of logic inside getFeaturedMediaById?

Copy link

vercel bot commented Jan 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-wp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 7:49pm

@brijr brijr merged commit 3e24371 into 9d8dev:main Jan 28, 2025
1 check passed
@brijr
Copy link
Collaborator

brijr commented Jan 28, 2025

This looks great, thanks for catching @lacruzwebdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants