Hot answers tagged

2

The issue in your code is simple: if you want to send a JSON response, then make sure it's a valid JSON response, i.e. send the correct Content-Type header and a proper JSON-encoded body. With jQuery.ajax(), though, you can omit the header, but you'd need to set the dataType to json. function my_ajax_callback1() { // Invalid JSON response. die(); } ...


2

I think you forgot an action of ajax in WP when submitting you not login. So, if you want it to fire on the front-end for both visitors and logged-in users, you can do this: add_action( 'wp_ajax_my_action', 'my_action' ); add_action( 'wp_ajax_nopriv_my_action', 'my_action' ); and after return ajax, you must use die() function to respond to the return data. ...


1

Apologies, was able to figure it out. It is application/CDFV2 as of WP 5.5.3


1

The function that you would want to use is sanitize_text_field() which among other things, strips all HTML tags, and remove line breaks, tabs and extra white space. // This worked fine for me - I got /directory/subdirectory/ $value = sanitize_text_field( '/directory/subdirectory/' ); // And so does this one - I got /thisfile.min.js $value = ...


1

This isnt a direct answer, but maybe can solve your problem. Why just dont open a port on your router to the local server?! I use apache2 has localserver and apache2 uses port 80 as default and also most routers to get access to internet in this case the router doesnt open any port at port 80 because is being already use by the router, but for example my ...


1

This is called pingback. Whenever you link another post, that post will be notified as a comment. I personally don't like this feature. You can disable it in Settings > Discussion > untick "Allow link notifications from other blogs". I think this setting will only apply to new posts, so you also need to disable them using Quick Edit. In your ...


1

I guess it is a hosting issue. Contact your hosting company support. If it is in the localhost server then there may have a permission issue ...


1

That is a fairly open-ended question. There is a lot you will have to do. The first step is you will have to create the database. It will look something like this: function db_install() { global $wpdb; global $db_version; $table_name = $wpdb->prefix . 'thenameofyourdatabase'; $charset_collate = $wpdb->get_charset_collate(); ...


1

It might be because of pagination. Check you /wp-admin settings. Also, try to set numberposts=-1. Source: https://github.com/picandocodigo/List-Category-Posts/wiki/More-parameters-you-can-use numberposts - Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit. Ex: [catlist name=mycategory numberposts=10] ...


1

Must be used inside the loop $post_images = get_children( $post->ID ); $images_count = count( $post_images ); echo $images_count;


1

@birgire 's answer is very good. https://wordpress.stackexchange.com/a/326969/198298 Some information might be missing though. As @birgire guesses, it really is necessary to wrap the code inside a wp.domReady( function() { // ... } ); even if the script is loaded with the dependencies array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ) like it is ...


1

Adding &_embed to your URL will add the wp:featuremedia to your JSON even if you have custom posts, Example https://example.com/wp-json/wp/v2/posts?search=Sometitlepost&_embed&order=asc


1

You can check if a plugin is active as follows: /** * Check if Some Plugin is active **/ if ( in_array( 'some-plugin/some-plugin.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { // Put your plugin code here }


Only top voted, non community-wiki answers of a minimum length are eligible