how to load posts to a custom post template after using template_redirect or template_include

here is the full code to force change theme by a reserved wordpress parameter add_action( ‘pre_get_posts’, ‘my_pre_get_posts’ ); function my_pre_get_posts($wp_query) { global $wpdb; // Confirm request is main query if(!$wp_query->is_main_query()) { return; } // Get post name from query $post_name = $wp_query->get(‘pagename’); // Get post type from database $post_type = $wpdb->get_var( $wpdb->prepare( ‘SELECT post_type FROM … Read more

What is wrong with my WP_Query Arguments?

Use this one- ‘category__not_in’ => array( 93, 94, 95 ), instead of- ‘category_not_in’ => 93, Note: The term is category__not_in, not category_not_in. Use 2 underscores after category. Edit: You are using- ‘offset’ => 1 That forces to show posts from 2nd one (skips the first post). So, it’s showing one post less! If you use … Read more

How to get setting from separate file?

Simple answer: Don’t add a separate PHP file for AJAX requests. Declare the functions that will be used in your plugin and load them via admin-ajax.php. add_action(‘wp_ajax_custom_action_name’,’custom_action_handler’); // to make AJAX action available for non-logged in users: add_action(‘wp_ajax_nopriv_custom_action_name’,’custom_action_handler’); function custom_action_handler() { global $wpdb; // optionally keep the actual functions separately // include(dirname(__FILE__).’/ajax-handler.php’); // custom_ajax_handler_process(); // … Read more

Get param from shortcode in plugin function

If you have this shortcode: [product id=”2″] Which is redered by this: add_shortcode( ‘product’, ‘getSingleProduct’ ); function getSingleProduct( $atts ) { shortcode_atts( [ ‘id’ => ‘0’, ], $atts ); // Do someting with the “2”. do_request( ‘GET’, get_api_url() . ‘api/product/’ . “2” ); // This “2” comes from the shortcode } You can get the … Read more

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