the_title gives me the page’s title not the post title in the following code

You are using the default page loop and it will output the current page attributes like title or other. You should create your own loop with custon query instead. See WP_Query or get_posts. Example $query = new WP_Query(array( ‘post_type’ => ‘post’, ‘posta_status’ => ‘publish’, )); if($query->have_posts()){ while($query->have_posts()){ $query->the_post(); echo get_the_title(); } wp_reset_postdata(); }

Including a post title in a twitter link

The problem is that get_the_title() will pass the title through a filter that texturizes the quotes. So a regular ” becomes a curly quote (“) and urlencode() will break it. So instead, write your own title function and use that: function my_get_the_title() { global $post; return $post->post_title; } This should bypass any unwanted filters and … Read more

Can’t get title of latest post

You’re getting there! Couple of issues – you need to actually grab the latest posts before you can work on them. And post_title is not a property of the ID, but the object itself: if ( $posts = get_posts( ‘numberposts=1’ ) ) { $title = $posts[0]->post_title; // carry on sir } Note: Ensure you have … Read more

How to change the page title from functions.php

If you refer to the post title you need to hook your function to the_title filter like explained in the codex. add_filter(‘the_title’, ‘my_custom_title’, 10, 2); If you refer to the HTML meta in your page then you need to hook your function to document_title_parts filter explained here. add_filter(‘document_title_parts’, ‘my_custom_title’, 10, 2); The two filters work … Read more

get_title without filter(the_title)

There’s a few ways to do this, but I would argue that the preferred way is, in general, fetching the post_title attribute from the post object. This does not depend on removing all filters for a certain function and adding them back later — the latter requires you to directly access the global $wp_filter. get_post … Read more

Filter get_the_title to remove certain characters?

The function the_title() is just a wrapper around the function get_the_title(). It’s understandably confusing that the filter the_title actually exists inside get_the_title(). So, whatever the function you’re using to actually display it, it doesn’t matter, you can filter its content by hooking into the_title

How to intercept Post Title on Post-Save

To set the title before it is saved, hook into wp_insert_post_data: add_filter( ‘wp_insert_post_data’, ‘wpse_75597_change_title’ ); function wpse_75597_change_title( $post_data ) { $post_data[‘post_title’] = ‘SOMETHING VERY LOUD’; return $post_data; }

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