How to create a page when a theme is activated?

There is a hook specifically for this purpose, called after_switch_theme. You can hook into it and create your personal page after theme activation. Have a look at this: add_action( ‘after_switch_theme’, ‘create_page_on_theme_activation’ ); function create_page_on_theme_activation(){ // Set the title, template, etc $new_page_title = __(‘About Us’,’text-domain’); // Page’s title $new_page_content=””; // Content goes here $new_page_template=”page-custom-page.php”; // The … Read more

How to get the excerpt of a page before more tag?

The content is manipulated by the get_the_content function, and that function always assumes the current post in the Loop. You can’t pass it an ID, strangely. The easiest way to get just the bit before the more for an arbitrary post ID is: $p = get_post(1); $p = preg_split( ‘/<!–more(.*?)?–>/’, $p->post_content ); echo $p[0]; There … Read more

How to display thumbnail and excerpt of a page on homepage?

<?php $post_id = 50; // assign post id $queried_post = get_page($post_id); if(is_home()) { ?> <div class=”product_title”><h3><a href=”https://wordpress.stackexchange.com/questions/72514/<?php echo get_page_link($post_id); ?>”><?php echo $queried_post->post_title; ?></a></h3></div> <div class=”product_image_location”><?php echo get_the_post_thumbnail( $post_id); ?></div> <div class=”description_product”> <?php echo $queried_post->post_content; ?></div> <?php } ?>

single page site with subpages

To me it’s very simple, but a bit static. You can make a new front-page.php with the structure you mentioned. Then first make some pages (i.e.: About us, Members 1, Contact etc.) in your wp-admin. And use the get_page() function to call different page [using their individual ID] into different zone. Am I right?

List Child Pages of Parent Parent Page (Child pages from Grand Parent)

Could you try this ? The idea is if there is a parent, we should list pages for the parent of this parent. <?php if ( is_page() ) { if($post->post_parent) { $children = wp_list_pages(‘title_li=&child_of=”. get_post( $post->post_parent )->post_parent .”&echo=0&sort_column=post_date&sort_order=DESC’); } else { $children = wp_list_pages(‘title_li=&child_of=”.$post->ID.”&echo=0&sort_column=post_date&sort_order=DESC’); } } Other solution would be to try to use depth … Read more