0

我想在侧边栏中的下面的代码中显示当前类别名称,但我不能。谁能帮我?

谢谢你。

<?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%%&deg; / %%low%%&deg;" numdays="4" iconset="Incredible" class="css_table_class"]'); ?>
4

1 回答 1

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%%&deg; / %%low%%&deg;" numdays="4" iconset="Incredible" class="css_table_class"]');
}
于 2012-06-28T18:15:10.527 回答