define('DISALLOW_FILE_EDIT', true); define('DISALLOW_FILE_MODS', true); /dev/head — WordPress text widget with text from post for each category woocommerce

WordPress text widget with text from post for each category woocommerce

How make wordpress text widget with text from post for each category woocommerce?
It's easy!

  • install plugin Enhanced Text Widget;
  • add code in Enhanced Text Widget textarea;
<?php  
function show_text($id)
{
$my_postid = $id;
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content=apply_filters('the_content',$content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}

global $wp_query;
$cat_obj = $wp_query->get_queried_object();

$category_name = $cat_obj->name;

switch($category_name){
case 'Test1': show_text(22);break;
case 'Test2': show_text(23);break;
case 'Test3': show_text(24);break;
case 'Test4': show_text(25);break;
}
?>

Теги: , , ,

Дата: 6 июня 2014

Автор: Аноним

Комментарии: 9