Categories
CMS Mastering Development Wordpress

JS working when used normally but not in wordpress

I have a shortcode that prints a simple form, a button is used to submit the form. The problem is that when it’s pressed, the form gets submitted normally, ignoring the js function. I can’t understand why it’s doing this, since trying this locally on XAMPP works (I needed to change something to adapt the […]

Categories
CMS Mastering Development Wordpress

jQuery UI Accordion loading very slow

I have a jQuery UI Accordion implemented and as the page loads, you see content of the three headers and tabs for a few seconds, and then they turn into the accordion. I’m not sure which part is causing the delay, and hoping you can help. In my functions.php: // Enqueue jQuery accordion function product_accordion() […]

Categories
CMS Mastering Development Wordpress

jQuery Click event is not fired at all

I’m trying to make a widget plugin that allows user to upload image. but I have a problem in jQuery events that it is never happen ! includes/myplugin.scripts function media_uploader_enqueue() { wp_enqueue_media(); wp_register_script(‘media-uploader’, plugins_url().’/simple-plugin/js/main.js’,array(‘jquery’),null, true); wp_enqueue_script(‘media-uploader’); } add_action(‘admin_enqueue_scripts’, ‘media_uploader_enqueue’); js/main.js jQuery(document).ready(function ($) { console.log($(‘#xyz’)); // works ! $(‘#xyz’).click(function (e) { e.preventDefault(); console.log("in click event"); // […]

Categories
CMS Mastering Development Wordpress

How to keep users unique id stored in session in addition to IP in WordPress plugin?

I want to get likes from two computers with the same IP in the post like plugin I developed for wordpress. Currently my plugin is working but when I like a post from a device with the same IP, the dislike button appears in the other device. How can i prevent this ? Here is […]

Categories
CMS Mastering Development Wordpress

Enqueue plugin for specific pages

I want to enqueue my plugin for certain pages. I’ve tried several things but nothing worked so far: add_action( ‘init’, ‘my_enqueue’ ); function my_enqueue() { global $post; if( $post->ID == 380 || is_home() || is_front_page() || is_single(380) || is_page(380)) { wp_enqueue_script( ‘lister_js’, plugins_url( ‘/js/lister.js’, __FILE__ ), array(‘jquery’), filemtime( ‘/js/lister.js’, __FILE__ )); wp_localize_script( ‘lister_js’, ‘my_ajax_object’, array( […]

Categories
CMS Mastering Development Wordpress

How to enqueue CSS and JS only on specific template?

I’m busy with my home.php template and I need a few CSS/JS files that are only loaded on that specific template. I tried doing it with if ( is_page_template( ‘home.php’ ) ) { //ENQUEUE CODE }, but somehow that doesn’t work. I don’t have the slightest idea where the error is. When I remove the […]

Categories
Mastering Development

WordPress jquery.countTo plugin

I’ve been having trouble with this plugin https://github.com/mhuggins/jquery-countTo it works great with HTML, however when I moved my website to wordpress everything crashed down. in my function.php file here’s what I have: I’ve created 1 function to load jquery and another function to load the script function include_jquery() { wp_deregister_script(‘jquery’); wp_enqueue_script(‘jquery’, get_template_directory_uri().’/js/jquery-3.5.1.min.js’,”, 1, true); add_action(‘wp_enqueue_scripts’, […]

Categories
CMS Mastering Development Wordpress

In a woocommerce’s project, How to update the cart quantity with ajax?

I’m building my own woocommerce theme with an HTML template that I bought for it. The question is: how can i update the cart’s label text with the ajax when a new product is added? See my code to display the cart’s count: <span class=”cart_count” name=’update_cart’><?= wc()->cart->cart_contents_count?></span> The button’s code to add a new product […]

Categories
CMS Mastering Development Wordpress

WordPress Ajax – Filter Posts by Category

I’m having trouble getting this Ajax tutorial to work – if anyone is able to help me figure this out it would be much appreciated. I follwed the instructions step by step and have gone over the code numerous times wihtout any progress. When I select the cateogries the posts don’t filter by category/taxonomy – […]

Categories
CMS Mastering Development Wordpress

error (Undefined index) and (Cannot modify header information – headers already)

Error: Notice: Undefined index: link_type in /home/golchind/public_html/wp-content/themes/golchindl/functions.php on line 40 Notice: Trying to get property of non-object in /home/golchind/public_html/wp-content/themes/golchindl/functions.php on line 58 Warning: Cannot modify header information – headers already sent by (output started at /home/golchind/public_html/wp-content/themes/golchindl/functions.php:40) in /home/golchind/public_html/wp-admin/admin-header.php on line 9 help : line 40 $type = $_POST[‘link_type’]; line 58 update_post_meta($post->ID,”_oscar_data”,json_encode(array(“episodes”=>$episodes,”links”=>$links,”type”=>$type), JSON_UNESCAPED_UNICODE)); function oscar_meta_box_js(){ wp_enqueue_style( […]