Ajax not working es expected (Returns 0)

Please try this: Add the following in your theme’s functions.php add_action( ‘init’, ‘tnc_aj_scripts’ ); function tnc_aj_scripts() { wp_register_script( “ajax_anmeldung_script”, get_template_directory_uri(). ‘/my-ajax.js’, array(‘jquery’), ‘1.0’, true); wp_localize_script( ‘ajax_anmeldung_script’, ‘mYAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ))); wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘ajax_anmeldung_script’ ); } add_action(“wp_ajax_ajax_anmeldung”, “ajax_anmeldung”); add_action(“wp_ajax_nopriv_ajax_anmeldung”, “ajax_anmeldung”); function ajax_anmeldung() { $result[‘one’] = ‘Hey’; $result = json_encode($result); echo $result; … Read more

Tried in different ways but sidebar not working?

add_action( ‘widgets_init’, ‘Y_widget_register’ ); You have a typo – use underscores. Here is the working piece: function Y_widget_register() { register_sidebar(array( ‘name’ => esc_html__(‘Sidebar’, ‘Y-07’), ‘id’ => ‘y-sidebar’, ‘description’ => ‘Dynamic Right Sidebar’, ‘before_widget’ => ‘<section id=”%1$s” class=”y-widget %2$s”>’, ‘after_widget’ => ‘</section>’, ‘before_title’ => ‘<h2 class=”y-widget-title”>’, ‘after_title’ => ‘</h2>’ )); } add_action(‘widgets_init’, ‘Y_widget_register’);

Remove an action hook within a Class

Since you are not specifying a priority to your actions, they will be executed in the order they are encountered. So your remove_action may very well be executed after the actions tied to the same hook have already been executed. You could solve this by attaching a higher priority to the action that does the … Read more

Filter taxonomy admin pagination

The root problem, as you can see here, resides in the fact that WP counts items (terms) to paginate this way: ‘total_items’ => wp_count_terms( $this->screen->taxonomy, compact( ‘search’ ) ), Instead, it should count terms from the result of the query. I believe this is an issue and that it should be reported on WP bug … Read more

Add meta field after post has been published

You can hook into post_updated action, if you want to access the post’s data after it’s been published. This hook passes the post’s ID, inundated post object, and updated post object. add_action( ‘post_updated’, ‘update_event_date’, 10, 3 ); function update_event_date( $post_id, $post_after, $post_before ){ $post_type = get_post_type( $post_id ); $event_datee = get_post_meta( $post_id, ‘_EventStartDate’, true ); … Read more

How to get $tag to fill into add_action() or add_filter()?

These 2 function add_action() and add_filter() are magics of WP and do not directly affect your code. In WordPress, they use hooks for mocking into existing functions, methods without changing it’s code. The $tag you are referring is the name of the hook that you want to use. List of core hooks can be found … Read more

Edit WooCommerce product content based on category

There’s a couple of ways to do it, you can edit the template file \woocommerce\templates\single-product\title.php directly and change your title format there. Otherwise, you can remove the WordPress hook in your functions.php file and add your own to override it which I borrowed from this answer <?php remove_action( ‘woocommerce_single_product_summary’,’woocommerce_template_single_title’, 5 ); add_action( ‘woocommerce_single_product_summary’, ‘modify_woocommerce_template_single_title’,5 ); … Read more