This function will return the title of a post for a given post ID.

learn more… | top users | synonyms

5
votes
2answers
2k views

Replacing the title in admin list table

Here is my situation: I am trying to filter the content of the title column in my custom post type edit table but I can't get it working. Here is what I have tried: ...
4
votes
2answers
1k views

the_title() and the_permalink() won't work on AJAX calls

I've run into a strange problem. I have a custom loop built with get_posts that works fine when loading the page normally: <?php $rows = get_posts(array( 'post_type' => ...
3
votes
3answers
4k views

How to split up the_title and insert a span tag

My titles, site wide, will follow this theme all within a h1 tag: Main title heading / Sub-title text I'm trying to wrap a span tag around all text after and including the '/' so my markup will look ...
3
votes
4answers
7k views

How to get page's ID if I know the title only?

Is there an exact opposite funciton to this one: get_the_title(ID) I know there's: get_the_id() But it doesn't seem to accept any arguments. So, basically, I'm looking for something like: ...
2
votes
1answer
2k views

How to add hook to the_title() and get_the_title()

I've having trouble with accented characters now if i do utf8_decode() before echoing the title the problem is solved but instead of changing this all over my theme, can't I do this in one place that ...
2
votes
1answer
298 views

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(' ', ...
2
votes
1answer
2k views

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 ...
1
vote
2answers
745 views

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-fild: Posttitle" Like "Cool: The new TV show from ...
1
vote
2answers
2k views

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 ...
1
vote
1answer
75 views

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? ...
1
vote
1answer
109 views

the_title filter returning wrong post type

I am using the the_title filter to attempt to prepend some text to a custom post type's title. Our website has several custom post types. Product - slug is eproduct Brand - slug is brand-listing ...
1
vote
1answer
167 views

Get post title with link

I am using this code to send an email from my wordpress site. It send permalinks of the posts. How can i edit this to have linked titles instead of just permalinks; if(count($ids) > 0){ ...
1
vote
3answers
278 views

Multiple Conditions for Child Page Title

I've been trying to work with Conditional Tags and cannot wrap my head around this problem. PHP novice here. On sub-pages I need to display the parent page title as well as the page title. I have it ...
1
vote
1answer
799 views

wordpress get gallery images title

I am retrieving some images post with: $img = wp_get_attachment_image_src( $attachment_id, 'full' ); How can I retrieve the image title? Thanks.
1
vote
2answers
282 views

Get url-friendly version of the_title?

How can I get an url-friendly version of the post_title? I´m using anchor links for my posts on an archive page, and for the moment the posts get the post_ID as a hash tag but I would like to get the ...
1
vote
2answers
131 views

Is there any difference between the_title() and echo get_the_title()?

Just a small question. Is there any difference in using <?php the_title() ?> or <?= get_the_title() ?> Yeah, I know somebody can consider using short echo tag a bad practice, I just ...
1
vote
1answer
79 views

Get post/page title from ID

I'm trying to get the post title of a post_type (post/page/portfolio) in the admin panel outside of the loop. I nearly tried all possible solutions, but without success: //method 1 $content_post = ...
1
vote
1answer
666 views

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 ...
0
votes
1answer
392 views

Replace text in the Title

In a string displayed by <?php the_title(); ?> I have to replace all & characters with and. Here is the code I've tried without success: <?php $wptitle = the_title(); $wptitle = ...
0
votes
1answer
161 views

Wrong post title displayed from loop

I'm building my own theme. I have a page set for my blog (with a template that I made) which I'd like to just display a few of my posts. It uses the following loop: <?php ...
0
votes
1answer
142 views

get_the_title outputs title until spacing; it does not get full length of title

If I have a post with a spacing in it (like: Hello World), than get_the_title shows me only "Hello" as a link and not the whole permalink. I already tried using a substring to get it done, but it did ...
0
votes
1answer
38 views

Wordpress title as keywords (tags) with excluded stop words

How to change normal sentence WordPress title to "tag like" list with excluded "stop words". Example: "This is one test post title about something." To: "one, test, post, title, something" This ...
0
votes
3answers
43 views

How to output the title of the blogs home page

I am using a static frontpage and a page for my blogposts. In my header.php I want to display the title of the selected page of my blogposts. For example: <?php if( is_home() ) echo ...
0
votes
1answer
313 views

the_title not working

I'm using the_title() to show the title of a custom post type, but it's not working; the title does not show. get_header(); $wp_query = new WP_Query(); $wp_query -> ...
0
votes
1answer
336 views

single_term_title() running before get_the_title() [closed]

This is a strange "problem" but I've had this happen on a few installs and I was wondering if anybody could give an explanation on why / how this happens. On a blog category if I code: <?php ...
0
votes
1answer
895 views

Get title of post image is attached to

So I found this post: Find the post an attachment is attached to and implemented Chip's suggestion but having a weird outcome. I am trying to pull the title of the post that the specific image is ...
0
votes
1answer
93 views

Can't get full post title if there a spaces in title

I want to make a custom query that checks the post title and puts in a different URL like this: <a href=bing.com/search?q=<?php echo single_post_title(); ?>>Blablabla</a> But it ...
0
votes
1answer
976 views

Title on hovering on the featured image

I have used the following code to make a slideshow of the featured image of a category.I want to show the title of the post when hovering on the image. But I don't know how to do it. Anyone please ...
0
votes
2answers
394 views

How can I remove the first two words and shorten get_the_title()

Some of my posts' titles have leading words, followed by a colon. I am removing the leading words and the column of every post title in the loop with the following: <?php $title = ...
0
votes
1answer
355 views

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()); ?>"> ...
0
votes
1answer
2k views

get_the_title and get_permalink outside of the Loop

I'm trying to list the parent to a page in the sidebar. I can get the parent-page ID. I can get it to print with a print_r function, but no matter what I try I can't get get_permalink and ...
0
votes
1answer
242 views

Safe way to get the post ID in the_title()

Is there a safe way to get the post ID inside the_title()? add_filter('the_title', "change_post_title"); function change_post_title($title){ } I tried using global $post and get_the_ID(), but ...
0
votes
1answer
62 views

Show post title words one by one [closed]

How to show post title words one by one, but to exclude words with 3 or less characters. Also it would be nice to be able to exclude some words, for example to make some list of words to exclude from ...
0
votes
1answer
97 views

Strip $before & $after strings from a page title

So I have plugin that pulls remote data (real estate listings) into a wordpress site. I have been asked by a client to allow the page title for each listing to be set based upon that information and ...
0
votes
1answer
133 views

how do I get the title in the post [closed]

I have a custom grid loop to show a specific post type on a page. This shows the excertp for each post but it does not link include the post title, and I would like each post to have a title that ...
0
votes
3answers
642 views

Add title to image post

I can't add the title on a featured image in the recent posts. try this but only get the alt <?php $default_attr = array( 'src' => $src, 'class' => "attachment-$size", ...
0
votes
1answer
113 views

How to get changed post title in my custom plug-in which fires when 'save_post' is called?

I created a custom WordPress plug-in that hooks onto 'save_post" using add_filter(). I need to do something with the post titles and whenever a user changes the title, my plug-in cannot get the new ...
0
votes
1answer
2k views

Random Custom Post Type Titles

So i found the code below from another question on here, it displays a list of titles from a custom post type, my question is, How do i get the list to randomize? <?php $queryObject = new ...
0
votes
2answers
1k views

Can't Get Parent and Child Categories of Custom Taxonomy to Display

I have a Custom Post Type set up with a Custom Taxonomy. For this Custom Taxonomy, I'm trying to figure out how to echo out the titles of the parent category and current child category within it. ...
0
votes
3answers
22 views

WordPress Load Only Page Text

I'm working on a page template and I need the_title to be separate from the page text. I'm not sure how to load the_content without it having the title. Can anyone help?
0
votes
0answers
29 views

How do I match the page title?

I want to hide the editor on a page, depending on what the page title is. I've created this function. But it doesn't hit matches for the page title: $editorless_pages = Array( 'home', ...
0
votes
2answers
33 views

Change post title if post has specific category

Basically what I am trying to achieve is to have title changed of posts which are in category number 30. My code is: function adddd($title) { if(has_category('30',$post->ID)){ $title = 'Prefix ...
0
votes
0answers
95 views

Ampersand in Title Causes issues in Breadcrumbs & Sidebar

I'm having a problem with ampersands in Wordpress Page Titles. I have a sidebar that displays the Page Parent Title & a list of children underneath. If the the Page Parent Title has an Ampersand ...
0
votes
1answer
727 views

WP action/filter to modify title before header output and article output?

I'm trying to split test two versions of a posts title using a custom plugin. So far I haven't found the right filter or action to hook into to modify the title on the meta tag level before the page ...
0
votes
1answer
39 views

Include category name in page template

The theme I am using inserts and styles the page title using this code. I would like to display the category name depending on whatever it is for that category. I have tried a number of methods but ...
0
votes
1answer
202 views

Hide H1 Title using the_title filter

I am trying to hide the pages H1 header IF a custom field specifies this. On a page back end I have added a custom field: Name = hide_title Value = true I then want to hide only the H1 using a ...
0
votes
2answers
190 views

Custom Post Type title not populating

I am attempting to get the title displayed for a function. I am sending myself an email to see if I can get this to work for different titles. Currently the only way I can get it to work is via hard ...
0
votes
1answer
79 views

Remove space when post title is blank

I want my custom post type title leave no spaces when there is no title in the post. I tried to use following code but is removed h1 and other tag. Please help. <?php if (the_title() != '') { ...
0
votes
2answers
234 views

Get post title of faulty link on 404 error page

My users can link to things that don't exist on the page. That's something I chose because it is the best option for my concept. Anyway, what I want to do is this... Let's say I clicked on a link that ...
0
votes
1answer
222 views

How to get all post titles starting with numbers and symbols?

I want to get all posts which are starting with a number (0-9) or symbols, in a list. I managed to get it work for letters, but this one is harder for me. Can someone help me out please? I tried ...