Articles of custom field

Custom post type name and assigning custom taxonomy

I’ve made mistake creating custom post type. I’ve put: register_post_type( ‘Post Name’, $args ); instead of register_post_type( ‘post_name’, $args ); Now I need to assign new custom taxonomy to this post type. Problem stars here: register_taxonomy( ‘custom taxonomy’, array( ‘Post Name’ ), $args ); doesn’t work. I’ve tried to change custom post type name to […]

Adding Template Post Content

I’ve tried searching for this using various terminology, but I always end up at questions pertaining to the php template files. That’s not what I’m looking for, so I’m asking a new question. I apologize if this is a duplicate. Basically, I’m looking for a way to create template posts. I’m using ACF Pro on […]

How add body_class from wp_termmeta

I need to assign a class to the body for woocommerce categories. What I’ve done: // add the fields when the term is created add_action( ‘product_cat_add_form_fields’, ‘add_product_cat_class_field’, 10, 2 ); function add_product_cat_class_field($taxonomy) { global $feature_groups; ?><div class=”form-field term-group”> <label for=”feature-group”><?php _e(‘Custom CSS Class’, ‘my_plugin’); ?></label> <input type=”text” class=”postform” id=”custom-class” name=”custom-class” value=””> </select> </div><?php } // […]

If value present, order posts by two consecutive custom fields

Basically on my site I have a bunch of song lyrics and in a static page I want to show them listed by album Link to my website and album position of the song and I have two custom fields with that data, sd_album_title and `sd_album_track_n. Plus some of the songs don’t have an album […]

Convert all dates stored in custom field

I have a custom field to store the date of games, and I store it in database like mm/dd/yyyy Now I need to convert all dates to dd/mm/yyyy So how can do that? Is timestamp a solution for it, if yes, how can do that I need to change all old data to new data […]

Display post from a date range from custom field

I currently have a custom post type that has two major custom fields that are need for the query. The ‘score_time’ field stores time of a score. Example: 12:20 The ‘score_date’ stores the date the game took place. Example: 01/22/2016 I need query to display post from a specified date range and they are ordered […]

Add multiple meta keys to a post at once

I figured how to add an input value as a meta key value to a new post from a frontend post form (thanks to @thedeadmedic), but I can’t figure how to add two or more meta keys at once. Is this possible with the next code? These meta keys are named ‘location2’ and ‘price’, and […]

Insert image into sub-field with update_post_meta

I found out that I could insert an image into a custom sub-field by just adding the image ID: update_post_meta($post_id, $metafield, 168); But that was a lucky guess – I didn’t see this info on the documentation for “update_post_meta”. But if I use this way, how do I specify the size of the image? And […]

Conditional featured image with youtube thumbnail

Basically what I am trying to do here is: Display the youtube thumbnail. If no youtube thumbnail -> Display the Featured image for the post. If no featured image -> Display the fallback image. However it seems I am doing something wrong because the webpage displays blank. <?php // Check if the post has a […]

How to add post meta fields to an article's <head> as meta elements

I need to add the following type of meta information in the article <meta name=”citation_publication_date” content=”1996/05/17″> <meta name=”citation_journal_title” content=”Journal of Biological Chemistry”> <meta name=”citation_volume” content=”271″> <meta name=”citation_issue” content=”20″> <meta name=”citation_firstpage” content=”11761″> <meta name=”citation_lastpage” content=”11766″> <meta name=”citation_pdf_url”content=”http://www.example.com/content/271/20/11761.full.pdf”> https://scholar.google.com/intl/en/scholar/inclusion.html#indexing