Tag Info

New answers tagged

2

You can use plugins such as BackupBuddy, but I prefer to script this and use wp-cli, which reads wp-config.php and means you don't have to worry about mysql credentials. wp-cli allows you to: export the db: wp db export <filename> import the db: wp db import <filename> safe search and replace (including serialised data): wp search-replace ...


0

Thanks all, I got it I changed the code to be $SQL = "SELECT * FROM ".$wpdb->prefix."orderdata WHERE cus_id='".$userdata->ID."' GROUP BY order_id ORDER BY autoid DESC"; $results = $wpdb->get_results($SQL); That solved the issue


0

Create a php script ( fpw-swap-thumbnails.php ) with the code below and put it in root of your site: <?php // load WordPress environment require( 'wp-load.php' ); $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish' ); // get all published posts of type specified in $args $posts ...


0

I will say, I don't exactly understand your words "when a front-end sets a date"... I'm assuming wp-admin setup. Go find a post expiration plugin. There seem to be more than a couple of these out there. The plugin I've used ws "Post Expirator" Awesome tool. You can create a start posting and stop posting date when the post is created. I used it on a ...


1

One problem with the query is that the self-join with the ambiguous WHERE gives you a crossed dataset (which is masked by the DISTINCT), so it would be simpler to use wp_post as a base to attach the joins that precisely match the keys, eg SELECT p.ID, key1.meta_value as prog_ongoing, key2.meta_value as prog_date_start FROM ...


1

First pass for a solution. It uses the new meta sorting that was introduced in 4.2: <?php $args = array( 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'OR', 'ongoing' => array( 'key' => 'prog_ongoing', 'value' => 1 ), ...


0

Why not use WP_Query()? Lot simpler this way: <?php $args = array( 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'prog_ongoing', 'value' => 1 ), array( 'relation' => 'AND', ...


1

wpdb uses PHP's mysqli_affected_rows() or mysql_affected_rows(), which can be disabled via an argument in php.ini. I am guessing that that is what has happened. Check the disabled_functions line in your php.ini file and remove the references to those function. Of the top of my head, I am not sure if extensions like Suhosin mess with that function but that ...


0

Here's my final code which answers my question. It allows the user to input a value through a text field which is then either added, replaced, or deleted from the database (if user types 'delete'). It also gets the value and displays it in the input field if there is one. function movie_edit_add_year($movie){ global $wpdb; $v = ...


0

Nevermind, I solved it on my own. While reading on the WordPress Codex for $wpdb, I saw that if I use OBJECT_K it will remove the duplicates and that solved my problem. If it helps anyone, here is my working code: function latest_posts_after_last_login( $atts ) { global $wpdb, $current_user; $atts = shortcode_atts( array( 'post_type' => ...


0

try with global $wpdb; echo $wpdb->last_query; as i am working with ajax, this is directly in string form.


0

short exmaple how i do it... (tables naming not really correct.) in this example i am trying to save _description $_POST variable. add_action ( 'edited_term', 'custom_edited_term', 10, 3); function custom_edited_term($term_id, $tt_id, $taxonomy){ if ( defined('DOING_AJAX') || defined('DOING_CRON') ) return; $_POST = ...


2

So what I'm going to do going forward if I use wordpress for this project is to create a reverse post id index. I don't think this is the "correct" answer and some people will definitely outright disagree with this approach but this is working for me in production. I got the idea from reading this blog post here: ...


1

You don't need to write a custom SQL for this. You can always leverage WP's get_post_custom() that returns array of all custom fields for a particular page or post. https://codex.wordpress.org/Function_Reference/get_post_custom



Top 50 recent answers are included