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 in my meta box from the admin edit I'd save the values "200", "201", "202" in a single field "_parent_id" and then grab it from the front end $array = get_post_meta($postID, "_parent_id", false); How should those …
I'm looking to cleanup wp_postmeta. I've found dozens of duplicate entries. I've spend about 8 hours looking through topics and trying code and plugins to no avail. The most useful article on the subject I found is this. However the article is from 5 years ago and I'm not sure that the suggested code leaves at least 1 entry from each duplicate. Also the plugin that is suggested (Cleanup Duplicate Meta) is exactly what I need, but it hasn't been …
How to create next/prev buttons that are price sorted and give results inside the product category you are in? This question has been asked multiple times and despite the multiple threads there wasn't an exact answer. Only relatively close ones that didn't do all of the above. Below you will find my answer which works in my tests so far.
I’m working on a games release feature for a website I’m building. So far everything is going smooth, but I’m stuck on one area. For the listings on the front end, I want it to look at the “release_date” field and only display games that have a release date >= that date. I feel the code below should work, but it doesn’t return/display anything on the front end. And if I switch it to <=, it displays everything. Any help …
I have a request to get postmeta records with a specific meta_value. global $wpdb; $result = $wpdb->get_results ( " SELECT * FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key LIKE 'wpcomplete' " ); foreach ( $result as $page ) { echo maybe_unserialize($page->meta_value).'<br/>'; } result : {"buttons":{"3":"1951965-debutant","4":"1951965-intermediaire","5":"1951965-expert"},"course":"examen"} I just need to clean the result like that buttons : 1951965-debutant 1951965-intermediaire 1951965-expert course : examen
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->ID ); $some_value = get_post_meta( $parent, 'some_metabox_param', true); } It's not working people, can you please have a look? UPDATE: the parent page in question is template that has this loop <?php query_posts( 'post_type=post&posts_per_page=5&paged=1' ); if ( have_posts() ) : global $more; ?> <div class="items"> <?php …
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 method Assign/update the custom field value for all posts and made changes 'post_category' => array(14,16,19); to select a particular category but it edited all posts of all categories. and used this method to change meta field but it removed url and …
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 (I'm looking for a number)... ... $post_title = $row->post_title; $id = $row->ID; $post_count = $wpdb->get_var(" SELECT COUNT(DISTINCT $wpdb->postmeta.meta_key) FROM $wpdb->posts LEFT JOIN $wpdb->postmeta WHERE $wpdb->posts.post_type = 'things' AND $wpdb->postmeta.meta_key = 'dates' AND post_id = $id "); echo $post_title . ' (' …
I'm creating a theme using the CF Post Formats plugin. But I've run into some trouble I don't know how to solve. Here's what I want to be able to do: Create a new standard-format post Enter a url into the _format_link_url custom field If the custom field is not empty, on save/update, change the post format to 'link'; else, remain 'standard'. For whatever reason, I can't get set_post_format to work in this context (perhaps there's a conflicting update?). I …
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 posts_nav_link all navigate by chronology. While I understand this default behaviour, I don't understand how to change it. I found that it maps through to adjacent_post_link in link-template.php, but then it starts to seem fairly hard-coded. Is it recommended to re-write this from scratch to replace it, or …
I have a problem while using TOC plugins 'cause all of TOC plugins use revision data to recognize header tag. I'm using my own metadata (custum field) plugin and the data doens't show on the revision page. It means that the TOC plugins can not recognize my header tag data on the post page. Any great ideas? This is one of the TOC plugins and you could see the "get the revision" public function widget( $args, $instance ) { global …
I have created a custom post type with an image gallery upload. Now I am trying to display the gallery on the front end. This is what I have so far that works to display 1 image, but if multiple images are uploaded all the URLs get stuck in the src tag. So I'm guessing I should loop through that array and spit out each one separately? Would that be the route to go and if so how can I …
I'm creating a Meta Box in my custom Plugin where the Administrator can select which users can view a certain post based on their roles. When I select the role and save the meta box content by clicking on the Update button, nothing gets saved because both $_POST['metabox_nonce'] and $_POST['membership_level'] are empty. Why is the form not sending any data? Thank you so much for your help. This is my code: add_action( 'add_meta_boxes', array($this, 'add_italianglot_membership_box' )); add_action( 'save_post', array( $this, …
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 = cpt_pm_product_order post-type 2 = cpt_product post-type 2 post_meta = cpt_pm_product_stock There's a cpt_product with cpt_pm_product_stock = 100, frontend operation enable specific user made order by inserting new cpt_product with post_meta cpt_product_order of 10 will substract cpt_pm_product_stock to 90 100 cpt_pm_product_stock - 10 cpt_product_order = 90 cpt_pm_product_stock cancelling order will delete/trash …
I have a custom post type and I also need a custom search. I want the post title and two custom fields to be indexed/queried. I found solutions for title only and for custom fields but not for both so I tried to combine. Why doesn't this work? function custom_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing - no search term in query $q = $wp_query->query_vars; $n = ! empty( …
For some reasons I show the Last Modified information to my users in the blog. Recently I have to clear up my categories and tags, but these actions will result in the update of 'Last Modified' field of a post, which is not actually I desired. Content updates are what readers really concerned about, and not about meta information (like tags, categories, custom fields, descriptions, etc). So is there a way to update the 'Last Modified' field of a post …
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: function custom_search_query( $query ) { if ( is_admin() && is_main_query() && $query->is_search ) { $query->set('meta_query', array( "relation" => "OR", array( 'key' => 'first_name', 'value' => $query->query_vars['s'], 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => $query->query_vars['s'], 'compare' => 'LIKE' ), array( …
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: <?php echo get_post_meta($post->ID, $prefix.'hjemmeside', true); ?> But I can't get the image to display, instead DEBUG is telling me that it is an "Undefined variable: post_meta_data in". Currently I'm using this script: <?php $custom_image = $post_meta_data['image'][0]; echo wp_get_attachment_image($custom_image, 'thumbnail'); ?> Is this wrong? ID for …