Trying to create a shortcode to display categories with a specific product tag

You need to pass your attributes in the shortcode as key-value pairs, and use them in php as an array as follows: [tagtagtag tag_id=246] function get_categories_with_product_in_tag( $atts ) { global $wpdb; return $wpdb->get_results( $wpdb->prepare( “SELECT categories.* FROM “. “{$wpdb->prefix}terms categories “. “INNER JOIN {$wpdb->prefix}term_taxonomy ctax ON (categories.term_id = ctax.term_id) “. “INNER JOIN {$wpdb->prefix}term_relationships crel ON … Read more

add role on WordPress in PHP on a second database

I managed to solve after several attempts using the following code: // Insert the role $role = array(‘gold_role’ => 1); $serialized_role = serialize($role); $DB_MEMBERSHIP->insert(‘wpvm_usermeta’, array(‘user_id’ => $user_id, ‘meta_key’ => ‘wpvm_capabilities’, ‘meta_value’ => $serialized_role)); It works very well and doesn’t slow down the shopping experience.

Storing huge number of users in wordpress

In this pursuit, since the students could be thousands in a school, would it be a good practice to have so many entries in the wp_users table by creating a separate user_role : students’? A separate user role will make no difference to site performance or scalability. Or should I create a separate table to … Read more

Build A Custom SQL Query for WordPress Search

A possible solution is to use the pre_get_posts action: add_action(‘pre_get_posts’, ‘custom_search_query’); function custom_search_query($query) { // run only if is a search query and if the search string is not empty if($query->is_search() && $query->is_main_query() && get_query_var(‘s’, false)) { // here you can use your custom query having ‘get_query_var(‘s’, false)’ as $Search string //”SELECT SQL_CALC_FOUND_ROWS *………. // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)