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

Edit Parent page drop menu when creating a page

You can use the page_attributes_dropdown_pages_args filter to remove whatever you want. It’s based off of the wp_dropdown_pages() arguments so you can use the exclude parameter to remove certain pages or a fake parent to remove all the pages: /** * Filter the arguments of Page Attributes Parent Dropdown * * @param Array $args – List … Read more

Get $post Object from another page

This is how you can get the post object of a page with a matching path, minus the /en part: $page_path = get_page_uri( get_queried_object_id() ); // en/page/child-page $target_page_path = str_replace( ‘en/’, ”, $page_path ); // page/child-page $target_page = get_page_by_path( $target_page_path ); // WP_Post of target page.

Get the Current Page Slug-Name

Assuming you’re doing this from inside the Loop, you can get it this way: global $post; $page_slug = $post->post_name; Then just use echo $page_slug; in the location(s) you which to have it displayed. For outside the loop, you will need to use different code: $the_page = sanitize_post( $GLOBALS[‘wp_the_query’]->get_queried_object() ); $slug = $the_page->post_name;

how to edit source code of specific page in wordpress?

Much of the code for any page, including header and footer, comes from your theme. If you want to create fully custom code, your best bet is to create a child theme (which just means creating a “style.css” file with some comments that refer to the parent theme, which is what you’re currently using) and … Read more

What is a subpage in WordPress?

The only difference between a page and a subpage is that a subpage contains it’s parent in the URL, as will any pages that sit as children to the child page… For illustration. Regular page: example.com/a-page/ Subpage: example.com/a-page/a-child-page/ Sub Subpage: example.com/a-page/a-child-page/another-child/ and so on… Aside from the URL there’s no other differences i can think … Read more

How to control who can view certain pages in BuddyPress? [closed]

I am new to BuddyPress so I don’t know which functions and variables to use here. Read the codex – for example: http://codex.buddypress.org/developer-docs/the-bp-global/ You could create a function in your theme- functions.php or in bp-custom.php and call it from template files and pass it parameters like allowed_users, etc. Or you code hard-code something like this … Read more