Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [post-meta]

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

0
votes
0answers
9 views

Hidden Form Custom Post Meta Field for Storing Post_id using PHP and save_post hook

In order to send email notifications to registered users when a new listing matches their breed and location preference, need the post_id stored in a meta field to have post_id parameter available for ...
0
votes
1answer
18 views

Hide Page Title with Post Meta

I tried to write code to have a checkbox on Pages in the backend to check if I want to hide the title of the page in frontend. But I find that the post meta is sometimes reset to show the title even ...
0
votes
1answer
16 views

Custom post type suddenly stoped working after WordPress 5 update

I build a simple plugin that has a CPT and 1 metabox section that collect extra information from admin. It was working fine in the old version but when i just updated it to WordPress 5 it stopped ...
2
votes
1answer
29 views

Some post meta fields stop saving after a few successful saves

I've only experienced this a few times: I have a plugin with many meta fields for pages and other post types. Very occasionally, the update_post_meta() function won't have any effect with just one ...
0
votes
1answer
21 views

Batch Extract Date from post title and put into ACF custom field

I have a custom post type called 'events' with around 700 posts, the titles are consistently formatted like this: Event Title - January 1st 2019 I need to isolate the date in another field. I am ...
0
votes
1answer
19 views

SQL query to change the value of a Custom Field

I am looking for a SQL query to change the value of a custom field, but not on all posts. Some posts have in the "post_template" custom field a "temp1" value, and I want to change this value to "...
0
votes
1answer
33 views

wp_query with ajax

I am trying to filter posts by year using WP_QUERY with AJAX And the current builder i am using is DIVI(for front end). Result Everything loads fine and i am facing one final roadblock that is when ...
0
votes
1answer
20 views

Archieve.php not loading for custom post type

I have a post with a category of blog . So i came across with this archieve.php , whereby we can edit the layout and content of a custom post type. From what I understand archieve.php contains the ...
0
votes
0answers
13 views

Attachment metadata has value of '1'

While accessing /wp-json/wp/v2/media endpoint I'd got an error 500. Checking the logs, I'd seen the following issue: PHP Recoverable fatal error: Object of class stdClass could not be converted to ...
0
votes
1answer
10 views

Suggestion to make posts have multiple associated items

I'm developing a WordPress theme and I need some expert advice to achieve a little complex result. My theme has a custom post type and that post type should have child items. For example the post is ...
1
vote
1answer
18 views

Get thumbnail url of custom meta image?

I have a line in my child theme as follows: $bg_image = wp_get_attachment_url( get_post_meta(get_the_ID(), 'bg_image', true) ); It successfully provides me with the url of the image stored in the ...
0
votes
0answers
14 views

Change picture attachment meta of all occurrences of a picture

I have a custom post type with multiple body copy boxes. I want to achieve the following. Add an image attachment to one body copy box. Add the same image to another body copy box by selecting it ...
1
vote
1answer
7 views

Random order of WP_Query results with highest meta value

I need to random of cars with highest price. My code: $argsLoop = array( 'post_type' => 'cars', 'posts_per_page' => 12, 'paged' => 1, 'meta_key' => '...
1
vote
2answers
53 views

How do I access post meta data when publishing a new post in Gutenberg?

I am updating one of my plugins for Gutenberg. I need to check for the presence of a custom post meta field when a post is updated or published, so I've hooked into publish_post: function ...
0
votes
1answer
23 views

Query post with meta_query where date is not in future

In my args I would like to exclude posts where the datum_event is not in the future. Currently it only displays posts with datum_event values that are in the past, but because older posts don't have ...
0
votes
1answer
21 views

Unknown Post Meta Records

I inherited a site that has had many developers. There are post meta custom post type records for custom post types that we do not have. They appear to have come in through an import when the site was ...
0
votes
1answer
11 views

Display Updated Date Instead of Published Date

Both published and updated date are showing on the post page. How can I replace the published date if the last date is updated? The code is here: Published on <a class="entry-date" href="<?php ...
0
votes
1answer
14 views

How to set meta_query if get_post_meta returns nested array for that key? [duplicate]

I need to get posts with specific post meta. If I inspect regular loop using following code: $args = array( 'post_status' => 'published', 'posts_per_page' => 77, 'post_type' => '...
0
votes
0answers
13 views

Save post meta save as multi dimensional array

I want to make portfolio page using meta field, where clicking to image opening image slideshows. So I want to loop main clickable image in array and images of slideshow as an array of main image, ...
0
votes
0answers
32 views

WP Query to order posts with a specific meta value first

I am trying to write a WP post query to get all posts which have a certain meta key, but with those which have the key set to a specific value to show first. The query modifications are in a ...
0
votes
0answers
27 views

WP post meta - for loop inside for loop

I wanna make a portfolio on-click opening images gallery using meta fields. So firstly I make array of portfolio images and loop them. Then I loop gallery images of every portfolio item, but it loops ...
1
vote
0answers
29 views

What type of index should I use for postmeta?

I already added a composite index but it still took 5 seconds to finish these 2 queries. SELECT COUNT( DISTINCT( wpp.id ) ) FROM `wpdgls_posts` wpp JOIN `wpdgls_postmeta` wpm ON wpp.id = wpm.post_id ...
1
vote
1answer
17 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', '...
1
vote
1answer
19 views

Where to put meta Keys

Hello im creating my custom checkbox in gallery and i already add that , but save doesn't work , can someone take a look and tell me where should i put meta keys ? function wporg_add_custom_box() { $...
0
votes
1answer
18 views

Please tell how to stop the category from showing up on posts

Please tell me how to remove the category hence, it does not show up on posts. my content.php file is given below...which contains the code for showing up meta. but I am not able to figure out the ...
0
votes
0answers
12 views

Calling custom fields value for pages to another page

I'm trying to include a product template in my header.php file and i want to get a custom field value on header from product page. I have added properly when i need to get custom field values from ...
0
votes
0answers
17 views

Get Previous Post based on Custom Field Name, for Custom Post Type

I am using this query but the results returned are based chronologically (from my understanding) for get_previous_post(). <?php $prevPost = get_previous_post(); if($prevPost) { ...
1
vote
0answers
23 views

how to solve slow WordPress site caused by attachment_metadata

My WordPress sites starting to become slower by time, after two years they become very slow. I tried many things, such as: improved my DB, used cache plugins (WP Rocket and W3 Total Cache) which both ...
0
votes
0answers
67 views

Custom meta POST request fired twice when updating a post in Gutenberg

I have made a feature similar in behaviour to Revision Notes, but for Gutenberg. It is a Gutenberg sidebar plugin which adds a text field where users can write an edit summary when they edit a post, ...
0
votes
0answers
9 views

Query the same posts twice with “rand”

I building a WorPress site that is going to run ads. The ads will display before and after a visitor interacts with certain parts of the site. Each ad is a post from a custom post type. The ...
0
votes
0answers
11 views

Filter past events in post list

I have been looking for a few days, but am struggling to find the function I need. I am creating an events post type for a theme, with the event start and finish timestamps saved in respective meta ...
0
votes
1answer
17 views

Reference multiple style sheets, clearing styles for permalink page, custom fields for css

my wordpress theme will be styling posts on the index page based on their post-ID class -this will result in a lot of css code over longer durations of time. To keep the website lightweight as ...
-2
votes
1answer
76 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 ...
1
vote
1answer
25 views

403 Error when text is pasted in Custom Metabox Textarea

I hope everyone is having a great day! I am creating this question as I have been stuck on this issue all day and I need some friendly advice. I have created a repeater custom metabox item for a ...
0
votes
1answer
44 views

Modifying post content with the_post action hook

I'm trying to understand the best way to modify the way that search results are displayed with my custom post type. I've got the search function working properly and giving the correct results and now ...
0
votes
1answer
45 views

How to display liked posts of current user in wordpress?

Im using an ajax like dislike post system on my wordpress theme. When the user likes the post there are some post metas to update or to add like the following: if( $post_like == "like" ){ ...
0
votes
1answer
58 views

How to add/update post meta to use in query?

I found a rating system that users can rate the post when commenting. Every thing is good but I want to use the average rating of posts to sort them to users based on average rating (in fact be able ...
0
votes
0answers
18 views

Generate post content from meta fields

I have a custom post type (match). Each posts on this CPT has one ore more custom fields. Is it possible to automatic generate the 'post content' with the value of my custom fields on these posts? ...
0
votes
1answer
56 views

Saving custom post types post_meta over REST-API fails

I try to save with wp-json my custom post types meta data but does not works in my case I create my custom post type with jjgrainger's class as it follows $arguments = array( 'public' ...
0
votes
0answers
28 views

How to properly get the wp_postmeta.meta_value of a custom post type in specifics?

In a RDMS with the following query I try to get postmeta.meta_value of the post with custom post type points. To identify which key they belong to I made a case when. This query returns a greater ...
0
votes
1answer
9 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
1answer
32 views

Saving html into postmeta without stripping tags - safe?

I have a product description box, I want to add the HTML from the description as postmeta, for some outside reasons I can't unescape the code coming back out of post meta. Is it safe to just ...
1
vote
0answers
44 views

post meta parameter in post custom-post-type endpoint with restapi

I'm trying to create a new custom post via the native Wordpress REST API POST /wp-json/wp/v2/CUSTOMPOST at the moment I used the wp-rest-api-controller plugin to activate the endpoints the custom ...
0
votes
0answers
33 views

Get post content before rendering

I am currently working on a shortcode function, where I need to access the content of a post, before its rendering. If I do it like this $content = get_the_content( get_the_ID() ); It gives me the ...
0
votes
0answers
11 views

Best Practice to display posts which contain a certain metadata

I'm working on a theme that allows the user to add meta data to a post. I want to display all the posts with my custom meta data on a front end page. However I am unsure the best way to go about ...
0
votes
0answers
16 views

How do I get all authors posts of a custom post type outside loop

I'm trying to create a utility script that to add some metadata into all posts of a certain post type. Right now I have it set up to loop through all users $blogusers = get_users(array( 'role'...
0
votes
0answers
11 views

Meta box built with loop have 1 error in input

I am making a loop to build metabox with several inputs. It is working , but there is something strange happening. When loop runs. all inputs are working fine except one. always the same one. ...
0
votes
0answers
31 views

Is there any way to get all custom posts and all custom terms with it's meta in few queries?

I'm developing a website with a record for me query count. It has 720 Query for the main page. I want to reduce it. The main page structure is like this: ~10 Custom Taxonomy Term Each Term has a ...
0
votes
0answers
15 views

How do I create a navigation menu from product meta (custom fields)

I'm trying to find out how to add a navigation menu to my site based on one set of custom field meta data. I have tried creating tags from the custom field but then all tags are displayed in a single ...
0
votes
1answer
102 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('...