How to get page title with the page ID?
Try with this: <?php echo get_the_title( $ID ); ?>
Try with this: <?php echo get_the_title( $ID ); ?>
<?php // would echo post 7’s content up until the <!–more–> tag $post_7 = get_post(7); $excerpt = $post_7->post_excerpt; echo $excerpt; // would get post 12’s entire content after which you // can manipulate it with your own trimming preferences $post_12 = get_post(12); $trim_me = $post_12->post_content; my_trim_function( $trim_me ); ?>
I finally got it working, but not with the code in my question. I totally scrapped that whole idea and restarted going in a new direction. NOTE: If anyone is ever able to sort out the issues in my question, feel free to post an answer. Also, if you have any other solutions, feel free … Read more
When WordPress is using pagination like this, there’s a query variable $paged that it keys on. So page 1 is $paged=1 and page 15 is $paged=15. You can get the value of this variable with the following code: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; Getting the total number of pages is a bit trickier. … Read more
UPDATE: This is now a decade old answer, meant for a very old version of WordPress. I can see the comments informing me that this might not work for newer WP versions, please do refer to the other answers below if mine is not working for your version of WP. For WP 2.*, this will … Read more
When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The meta_key is _wp_page_template and the meta_value will be the page template You can simply make use of get_pages to retrieve all pages which have a meta_value of the specified template … Read more
Please check the parameter ‘parent’. It seems there is a space after the name.
You can use the wp hook and check the global $wp_query object or any conditional. add_action( ‘wp’, ‘wpse69369_special_thingy’ ); function wpse69369_special_thingy() { if ( ‘special_cpt’ === get_post_type() AND is_singular() ) return print “Yo World!”; return printf( ‘<p>Nothing to see here! Check the object!<br /></p><pre>%s</pre>’, var_export( $GLOBALS[‘wp_query’], true ) ); } See: wp in codex.wordpress.org and … Read more
Just in WordPress 4.9 there’s this bug: https://core.trac.wordpress.org/ticket/42573 causing the template files to only be rescanned once every hour. To fix (until they release a new WP version with this changed), download the patch on that bug ticket and make the changes from the patch to wp-includes/class-wp-theme.php. Hope this saves someone the 2 hours I … Read more
is_home() checks for the “Posts Page”, despite the somewhat confusing function name.