Get next/previous cousin page

I solved this by getting all pages, assigning them by level, and then getting the next page of the same level. If you also want the previous page then you should probably cache the functionality that groups the pages by level. function wpse16875_next_page_same_level_link() { $next_page_same_level = wpse16875_next_page_same_level(); if ( $next_page_same_level ) { return ‘<a href=”‘ … Read more

Object gets unwanted width and height

You can try this: add_filter( ‘media_send_to_editor’, ‘remove_width_height_attribute’, 10 ); function remove_width_height_attribute( $html ) { $html = preg_replace( ‘/(width|height)=”\d*”\s/’, “”, $html ); return $html; }

How to get a feed for post type ‘page’?

Feeds for post types are called with feed/?post_type=POSTTYPE. For no obvious reasons this doesn’t work for the post type page – you get the posts instead. But there is a filter to fix that: ‘pre_get_posts’. Let’s use it: add_action( ‘pre_get_posts’, ‘t5_pages_in_feed’ ); /** * Set post type to ‘page’ if it was requested. * * … Read more

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

List all pages and children in separate ul

your code is missing the = after child_of <?php $args = array( ‘sort_column’ => ‘menu_order’, ‘parent’ => 0, ); $pages = get_pages($args); foreach($pages as $page){ ?> <ul> <li> <?php echo ‘<a href=”‘ . get_permalink( $page->ID ) . ‘”>’ . $page->post_title . ‘</a>’; ?> </li> <?php wp_list_pages(‘title_li=&depth=0&child_of=”.$page->ID.”‘); ?> </ul> <?php } ?> if you want to … Read more

How to count current user’s pages?

Look what count_user_posts() does inside and change the post type parameter: global $wpdb; // ‘page’ is the important part here $where = get_posts_by_author_sql(‘page’, true, $userid); $count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->posts $where” ); Then you change your snippet to: global $wpdb; $user = wp_get_current_user(); $where = get_posts_by_author_sql( ‘page’, true, $user->ID ); $count = $wpdb->get_var( … Read more

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