How does wordpress calculate the page depth?

Ok, lets break it down, all the links are going to be to the source code. wp_list_pages() only uses get_pages() to (sic!) get pages, walk_page_tree() does the hierarchical structuring inside it. The further course of the process goes Walker_Page – and the generic Walker of course -, unless a custom walker is used. Inside walk_page_tree() … Read more

Custom Search Page Pagination Not Working

You’re running into a conflict between your replacement query and the default search query that’s running behind the scenes. Instead of running a new WP_Query, try modifying the default query by hooking to pre_get_posts: function wpse276396_search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $text = urldecode( get_query_var(‘search_text’) ); $my_products = aws_search_byozan($text); … Read more

How to display list of child pages of parent page in wordpress?

Add this code to your functions.php. An explanation of the code is given below. function wpb_list_child_pages() { global $post; $id = ( is_page() && $post->post_parent ) ? $post->post_parent : $post->ID; $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=” . $id . “&echo=0’ ); //you can add `&depth=1` in the end, so it only shows one level if ( $childpages … Read more

Limit number of pages that use a specific template?

You can approach this by first using a database query to count the number of pages that are already using the template: $query = “SELECT COUNT(*) as total FROM prefix_posts as p JOIN prefix_postmeta as m ON p.ID = m.post_id WHERE p.’post_type’ = ‘page’ AND p.’post_status’ = ‘publish’ AND m.’meta_key’ = ‘_wp_page_template’ AND m.’meta_value’ = … Read more

Password protected post or page – error message by wrong password?

not really, but can try something like: add_action(‘wp’, ‘check_post_pass’); function check_post_pass(){ if(!is_single() || !post_password_required()) return; global $post; if(isset($_COOKIE[‘wp-postpass_’.COOKIEHASH]) && $_COOKIE[‘wp-postpass_’.COOKIEHASH] !== $post->post_password){ define(‘INVALID_POST_PASS’, true); // tell the browser to remove the cookie so the message doesn’t show up every time setcookie(‘wp-postpass_’.COOKIEHASH, NULL, -1, COOKIEPATH); } } in your template: if(defined(‘INVALID_POST_PASS’)) _e(‘The password you entered is … Read more

Different fields in My Profile page depending on user role

I’ll post whole code which have to be in functions.php it’s legit WP valid code, how it should be done 🙂 This should work, of course you have to put your role name in switch. UPDATED FOR PERFORMANCE: add_action( ‘show_user_profile’, ‘user_fields_for_admin’, 10); add_action( ‘edit_user_profile’, ‘user_fields_for_admin’, 10); function user_fields_for_admin( $user ){ switch ($user->roles[0]) { case ‘SOME … Read more

Set Session Time Limit for Password Protected Posts

The reason is when you execute this code setcookie(‘wp-postpass_’ . COOKIEHASH, ”, 0, COOKIEPATH); It will reset your post password cookie to blank ”, so it just work once To solve this you need to assign the original cookie and extend the timeout, like this setcookie(‘wp-postpass_’ . COOKIEHASH, $_COOKIE[‘wp-postpass_’ . COOKIEHASH], time() + 60 * … Read more

How to get post or page excerpt using post_excerpt

EDIT Seems that I some how misunderstood you. I do think you are missing the point of the post_excerpt. When you create a new post or page (AFAIK for pages as well), you have the opportunity to create a manual excerpt in the excerpt meta box (to make it available, just enable it in screen … Read more

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