Articles of get the title

how i can add title to my featured image?

I want to add a title to my featured image, how I can add this item: $attr = array( ‘title’ => ‘howdy partner’, ‘alt’ => ‘a nice view of the ocean’, ); // pick one, note 2 or 3 arguments: the_post_thumbnail( ‘post-thumbnail’, $attr ); echo(“<a href=’$p->permalink’>”. // null for current $post->ID (use within loop) get_the_post_thumbnail( […]

How to sanitize post title with commas

I need to sanitize WordPress title with commas that is using commas to replace the spaces. i used this but didn’t worked for me echo sanitize_title_with_commas(“the_title”); What i mean is: if this is the main title this is WordPress forum when I use the code it will become this,is,wordpress,forum Thanks in advance.

Can't get title of latest post

I’ve just started learning PHP/Wordpress yesterday – here is one of my first plugins. Unfortunately, it’s not working like it’s supposed to – the title doesn’t display. What’s wrong with my code? function show_title_on_dashboard() { $newest_post_id = $post[0]->ID; $title = $newest_post_id->post_title; echo “Latest Post: $title”; } add_action(“admin_notices”, “show_title_on_dashboard”);

Including a post title in a twitter link

Im trying to make a Twitter button on each article of my blog. This is the code I use on single.php <a href=”http://twitter.com/home?status=<?php echo urlencode(get_the_title()); ?>”> Tweet this! </a> The problem is that I have a blog post with this title: Give format to “bodytext” and when I tweet it, the quotes appear as Give […]

get the_title_attribute by id

I’m creating a list with a few permalinks which I call to with <a href=”<?php echo get_permalink($id); ?>” title=”…. And for the title I want to call the_title_attribute(). But it seems it can only be called within a loop, and not by id. How do I correctly get a title attribute? Note: The reason I […]

Long Post Title Misaligning Grid with Featured Image

I’m putting together a grid with the featured images as the background and the post title above. It works fine, but when the post title spreads over two lines the entry before or after is moved up/down and the grid is misaligned. I can’t work out why it’s doing this so any help would be […]

custom field to always to .get_the_title()?

Is there a way to have always the the_title() tag also includes a custom field called subtitle? I want to have a title like this: “subtitle-custom-field: Post Title“. For example, “Cool: The new TV show from Werner Herzog.” In this case, cool would be the custom field value, and the new TV… would be the_title(). […]

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

Trying to wrap my head around the loop concept… Given a template page (page-work.php) with just this code: <?php the_title(); ?> WP correctly shows the title of that page. As I understand it, this is outside any loop and shouldn’t work (Codex says to use get_the_title in those cases). So the question is, why does […]

posts order by title second word

This is a common question, i haven’t been able to find a straightforward answer to. I want to generate a list of a custom post type titles. im using ‘orderby’ => ‘title’ to have them display alphabetically. The titles are names and last names and i want to sort by the last name. I know […]

How to intercept Post Title on Post-Save

I am new to WP and I couldn’t find this solution by myself. this is my function, function explodetitletotags() { global $post; $title = $post->post_title; $tags = explode(‘ ‘, preg_replace(‘/[^\p{L}0-9 ]/’, ‘ ‘, $title)); foreach $tags as $tag { global $post; $thePostID = $post->ID; wp_add_post_tags($thePostID, $tag); } } add_action(‘publish_post’, ‘explodetitletotags’); The Function works like a […]