how to get specific page content

Rather than call WP_Query() you can use get_post() and “set up” the global $post. This is probably a little more efficient than @tf’s answer, though the ideas are broadly the same. Please note, in both cases you should reset the post data afterwards. /** * Display the post content. Optionally allows post ID to be … Read more

list pages only from master parent

This is what I have used in a few projects that always displays the children pages even if you’re are viewing a child page. See if this is what you had in mind <?php if(!$post->post_parent){ // will display the subpages of this top level page $children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″); $ancestors = $post->ID; }else{ // diplays only … Read more

How to echo excerpts with wp_list_pages?

If you want to make use of all the nifty filters for the title and excerpt/content (and why would you not want that?) you should loop through a custom query instead of using get_pages and the pages’ plain contents: <?php $args = array( ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, … Read more

What is the proper way to get contents of a page?

A few notes before I start NEVER EVER use php shortcodes, they are bad, confusing and not supported by default on some servers. IMHO, they should have never made it into PHP in the first place. WordPress Standards (which doesn’t mean much) also “prohibits” the use of shorttags. Use proper php tags and forget that … Read more

Check if admin is editing page or custom post type

is_page() is not working on the admin area so I needed to use the following code function this_screen() { $current_screen = get_current_screen(); if( $current_screen ->id === “page” ) { include_once ‘page_admin.php’; } } add_action( ‘current_screen’, ‘this_screen’ ); You can replace “page” to any custom post type name

Include a specific page in your template

Another great way of accomplishing something like this would be taking advantage of WordPress Custom Post Types. You could set up 3 different types of features for easy use in the WordPress back-end. First, Set up the Custom Post Types To do this, open up your theme’s functions.php file and include something like this: <?php … Read more

Custom /page/2/ template (different from index.php)

I would use the is_paged() conditional inside index.php to load two separate templates containing your layouts. Something like this: if ( is_paged() ): get_template_part( ‘content’, ‘first-page’ ); else: get_template_part( ‘content’, ‘paged’ ); endif; Assuming you have two templates, content-first-page.php and content-paged.php. Edit: If you just want a different template for part of your index page, … Read more