Custom user role that can only edit specific (non-custom-type) page and all child pages [duplicate]

There’s no way in WordPress to assign the capability for editing (or any action) a specific post to a role. However, you can filter capabilities checks and change them on the fly using the map_meta_cap. When handling post permissions, WordPress ultimately deals in just 4 capabilties: edit_post read_post delete_post publish_post Then whenever an action is … Read more

How can I programmatically create “child” pages on theme activation?

As @Soulseekah said, you can do this with post_parent. I didn’t test with the following code, but it should work $pages = array( array( ‘name’ => ‘page1’, ‘title’ => ‘Page 1’, ‘child’ => array( array( ‘name’ => ‘page11’, ‘title’ => ‘Page 1.1’ ), array( ‘name’ => ‘page12’, ‘title’ => ‘Page 1.2’ ) ) ), array( … Read more

Get Permalink for the top level parent of child pages

Here’s a way to get the top page url: $top_page_url = get_permalink( array_slice( get_ancestors( get_the_ID(), ‘page’ ) , -1 ) ); where get_ancestors() returns an array containing all the parents (ID) of the given page. You can read more about it in the Codex here. Here are various ways to get the last array item, … Read more

Prev/Next child navigation for current page?

All right, here it is, fully working: <?php $pagelist = get_pages(“child_of=”.$post->post_parent.”&parent=”.$post->post_parent.”&sort_column=menu_order&sort_order=asc”); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search($post->ID, $pages); $prevID = $pages[$current-1]; $nextID = $pages[$current+1]; ?> <div class=”navigation”> <?php if (!empty($prevID)) { ?> <div class=”previous”> <a href=”https://wordpress.stackexchange.com/questions/54422/<?php echo get_permalink($prevID); ?>” title=”<?php echo get_the_title($prevID); ?>”>Previous</a> </div> <?php } … Read more

Child Pages Loop

I’m fairly certain the problem is that some template tags rely on the global $post variable. Using setup_postdata() as you are now, will not alter $post. If you replace all the instances of $pageChild with $post, everything should work. However, I would strongly recommend using the WP_Query class and setting up your post data with … Read more

Is there a default template file for child pages / subpages?

There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more

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