Pass WP data to javascript

The most direct answer to your question as it stands is “yes” – there are many ways to acquire data from WordPress without embedding it in the page’s markup or an inline <script> generated via wp_add_inline_script()/wp_localize_script(). A couple of options would be to have your JavaScript make a web request to the REST API (either … Read more

How to determ a custom post type url?

You need to register a custom taxonomy for you custom post type. For example: add_action(‘init’, ‘register_book_taxonomy’); function register_book_taxonomy() { $labels = array( ‘name’ => ‘Book Categories’, ‘singular_name’ => ‘Book Category’, ‘search_items’ => ‘Search Book Categories’, ‘all_items’ => ‘All Book Categories’, ‘parent_item’ => ‘Parent Book Category’, ‘parent_item_colon’ => ‘Parent Book Category:’, ‘edit_item’ => ‘Edit Book Category’, … Read more

Prevent publishing of uncategorized posts

The in_category function works only on existing (saved) posts. Here you can directly access the category in $postarr like this: if (‘affitti’ == $postarr[‘post_category’])) { wp_die(‘Error: Posts cannot be published with the default category.’); } By the way, are you sure you want to use wp_die for this and not some other error message? People … Read more

wp_logout function not executed

I also tested the code on a local sandbox WP and it worked as expected. As Howdy_McGee commented this is probably a conflict with 3rd party code. If disabling theme and plugins is not an option, you can try changing the priority of the actions – i.e. the third parameter to add_action(). By default priority … Read more

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