php - How to format $output the right way? -
i not know php, googling codes, , came on need in wordpress site. code shows nothing, neither brokes site, think not correct can me. here code:
$output.= '<div class="column1">' $categories = get_the_category(); $separator = ' '; $output = ''; if($categories) { $output .= '<div class="above-entry-meta"><span class="cat-links">'; foreach($categories $category) { $output .= '<a href="'.get_category_link( $category->term_id ).'" rel="category tag">'.$category->cat_name.'</a>'.$separator; } } $output .='</span></div>'; $output.= '</div> <!-- end column1 -->';
i want output current post categories via shortcode, , 1 part of same. need on how goes example, ll able continue codding following example.
try code
$output = ''; $output .= '<div class="column1">'; $args = array( 'orderby' => 'count', 'order' => 'desc', 'number' => 5 ); $categories = get_the_category($args); $separator = ' '; if($categories) { $output .= '<div class="above-entry-meta"><span class="cat-links">'; foreach($categories $category) { $output .= '<a href="'.get_category_link( $category->term_id ).'" rel="category tag">'.$category->cat_name.'</a>'.$separator; } } $output .='</span></div>'; $output.= '</div> <!-- end column1 -->';
Comments
Post a Comment