Filter out results from REST API

If you’re using WP 4.7+ you can filter the query using the rest_$type_query hook wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:L267 This is a working example that filters current query by given terms $types = [ ‘post’, ‘page’, ]; foreach ( $types as $type ) { add_filter( ‘rest_’ . $type . ‘_query’, ‘filter_rest_query_by_zone’, 10, 2 ); } function filter_rest_query_by_zone( $args, $request … Read more

How can i force Display names to be the same as Usernames?

You can use the wp_pre_insert_user_data filter. function wpse_filter_user_data( $data, $update, $id) { if( isset( $data[ ‘user_login’ ] ) ) { $data[ ‘display_name’ ] = $data[ ‘user_login’ ]; return $data; } $user = get_user_by( ’email’, $data[ ‘user_email’ ] ); $data[ ‘display_name’ ] = $user->user_login; return $data; } add_filter( ‘wp_pre_insert_user_data’, ‘wpse_filter_user_data’, 10, 3 ); You’ll probably want … Read more

WP showing “warning: call_user_func_array()”, What to do?

The error you’re getting is showing, because somewhere on your site (your theme or one of your plugins) is registering a filter function that doesn’t exist. Somewhere in your code, there will be such line (or similar to it): add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); It may use different hook, so it may also look like: add_filter( … Read more

How to remove filter added by another plugin in a class

You did not write where you put the filter removal code, but I suspect you tried to delete it before it was added. Another important point, you have not given the priority parameter in remove_filter(). Quote from the documentation: remove_filter( $tag, $function_to_remove, $priority ); Important: To remove a hook, the $function_to_remove and $priority arguments must … Read more

How to create gutenberg block using REST API independently or as headless way?

Block editor blocks are dynamically constructed by parsing the HTML of post_content. Blocks are delimited by HTML comments that looks like these: <!– wp:image –> <figure class=”wp-block-image”><img src=”https://wordpress.stackexchange.com/questions/359758/source.jpg” alt=”” /></figure> <!– /wp:image –> The way the actual data of blocks is stored depends entirely on the block. Blocks can either store their attributes inside the … Read more

Output in XHTML or HTML 5 for plugins?

WordPress will not help you here. In back-end use conservative XHTML 5: <br />, but not <figure> (see WP coding standards). In front-end … it is hard to determine the Doctype and the usage of polyfills, so stay with regular HTML as long as possible or load the necessary polyfills from your plugin.

wordpress get meta value by meta key

WP_Query selects posts and not meta value that is way you are not getting the value. You can use the returned post ID to get the value something like: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 1, ‘meta_key’ => ‘picture_upload_1’ ); $dbResult = new WP_Query($args); global $post; if ($dbResult->have_posts()){ $dbResult->the_post(); $value … Read more

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