0
votes
2answers
53 views

Inserting data into `post meta` table?

How would I be able to insert data into the post meta table? I know how querying and wpdb works but I have no idea how I can just insert it into the table. I have these two fields I want to insert ID ...
0
votes
1answer
194 views

$wpdb->get_col and ORDER BY?

this is the query that returns the listing of a custom post type $apartments = $wpdb->get_col( " SELECT DISTINCT( post_id ) FROM $wpdb->postmeta ...
1
vote
1answer
792 views

using $wpdb to get custom post type with term

I'm trying to get the title of the first custom post type with a specific term in a taxonomy. But I'm not great at SQL so therefor not great with using $wpdb. Here is my code: $posts = ...
0
votes
1answer
72 views

Adapting plugin for custom post type?

I am trying to reformulate a function (in a plugin) so that it applies to posts in a custom post type rather than normal posts. function saving_posts($post_id) { global $wpdb, $user_ID; ...
0
votes
2answers
77 views

$wpdb is queried but results don't show

I am trying to show a list of custom post types on a page template. When I view the page, instead of seeing the different posts, I see the actual page repeated. For example, If I have 5 posts, the ...
1
vote
1answer
162 views

How to best delete orphan wp_postmeta

I'm in the middle of doing some fairly complex queries involving metadata from a custom post type. Unfortunately if any posts are deleted the metadata stays put which complicates matters as I am ...
0
votes
0answers
88 views

Retrieve post data via WPDB class

I'm trying to figure out doing a custom query using the $wpdb Object. I have custom type posts, event_posts, that have meta data, images, as well as event dates which are input in the post with the ...
0
votes
2answers
1k views

$wpdb returns no results with SELECT query on custom post type, works on default post type

EDIT: Adding more background info. I've coded a plugin that adds a meta box to the post page. When the post is published, the plugin will generate a random ID for the post, and insert the random ID ...
0
votes
0answers
95 views

Filter content by custom field and category

Im trying to filter an Wordpress request with 2 parameters. by a custom field (REGION) there are 6 regions by categorie, there are n-categories with 1 value per post. As result i would like to have ...
0
votes
1answer
70 views

Saving custom metabox data with a twist

I've got more than a few metaboxes being used with a custom post type and I'm running into an issue where my data is not being saved as expected. Here is the relevant part of the code, and its within ...
2
votes
1answer
257 views

Get terms that contain posts that in turn belong to other terms?

So I have custom taxonomy called "shape" and another one called "color". If I want to get the list terms under shape that contain posts that are also present in terms under color, how do I do that? ...
1
vote
2answers
346 views

$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies

It's easier if I made an example: I have a custom post type MYPOSTTYPE, with 3 taxonomies TAX_1, TAX_2 and TAX_3 If I have 3 terms: 'TERM_TAX_1' in TAX_1, 'TERM_TAX_2' in TAX_2, and 'TERM_TAX_3' in ...
1
vote
1answer
256 views

Converting the_content string to an array?

I have created a custom taxonomy, this taxonomy is dedicated to image attachments, when I upload my images $post->post_content returns a string like: '[caption id="attachment_98" align="alignnone" ...
0
votes
4answers
914 views

Trying to display posts by authors in with specific user meta

Ok here's the solution: <?php $wp_user_search1 = new WP_User_Query( array( 'meta_key' => 'state' , 'meta_value' => 'NM', )); $listers1 = $wp_user_search1->get_results(); $lister_ids1 = ...
1
vote
1answer
284 views

using custom taxonomies on non wp table?

I'm building a program registration system that will have a complex data structure. There are programs (custom post type, CPT), teachers (CPT), registrations (custom table and meta table), payments ...
0
votes
1answer
448 views

$post not working working in AJAX plugin with custom post type

I am trying to create a plugin that can relate two posts to each other, and to do so I am trying to use AJAX, but I am having trouble getting the current posts ID using $post->ID. I am trying to ...