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

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

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 } ?>

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

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