How do I use get_query_var() within plguin code
get_query_var works within any code, theme or plugin. But it will only return meaningful data after the query has been processed. So, use it on the init hook or later.
get_query_var works within any code, theme or plugin. But it will only return meaningful data after the query has been processed. So, use it on the init hook or later.
UPDATE wp_posts SET post_author = [NEW_ID] WHERE post_author = [OLD_ID]
These look like 2 separate questions. The first I think is a single vs double quotes issue: Try this: $html=””; foreach ( $recent_across_network as $post ) { $html .= ‘blog_id, ‘.$post->ID.’ ) . ‘”>’ . $post->post_title . ”; } $html .= ”; The line in the foreach is putting $post->ID in single quotes which won’t … Read more
With a WP_Query() you can have all of them what you want in an easy way. See all the arguments available in the Codex. With the following code, we are grabbing all(-1) the posts from wp_posts table, and using the post ID we are grabbing the postmeta items. <?php $productquery = new WP_Query( array( ‘post_type’=>’wpcproduct’,’post_status’=>’publish’,’posts_per_page’=>-1 … Read more
If that is the error, a couple of things could be going on. The part that uses ‘require’, ‘require_once’ and ‘include’ is not likely correct in the code. Each of these code statements should end with a semi-colon [;] not a comma [,] hh3_ I expect is the table prefix initially used in your database. … Read more
You can use wp_signon function Here is an example $creds = array(); $creds[‘user_login’] = ‘example’; $creds[‘user_password’] = ‘plaintextpw’; $creds[‘remember’] = true; $user = wp_signon( $creds, false ); if ( is_wp_error($user) ) echo $user->get_error_message();
Look at the section on $wpdb->get_results(), it allows you to send distinct queries to the database, which is what it sounds like you are looking to do. So… // 1st Method – Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object global $wpdb; $results = $wpdb->get_results( … Read more
You are getting the error because, by default, wp_get_recent_posts returns an array of posts (due to backward compatibilty) and not the required WP_Post object which is required to setup the template tags. Look at the source code, and you will see that wp_get_recent_posts is a simple wrapper function for get_posts (which is just a wrapper … Read more
If you only wish to effect the one, single query then just can pass the offset argument through the arguments array. $offset = 1; $ppp = 3; if ( $query->is_paged ) { $page_offset = $offset + ( ($query->query_vars[‘paged’]-1) * $ppp ); } blog_items = array( ‘post_type’=> ‘post’, ‘paged’ => $paged, ‘posts_per_page’=> $ppp, ‘status’ => ‘publish’, … Read more
This should be working: Be sure that your DB prefix is “wp_” Update wp_users set wp_users.user_login=wp_users.user_nicename where wp_users.user_login=”x”