Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

To display only assigned category you need to change hide_empty to true. Please see the modified code: $args = array( 'hierarchical' => 1, 'show_option_none' => '', 'hide_empty' => true, 'parent' => 134, 'taxonomy' => 'product_cat' ); $subcats = get_categories($args); echo '<ul class="wooc_sclist">'; foreach ($subcats as $sc) { $...


0

Made ajax call as a function to avoid the Console Error 400 Post. It opens the channel and I was able to get the parameters passed. counter.js jQuery(document).on('click','.counter',function(e){ testAjax(the_ajax_script.ajaxurl); }); function testAjax(link) { $.ajax({ url: link, type: 'post', data: { 'action': 'set_button_count', ...


0

I have shown your questions and i have found correction in it. You need to update your code as below. .on( 'select', function() { if(attachment.mime == "image/jpg" || attachment.mime == "image/jpge" || attachment.mime == "image/png") { var attachment = custom_uploader.state().get( 'selection' ).first().toJSON(); jQuery( '#previewImage'...


2

The block editor is restoring back the title that was last saved (or typed manually into the textarea), so with the block editor, you can change the title dynamically using this code: wp.data.dispatch( 'core/editor' ).editPost( { title: 'Title here' } ) PS: You should make sure your JS file has the wp-editor, wp-edit-post or wp-data as part of the ...


0

Generally you can't impact when and how your plugins are loading their own stylesheets. Messing around with that will usually mean you can never update because it'll reset all your work. That's the trade off of using plugins - you lose control over some things that impact your performance, accessiblity, and validation. Without astronomical budgets and time ...


0

This function in /themes/lucid-press-child/js/custom-js.js is your problem. function homepageNavigationClasses(){ if(jQuery('body.home').length){ //jQuery('#navigation a').not('.sub-menu a').click(function(event){ jQuery('#navigation a').click(function(event){ var clickedLink = jQuery(this).text(); clickedLink = ...


1

I have come up with better and new working version that supports all file types which I am going to share here in case anyone else is looking for this answer. Input field added to metabox <input type="text" name="sermon_mp4" id="sermon_mp4" value="<?php echo $sermonmp4; ?>"/> <input type="button" id="sermon_mp4_button" value="Add Sermon ...


1

There is is_404(). I normally use it to do just the opposite, to add CSS and JS animations which are specific to the 404 error page. In your case that would be: function wpse_339946() { if ( ! is_404() ) { wp_enqueue_script( 'tracking-js', get_template_directory_uri() . '/js/tracking.js' ); } } add_action( 'wp_enqueue_scripts', '...


0

This might help you. add_action('wp_footer', 'insert_my_js_to_footer'); function insert_my_js_to_footer(){ ?> <script> // your script here. </script> <?php }; UPDATE: And if you want to append the php file itself then you can try this. add_action('wp_footer', 'insert_php_file_to_footer'); function insert_php_file_to_footer(){ ...


0

You could use the is_page() function on your footer to check if it is a 404 page, then don't add the js code if it is the 404 page. Added the commenter is right - a 404 is a response, not a page, so you can't test for it. (I blame temporary insanity...) So .... the answer is now.... updated Create a 404 page template that doesn't include the js code. That ...


0

Solution: add an action on the tag vc_edit_form_fields_after_render. add_action( 'vc_edit_form_fields_after_render', function() { echo '<script src="' . AN_URL . 'test.js"></script>'; // Or something other }, 9 ); In the functions.php or equivalent. (Indeed, the tag vc_edit_form_fields_after_render is used by do_action( '...


0

You can try this add-on to make conditional fields. https://nl.wordpress.org/plugins/cf7-conditional-fields/


0

You need an ajax call to perform server-side functions. So in stampme() before or after you show the message you need something like this: jQuery.ajax({ url: ajaxurl, data: { action: 'WPSE_339452_update_user_meta', value: jQuery('input[name="inputcode"]').val() //if that's the value you want to save... }, ...


0

Perhaps you could either use admin ajax or the WP REST API to send a request to the server for the user meta update. If you have a look at the WP documentation (links above) or similar questions here on WPSE, you can find examples on how to do it. Update user meta with ajax https://wordpress.stackexchange.com/search?q=Update+user+meta+ajax Update user ...


0

Ideally, you can access those headers with response.header, but not all headers are available publicly unless exposed manually. In your case, to access X-WP-Total by the client, you need to set the Access-Control-Expose-Headers header on your server: Access-Control-Expose-Headers: X-WP-Total


0

The problem is due to WordPress Gutenberg's some js which doesn't support defer. I had the same problem, I have added a WordPress hook to defer js. I have added a condition now that the hook will not call on admin pages and it fixed my issue. OLD code: add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 ); New code: if ( !is_admin() ) { add_filter( '...


0

instead of using get_template_directory_uri().'/assets/js/pre.js','1.0.0' try using get_theme_file_uri('/assets/js/pre.js','1.0.0') It worked for me, for some reason when use get_template_directory_uri() you will get a 403 error


0

All sorted. My theme actually had a section for custom javascript in the theme options. I added the code there and used the enqueue for the bootstrap - all working fine now.


0

As you can see on this answer thread, you can use toUpperCase() in a custom function that will set the fields length and convert the fields input to uppercase, using the following: add_action("wp_footer", "cod_set_max_length"); function cod_set_max_length(){ // Only on checkout page (not on order received or order pay pages) if( is_checkout() &&...


0

You could do a couple things. Use JS toUpperCase() to transform the text. var upper = text.toUpperCase(); Or just use CSS to do it. #yourID { text-transform: uppercase; }


0

You are looking for pre_get_posts. This action is run between the composition of a (search) query and the actual query, to allow you to change the query. So, it would allow you to intercept banned keywords like this: add_action( 'pre_get_posts', 'wpse338558_intercept_banned_keywords' ); function wpse338558_intercept_banned_keywords ($query) { $banned = ...


0

Try this code: // Conditionally show price (function ($) { window.onload = function() { if ($("#select_price_option").val() == "I need more information") { $('#price_input_div').hide(); } $("#select_price_option").change(function() { if ($(this).val() == "I need more information") { $('#price_input_div').hide(); } else { $('#...


0

Actually, it is not WordPress that is inserting the CDATA tags, but the visual editor, TinyMCE. Details of TinyMCE are offtopic here, but you can read a solution to this on Stackoverflow. That said, stopping TinyMCE may not be the full solution you want. WordPress itself also has a function for adding CDATA tags, wxr_cdata, which is used when outputting a ...


Top 50 recent answers are included