You have an error in your SQL syntax – Help with query

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

Select query for a login

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();

Error when using setup_postdata()

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

How select a specific query when setting offset?

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

How can I get the query that would be run for the archive page?

In each of your hooks & filters handlers, in addition to checking for archive conditions, check for a custom query var that you can then set for a custom/manual query. For example, where you might have: function wpse_223991_pre_get_posts( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_post_type_archive( ‘my_post_type’ ) ) { // Awesome custom stuff } … Read more

How to run a mysql query when admin updates user role?

You are going in wrong direction there is no way to get user role while admin change from back end. You can retrieve the role object for the current user by calling get_role(), but that’s an object rather than a string with the role name. function get_user_role($uid) { global $wpdb; $role = $wpdb->get_var(“SELECT meta_value FROM … Read more

Insert static element only once in query archive

Use the Index of the post currently being displayed to trigger when your custom content is rendered. current_post can be found on WP_Query from within the loop. <?php while( $archive_query->have_posts() ) : $archive_query->the_post(); ?> <article <?php post_class(); ?>> The Content </article> <?php if ( $archive_query->current_post === 2 ): ?> <div>Custom Content</div> <?php endif; ?> <?php … Read more