wpbd to connect to a VPS mysql database
You can create a new wpdb object, and then use that. global $mydb; $mydb = new wpdb( $db_user, $db_pass, $db_name, $db_host ); …and then use $mydb as you would the global $wpdb object.
You can create a new wpdb object, and then use that. global $mydb; $mydb = new wpdb( $db_user, $db_pass, $db_name, $db_host ); …and then use $mydb as you would the global $wpdb object.
add_shortcode(‘myCustomShortcode’, ‘this_particular_function’); As soon as I looked at my code this morning I realized I was trying to pass the function name ([this_particular_function]) as the shortcode, not the shortcode name ([myCustomShortcode]). I overlooked this SO many times yesterday trying to look for some complex answer! I am smacking my head on the desk. Everything works … Read more
Yes, you can. You would need to add a custom field that would store the ID of other post type. I would recommend using a select list. You could try something along these lines: add_action( ‘add_meta_boxes’, ‘wpse_143600_add_box’ ); add_action( ‘save_post’, ‘143600_save_box’ ); //create the metabox function wpse_143600_add_box() { add_meta_box( ‘related_testimonial’, __( ‘Testimonails’, ‘wpse_143600_translation’ ), ‘wpse_143600_testimonial_box’, … Read more
After more reading and testing, i’ve realised that i misunderstood how AJAX works, therefore it was never gonna work the way i thought it would. For those who come across this, i hope this will help. In shortcode function i generated the api url with params specific to the page where shortcode is called. eg … Read more
Creating a table via dbDelta
This code should do the trick. You will just need to add the post type(s) to the line below. function my_disable_gutenberg( $current_status, $post_type ) { // Disabled post types $disabled_post_types = array( ‘book’, ‘movie’ ); // Change $can_edit to false for any post types in the disabled post types array if ( in_array( $post_type, $disabled_post_types, … Read more
So, what was messing up with the menu items setting was assignment operator on the decision structure (condition) instead of comparison (or equal) operator to add the items based on menu location. I don’t know how I missed or made that shameful kind of mistake. Anyway, below is the working code template for WordPress menu … Read more
Make a variable global and use it for inline script
You didn’t provide any information on how you’re getting the script on the page to begin with. Assuming that this is something you have hardcoded into your template, here is a way you could approach it. First, you need to check if the user is logged in, because if they are not, there’s no point … Read more
WordPress different custom tag being displayed in on tag list