Multiple Conditions for Child Page Title

Based on the comment exchange, here’s what I think you’re after: <h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1> <?php if ( $list = wp_list_pages( “echo=0&child_of=$post->ID” ) ) : ?> <h2>Select a sub-page</h2> <ul> <?php echo $list ?> </ul> <?php elseif ( $post->parent ) : ?> <h2><?php the_title() ?></h2> <?php endif ?>

How to display thumbnail + tags + title of a child page?

Assuming that you’ve enabled support for both post thumbnails and post tags for static Pages, I would use WP_Query() to build your query, and do something like the following: global $post; $child_pages_query_args = array( ‘post_type’ => ‘page’, ‘post_parent’ => $post->ID, ‘orderby’ => ‘menu_order’ ); $child_pages = new WP_Query( $child_pages_query_args ); if ( $child_pages->have_posts() ) : … Read more

custom field to always to .get_the_title()?

<?php function add_subtitle($title, $id) { $subtitle = get_post_meta($id, ‘myCustomField’, true); $new_title = $title; if(!empty($subtitle)) $new_title = $subtitle . ‘: ‘ . $new_title; return $new_title; } add_filter(‘the_title’, ‘add_subtitle’, 10, 2); Basically, this uses the the_title filter to add the subtitle to your title. It only adds it if that custom field is available, otherwise, it leaves … Read more

get the_title_attribute by id

hey just look in code and it also support fourth parameter post global $post; the_title_attribute(array(‘post’=>$post));//post object or global $post; the_title_attribute(array(‘post’=>$post->ID));//post id so you can use it like <a href=”https://wordpress.stackexchange.com/questions/111931/<?php echo get_permalink($id); ?>” title=”<?php the_title_attribute(array(‘post’=>$id)); ?>”> //where $id is post id Important Link the_title_attribute

posts order by title second word

The simplest method may be to just save titles as last name / first name, then they will naturally sort. You can then reverse the title when you output it in the template. Your attempt to modify the orderby query var is fundamentally flawed. Order is created by MySQL, which doesn’t understand PHP, and can’t … Read more

Replacing the title in admin list table

1. Change post title in post list column I misunderstood what you wanted – obviously. You can do that like this: add_action( ‘admin_head-edit.php’, ‘wpse152971_edit_post_change_title_in_list’ ); function wpse152971_edit_post_change_title_in_list() { add_filter( ‘the_title’, ‘wpse152971_construct_new_title’, 100, 2 ); } function wpse152971_construct_new_title( $title, $id ) { //print_r( $title ); //print_r( $id ); return ‘new’; } Making use of the admin_head-$hook_suffix … Read more

Get post/page title from ID

If you have only ID of a post and you want only the title of that post, then using get_post_field will be best way to do this, I guess. The syntax of this function: get_post_field( $field, $post_id, $context ); So code, that will solve your problem looks like that: $title = get_post_field( ‘post_title’, $POST_ID ); … Read more

the_title(); works in a page template, outside the loop. Why?

The global $post object exists already for singular views before wp_head is called. It is just not filled with all data. The the_title() calls get_the_title() which in turn calls get_post(). And that calls $GLOBALS[‘post’] if no post ID has been passed. See also Generating the ogp tags in theme for a use case.

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