Articles of get the title

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 this won’t work in some cases (e.g. on a single page where the_title() is being called inside the navigation to link to the next post. global $post and get_the_ID() will […]

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?

Modifying recent post widget to include icons for post titles

I have downloaded a plugin from the wordpress repository which allows adding font icons to the titles of posts, you can select a different icon for individual posts according to preference. Now, the plugin displays the icon just fine in the post archive template and single post template, but does not show the featured icon […]

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 a string and set it as argument parameter? $arguments = array( ‘tag’ => the_title(), ‘cat’ => […]

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 get_the_title($ID);} ?> </head> but it returns a blank page. However if I only write <?php echo get_the_title($ID); ?> the page come […]

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 get_the_title to display. <?php global $wp_query; if(!$wp_query->post->post_parent){ //no parent $children = wp_list_pages(“title_li=&depth=1&child_of=”.$wp_query->post->ID.”&echo=0″); // will display the […]

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 = get_the_title(); $title_array = explode(‘:’, $title); $first_word = $title_array[1]; echo $first_word; ?> How can I also limit the total length of the […]

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 help. Code in functions.php register_post_type( ‘featured_content’ ); add_action( ‘init’, ‘get_the_js’ ); function get_the_js() { wp_register_script( […]

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 attached to. This is my query: <?php $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => […]

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<?php echo single_post_title(); ?>>Blablabla</a> But it does not work for me if I have a post with a space in it, like Hello World. Then it only shows me Hello in the link. How […]