Pass parameter to hooked function using custom page template
you make a mistake in the call of add_action the last parameters must be changed from 1 to 2 add_action(‘pre_get_posts’,’shop_filter_cat’,10,2);
you make a mistake in the call of add_action the last parameters must be changed from 1 to 2 add_action(‘pre_get_posts’,’shop_filter_cat’,10,2);
The 404 page happens because the permalinks haven’t been updated after you inserted the code. You can do either of these things: Manually update the permalinks after you add the new custom post type (needs to be done only once) Include the custom post type file in the theme setup function and follow with a … Read more
Try using get_post_ancestors. Here is how you can apply this in your case: <?php global $wp_query; $post = $wp_query->post; $ancestors = get_post_ancestors($post); if( empty($post->post_parent) ) { $parent = $post->ID; } else { $parent = end($ancestors); } if(wp_list_pages(“title_li=&child_of=$parent&echo=0” )) { wp_list_pages(“title_li=&child_of=$parent&depth=1” ); } ?> You’ll probably need to remove the depth parameters to show you’re 3rd … Read more
you can write the script with a conditions <?php is_front_page(){ ?> <script> jQuery(window).ready(function($){ $(“#sidebarRight”).animate({right: ‘0px’}); }); </script> <?php } ?> alternatively you can set the cookie or localstorage that the animation has been completed <script> if(!localStorage.getItem(“animated”)){ // check if the animated is set if not set do the animation jQuery(window).ready(function($){ jQuery(“#sidebarRight”).animate({right: ‘0px’}); localStorage.setItem(“animated”, “yes”); // … Read more
there is a filter for that and it’s called… body_class 😉 This should work for your case: function add_my_custom_body_class( $classes ) { if ( is_page_template( ‘page-customer.php’ ) ) { $classes[] = ‘body_customer’; } return $classes; } add_filter( ‘body_class’, ‘add_my_custom_body_class’, 10, 1 ); if you wanna add class based on page ID (as you’ve mentioned in … Read more
The code seems fine. Please check by loading the script in the footer and also use the wp_footer in your .php file.
I would like to know the location of allValue.php file. That’s not how it works. The value of page doesn’t tell WP which file to load, it’s just a name, an identifier ( the menu_slug to be specific ). For example, we can use this code to add a top level menu page to WP … Read more
You can use the template_include hook to accomplish this. Add this to your active theme’s functions.php file (or create a plugin). add_filter( ‘template_include’, ‘wpse376643_load_html_page’ ); function wpse376643_load_html_page( $template ) { if ( is_page( ‘the-page’ ) ) { // You’ll have to use the server path to your index.html file. $template=”/path/to/your/content/oct2020/index.html”; } return $template; }
It was correctly pointed out what the issue is, but I also want to explain it so you have better idea of mechanics: when you use query_posts() it writes down generated WP_Query object into global $wp_query variable; have_posts() and the_post() functions are wrappers for methods of same name called using global $wp_query object; so what … Read more
All you need to do is just create a new file in your theme root directory. This file must start with following code: <?php /** * Template Name: No Sidebars */ Name your file, for example, page_nosidebars.php and then WP will add No Sidebars template to available templates list. There is nice article about it … Read more