Get parent of current page

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

Load sidebar template just once to prevent multiple animations

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

Inject class in body when particular page template is used

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

How To Load an HTML File As A WordPress Page (With No 301/No Redirect)

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; }

Why this code causes infinite loop?

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)