My Button Default Click Is Not Working In WordPress Using Javascript Code

Anytime you want to use JavaScript in WordPress, you should enqueue it. Save the JS as a file, ie clickbutton.js inside your theme folder: document.getElementById(“defaultOpen”).click(); Then in functions.php, enqueue that file: add_action(‘wp_enqueue_scripts’, ‘wpse_371294_enqueue_js’); function wpse_371294_enqueue_js() { wp_enqueue_script(‘click-button’, get_template_directory_uri() . ‘/clickbutton.js’, array(”), “1.0”, true); } (If you only need the file to run on one page, … Read more

Hide HTML element (by class or ID) with PHP

As per our discussion in the comments, all you really need to do is .remove() the element. The following is the approach I’d take. First I’d check to make sure the element exists before attempting to remove it. If it’s there, then run jQuery’s .remove(). if( $( ‘#elementID’ ).length > 0 ) { $( ‘#elementID’ … Read more

Search WordPress using static html page

If you want to submit a form you need a <form> element to contain the input. (You can get away without one but you’d need script to fake the submit.) The action is the homepage with the search text in an input named ‘s’, e.g. <form method=”get” action=”https://example.com/”> <input type=”search” name=”s” /> <input type=”submit” value=”Search” … Read more

How to display post content in the block editor

It is true that using RawHTML (or dangerouslySetInnerHTML) is discouraged and indeed prone to XSS attacks like <img src=x onerror=alert(1)//> and <p>abc<iframe//src=jAva&Tab;script:alert(3)>def</p>. But if you need to set HTML directly from React, then you’ll have to use dangerouslySetInnerHTML, either directly (e.g. <div dangerouslySetInnerHTML={ ({ __html: ‘foo <b>bar</b>’ }) } />) or via RawHTML in Gutenberg … Read more

Wrapping a Sidebar within

UPDATE: now that the post is clarified, in your custom sidebar declaration change these lines to the following (this preserves existing wrappers too, which are advisable to leave in unless you know you want to delete them): ‘before_widget’ => ‘<div class=”customdiv”><div class=”widget-content”>’, ‘after_widget’ => ‘</div></div>’, I assume you’re trying to edit a system-loaded sidebar. Try … Read more

how to hide submenus for the not active pages

I use just such a menu in my Oenology Theme. Feel free to use the sidebar menu CSS to suit your needs! Rather than try to post it all here, I’ll just link to the Oenology GitHub repository. EDIT: Here’s where the sidebar navigation menu style definitions start.