如何在wordpress主题设置面板中使用preg_replace来获取帖子标题或标签

I don't understand how do you use the preg_replace command in php

I created a text area in theme settings panel to display a default description for every post and would be nice if I can mix the description using {tags} or {title} to grab the post title or post tags.

I have tried using the following code but got some errors.

description code

$description = get_post_meta($post->ID, 'field_description', true); if(!empty($description)) {

$seo_desc = get_option('mytheme_seo_description');

echo $description; 

} else if(!empty($seo_desc)) {

echo $seo_desc;

setting panel

$options[] = array( "name" => __('SEO DESCRIPTION','mytheme'),
"desc" => __('Mix {title} {tags} {categories} in a default description to grab post title, tags and categories','mytheme'),
"id" => $shortname."_seo_description",
"std" => "",
"type" => "textarea");

Is it possible to use {title} {tags} {categories} for grabbing the post title,tags and categories using any function?

Anyway I just got it using str_replace

$description = get_post_meta($post->ID, 'field_description', true);
if(!empty($description)) {

$seo_desc = get_option('mytheme_seo_description');
$seo_desc = str_replace("{title}", $post->post_title, $seo_desc);
echo $description; 

} else if(!empty($seo_desc)) {

echo $seo_desc;

I was using the wrong variable but it was just a pice of code

 $seo_desc = str_replace("{title}", $post->post_title, $seo_desc);

So now I can use {title} in textarea in the theme settings panel to get the post title thanks for all

You could write some shortcodes to do that. The only difference is that it will target [title/tags/etc] instead of {title/tags/etc} and it should be able to parse them automatically if they are used.