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
713 views

WP-API + JS Backbone client - how to update post meta

Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows: var parentId = 96; // the post id var metaData = new wp.api.collections.PostMeta('', {parent: ...
0 votes
2 answers
710 views

How to return/export only data showing on screen in custom post type view all screen

If I for example filter my custom post type by date and it only shows 2 records on screen, I only want to export those 2 records, but it is exporting a bunch of records out of my control ie: the wrong ...
2 votes
1 answer
1k views

get_post_meta fails after switch_to_blog

I have some code for custom cron in wordpress multisite, that from each blog site, gets their posts and postmeta data and put them on an xml structure. But, when I retrive metadata (using ...
0 votes
1 answer
717 views

Adding Custom Metadata to my Archive/Posts page

I am currently working on a news website and using the Wordpress archive feature to display all my posts in a feed (when you click on the post titles you are taken to the source website).I need to add ...
0 votes
1 answer
1k views

Rename image filename using 'media_handle_upload'

I need to rename images uploaded by the user when they post on my site. I have a code that works perfectly to save the image and make it part of the post. But I want the images to be renamed to have ...
0 votes
1 answer
811 views

Unable to gather Image URL from Custom Post Type's; Custom Meta Field

I have wrote a very basic plug-in, it creates a Custom Post Type (CPT) that has multiple custom meta fields. I cannot seem to echo out the Image URL. I have tried a heck of a lot of other similar ...
0 votes
1 answer
16 views

Quering a post object based on another related post object

I have two post types - Ticket and Event Each ticket has a meta called 'event_id' which connects it to an Event. Suppose I want to fetch all events with more than 3 tickets. I want to do it in a ...
0 votes
1 answer
1k views

Use WP_query to match post types based on custom field values

i'm trying to query posts from the post type Product that match with the current post in the loop from the post type Item, based on the custom fields product-ean and item-ean. For example: i have a ...
0 votes
1 answer
1k views

get_post_meta not work in php foreach

i have these codes : foreach ( $ids as $idss ) { echo get_post_meta($idss, 'IMDB', true); } i have search box with Form element that search and find all id ( $ids ) of searched word . i want to ...
0 votes
1 answer
7k views

How to add dynamic content in title and meta description in wordpress theme for homepage, post page, category, tag and pages

I am creating wordpress theme and want to get and display dynamic content for my theme Title Tag and Meta Description Tag. For Title Tag Content: I want Title For Meta Description: I want Bloginfo('...
0 votes
1 answer
1k views

Blogposting Schema & Structured Data without plugin

I would like to add blogposting schema markup so each new post is automatically optimized for rich data. Some code on the web is messy and needs updates per each post, also plugin is not best option ...
0 votes
1 answer
1k views

Metadata on the WP_Post object

I'm having trouble understanding the behavior of a WP_Post variable (and / or possibly the behavior of var_dump itself). As far as I know, var_dump will inspect all data from a variable. From the PHP ...
0 votes
2 answers
1k views

post_title in save_post action

I use save_post action to save meta field and to check if post title is set. So I check the value returned by empty($post->post_title) but I get true also if I set the title.
0 votes
1 answer
2k views

add action save post type and update post meta woocommerce

I want update post meta in product woocommerce when I save o update the product. I write this function (and insert in functions.php) with save_post_NAME_CPT but don't work. add_action('...
0 votes
1 answer
11 views

How to update post view count?

I am adding post view +1 whenever someone is loading the page in wordpress. so everytime someone reloads it automatically gets +1. this will cause to store very large value in meta value. is it ok?
1 vote
1 answer
2k views

How to create a meta_query to get all posts with a specific meta data?

Here are the args for my query : $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' =>...
0 votes
2 answers
1k views

Create action running on trashed_post hook to modify post_meta value

I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = ...
1 vote
1 answer
801 views

Is it possible to store Json data in post_meta and manipulate

I just want to add json data type in post meta field as like in normal database. json data will be in the structure below, Post Name Meta Data 1.Sample title 1 ---> ...
1 vote
1 answer
2k views

Update post meta without deleting the old entries

$old = get_post_meta($post_id, 'figure_sugsubject_repeatable_fields', true); $new = array(); $figuresugsubjectpositions = $_POST['figuresugsubjectposition']; $figuresugsubjectworkplaces = $_POST['...
0 votes
2 answers
1k views

register_meta not showing custom post type metabox data in rest api

I have added a custom post type and I want to expose the custom field value in the rest api. As per the docs register_meta can be used. I have created a custom post meta box using the wordpress way. ...
0 votes
1 answer
1k views

How to programatically create a WooCommerce downloadable product?

Is there a way to add, for example, an MP3 file to a WooCommerce product from PHP rather than from the dashboard panel? Looking in the database I see that downloadable_files seems to be a serialized ...
0 votes
1 answer
912 views

I need query_posts() to order results first by a meta value and then by post ID

I've read all the WordPress docs that seem relevant, and I've read lots of posts here and on other sites to find an answer to this, but I still can't find a way to do this. I have a custom post type. ...
0 votes
1 answer
780 views

How do I delete element from a serialized array upon deletion of a post?

I want to delete an element (post id) from a serialized array associated with a specific meta_key. The following screenshot tells the whole story. What you're seeing are, post ids saved in a ...
0 votes
1 answer
1k views

get_post_meta image width for lazy load

I'm trying to lazy load a page of images in Wordpress - I've tried the plugins but none of them seem to work(I only want to lazy load image on some pages.) So I'm now trying to do it with a plugin - ...
0 votes
1 answer
756 views

Where is get_post_meta value located?

I'm working on a wordpress website created quite long ago. In the header file I see the following code: <?php query_posts("page_id=63"); while ( have_posts() ) : the_post() ?> <?php echo ...
0 votes
1 answer
817 views

wordpress simple post multi rating with post_meta and user_meta

I am trying to create a multi criteria post rating function with simple form and post_meta and user meta. The Goal when users submits their ratings 2 things should happen: 1.the ratings is stored ...
1 vote
1 answer
813 views

How to update the title of audio file through its attachment metadata

I am trying to programmatically update some metadata of audio file attached to a post. I have been able to update the artist and album properties of the audio file but title doesn't stick. I can go ...
6 votes
2 answers
2k views

Admin Area Custom Type Search By Meta Fields Without Title & Content

I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code: ...
1 vote
1 answer
996 views

Saving zero as meta value

I have a meta_key called "_ordre" and each time I create a new custom post, a new meta_value is set for that meta_key. The thing is, when I set the value of '_ordre' to 0, the meta_value is not saved ...
0 votes
1 answer
1k views

Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete

I am trying to write a plugin that adds a custom meta field to image attachments to give images a credit field. I use the 'attachment_fields_to_edit' and 'attachment_fields_to_save' filters. ...
2 votes
1 answer
4k views

Saving custom image meta fields

I have currently added a custom meta field to upload a media file (image). I can successfully add the upload button to display and it works but I'm having problems saving the field when updating the ...
0 votes
1 answer
2k views

Get meta information from post parent

So I am in a single page and I want to get some meta information from a parent page. This code is inside my footer.php: if (is_single()) { global $post; $parent = get_post_achestor ( $post-&...
0 votes
0 answers
31 views

rest_api_init is not getting invoked inside a Class

When I include the code to expose custom post meta using the rest_api_init hook outside a specific class, it works perfectly, such as in the functions.php file. However, when I place the same code ...
0 votes
0 answers
31 views

How do I access the current post object within a block theme template or pattern?

How should I be able to query things like specific metadata or any other thing from the post object? Apparently I don't have access to basic functions like get_the_ID() or similar functions inside ...
1 vote
1 answer
1k views

Save an array of values in the post meta box

I created box meta for a custom post type. From the admin edit for the post, I want to enter in multiple values so that it saves as an array so I can then call it as an array from the front end. So ...
1 vote
1 answer
1k views

get_post_meta slowing down my page load (in a plugin)

I've been working on this project where I need to load events (custom post type) and a whole bunch of meta data for every event. The problem is that page loading times are getting longer and longer ...
0 votes
1 answer
2k views

WordPress AJAX load post metadata in modal

I have a custom page template (front-page.php) and I have a custom metabox which is assigned to this page template. Metabox have 7 sections, and each section have 2 inputs. It looks like: 1. Client ...
0 votes
1 answer
901 views

Update Post metafield of specific categories

I have some meta fields in WordPress created by theme and i want to update it by using php. The metafield stores url and i want to add some string after current url in custom meta. i tried these ...
39 votes
13 answers
28k views

Can the Next/Prev Post links be ordered by menu order or by a meta key?

I have a series of posts that are ordered by a meta_key value. They could also be arranged by menu order, if necessary. The next/prev post links (generated by next_post_link, previous_post_link, or ...
0 votes
3 answers
1k views

Counting number of identical meta keys

Im looking to count how many meta keys exist within a post, because each time a specific user action happens, a new meta key is created with a date in it. I have this, which does not return anything (...
0 votes
1 answer
2k views

Get value from an input field and pass into update_meta_data as $meta_value

I am building a woocommerce site and I have some input fields the on the product page. one is for recipient email (its for a gift car). Everything works, and the recipient email is saved on the order, ...
0 votes
0 answers
16 views

Force post update with React

I'm creating a plugin and I have added a custom settings panel in the editor sidebar. In my settings panel I have a couple of text inputs and a custom button that calls an endpoint to pass some data ...
4 votes
3 answers
8k views

delete unused postmeta

I love the comment by s_ha_dum : http://wordpress.org/support/topic/sql-query-to-delete-postmeta and havent tried it yet, but Im wondering just how 'clever' this actually is? Does the unused postmeta ...
0 votes
1 answer
2k views

change attachment custom field onChange event

The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ? Ajax <script> function dynamic_Select(field, aid, value) { console.log(...
1 vote
0 answers
18 views

How can meta values from another site in a multisite be used in a custom query?

Currently, I am using the pre_get_posts action to create a custom query, ordering the posts based on a meta value like so: add_action( 'pre_get_posts', 'my_custom_order' ); function my_custom_order( $...
1 vote
1 answer
1k views

Hide custom meta data if empty

I have a custom field created for WooCommerce products. I am using the below code to create // ADD CUSTOM WOO DATA add_action('woocommerce_product_options_general_product_data', '...
3 votes
2 answers
6k views

Displaying Meta Box Image

I have some problems displaying info from my custom meta box in my custom post type single. I'm using Reusable Custom Wordpress Meta Boxes by Tammy Hart. I'm able to display the textfields using this:...
0 votes
1 answer
985 views

How to get several fields from wp_query?

I'm going to get several fields from wp_query result. I know about wp_list_pluck() function, but it accepts only one field paramether. How to get several ones if I'd like to take several parameters ...
1 vote
1 answer
876 views

Get Custom Logo Alt Text

I'm trying to get the alt text of the custom logo specified in the theme customization. Unfortunately this doesn't work because it seems the alt text is not included in the post meta: $custom_logo_id ...
0 votes
1 answer
2k views

Create Meta boxes dynamically

I followed and created a meta box using all code from this question here: Create more Meta Boxes as needed Basically only two fields are created when you click on Add track button: Song title field ...

1
2 3 4 5
40