Articles of custom field

Use custom field as a variable

I am trying to use a custom field value within a google api url. I have 2 custom fields. I need to output the value of these custom fields within a url. Custom field keys: app_collection-postcode app_delivery-postcode This is the google url. I need to put the two postcodes in place of $postcode1 & $postcode2 […]

wp_query with multiple custom fields

My Query is this: $products = new WP_Query( array( ‘post_type’ => ‘ys_product’, ‘orderby’ => array( ‘date’ ), ‘order’ => ‘DESC’, ‘posts_per_page’ => 8, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘ys_product_status’, ‘value’ => ‘ok’ ), array ( ‘key’ => ‘ys_product_start’, ‘value’ => date(‘Ymd’), ‘compare’ => ‘>=’ ), array ( ‘key’ => ‘ys_product_end’, ‘value’ […]

UnWanted Custom field added in the wp page edit area

I have made a plugin in which post meta required ? Now i get unwanted custom field. Here is code that i am using to add custom meta in post type= recommendation add_meta_box(‘plugin-recommendation-box’, ‘Recommendation’, ‘add_plugin_recommendation_box’, ‘recommendations’, ‘normal’, ‘default’); function add_plugin_recommendation_box(){ global $post; $title = get_post_meta($post->ID, ‘recommendation_title1’, true); $price = get_post_meta($post->ID, ‘recommendation_price’, true); $reg_price = get_post_meta($post->ID, […]

Before Delete Post

I am trying to update the value of one custom post type’s meta when another custom post type is deleted. When a space_rental is deleted, I need to update some meta value on a space. I don’t think I can use delete_post because it fires after the meta data has been deleted, but this isn’t […]

Saving an array in a single custom field

I have the following array that I want to store in a single custom field. array(“Accounting”=>”Peter”, “Finance”=>”Ben”, “Marketing”=>”Joe”); I want to store it by typing it in a custom field in wp-admin. Then I want to retrieve this custom field as an array in a page, with something like $pos = get_post_meta($post_id, ‘pos ‘, true); […]

Get Meta from Custom Field of Image URL

I have a custom field that is an Image and the return value of the field is Image URL. I have custom page templates where I render these image fields. Is there a way to get the meta info for the image through the image url. I do not want to change the return value […]

Display Custom Post Type Fields

I’m making a website and want to display Events. Therefore I made a Custom Post Type called ‘event’. I’m querying events to show them in a page. The Events I made also have some custom fields like : ‘Location’, ‘Day’, ‘Month’, ‘Year’ and a category. This is my code now : <?php $args = array( […]

Authors details such as social media links, emails etc → Is this Meta or something else?

The author section of my first WordPress theme is currently hard coded in HTML. See the live website here. This One. These social media Icons and the link associated with them are not provided in the backend author dashboard by default and they need to be coded. Can someone guide me how to? Is this […]

Add a post meta key and value only if it does not exist on the post

I have a custom field on a WooCommerce product, and I am entering the ID of another product into it. When saving that product, I am adding a meta field to the product that was inputted, creating a “link” between them. I have this working fine, but the issue is that it adds it even […]

Get all posts that do not have a specific custom field without using a subquery

I need to get all posts that do not have a particular custom field, (e.g. custom_field). The following query works fine: SELECT * FROM wp_posts WHERE ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = “custom_field”) I try to avoid using subqueries if possible. How can this query be rewritten so it doesn’t use […]