wordpress function through ajax not being called

Based on your comments, I don’t think the MyAjax variable is being localized using wp_localize_script(). In your case, you’ll most likely need something like the following: wp_localize_script( ‘script’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), ) ); That said, I don’t really have enough information to provide a more detailed answer. EDIT: This and the … Read more

different body classes for each category

If i understood what you are lookin for, this should work, it uses get_queried_object() function: // Adding categories name to body class on archives add_filter(‘body_class’,’add_category_to_body_class’); function add_category_to_body_class( $classes ) { // check if in category if ( is_category() ) { // get the queried object, in this case, a category object, and assigns to a … Read more

How to use if (is_page_template (”))

is_page_template() checks against post type templates specified by the theme using /** * Template Name: My Template */ at the top of the template file. Not any arbitrary template file. For this, you might wanna check out the answers over at Get name of the current template file. You could grab the code from the … Read more

Pagination not working on my archive page for a custom post type

So I got this to work by adding this function to functions.php // Custom query for events function set_posts_per_page_for_events_cpt( $query ) { if ( !is_admin() && $query->is_main_query() && is_post_type_archive( ‘events’ ) ) { // set date $currentdate = date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”),date(“Y”))); $meta_query = array( array( ‘key’=>’event_date’, ‘compare’ => ‘>=’, ‘value’=> $currentdate, ‘type’ => ‘DATE’, ), ); $query->set(‘meta_query’, … Read more

Change post count on tag/terms pages to 10

You’re almost there my friend. Just check with $query->is_tag() rather than only is_tag(). So your updated code will be- function main_query_mods( $query ) { // check http://codex.wordpress.org/Conditional_Tags to play with other queries if(!$query->is_main_query()) { return; } if($query->is_tag()) { $query->set(‘posts_per_page’,10); } } add_action( ‘pre_get_posts’, ‘main_query_mods’ );

WordPress – Custom Nav menu for logged in users – Shopkeeper theme

I think you already did part of this but i am detailing all steps: 1.- Register 2 nav menus: register_nav_menus(array( ‘logged-in’ => __(‘Logged In Menu’, ‘yourthemename’), ‘logged-out’ => __(‘Logged Out Menu’, ‘yourthemename’) )); 2.- Create the menus going to Appearence -> Menus in the back-end, assign each one to his corresponding location. 3.- Where you … Read more