Tag Info

New answers tagged

1

Don't forget that when you are adding a filter it will stay there for all subsequent request. I would suggest you remove the closure and do something like this: function x_example( $input ) { remove_filter( 'posts_where', 'x_example' ); return $input; } add_filter( 'posts_where', 'x_example' ); You will have to do the same thing for the posts_join ...


1

The function you are looking for is wp_update_post(). You would want to have your posts which you want to update, then set up a loop to update each one individually. // However you get your posts, ID's, etc. $posts = get_posts( array( 'post_type' => 'post' ) ); for ( $posts as $post ) { wp_update_post( array( 'ID' => $post->ID, 'post_parent' ...


0

There is a plugin for this. It allows comfortable use of the backend and also replaces the URL in the post-content and some other fields, if you want to: https://wordpress.org/plugins/better-search-replace/


3

The Bad News: The core open source base of Wordpress does make quite a few assumptions about being run on a single server (wp-content, user uploads and media library to name a few) The Good News: Pretty much all cloud providers (including Azure) have abstractions that allow you to work around these design limitations. Fundamentally, you'll be addressing ...


-1

In your case is not possible SQL injection attack. Your code don't need additional protection because don't use user input like: post, get, request, cookie. http://php.net/manual/en/security.database.sql-injection.php Don't use complicated function when are not necessary to save server resources.


0

I had this problem and found out right on wp_hash_password() Compare an already hashed password with its plain-text string <?php $wp_hasher = new PasswordHash(8, TRUE); $password_hashed = '$P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/'; $plain_password = 'test'; if($wp_hasher->CheckPassword($plain_password, $password_hashed)) { echo "YES, Matched"; } ...


0

What you're describing is likely best done in a simple WordPress plugin. You're user roles are already stored in WordPress, so a plugin to do this is likely only a few lines long. Also an existing plugin like File Away may accomplish what your attempting. This plugin surfaced when I did a plugin search for the terms... download directory based on ...


0

I was missing quotes around my hidden attribute in my html form. The correct syntax is echo "<input name='mygroup' type='hidden' value=".$_POST['groupname'].">";


0

if you want to keep the row with the lowest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id > n2.id AND n1.meta_key = n2.meta_key OR if you want to keep the row with the highest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id < n2.id AND n1.meta_key= n2.meta_key


0

I found your post when I was looking to do the same thing. I don't know if I am too late for you, but maybe someone else will benefit. I have used a simple, free, effective plugin called 'Page Links To' It puts an extra box near the bottom of each editing page, and defaults to 'its normal Wordpress url'. But you can change it to redirect to a custom url, ...


1

I am not sure where you got that export code but I don't see the PRIMARY KEY defined as it should be. Take a look at the code from Core that creates the table: 87 CREATE TABLE $wpdb->commentmeta ( 88 meta_id bigint(20) unsigned NOT NULL auto_increment, 89 comment_id bigint(20) unsigned NOT NULL default '0', 90 meta_key varchar(255) default ...


0

After struggling with different functions , I figure out $wpdb->get_row() and $wpdb->get_var()The first one returns rows into an associative array or numerical array , depends on the second argument in $wpdb->get_row('query',ARRAY_A or ARRAY_N or OBJEECT) and the second one that I used to solve my problem return only one variable from particular ...


0

Basically what is the difference btwn $wpdb->get_results and $wpdb->get_var, I see your query is working fine after removing where clause. Just know that one thing $wpdb->get_results returns an array.


3

Here's one experimental idea: Assume we got: post A with the custom field location1 as UK - London post B with the custom field location2 as France - Paris post C with the custom field location3 as USA - New York Then we could use, for example: $args = [ 'meta_query' => [ 'relation' => 'OR', [ 'key' ...


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



Top 50 recent answers are included