I have WordPress site. So I make code to convert title of post to english from arabic but the code get the title of post from WordPress.
I use plugin All in one SEO pack. So I add title to plugin on every page, not title of post but title in input All in one SEO pack.
I want get the title of All in one SEO pack to convert it.
Here is code for convert title in functions.php
:
function arb2en_title($post=0)
{
$text = get_the_title($_aioseop_title);
/*
function arb2en_title($post=0)
{
$text = get_the_title($post);
*/
$arb_en_map=array(
'د'=>']',
'ج'=>'[',
'Ø'=>'p',
'Ø®'=>'o',
'Ù'=>'i',
'ع'=>'u',
'غ'=>'y',
'Ù'=>'t',
'Ù'=>'r',
'Ø«'=>'e',
'ص'=>'w',
'ض'=>'q',
'Ø´'=>'a',
'س'=>'s',
'Ù'=>'d',
'ب'=>'f',
'Ù'=>'g',
'ا'=>'h',
'ت'=>'j',
'Ù'=>'k',
'Ù
'=>'l',
'Ù'=>';',
'Ø·'=>''',
'ظ'=>'/',
'ز'=>'.',
'Ù'=>',',
'Ø©'=>'m',
'Ù'=>'n',
'Ùا'=>'b',
'ر'=>'v',
'ؤ'=>'c',
'Ø¡'=>'x',
'ئ'=>'z',
'Ø¥'=>'Y',
'ÙØ¥'=>'T',
'ÙØ£'=>'G',
'Ø£'=>'H',
'ÙØ¢'=>'B',
'Ø¢'=>'N'
);
foreach($arb_en_map as $key=>$value)
{
$text=preg_replace("/$key/",$value,$text);
}
return htmlentities($text);
}
This code get title of post but I need get title in input All in one SEO pack. How can I do that?
It’s easy
<?php echo get_the_title( $post_id ); ?>
Hope that helps
This is old question but I am answering it because it is appearing in Google search results.
All in one SEO pack use custom fields to store date in database.
Assuming that the custom field name for title field of All in one SEO plugin is â_aioseop_titleâ. (please confirm first if plugin is using custom filed name other than _aioseop_title then replace it with that name).
So to get value of title field of seo plugin use this line of code in your function in functions.php:
Explanationâ¦
$post_id:
To get post id you can use:
$key:
$single:
Ref: https://codex.wordpress.org/Function_Reference/get_post_meta
:: I have not tested it so in case of any problem leave a comment I will be happy to help.