Questions tagged [post-meta]

Post meta is a data set containing additional core as well as custom post information.

Filter by
Sorted by
Tagged with
0 votes
1 answer
165 views

do_shortcode based on _thumbnail_id

Situation I've created a Custom Post Type called 'Banners'. On each post I'm able to add a featured image. This will be saved in my database and will get an _thumbnail_id. Also on each post edit page, ...
0 votes
2 answers
7k views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
2 votes
1 answer
394 views

Meta tags in shortcode

The thumbnail and title shows up as it should, but the post meta displays on the top of the page. What is the correct code for retrieve the post metadata? function evasmat_posts_shortcode(){ $q =...
1 vote
0 answers
328 views

Run Shortcode of post's custom field in functions.php / Plugin

After 3 or 4 hours of searching the web for a solution, I abandoned it and hopefully you can help me? I added a sub-headline as a custom field (subheadlineclass). That works pretty. I can save, edit ...
9 votes
2 answers
58k views

Adding meta tag without plugin

Is it possible to add meta title, meta description, meta keywords in every page without installing plugin? My client require not to install plugin. I am curious about this case, all I know is the ...
0 votes
1 answer
215 views

Unable to get specific value from post meta

I am using get_post_meta() to retrieve a custom meta field value from a given post. The custom meta box has a parent checkbox which has 3 child checkboxes. I want to get the values of both parent and ...
0 votes
1 answer
67 views

Custom meta box data not saving

I created this meta box for my custom theme. I thought I followed all the guidelines, but I'm hitting a wall. The meta box and all fields are showing, but when I update, the data is not saved. Meta ...
4 votes
2 answers
6k views

Delete duplicated wp_postmeta record

I have many duplicated wp_postmeta record (about hundreds record with same post_id & meta_key) and need to delete safely via mysql, is there any effective way to delete the postmeta record. ...
0 votes
2 answers
1k views

Displaying Custom Post Meta

I am developing a simple ranking plugin. Every post has it's own like count, and these counts are saved as custom-fields. The problem is, no matter how much i research, i still couldn't find the ...
0 votes
1 answer
315 views

Sending mail not working correctly

SITUATION I have a reserve system for a restaurant and I'm trying to send data out of my wpdb to myself with the mail() function around 3pm. So I get a overview of all the reservations for the current ...
0 votes
0 answers
175 views

How to get a post meta value and pass that to update_option when a post is created or updated?

When a user publishes or updates a post I want to get a post meta value from that post itself. Then I want to use update_option() to pass that value into the get_option() name. I've been trying ...
2 votes
1 answer
583 views

Unable to show ACF's Image Custom Field properly in Genesis Framework [closed]

WP 4.7.3 with Types, Genesis Sample Theme, ACF and a few very well-known plugins, nothing special or non-standard. I know how to display custom fields from an Advanced Custom Fields Repeater Field on ...
2 votes
2 answers
50 views

Is there a way to list tags order by post_meta field

Im working on a plugin. I placed like button under each post so users can like the post. When user click the button it updates 'likes_count' post_meta field which i created. Now here is my question. I ...
7 votes
2 answers
19k views

How to get all custom fields of any post type

I have several post types. I want to get all custom fields associated with that post type. Example: Post -- image -- Featured image -- body I need to get all fields or custom fields in array. I ...
-2 votes
5 answers
3k views

Problem with get_post_meta

I am using this code to retrieve post meta: if ( get_post_meta($post->ID,'a',true) == '') { echo '<img src="' . get_bloginfo( 'template_url' ) . '/img/img22.jpg" ></img>'; } else {...
0 votes
1 answer
183 views

Delete postmeta when uninstall/delete plugin

I have a custom plugin I created that adds some custom meta input fields to every post I want to remove all this plugin generated rows of postmeta for each post when I uninstall/delete the plugin ...
1 vote
1 answer
589 views

update_post_meta for repeated custom field [closed]

I have a repeatable custom field made with "cmb2" plugin: $meta_box->add_field( array( 'name' => 'error', 'id' => '_pf_error_log', 'type' => 'text', 'repeatable' => true, ), ) ); ...
0 votes
1 answer
140 views

custom search results - order results differently by post type

i've done a fair look round before posting this and i'm not getting much luck. Here's the scenario. I have a search query which retrieves normal posts and two additional custom post types (...
0 votes
2 answers
61 views

Link image with data from the wpdb

It might be a stupid question, but I can't get it to work.. Problem I have no idea how to link my image on the frontend with the url from the database. Situation I've created a Custom Post Type ...
0 votes
3 answers
192 views

is_main_query() never called on WP 4.4

I'm fairly new to WP development, however as far as I can see I've followed the correct procedure in my custom archive page (below). If I remove the check for is_main_query() it wipes the menus out ...
0 votes
1 answer
360 views

update a posts of other custom post type

i create a new custom post type which i named "invoice" and then i create an new custom post type named "car" which contained a field "Km traveled" i want to update the field of "km traveled" of post ...
1 vote
6 answers
1k views

trying to do if post meta !=0

I'm trying to do a simple if function on my code but for some reason it just isn't working correctly. I've gone over it several times to see if there is anything I'm missing, but no luck. I'm trying ...
0 votes
1 answer
564 views

undesrtanding get_post_meta function

Is there any way to avoid that when you don’t specify a $key ('') and set $single to true in get_post_meta, it returns all keys still with an array of values, instead of returning a single value only ....
1 vote
1 answer
1k views

How to show author name only if the post is in a specific category?

I have this function in my theme, what i want is to display author name only for the selected category (say category id 90). No author name should be displayed for the rest of the categories. I ...
5 votes
3 answers
3k views

update_post_meta not saving when value is zero

I have a problem with the update_post_meta function. I have a user submitted value, which I pass via $_POST and then saving to post meta. All is working fine, but when the value is '0' the post meta ...
1 vote
2 answers
3k views

Display custom post type from dynamic custom field

I am trying to create a custom meta box that lets you add rows dynamically. Following code snippet works fine and and saves data in my edit page section. However, I can't get it to display the data on ...
1 vote
1 answer
144 views

update custom post type meta from a shortcode

I have the following scenario: I have a custom post type called "tablepress_tables" that is create by the plugin "Wordpress", Tablepress has a shortcode to display the number of rows which is [table-...
0 votes
1 answer
544 views

Saving custom fields for WP_Query to retrieve

Thanks in advance for any help offered. I am writing a plugin for wordpress that has multiple custom post types sharing some custom meta boxes and fields. I have everything working and saving ...
1 vote
1 answer
45 views

How to separate posts in loop?

Let say I want to separete posts on how big or important they are. I want to set some kind of label on them so I can display them with different style. I want to create some values to choose from, ...
7 votes
1 answer
2k views

Storing revisions of metadata for custom post type

Storing metadata for custom post types is easy, you just need to add an action for 'save_post' with your method that handles this. In which you have then something like the following for a field that ...
1 vote
1 answer
247 views

get_post_meta remains empty while looping all menu items and using the ID

I am trying to create some sort of custom menu. Where I list all titles of my pages in the main menu and display the value of a meta box of each of these pages. For some reason the get_post_meta ...
1 vote
0 answers
51 views

get_post_metadata causing some meta data to fail

I'm using the following code to extend subscription trial lengths, which requires me to modify the metadata. the problem of, other metadata is also failing, such as custom attributes and variations. ...
38 votes
4 answers
84k views

what is the correct way to compare dates in a WP query_posts meta_query

I have a query_posts call in a WP template. Through the use of the More Fields Plugin I can give the site admin the ability to create an event (custom post type) and then enter a date which is ...
4 votes
6 answers
12k views

Meta compare with date (stored as string) not working

I have a custom post type that has a number of meta boxes in it. One of these is an expiration_date field that stores its info in the db as a string formatted like Feb 1, 2017 I am trying to write ...
0 votes
1 answer
223 views

How do I extract the contents of a CPT's custom field for all posts?

I need to generate a CSV report with information that is stored into a few custom fields of a custom post type. How do I list just the content of these custom fields, for all — or a subset &...
1 vote
0 answers
320 views

Compare old meta with new post meta

How do I compare old meta what was already stored in the database with the new meta data what was just set by the user? For example if you want to keep track of how many times a button is clicked. ...
1 vote
2 answers
119 views

Large AND OR query timing out

I am working on a wordpress calendar plugin and ran into a issue with custom fields. I can do two separate queries one for repeat events and one for static events but when I try to combine them my ...
4 votes
3 answers
5k views

Custom Post Type with Input fields to seperate table on database.

At the moment I'm using a custom post type called 'locations' I would like to be able to put input fields into the custom post type that would store the information such as ( address, type, phone ...
0 votes
1 answer
42 views

How to fetch posts that are stored in the different table than the default table (wp_posts)?

How can I Fetch posts that are stored in the different table than the default table (wp_posts)?
0 votes
1 answer
4k views

Need a SQL query to update meta_key='_price' with value in meta_key='_regular_price'

I don't know how many products are like this, but I know there are many. in the db; The _regular_price value of the post(wc product) is higher than the _price value. I don't know how or when this ...
0 votes
1 answer
77 views

Stripe multiple transactions

I have created a custom post type and each custom post type holds an order. When an item reaches a certain amount of orders I wish to process the payments. if ($orders > 10){ //Charge ...
0 votes
1 answer
63 views

Meta key in wp_query bug?

$query_args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'order'=> 'desc', 'orderby' => 'meta_value date', 'paged' => $paged ); This is my current query to sort posts. What ...
0 votes
1 answer
77 views

Custom permalink for each post

im importing data from Drupal to WP. I have more than 10 000 posts. Each post have ID, category and slug. For example: Category> important ID> 11111 Slug> hello-world I need to keep permalinks ...
0 votes
1 answer
1k views

update_post_meta not work [closed]

// Create tab add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' , 99 , 1 ); function add_my_custom_product_data_tab( $product_data_tabs ) { $product_data_tabs['my-...
3 votes
1 answer
576 views

Manipulating post meta in the customizer

I am working on a plugin for custom fields throughout the admin and I am trying to create as many locations for fields as possible. So far I am successfully doing this for quite a few of those ...
0 votes
1 answer
546 views

count post meta values

I have a custom function to count downloaded times for a specific file attached in the post, but i want to display the count of whole post in my website post meta = download_times and how to skip ...
1 vote
1 answer
1k views

Save both current and new version of post meta

I want to save two versions of my custom meta box data called "sidebar". I want to compare a new and old version of this data later on, so that is why I want to save a copy of the current "sidebar" to ...
2 votes
1 answer
2k views

How to sanitize post meta field value?

I have added a meta field for text input. I want to allow some html tags such as <strong> and <i> For example: <strong>hello</strong> world I can save the input field value ...
1 vote
1 answer
923 views

Add custom field to all posts in specific post_type

I want to add custom field 'tnid' to all my posts, and have it's meta value taken from field 'name' i have the following working query: INSERT INTO wp_postmeta (post_id, meta_key, meta_value)( ...
0 votes
1 answer
2k views

Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle

I'm getting custom fields using <?php $meta = get_post_custom($level_2->ID); ?> <?php foreach ( $meta as $key => $value) { ?> <?php echo $key.': '.$value[0].'<br />'; ?&...

1
17 18
19
20 21
40