Reputation: 11
In my website https://chicken-device.ir, I have many not find the page, after I change the permalink of a post.
Many of the not found pages are for images pages. I wrote some code to redirect url link e.g. https://example.com/post-name
to https://example.com/blog/post-name
.
Now I have many attachment files then return 404 page in google webmaster tools. How can I detect post type attachment in WordPress? target only attachment file page.
Upvotes: 1
Views: 132
Reputation: 200
Post the code that redirects urls. You can check post type with this code:
$queried_object = get_queried_object();
$post_type = $queried_object->post_type;
Upvotes: 0