目录
首页 笔记 详情

WordPress 为自定义模型的archive页面增加关键字和描述


WordPress 为自定义模型的archive页面增加关键字和描述

//主题功能支持
function custom_theme_setup()
{

	add_theme_support('title-tag');
}
add_action('after_setup_theme', 'custom_theme_setup');

//关键字和描述
function wp_keywords_description()
{
	$p_tpye = get_post_type();
	//var_dump(get_post_meta(283, 'aiosp_description', true));
	switch ($p_tpye) {
		case "service":
			echo '<meta name="keywords" content="' . get_post_meta(283, '_aioseop_keywords', true) . '">';
			echo '<meta name="description" content="' . get_post_meta(283, '_aioseop_description', true) . '"> ';
			break;
		case "capability":
			echo '<meta name="keywords" content="' . get_post_meta(314, '_aioseop_keywords', true) . '">';
			echo '<meta name="description" content="' . get_post_meta(314, '_aioseop_description', true) . '"> ';
			break;
		case "case":
			echo '<meta name="keywords" content="' . get_post_meta(316, '_aioseop_keywords', true) . '">';
			echo '<meta name="description" content="' . get_post_meta(316, '_aioseop_description', true) . '"> ';
			break;
		case "blog":
			echo '<meta name="keywords" content="' . get_post_meta(312, '_aioseop_keywords', true) . '">';
			echo '<meta name="description" content="' . get_post_meta(312, '_aioseop_description', true) . '"> ';
			break;
		default:
			echo '<meta name="keywords" content="' . get_post_meta(283, '_aioseop_keywords', true) . '">';
			echo '<meta name="description" content="' . get_post_meta(283, '_aioseop_description', true) . '"> ';
	}
}

add_action('wp_head', 'wp_keywords_description', 1);

 


写笔记

咨询

您的电子邮箱地址不会被公开。 必填项已用*标注