How to Fix Post Tags Error for Custom Post Type Post in WordPress | Warning Foreach Argument Type Fix
welcome to Webnewster.xyz
see this error warning for each argument must be of type array object bool this is not a regular post this is custom post in a custom post type this is custom post type
test post type we've got two posts here so if i go to my regular posts these are my posts and i go to single post we see these tags at the end of this post and these tags will work but for this custom post type we don't have tags here that is why we are looking at this warning here these tags are coming from the template appearance theme editor and template parts single single layout and here this is some custom code to display tags for single post
so we have got global post here and then post id as tag get the tags so these tags are not available for custom post type like this test post type that is why we are looking at this error for this custom post type and the solution is to just check if this is single post and post type is post not test post type like check right here if and inside if use is single and post type is post
then display all of this then display tags and this is a mistake here this is not single this is singular update file and let's refresh this blog post that is a regular post in our wordpress site so we can see tags here and now for our custom post type we will refresh it and the error is gone from here because we are just checking if the if this is single post and post type is post
then get the tags and tags were not available for this custom post type so these were not showing here and we were looking at the warning for each argument must be of type array object bull okay i hope it helped like share subscribe and i will see you in the next video
Comments
Post a Comment