my code must be like that to get page title and add it to my e-mail as a subject
<a href="mailto:[email protected]?subject=<?php echo get_the_title(); ?>&body=BLABLA">LIBNK TEXT</a>
PHP or HTML snippets not working.. It shows php as a basic text.. not get the right value
Is anyone there to help me.. Its a bit urgent
]]>I have been using the All in One Seo plugin for the last 10 years and want to thank you guys for creating such a useful plugin.
Well, I need to access the title that’s been overwritten by the AIOS plugin and so that I can use it instead of get_the_title()
. I want to use it to echo the following tag:
<meta itemprop="headline" content="php /*Print the title of the page here*/ echo get_aios_title();" />
But I don’t know what that function is to call for my requirement.
Please help!
]]>Can you please explain why the get_the_title()
function is empty when called on some sections of the Singular Event page?
To reproduce, activate the Twenty Twenty Theme or its child theme and add the code below to the functions.php file.
add_action( 'wp_body_open', function(){
echo '<h1 style="color: red">' . get_the_title() . '</h1>';
} );
View a single post page and an event page. You’ll see that it renders fine on the post page, but displays nothing (or empty) in the singular event page.
Please clarify or provide a workaround.
Thanks in advance.
Best regards,
Carlos
]]>I am wondering if there is any way I can retrieve a post title which I am in right now in the footer.
For example, if I am in the post “Hello World” I want the footer say “Hello World”. When I am in the post “Hi WordPress” I want the footer say “Hi WordPress”. But I do not want pages to do that too.
Is there any way to do so? Thank you!
(I searched up any maybe it has something to do with “get_the_title”? I have no idea.)
]]>i am using content-product to show a product inside a wordpress post.
Now the product should be related to the post, so I need to get the post title inside the woocommerce product.
When i use get_the_title, the_title … i always get the title of the product, not the post.
Is there a way to get this?
Thanks!
]]>
function add_custom_field_automatically_two($post_ID) {
global $post;
$post_id = $post->ID;
global $wpdb;
//$my_customf = $post->post_title;
//$my_customf = get_the_title( $post_id );
$my_customf = "something string"; // worked, but I need post_title!
add_post_meta($post_ID, 'my_customf', $my_customf, true);
}
add_action('publish_page', 'add_custom_field_automatically_two');
add_action('publish_post', 'add_custom_field_automatically_two');
?>
Thanks
]]>So I found a way to do it by creating a shortcode:
——————————
/* title to get the post title */
function myshortcode_title( ){
return get_the_title();
}
add_shortcode( ‘page_title’, ‘myshortcode_title’ );
This is working excellent for desktop, since I can add html tags to [page_title] such as <h3>[page_title]</h3>
Now, for some strange reason the theme or wordpress is not rendering the shortcode for mobile.
Any ideas?
]]>I am wanting to have a copy of the title in my content, and not simply want to duplicate the the_title (); in single.php, because this does not make the title value available in dasboard, I duplicate the title to have it in my content but available in post edit. have a copy of values of post_title in my post_content
add_filter( 'wp_insert_post_data' , 'get_post_title' , '999', 2 );
function get_post_title( $post_content, $postarr='' ) {
$post_content['post_content'] .= $post_title;
return $post_content;
}
I want to do this in all my posts.
thanks to all.
]]>I am using the Advanced Custom Fields plugin to create custom fields for some custom post types I created. A lot of information needs to pass from one custom post type to the next. What I am working on right now is creating a title from a combination of two other post titles which the user selects in the custom fields.
IE: Select 1 – Select 2 Title
I have the code to do this, and I can even easily pull the post ID of the posts to be used in creating the titles. Here is where I am having a problem, and it may just be that I am too new at php. I want to use get_the_title(); to display the two titles. Currently, my code looks like this:
<?php
$sa_customer_id = the_field('sa_customer'); /* Sets variable to post ID number, ie echo $da_customer_id writes 130*/
$sa_site_id = the_field('sa_site');
get_the_title($sa_customer_id) . " - " . get_the_title($sa_site_id) . " Audit"; ?>
The title displays correctly when I manually place in the post ID’s, but defaults when I use the variables. I realize now, I need to create an object for the variables, but I am at a loss for how to do this. Any help or suggestions would be greatly appreciated!
]]>I’m using the get_template_part() function to get the various parts of templates but I run into a problem using basic functions like get_the_title(), or get_the_id()…I’ve to specify the ID of the page putting the ID as an argument of the function for example: get_the_title(’64’).
Because I’m using the plugin “Advanced custom fields” I’m getting the same problem…I have to declare the ID of the page to get the ACF text fields otherwise I will automatically get the ID of the HOME page.
I can’t even use the get_the_ID() function because this is still returning the ID of the HOME page (the first page?).
Although if I open the single page alone, using the above functions everything works fine and I’m getting the right page ID.
I wonder if there’s any workaround or something that i’m missing!
Thanks.
]]>