Hide page visual editor if template is selected – redux

The following works for me, testing with TwentyTwelve. Using load-{$pagenow} instead of admin_init avoids the checking for the global $pagenow. See comments for further info: // Run only when editing a page // For new pages load-page-new.php should be used // See: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/admin.php#L217 add_action( ‘load-page.php’, ‘hide_editor_wpse_88886’ ); function hide_editor_wpse_88886() { // Not really necessary, but … Read more

Restrict acceess of a page in backend

This can be done in two steps. First, add a hook to the page /wp-admin/edit.php?post_type=page to remove the desired page from appearing to other users. And another hook to redirect non-authorized users from trying to access the page directly /wp-admin/post.php?post=ID&action=edit. Here, the post type is page, but it can be changed to any other. Make … Read more

foreach error on false boolean from get_terms

What you need is pretty much straight out of the Codex: $terms = get_the_terms( $post->ID, ‘on-draught’ ); if ( $terms && ! is_wp_error( $terms ) ) : $draught_links = array(); foreach ( $terms as $term ) { $draught_links[] = $term->name; } get_the_terms() can return a term object, false, or a WP_Error object. You are checking … Read more

Check if has any sidebar active on current page

I believe the issue here is a problem with vernacular. is_active_sidebar isn’t page specific — just checks to see if it has data within it throughout the entire site. You are asking a different question. Sounds like you are asking “does this template reference and sidebars AND do any of those sidebars have data in … Read more

How can I show drafts in wp_dropdown_pages list?

Update It seems that you can do this directly with WP function wp_dropdown_pages() as birgire points out in his response below: https://wordpress.stackexchange.com/a/240275/102371 This solution is longer, and uses get_posts() to fetch specific post statuses. $pages = get_posts( array( ‘post_type’ => ‘page’, ‘post_parent’ => 0, ‘post_status’ => array( ‘draft’, ‘publish’ ) ) ); echo ‘<select name=”selected-food-type” … Read more

Display subpages under parent page as a list within a loop

First set your arguments(settings) $args = array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); $children = get_children( $args, $output ); then you can use something like this <?php if (!empty($children)):?> <ul class=”row”> <?php foreach($children as $dest){ $permalink = get_permalink($dest->ID); echo “<li class=”col-sm-4″><a href=”https://wordpress.stackexchange.com/questions/254608/{$permalink}”>” . $dest->post_title . “</li>”; }?> </ul> … Read more

Loop with Dynamic Categories

The code below enables categories for pages. An example page template is provided which loops through the categories assigned to the page and displays the posts for each category. If you want to limit the user to selecting only one category, you can use a solution such as Taxonomy Single Term. Associate the category taxonomy … Read more