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
1answer
14 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
1answer
33 views

How to get post by meta value

I am trying to get post of custom post type by two meta value but it does not work. I have followed lots of article but not worked below are my code. Note: 1. first meta value is a type of date eg: '...
-1
votes
0answers
14 views

save $_GET as meta

how shall i save $_Get as meta value ? I want to save $_GET at the end of the page and again call it at the begin to see if it changed or not. any idea about comparing $_Get with last refresh of the ...
2
votes
1answer
117 views

Using Advanced Custom Field (ACF) to insert meta description on each page

I have used ACF hundreds of times but never to edit the meta description. I have created a simple text field in ACF, then tried to use this script: <?php $meta_description = get_field('...
1
vote
2answers
18 views

how to build (custom) stats for post views, per month

Does anyone know how I could code something to get the most viewed posts per month (without Jetpack), ideally without having to create a new DB table ? Maybe there is a smart way to achieve this only ...
0
votes
0answers
30 views

Custom Fields Not Showing (ACF not installed)

Custom Fields not showing on edit page. When I look at Screen Options it doesn't even show up. I've looked around for a while and saw that people who had the Advanced Custom Fields ran into the same ...
0
votes
1answer
17 views

How add multiple wp_editor_box to new post

I am trying to use multiple wp_editor_meta_box to my posts for custom post_meta but the problem is when I use the same codes for each of them there is an error Fatal error: Cannot redeclare ...
0
votes
1answer
34 views

Wordpress yoast seo plugin - parse snippet var in meta description

I am using this function to get the yoast meta description $metadesc = get_post_meta( $id, '_yoast_wpseo_metadesc', true ); But it is returning the snippet variable. From transitional styles %%...
2
votes
2answers
22 views

Get post from meta_key and meta_value

I have this sql statement: SELECT post_id FROM wp_postmeta WHERE meta_key = $param1 AND meta_value = $param2 I am facing one problem: I don't know how to do that sql code with wordpress ...
0
votes
0answers
30 views

Display multiple meta_key/meta_values by single SQL query

This is my query SELECT P.ID, P.post_title, P.post_content, P.post_author, MAX(IF(PM.meta_key = 'ex_latitude', PM.meta_value, NULL)) AS lat, MAX(IF(PM.meta_key = 'ex_longitude', PM.meta_value, NULL)) ...
1
vote
1answer
21 views

meta_post_meta return value 1

I want to return some post meta , but when i use the functions get_post_meta or get_post_custom the functions returns allways the values 1 for all the meta data, i tried several thinks but they ...
2
votes
0answers
72 views

Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta

I have a custom meta box for saving values from two input fields into a single post meta field. The data is saved serialized in the DB: get_post_meta( $post->ID, '_custom_key', true ) will ...
0
votes
0answers
56 views

Attachment metadata randomly missing

I have this website with about 3000 posts and 4000 images in the media library. For a long time now, some image thumbnails will randomly disappear from the media library: When I click to open the ...
0
votes
1answer
16 views

Using a comma instead of a pipe to separate metadata

The default way WordPress separates different types of meta data, such as in the post meta data, is using a pipe |. For example, Author Name | Date | Cat1, cat2, cat3 On a Wordpress site, with an ...
3
votes
2answers
103 views

Regenerate missing _wp_attachment_metadata

For some reason, some of the thumbnails of my media library are randomly becoming missing. I've found out _wp_attachment_metadata isn't present in the database for those images with missing ...
0
votes
0answers
14 views

Export media library with metadata and import into new blog

I am looking for a way to export my media directory, along with all meta data and import into a new blog I can download all files via ftp, but i would lose all title and alt attributes associated ...
0
votes
0answers
12 views

How to edit post meta data on Wordpress

i have news aggregator site i want to make on homepage under title to show source like here https://i.postimg.cc/QMmwQCrb/STACK-OV.png
0
votes
1answer
62 views

Save/update post_meta with Gutenberg from the panel

I've created a block, and I need to save as post_meta a value from an action on the panel. Php side: add_action( 'init', 'yasr_gutenberg_show_in_rest_overall_meta' ); function ...
0
votes
0answers
10 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
22 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
28 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
34 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
20 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
50 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
24 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
14 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
11 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
20 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
9 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' => '...
2
votes
2answers
177 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
25 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
25 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
16 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
16 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
15 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
45 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
32 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
44 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
31 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
22 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
20 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
22 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
28 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
178 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
12 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
14 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
19 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 ...