howto display category name instead of slug
-
Hi folks
recently I add new theme to my site with options (control panel).
this theme has multible content displaying methods, I have issue with these since I am not good enough in php
and I looking for someone to help me to figure out
the primary issue that my theme depand on slug not category name, my theme option.php look like something like this<?php $shortname = "op"; $default_colorscheme = "Default"; $cats_array = get_categories('hide_empty=0'); $pages_array = get_pages('hide_empty=0'); $site_pages = array(); $site_cats = array(); foreach ($pages_array as $pagg) { $site_pages[$pagg->ID] = htmlspecialchars($pagg->post_title); $pages_ids[] = $pagg->ID; } foreach ($cats_array as $categs) { $site_cats[$categs->cat_ID] = $categs->cat_name; $cats_ids[] = $categs->cat_ID; } $op_categories_obj = get_categories('hide_empty=1'); $op_categories = array(); foreach ($op_categories_obj as $op_cat) { $op_categories[$op_cat->cat_ID] = $op_cat->category_nicename; } $categories_tmp = array_unshift($op_categories, "اختر تصنيفاً:"); $effects = array("fade", "slideRandom", "overRandom", "slideUp", "slideRight", "slideDown", "slideLeft", "overUp", "overRight", "overDown", "overLeft", "none"); $options = array ( ... ... array( "name" => "Content category one", "desc" => "Select the category for first content category.", "id" => $shortname."_content_cat_one", "std" => "Select a category:", "type" => "select", "options" => $op_categories), array( "name" => "Number of posts in the first category", "desc" => "Select number of posts in the first category.", "id" => $shortname."_content_number_one", "type" => "select", "options" => array('1','2','3','4','5','6','7','8','9','10')), array( "name" => "Layout to posts for the first category", "desc" => "Select the layout to posts for the first category.", "id" => $shortname."_content_layout_one", "std" => "One big and three small posts", "type" => "select", "options" => array('First post with bottom content and the rest small posts','First post full width','All posts with bottom content','All posts with right content','Small posts with right content')), ... ...
and the output home_content.php file look something like this
<div id="home_category_content"> <?php if (get_option('op_content_one') == 'on') { ?> <div class="home_category_posts"> <?php $featucat = get_option('op_content_cat_one'); $numbercatposts = get_option('op_content_number_one'); $my_query = new WP_Query('showposts='. $numbercatposts .'&category_name='. $featucat .''); if ($my_query->have_posts()) : $i = 0; ?> <?php print '<div class="home_cat_line"><h2>'.$op_content_cat_one.'</h2><span></span></div>';?>
my problem is the variable $op_content_cat_one return the category nicename (slug) and I want to get category name.
so will you please help me with thisTIA
SaFi
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘howto display category name instead of slug’ is closed to new replies.