如何在WordPress中获得帖子标题? [英] How to get post title in WordPress?

查看:37
本文介绍了如何在WordPress中获得帖子标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 WordPress 网站.所以我编写代码将帖子标题从阿拉伯语转换为英语,但代码从 WordPress 获取帖子标题.

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.

我在一个 SEO 包中使用插件.所以我在每个页面上为插件添加标题,不是帖子标题而是输入标题全部在一个 SEO 包中.

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.

我想获得 All in one SEO 包的标题以进行转换.

I want get the title of All in one SEO pack to convert it.

这是functions.php中转换标题的代码:

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);
}

此代码获取帖子标题,但我需要在一个 SEO 包中获取所有输入中的标题.我该怎么做?

This code get title of post but I need get title in input All in one SEO pack. How can I do that?

推荐答案

很简单 <?php echo get_the_title( $post_id );?>

希望有帮助

这篇关于如何在WordPress中获得帖子标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆