Menu Custom Data Attributes

If you want to add a custom data attributes to the menu that’s generated by wp_nav_menu function. You can use the nav_menu_link_attributes filter to add the desired attributes to the <a> elements. function add_menu_atts( $atts, $item, $args ) { $atts[‘data-hover’] = $atts[‘title’]; // add data-hover attribute return $atts; } add_filter( ‘nav_menu_link_attributes’, ‘add_menu_atts’, 10, 3 );

The correct way to add a JavaScript in the functions.php [closed]

function my_scripts() { // Register the script like this for a plugin: wp_register_script( ‘custom-script’, plugins_url( ‘/js/custom-script.js’, __FILE__ ) ); // or // Register the script like this for a theme: wp_register_script( ‘custom-script’, get_template_directory_uri() . ‘/js/custom-script.js’ ); // For either a plugin or a theme, you can then enqueue the script: wp_enqueue_script( ‘custom-script’ ); } add_action( … Read more

How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?

Here is a simple example from w3 schools that uses a bit of JS to copy the value of a input field. <input type=”text” value=”StackExchange WordPress” id=”myInput”> <button onclick=”myFunction()”>Copy text</button> <p>The document.execCommand() method is not supported in IE9 and earlier.</p> <script> function myFunction() { var copyText = document.getElementById(“myInput”); copyText.select(); document.execCommand(“Copy”); alert(“Copied the text: ” + … Read more

Acessing HTML element with no specific tag on it [closed]

Your <h3> isn’t closed. The Proper Way: The real way to fix it would be fixing the PHP. In one of your template theme files you’ll have <div class=”post-header”> <?php echo get_the_date(); ?> <h3 class=”title”> <?php the_title(); ?> <h3> </div> You’ll want to delete the get_the_date() line. If your theme is from an author that … Read more

Use of http form post

Honestly, your best bet is to actually use $_POST to process this logic. In your form, your submit buttons lack a name attribute which would allow you to do this: <form method=”post” action=”http://xxx.yyy/wp-admin/admin-post.php”> <td width=”60″ height=”26″> <input type=”submit” value=”Lot #” name=”lot”> </td> <td width=”154″ > <input type=”submit” value=”Name” name=”name”> </td> <td width=”154″> <input type=”submit” value=”Subdivision … Read more

How to disable escaping html chars in wordpress?

If you want to write some code, you can use a shortcode: add_shortcode( ‘unescape_js’, ‘add_js_code’ ); function add_js_code( $atts, $contents=”” ) { $contents = html_entity_decode( $content ); return $contents; } Usage – in text editor [unescape_js] Your js code && more js codes…[/unescape_js] But saving js code directly into DB is not recommended at all.

WordPress forms submissions and PHP files

Have you try with admin-post.php for your form submission. admin_post hook available in WordPress gives you great control over the flow of execution for your form. Using the above form, the following HTML content would execute the above hook when the user clicks either Submit. <form action=”http://www.example.com/wp-admin/admin-post.php” method=”post”> <input type=”hidden” name=”action” value=”custom_form”> <input type=”hidden” name=”data” … Read more