How do I fetch all comments per post via WP REST API?
https://example.com/wp-json/wp/v2/comments?post=<POST_ID> will return comments for a specific post
https://example.com/wp-json/wp/v2/comments?post=<POST_ID> will return comments for a specific post
Block Style Variations allow providing alternative styles to existing blocks using filters, as explained here. Here are some examples for your case using the server-side functions (php). You can either add the css style inline: register_block_style( ‘core/html’, array( ‘name’ => ‘full-width-video’, ‘label’ => __( ‘Full Width Video’ ), ‘inline_style’ => ‘.wp-block-html.is-style-full-width-video { width:100%; }’, ) … Read more
so I’m not sure the enqueuing is even happening No, it’s not, because you only registered the scripts, but never enqueued them — which should be done using wp_enqueue_script(). Also, you should make frogaloop as a dependency for your snippet.js script. Hence, register the frogaloop script before your snippet.js script. // Register the scripts. wp_register_script( … Read more
You can the code to head or before body tag this way. Add this code at the last of functions.php add_action( ‘wp_head’, function() { ?> <!–Start of Tawk.to Script–> <script type=”text/javascript”> var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date(); (function(){ var s1=document.createElement(“script”),s0=document.getElementsByTagName(“script”)[0]; s1.async=true; s1.src=”https://embed.tawk.to/5b54359ee21878736ba23110/default”; s1.charset=”UTF-8″; s1.setAttribute(‘crossorigin’,’*’); s0.parentNode.insertBefore(s1,s0); })(); </script> <?php } ); Hope it helps
You’re not supposed to make HTTP requests etc directly inside React components, you need to use useEffect. A react component needs to run as quickly as possible, even if work that needs doing isn’t finished yet. By using useEffect you tell React to run a separate function after rendering is complete, giving you the opportunity … Read more
Using woocommerce woocommerce_add_to_cart_fragments filter you can do that. Going by the id attribute that you currently have for the span that displays the cart total, you can use the following code add_filter(‘woocommerce_add_to_cart_fragments’, ‘bt_update_cart_total’); function bt_update_cart_total ($fragments) { $fragments[‘#order-total-price’] = ‘<span id=”order-total-price”>’ . WC()->cart->get_cart_subtotal() . ‘</span>’; return $fragments; } Add this code to your functions.php file … Read more
Never mind I found it. let selectEntries = Object.entries(myjson).map( ([k, v]) => ({label: k, value: v}) );
Yes you can use the index.asset.php file in the ‘enqueue_block_editor_assets’ action. I guess you missed to npm install the dependencies you want to use and import them in your script. That’s how @wordpress/scripts generates your asset.php file. If you do not import the dependencies in your JavaScript files the dependency management of asset.php wont work. … Read more
WordPress.com does not allow you to post javascript. From WordPress.com Support: Users are not allowed to post JavaScript on WordPress.com blogs. JavaScript can be used for malicious purposes. As an example, JavaScript has taken down sites such as MySpace.com and LiveJournal offline in the past. The security of all the blogs is a top priority … Read more
The jQuery(document).ready event is called when the document DOM is ready to be manipulated. In earlier days we attached all our handlers to document.load, but this waits until all images are loaded too, and most of the time one doesn’t need that. There are three equivalent ways of hooking into this event, and a fourth … Read more