Solved

Outputting Just The Category Name Using  Exisiting Function

Posted on 2007-04-04
3
169 Views
Last Modified: 2013-12-12
I'm new to PHP (from ColdFusion) and am looking to output JUST the Category within a modified template design.  Is there a function I can use to do that?  the_category() returns the category name with the built in link to the catgeory.  I just need the category name outputted.

If there is no function, can someone help me write one?

500 points to the person who can help me learn a little about PHP and WordPress.

Thanks.

Phil
0
Comment
Question by:SiriusPhil
  • 2
3 Comments
 

Author Comment

by:SiriusPhil
ID: 18852651
By The Way... I'm running WordPress 2.1.
0
 
LVL 10

Accepted Solution

by:
Chris_Gralike earned 500 total points
ID: 18853473
Can you give us an example of the function you are trying to alter?

I dont know much about wordpress so i downloaded it and located the file wich contains the functions. The question now is, wich one do you use in the template?

function get_category_children($id, $before = '/', $after = '') {
}

function get_category_link($category_id) {
}

function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
}

function get_the_category($id = false) {
}

function get_the_category_by_ID($cat_ID) {
}

function get_the_category_list($separator = '', $parents='') {
}

function in_category($category) { // Check if the current post is in the given category
}

function the_category($separator = '', $parents='') {
}

function category_description($category = 0) {
}

function wp_dropdown_categories($args = '') {
}

function wp_list_categories($args = '') {
}

Next it could be nice for the developers here to see the complete code of the function in question. You can find the file in,
wordpress\wp-includes\catagory-template.php

(Be mindfull most include classes that add functionality to the functions displayed in that file)

-regards,
0
 
LVL 10

Expert Comment

by:Chris_Gralike
ID: 18853483
ps the get_the_catagory(); function is the following

function get_the_category($id = false) {
global $post, $category_cache, $blog_id;

      $id = (int) $id;
      if ( !$id )
            $id = (int) $post->ID;

      if ( !isset($category_cache[$blog_id][$id]) )
            update_post_category_cache($id);

      $categories = $category_cache[$blog_id][$id];

      if ( !empty($categories) )
            sort($categories);
      else
            $categories = array();

      return $categories;
}

-Regards,
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now