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:
get_post_meta( $post_id, $key, $single );
Explanation…
$post_id:
To get post id you can use:
global $post;
$post_id = $post->ID;
$key:
$key = “_aioseop_title”; //check if plugin is using same name for title field
$single:
$single = true; // if true then it will return single value otherwise all values of _aioseop_title in an array.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With