Check if a post’s meta key exists or not

Sometimes in wordpress, we need to know whether a meta key for a post/page exists or not. It may have any value or blank value but we need to check whether it is already created or not. Similarly, someone may also need to know whether a usermeta or comment’s meta exists or not. Earlier it could be checked via firing wp-query only but now it can be checked  simply via using a wordpress function which is metadata_exists, such as :

metadata_exists($meta_type, $object_id, $meta_key) Keep on reading

Rules to avoid 404 error on WordPress form submit

There are some rules that are to be kept in mind while creating form in wordpress. If you won’t follow those rules then you will get 404 page on form submit:

  1. Name Field’s name should not be name, e.g : <input type=”text” name=”name” value=”” /> is wrong, because by default wordpress use name field to identify comment submission. Don’t use name as name of input field. Write another name such as <input name=”custom_name” type=”text” value=”” />
  2. Email Field’s name also should not be email, e.g : <input name=”email” type=”text” value=”” /> is wrong, because by default wordpress use email field to identify comment submission. Don’t use name as email of input field. Write another name such as <input name=”custom_email” type=”text” value=”” />
  3. Similarly don’t keep name of any input field same as custom post type slug. For example if you have a post type testimonials then don’t use field’s name as testimonials.

Keeping in mind these points you can avoid 404 page error on form submission. Keep on reading