Create a post with REST API and adding a category

Solution was simple. Set DOM element value in JS variable instead of “document.getElementById(‘post_category’).value” in array. var submitBtn = document.getElementById(‘submit-post-btn’); submitBtn.addEventListener(‘click’, function(){ var categoryTerm = document.getElementById(‘post_category’).value; var postData = { “title”: document.getElementById(‘post_title’).value, “content”: document.getElementById(‘post_content’).value, “status”: ‘publish’, “categories”: [categoryTerm] } };

calling JS to custom menu design

Surely. function loadMenuScripts() { wp_enqueue_script( ‘main’, get_template_directory_uri() . ‘js/main.js’, array( ‘jquery’ ), ”, false ); } add_action( ‘wp_enqueue_scripts’, ‘loadMenuScripts’ ); Additionally, if you need to load it in the footer, go ahead and change the action to: add_action( ‘wp_footer’, ‘loadMenuScripts’ ); Also, it seems as if this is an option for users. Before enqueueing, check … Read more

WordPress Customizer: Check for value of CSS selector and replace it

You’re using a selector in this: if ( $( ‘#customizer-preview .site-title’ ).length > 0 ) { $( ‘#customizer-preview .site-title’ ).remove(); } It’s just like styling CSS property, if you were to add that rule to a style sheet, it would add styles for the element #customizer-preview .site-title So the code above is saying if an … Read more