我想在侧栏中的下面的代码中显示当前的类别名称,但我不能。任何人都可以帮助我吗?
谢谢。
<?php
$weather_city = the_category_name();
if ($weather_city)
echo do_shortcode('[forecast location="' . $weather_city . ', Greece" caption="" measurement="C" todaylabel="Σήμερα" datelabel="%%weekday%%" highlow="%%high%%° / %%low%%°" numdays="4" iconset="Incredible" class="css_table_class"]'); ?>
答案 0 :(得分:0)
$current_categories = get_the_category(); // array of objects
if (!empty($current_categories)) {
$category = reset($current_categories); // take the first one
$weather_city = $category->cat_name;
echo do_shortcode('[forecast location="' . $weather_city . ', Greece" caption="" measurement="C" todaylabel="Σήμερα" datelabel="%%weekday%%" highlow="%%high%%° / %%low%%°" numdays="4" iconset="Incredible" class="css_table_class"]');
}