rest_no_route custom route

The problem is, you are calling a static method from inside of a non-static method. The following will work. class theme_Rest_Routes extends WP_REST_Controller{ public static function init() { $instance = new self(); add_action( ‘rest_api_init’, array( $instance, ‘register_routes’ ) ); } public function register_routes() { register_rest_route( ‘theme/v1’, ‘/menu/’, array( ‘methods’ => ‘GET’, ‘callback’ => array( $this, … Read more

AJAX Load more on CPT returning random posts

Use this below code it will work as I have used this and working fine at my end. <?php $querystr = ” SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->terms.slug = ‘branding’ AND $wpdb->term_taxonomy.taxonomy = ‘taxonomy_name’ AND $wpdb->posts.post_status=”publish” AND … Read more

wordpress admin ajax url rename

you can try this: https://github.com/devgeniem/wp-no-admin-ajax “A WordPress plugin that changes the WP AJAX routine and rewrites the ajax requests to custom url rather than admin-ajax.php back-end.”

Loading comments in ajax – comment-reply function missing $args

You do not need an existing $args variable here, you can define your own arguments and they will override the defaults. See the get_comment_reply_link() docs for the defaults. Instead, you can pass the arguments you want directly. comment_reply_link( array( ‘reply_text’ => __( ‘Répondre ‘, ‘autourdesanimaux’ ), ‘depth’ => $depth, ‘max_depth’ => get_option( ‘thread_comments_depth’ ) ) … Read more

How to create an ajax endpoint without js?

When using JS fetch api with the wordpress is set up your issue is with the body. fetch passes body data in a way that wordpress can’t understand. Your body: {} should be like this body: new URLSearchParams({ username: ‘thewhitefang’, password: ‘@bhishek01’, action: ‘login_ajax’ }) and you need to change your content-type as well. ‘Content-Type’: … Read more