Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [get-the-title]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
32 views

How to edit specific title instead of all the title calls

I would like to add an html element right before the title of the blog posts. The code I'm using is as follows: function add_html_above_title($title, $post_id) { if (is_single() && $...
s.sufi's user avatar
  • 3
2 votes
1 answer
116 views

Display image title and caption on posts and pages

I want a simple function to display image titles and captions alongside each other below the images on wordpress posts and pages. All the answers I have seen do not work for me. Either they leave the ...
Anand Prakash's user avatar
0 votes
1 answer
47 views

Auto Generate Post Title from 2 ACF Taxonomies [closed]

I am looking for a custom function to auto generate a post title/slug for a specific CPT from two taxonomies and one custom field, created with ACF Pro. Auto generation should be done only when the ...
austriadesign's user avatar
0 votes
1 answer
40 views

Replace post title based on conditions

So I would like to replace the entire title of posts in WordPress bases on user behaviuor and role. Please note that I would like to replace the entire post title and not the prepend or append text to ...
Boris Smolyanov's user avatar
0 votes
0 answers
164 views

How to ignore WP_ERROR caused by "get_the_excerpt" method in an AJAX call?

function get_post_data(){ $post_id = $_POST['post_id']; ... $data['title'] = get_the_title( $post_id ); ... $data['excerpt'] = get_the_excerpt( $post_id ); ... ...
Tom's user avatar
  • 13
0 votes
0 answers
193 views

Filter the title to only affect the_title() template function

I am using the_title filter to add an HTML snippet under the title, as follows: I only want the output to happen for the main title in the posts or page view. That's why I added an early return to ...
Álvaro Franz's user avatar
0 votes
1 answer
386 views

Shortcode Not Working in Slider When Added To Post Title

I've coded a shortcode to add manually to specific post title fields so i can style part of a title add_shortcode( 'green', 'green_shortcode' ); function green_shortcode( $atts, $content = 0 ) { $...
Brad Dalton's user avatar
  • 6,926
0 votes
0 answers
26 views

Display Most Recent Post Widget Title On Page

I want to display the Recent Posts Widget title on a page, however I could not find a solution yet. I dont want to display the recent posts on the page only the title of the most recent posts widget, ...
Simó Tamás's user avatar
1 vote
0 answers
68 views

Don't see add_filter result in the site front page

I modified the site title the 'the_title' filter. I am using ACF pro repeater, I want to achieve is that if there is content in the repeater a + will be added to the post title. I wrote this script: ...
DavSev's user avatar
  • 143
0 votes
1 answer
87 views

Trim Titles Only On Some Pages

I Need to Trim the h2.entry-title, including whitespace and special character Only On Homepage, Category Pages, and Tag Pages. (eg. Gowland Remote Control Car – RC Cars Xmas Gifts) I Need All Titles ...
Vikral's user avatar
  • 1
0 votes
1 answer
252 views

Changing Title Tag on Shop Archive Page (current solution reverting to Title of First Product in Loop)

Firstly, add_theme_support( 'title-tag' ); is enabled in my theme. I have two filters to modify titles, this one hooking on to the_title add_filter( 'the_title', 'custom_account_endpoint_titles', 10, ...
bbruman's user avatar
  • 464
0 votes
1 answer
2k views

Multilanguage website get the title, on different languages

I am working on a website, and I am using Polylang to translate it to a different language. In my code I want to get a page title, and display it. My issue is I cannot get it by ID or page_by_path ...
Simó Tamás's user avatar
0 votes
1 answer
429 views

Modify WordPress Page Title (<head></head>)

I'm trying to modify the WordPress page title. However I'm fairly new to WordPress functions, hooks (filters & actions) and so on. What I could achieve is to change and modify WordPress titles in ...
Still Ready's user avatar
0 votes
1 answer
716 views

Display text if title in archive has specific word

In tag pages, I want to display specific text if the title containing a specific word. As example: I have a Tag and tag archive page: Yellow Banana And I want to display “cool fruits” in all tag ...
Seryozha's user avatar
0 votes
0 answers
159 views

Post title not displaying as recorded in the wp_posts table

I have a WordPress install in which the "post_title" field from the "wp_posts" table is not making it into the WP_Post->post_title variable. So, for a given post in the wp_posts table that has a ...
paulswanson's user avatar
1 vote
3 answers
4k views

Is there any difference between get_the_title() and single_post_title()?

Is there any difference in using <?php get_the_title(); ?> or <?php single_post_title(); ?> Because I can always get same value
Kazu25's user avatar
  • 33
0 votes
1 answer
34 views

Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?

I've been trying and failing at trying diff code snippets and searching online for something that works. Posted on the more general forum but saw recommendations to post WP questions on this forum. ...
user1102824's user avatar
0 votes
1 answer
2k views

Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters

I have a custom post type 'news' and would like to limit the title character length to 42 characters on the custom post type archive page for 'news' The following code is how the title is displayed ...
pjk_ok's user avatar
  • 908
0 votes
1 answer
320 views

post_exists returning 0 if title contain special characters

I am using the below code: $title = get_the_title($result->post_id); if ( 0 === post_exists( $title ) ) { $title = 'Document Id: '.$result->post_id .' (Deleted)'; } But it's returning 0 if ...
Waleed's user avatar
  • 21
0 votes
2 answers
300 views

How to use get_the_title with text on the 'alt' of the_thumbnail array?

I'm currently using <?php the_post_thumbnail('250px', array('class'=>"review-siteshot", 'alt' => get_the_title() )); ?> I know that 'alt' => "review" will output review as all text. I'...
Bikram's user avatar
  • 338
0 votes
2 answers
363 views

How can i make wordpress blog title clickable and direct to the post itself

How can i make wordpress blog event titles clickable and direct to their respective post itself? Thank you! <li id="post-<?php the_ID(); ?>" <?php post_class( 'stm_post_info' ); ?>> ...
Samuel's user avatar
  • 3
4 votes
4 answers
2k views

Remove "Private" + ":" in title does not work

I would like to remove the "private" prefix for each post title. I found the filter here. I managed to removed the word "Private" but when I concatenate with " : ". That does not work anymore. I ...
J.BizMai's user avatar
  • 870
1 vote
1 answer
2k views

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

<?php if(have_posts()){ while(have_posts()){ the_post(); echo get_the_title(); } } ?> this is my loop, really simple, im calling this within a custom page template i ...
Eli's user avatar
  • 11
0 votes
2 answers
880 views

Add HTML code before the title of the Tag page

I want to show an iframe at the top of a specific Tag page, so once I have is_tag('my_tag'), I will add the iframe before the title of the page. I've tried this code to show the iframe before the ...
Jaafar Abazid's user avatar
0 votes
2 answers
608 views

WordPress Image Slider Looping Title Not Working

In my index page there are two slider one is working fine but the second one is giving some problems. FIRST ONE <?php global $post; $i=0; $args = array('post_per_page' => -1, 'post_type' =>...
Mohammad Asif's user avatar
0 votes
1 answer
120 views

Can't properly set the_title add_filter to show short_URL

I am trying to show Bitly's Post short URLs for my blog posts but something seems off as when I am using this code, I see the output all over the page for menu items etc... Additionally, the URL ...
Dr.Hariri's user avatar
0 votes
1 answer
41 views

How to show users search phrase in SEO Title

How to create dynamic SEO titles? If users search phrase should be shown in the SEO Title in the google search. Ex: If a user searches "Meat delivery in Hyderabad" title in google search should be ...
Maqbul Baig's user avatar
0 votes
1 answer
594 views

How come I get internal server error even with try catch for get_the_title in functions.php?

I'm relatively new to PHP & wordpress but not to programming. I wanted to have a title relative to the $post title, so I created the following filter and added it to functions.php: add_filter('...
Adelin's user avatar
  • 105
1 vote
1 answer
3k views

How do I hide the current page's title?

I have this code: add_filter( 'the_title', function() { return ""; }); Or, respecting the hook's arguments: function remove_title( $title, $id ) { $title = ''; return $title; } ...
coolpasta's user avatar
  • 919
0 votes
0 answers
555 views

Display title of custom post type dynamically

I've registered my custom post type in functions.php like so: function whatwedo_custom_post_type() { register_post_type('whatwedo', array( '...
Nancy's user avatar
  • 234
0 votes
1 answer
313 views

How to place POST TITLE any location inside the posts page

I am editing the single.php file, and I want post title to appear inside a particular div. Since my theme doesnt show the post title, I want to retrieve the post title on posted article page. " > &...
dark silence's user avatar
-2 votes
1 answer
2k views

How to store wordpress title in a variable

trying to run a PHP youtube v3 data in a WordPress theme $grab=ngegrab('https://www.googleapis.com/youtube/v3/search?key='.$devkey.'&part=snippet&order=relevance&maxResults=5&q='.$...
unity ekeinde's user avatar
1 vote
1 answer
655 views

change title separator

tell me how permanent the links to change the splitter from vertical to horizontal of the main page write website. | — http://joxi.ru/a2XlxQXcyeKPj2 The name of the site | short name The name of the ...
Sale ManagemenT's user avatar
-1 votes
1 answer
192 views

Why this Read More Not working in Php?

Only that Read More issue is remaining. <?php while(have_posts()): the_post(); echo '<h2>'.get_the_title().'</h2>'; echo get_the_post_thumbnail(...
TheDose's user avatar
  • 198
1 vote
2 answers
2k views

How to change the page title from functions.php

I have an ACF custom field that depends on the value I need to change the page title, however, I cannot affect the page title, it appears my code is running after the page title is generated. To ...
Paul Cullen's user avatar
0 votes
4 answers
408 views

Adding Filter | Page Title | Template | Why the_title affecting on menu?

I've added a template in my theme, I want to change page title using following code. but its change my menu titles also. I'm unable to fix this issue. Please help. function get_id_by_slug($page_slug) ...
Shahrukh's user avatar
0 votes
1 answer
503 views

Print title page in header of a specific page

I'm trying to customize Avada template. I want to print in the header the page title, but only for specific pages. So I tried in header.php <head> <?php if ( page_is('80') ) { echo ...
Francesca Meconcelli's user avatar
1 vote
1 answer
144 views

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 ...
mehdi's user avatar
  • 11
-2 votes
1 answer
38 views

echo spesific title get_the_title

I have two title QCM Rare I want to show the title into table header foreach($quiz_ids as $quiz_id){ echo '<th><a href="'.get_permalink($quiz_id).'" target="_blank"> '.get_the_title(...
Kimberly Rider's user avatar
1 vote
1 answer
616 views

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 ...
Onuwa O's user avatar
  • 17
1 vote
1 answer
209 views

Access get_the_title() from 'excerpt_length' filter

Is there a way to access the get_the_title() function from a excerpt_length filter? For example, setting the excerpt length to be the same as the title: function excerpt_length_same_as_title( $...
user126296's user avatar
-1 votes
2 answers
279 views

Wordpress loop put title into variable

I am trying to get the permalink and title into variables to use outside of a loop - I have made it work for the thumbnail but for some reason can t get it to work for these two. Here is my code: &...
anna's user avatar
  • 71
0 votes
1 answer
253 views

Use title of post as argument for query

I want to use the title of the actual post as argument parameter for a wp_query. I already tried to set it with the_title or get_the_title() but it does not work. Is it possible to save the title as ...
maidi's user avatar
  • 115
1 vote
1 answer
171 views

Custom post type title is set by other custom post type

Im trying to make a small plugin that can produce a team with a trainer. The team is a Custom Post Type and the trainer is a Custom Post Type. When I create a new team, i read all the trainers in a ...
Jacob Thygesen's user avatar
0 votes
1 answer
964 views

the_title() is not displaying over the_thumbnail

With the static html/css title that i have inside h1, is displaying over image, but when i use the_post_thumbnail(); with the_title();. Title moves above the image What may be the issue? <div ...
Viktor's user avatar
  • 173
1 vote
1 answer
54 views

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/...
Gecko Boy's user avatar
-1 votes
2 answers
51 views

Bug with post titles [closed]

My post titles are displaying the title of the media (image) rather than the title of the post. WP V4.8 using postgrid for posts; deactivated this, issue still occurs deactivated current theme; ...
jmiller's user avatar
  • 101
0 votes
1 answer
443 views

Customise the_title in admin area

Experienced in PHP but new to WordPress, so excuse me if I'm not calling things the right things. Basically my set up is that I want the pages to be called one thing in the admin area for ease of ...
rickibarnes's user avatar
0 votes
1 answer
7k views

How to add dynamic content in title and meta description in wordpress theme for homepage, post page, category, tag and pages

I am creating wordpress theme and want to get and display dynamic content for my theme Title Tag and Meta Description Tag. For Title Tag Content: I want Title For Meta Description: I want Bloginfo('...
Master Prons's user avatar
1 vote
2 answers
3k views

get_title without filter(the_title)

I'm using a function to filter the_title, adding a string onto the end, but would also like to return the original title, unfiltered on the same page. Is there a way to get the title without it being ...
Kevin Nugent's user avatar