Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2
votes
2answers
255 views

Meta query interfering with orderby relevance

I'm trying to re-order the search results using the pre_get_posts hook and set the orderby parameter to relevance. I also want to put priority posts, which is based on post meta _prioritize_s to be ...
0
votes
0answers
26 views

How to speed up UPDATE wp_postmeta queries?

When i do update to wp_postmeta value it's slower than expected: # Query_time: **1.482146** Lock_time: 0.000157 Rows_sent: 0 Rows_examined: 30 use the-db; SET timestamp=1556258093; UPDATE `...
0
votes
1answer
43 views

update_post_meta performance in a loop woocommerce

I have a simple question, I am working on the list order screen of woocommerce and want to add some buttons that via ajax will update some data to the database using update_post_meta. The issue is ...
1
vote
0answers
63 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
2answers
150 views

Display post number by category

I try to add auto increment post numbering by category. Like cat="myID" > post 1, post 2, post 3... Display post number not post ID number In find this solution, and use post_meta looks a good way. ...
1
vote
1answer
89 views

Multiple postmeta with same name for one post in wp_postmeta table

I have a hidden post meta called _payment for my posts. When i was looking into the tables of the wordpress, I noticed that there are tens of this post meta with the same name for the same post! Here ...
1
vote
1answer
345 views

Delete all post meta except featured image Using SQL

Please I just migrated my site and I found out that wp_postmeta consumes most of my cpu resources, Is the any Sql code to Delete all post meta except the featured image. I dont want to Use wp ...
2
votes
2answers
322 views

Sanitizing `wp_editor();` Values for Database, Edit, and Display

I'm using custom instances of wp_editor(); to allow rich text editing of Post Meta associated with a Post Object. I'd like to perform much of the same sanitization that occurs with post_content for ...
0
votes
0answers
53 views

Database structure for thousands of posts

I need to make a large custom customer database and was how to structure it in WP. It will run without woocommerce or anything. The client will not have access to the dashboard. There will be ...
0
votes
1answer
182 views

Saving Post Data in Another Database

So my problem is: I have a scraping script, who scrapes info and saves it into his own database, when I use that info for my posts, but what I did was copy all info and put it into wp_posts and ...
0
votes
1answer
220 views

SQL query : Select a thumbnail for a media

I'm doing a custom gallery for a portfolio page in a website and It works well if I simply use the URL of the media uploaded this way : SELECT * FROM wp_posts AS p INNER JOIN wp_postmeta AS m ON p....
1
vote
1answer
96 views

WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another

I have a lot of meta_key and their relative meta_value associated to a post, for example, post_id = 4319. How can I assign, using an SQL query, all the values to another post_id? for example, post_id ...
2
votes
1answer
54 views

Which is best in the following scenario : post_meta vs custom table vs parent/child posts

I’m looking for a bit of advice on which way to go with a development question. I’m building a community site where subscribers create their own private posts. The data they enter falls into two ...
1
vote
1answer
690 views

Storing data for a wordpress plugin

I am writing a plugin that needs to store data for a day (everyday). The data is retrieved from a CSV file. I will be retrieving three columns of financial data (Fund ID, Fund Description and Price) ...
0
votes
1answer
95 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
2answers
46 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
0answers
423 views

How much post meta data is too much?

I am creating a module on a site that allows users to reserve space, by the half hour, in roughly 10 different spaces. They can book a max of six months out from the current date. I am trying to ...
1
vote
1answer
86 views

How can I change the meta_key for a particular piece of information?

I've been adding on to a plugin I'm using that works well overall, but has several issues that I've been having to go in and fix within it's core files. The issue I'm dealing with right now is trying ...
1
vote
2answers
100 views

Where to hook my plugin's action

I'm writing a plugin that every time you: publish a post edit an already published one delete a published post it makes several queries to the database, gets certain post data (title, excerpt, ...
0
votes
2answers
3k views

Where does the actual data stored by add_post_meta

I am pretty new to WordPress API, loving it btw, I have a small project, adding a like button to the end of every post, pressing it makes user like the post, button changes to dislike, pressing again ...
1
vote
1answer
2k views

Delete all post meta except featured image

My aim is to clear up my database entries. I did a migration from blogger which added many useless post_meta. I found a plugin (db reset) that has the option to reset/delete all post meta. However if ...
5
votes
1answer
1k views

So much data in postmeta

Last year started using custom fields and in one year I have 230,540 rows in wp_postmeta table. This year will add more data and new fields and I don't know what to do, to create new table or continue ...
0
votes
1answer
935 views

Structure of postmeta meta_value for woocommerce product download

So I'm working on a monster script to port all of our existing stuff from Joomla/Virtuemart to Wordpress/WooCommerce. So far I've got just about everything done with moving over our product ...
13
votes
3answers
6k views

Why WordPress choose data serialization over json_encode?

In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP serialize() in storing data into db in many cases. But in a recent search I found a serious community ...
0
votes
2answers
88 views

Looking for suggestions on creating simple database (Help!!)

I'm working on creating a basic database for a theatre and really need some suggestions as the best way to approach this. Each production from this theatre will have its own page. The page should ...
0
votes
1answer
1k views

How do i get value from wp_postmeta?

I am trying to get a specific value from wp_postmeta, I'm aware about meta_key and meta_value. Problem is Meta value stores lots of values and i want specific value. Here's the value in the ...
0
votes
0answers
646 views

add_post_meta not saved

EDIT I changed it to if(isset($_POST['Make'])) update_post_meta($pid,"Make", $_POST['Make']); if(isset($_POST['Year'])) update_post_meta($pid,"Year", $_POST['Year']); if(isset(...
5
votes
1answer
163 views

Dealing with Many Meta Values, 30+

I have a "Listing" post type with 30+ meta keys which I feel like can cause a strain on the database when there's 100+ posts. Usually what I do is save each meta value 1 by 1 like so: if(isset($_POST[...
0
votes
0answers
45 views

Mysterious template change after database import/export

When I switch databases from my local environment to the host, some of the pages inexplicably change templates. E.g. there is a custom template "Home" and when I switch the db's it ends up with the ...
0
votes
1answer
228 views

Custom Post Type not showing anything added by code anymore?

So I have a piece of code written and it worked before, hasn't been edited hasn't been changed, no updates on the WP DB no updates on any plugin on WP and it's suddenly not working correctly. This ...
0
votes
1answer
704 views

delete duplicate meta_value with same post_id

I've trying to cut down on the time to query a custom post type. After looking at the database and the wp_postmeta table, for some reason, there is some duplicate meta values for the same post_id and ...
2
votes
1answer
485 views

Exporting Data from WordPress into a flat table

I need to be able to export the data within WordPress so that each object is contained in a single row, like a flat table. Imagine each post type as it's own database table, containing columns that ...
1
vote
1answer
290 views

Is it possible to store visitors IPs in wp_postmeta table?

Or in any of the other 11 Wordpress tables. I also need to store: submission date, name, contact number in the same table. What approach would be best? A custom table or using a standard table?
0
votes
1answer
46 views

Recommended Post Structure for DB Storage

I'm trying to write a plugin that would help my local little league manage their league, and though I've read the New Table vs Post Meta question, it's still a bit unclear and I'm hoping someone here ...
0
votes
1answer
642 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 ...
4
votes
2answers
673 views

What is the advantage of the wp_options design pattern?

As we all know, a design pattern that is used frequently in Wordpress' DB code is the idea of persisting data for a particular object (blog/post/comment), indexed with a particular name or key. We ...
1
vote
1answer
573 views

Importing Data from a Non-WordPress database, into WP

I'm migrating data from a totally different database style into WP. The main issue I'm trying to wrap my head around is how to import any meta data, given that WP uses a key value pair style for meta ...
3
votes
2answers
393 views

What is an efficient way to query based on post_meta?

The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a ...
0
votes
2answers
400 views

Does post_meta data need to be unserialzed?

Is it possible to unserialize data in the mysql query at the run time? i don't want to use unserialize() function of php. I need to fetch the value "mathematics" from the below serialized value ...
3
votes
2answers
646 views

Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?

I have a custom CMS, that we're looking to port over into Wordpress. (I can see you asking yourself: Why not just stick with the custom CMS? Well, it's outdated, clunky, and getting to be too much ...
1
vote
1answer
509 views

One post carries 30 postmeta values, is this too much?

I have some data saved as post meta, occasionally some plugins may save an extra piece. Now I installed bbpress, it saves at least 10 pieces of post meta. Adding them together, there are nearly 35 ...
4
votes
3answers
4k 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
1answer
159 views

Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types

I've been playing around with WordPress for a couple of months now and when a client requests that he/she be allowed to modify, add content without my intervention, my defacto standard is WordPress. I'...
4
votes
1answer
435 views

What is the most secure way to store post meta data in WP?

Sony's recent security "holes" showed how unsafe it can be to store data unencrypted. As some of you may know, I 'm working on re-releasing the free CRM theme Driftwood. What is the most secure way ...
3
votes
1answer
1k views

importing data from non-wordpress mysql db

I have created an import file to get the articles from a non-wordpress db and bring them in as posts in wordpress, I am not sure how to bring over the thumbnail image into my custom field I defined as ...
1
vote
2answers
1k views

delete post meta from db, even if does not exist?

it is not the first i see that we "delete" a post meta even if it does not exist : example : $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; ...
3
votes
2answers
5k views

How to delete outdated, wrongly sized images in _wp_attachment_metadata?

I've got several custom image sizes for my blog. One of these is setup as add_image_size( 'slide', 640, 290, true );. These are used in a header slideshow. My problem is I've upped the dimensions of ...
0
votes
2answers
868 views

Remove “%” from strings in serialized arrays in wp_postmeta

In the course of converting a blog from Blogger to WP and running a script to grab hot-linked images for hosting, I ended up with some funky images names like act%252Bapandas-210x290.png These image ...
0
votes
3answers
479 views

Uknown meta entries in wp_postmeta

I'm working on a site that has been running for few years and had different maintainers so it's kind of a mess. What I found weird is a lot of entries in wp_postmeta where all the keys are numeric and ...
28
votes
5answers
20k views

Post meta vs separate database tables

When developing plugins that requires data storage, what's the pros and cons of using one method or another ? The explanation given in the codex is not detailed: Before jumping in with a whole new ...