How to create WordPress custom end point with multiple parameters?

When you register a route, parameters accepted via the query string (eg. ?a=b&c=d) are not registered as part of the endpoint, like you have done. Those parameters just need to be defined in the args property: add_action( ‘rest_api_init’, function() { register_rest_route( ‘woo/v2’, ‘woocommerce/order_summary_by_date’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘woocommerce_orders_by_dates’ ‘args’ => array( ‘start_date’ => … Read more

Error in pdf generating plugin using FPDF

The problem is that your output_pdf() function is being called too early. You have the function running in the root of the main plugin file, meaning that it runs as soon as the plugin is loaded, and before before WordPress has finished loading. You need to at least hook it to run later, such as … Read more

Changing menu order of a specific plugin in dashboard

I could see “WP Links Page” is a custom post type, so if it’s not registered by your own code, e.g. it’s registered by a plugin (using register_post_type()), then you can use the register_post_type_args filter to change the menu_position argument like so: add_filter( ‘register_post_type_args’, ‘my_override_register_post_type_args’, 10, 2 ); function my_override_register_post_type_args( $args, $post_type ) { // … Read more

wp-mail attachment is not sent for no reason?

I changed the code to this and it worked ! Don’t know why I should do this and this is very odd but whatever. function send_mail_to_admin($orderId , $attachment_img){ $attachment_img = str_replace(“https://seabou.com/wp-content” , “” , $attachment_img); $attachment_img = array( WP_CONTENT_DIR . $attachment_img ); $headers = array(‘Content-Type: text/html; charset=UTF-8′,’From: انجمن آبزیان <[email protected]>’); $body = “<html><body> <b style=”font-size:14px;direction:rtl;text-align:center;”>یک … Read more