entire JS folder not loading in a WP theme

The problem is die(). You can’t die() inside a template or it will stop the entire site loading at that point. If you looked closer you’d notice that it wasn’t just the JS folder that wasn’t loading, it was the whole footer. You need to separate you code into 2 functions. One that outputs the … Read more

Post not populating for custom post type based on category selection

But this part is not executing → $args = array( ‘category_name’ => $taxonomy, ‘post_type’ => ‘video’, ‘posts_per_page’ => -1, It probably is. It’s just wrong. If you want to query posts by terms in a custom taxonomy you need to add a taxonomy query: $args = array( ‘post_type’ => ‘video’, ‘posts_per_page’ => -1, ‘tax_query’ => … Read more

How to insert class in each list of categories?

Why don’t you use get_categories instead. Here is an example: $categories = get_categories(); $output=””; if($categories) { $output = “<ul class=”list-inline”>”; foreach($categories as $category) { $output .= ‘<li class=”list-inline-item”><a href=”‘.get_category_link( $category->term_id) . ‘”>’.$category->cat_name.'</a></li>’; } $output .= “</ul>”; } echo $output; Head over here for more available modification options

Way to redirect all Product Sub Category to its Main category Page?

You will have to use JS for the redirection since header is already sent before we can check the category, following snippet would do the work: add_action(‘woocommerce_before_main_content’,’redirect_to_top_level_parent’,1); function redirect_to_top_level_parent(){ if (is_product_category()){ $cate = get_queried_object(); $cateID = $cate->term_id; $parentcats = get_ancestors($cateID, ‘product_cat’); $count = count($parentcats); if ($count > 0){ $count = $count-1; $link = get_term_link( $parentcats[$count], … Read more

How to remove a class function from a plugin by using remove_action()?

[ Nova_Restaurant::init(), ‘sort_menu_item_queries_by_menu_order’ ] You want something of type callable, that matches what was given when add_action. There are only a handful of valid callables: [ ‘my_function_name’ ] aka my_function_name(); [ ‘my_class_name’, ‘my_static_function’ ] aka my_class_name::my_stati_function() [ $object, ‘the_objects_function’ ] aka $object->the_objects_function [ function() {} ] an anonymous function or closure So some translation: remove_action(‘parse_query’,’WM_Nova_Restaurant’, … Read more

Where Should i write the code for wordpress ajax voting?

Use REST API endpoint instead! Lets register an endpoint at /wp-json/tomjn/v1/test, that calls tomjn_rest_test() when you hit it: add_action( ‘rest_api_init’, function () { register_rest_route( ‘tomjn/v1’, ‘/test/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘tomjn_rest_test’ ) ); } ); Now lets add the tomjn_rest_test function: function tomjn_rest_test( $request ) { return “moomins”; } Now when we visit … Read more

How do I create a custom permalink structure for a page template

There are different filters available to create the custom permalinks for the posts, custom posts or pages: post_type_link – for custom post types post_link – only for post_types ‘post’ page_link – for pages only ( which you are looking for ) Here is the sample code based on your query: public function custom_permalink_for_page_template( $url, $post … Read more

Show all tags within a category?

The best way to do that would be to create a custom page template, and make a custom loop that would only display the posts in you specific category and tag. For example: global $wp_query; $args = array( ‘category__and’ => ‘category’, ‘tag__in’ => ‘post_tag’, //Enter tag id for this field (not tah name) ‘posts_per_page’ => … Read more