Jump to content
Sign in to follow this  
rpacker

Displaying Category Description

Recommended Posts

rpacker

Which base template is used to insert the following code in order to display a category description and is there a particular location to place the code? <?php echo category_description(); ?>


Randall Packer

Multimedia Artist & Educator

http://www.randallpacker.com

Share this post


Link to post
Share on other sites
Danny
Hi Randall, I think you may need to add this as a hook in functions.php, I'm so so with hooks, so as much as I hate to pass the book, I think it would be best to wait for Catrina or Kastelic to answer your question (sorry guys) :D

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
rpacker
@Catrina and @Kastelic: I welcome any solutions for displaying category descriptions. Thanks!

Randall Packer

Multimedia Artist & Educator

http://www.randallpacker.com

Share this post


Link to post
Share on other sites
rpacker
It turns out someone got this working: in iBlogPro, and I tried the exact same placement of the code in the sections.postsinfo.php template, but it didn't work.

Randall Packer

Multimedia Artist & Educator

http://www.randallpacker.com

Share this post


Link to post
Share on other sites
Rob
Russell, as Danny suggested, it may be best to wait till Catrina or Kastelic are available.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
kastelic
The simplest way to add a line of code is indeed using a hook, and by adding the code in platformbase/functions.php (anywhere after the first couple lines setting things up will do). You need to have the base child theme activated for this to work. Here is an example: [code] ///CATEGORY DESCRIPTION add_action('pagelines_inside_top_maincontent','category_intro'); function category_intro(){ if (is_category()) { echo category_description(); } } [/code] The "add_action" adds the function to the page, the first parameter being the "hook" that you want to use which determines the location on the page (pagelines_inside_top_maincontent), and the second parameter (category_intro) being the particular function or chunk of code you want to execute there. Below that you have the function itself which as you can see, has the name of the second parameter of the "add_action" line. First, it is using an if statement to determine if it is a category page. You can omit this if you are displaying the category description of a specific id, rather than the current one, which is default. See http://codex.wordpress.org/Function_Reference/category_description for more details on this. Note also that you don't need to enclose your line in "" tags since you are already in withing php tags just by being in functions.php. The hook that you use can be adjusted to whatever you need it to be. At the bottom of this post i have provided a partial list of hooks. Note that not every hook appears on every page, it depends on which sections you have active and so on. Another thing to make sure of is that you actually have a description filled out for each of your categories by clicking Posts -> Categories and the Edit under a category title. Finally, the function category_description() is meant to appear on a category page (which is an "posts" page of a certain category.) If you want to display it on any other type of page you have to enter the id either manually or with a variable. If you want to test to be sure that your function is working at all do this: [code] ///CATEGORY DESCRIPTION add_action('pagelines_inside_top_maincontent','category_intro'); function category_intro(){ echo "test"; } [/code] Partial list of hooks: [code] HEADER pagelines_before_html pagelines_head pagelines_before_site pagelines_before_page before_header pagelines_before_main BRANDING pagelines_before_branding pagelines_inside_top_branding pagelines_inside_bottom_branding pagelines_after_branding pagelines_before_branding_icons pagelines_branding_icons_start pagelines_branding_icons_end pagelines_after_branding_wrap NAVIGATION pagelines_before_primary-nav pagelines_inside_top_primary-nav pagelines_inside_bottom_primary-nav pagelines_after_primary-nav SECONDARY NAV pagelines_before_secondnav pagelines_inside_top_secondnav pagelines_inside_bottom_secondnav pagelines_after_secondnav CONTENT pagelines_before_maincontent pagelines_inside_top_maincontent pagelines_inside_bottom_maincontent pagelines_after_maincontent pagelines_before_columns pagelines_before_maincolumn pagelines_before_sidebar1 pagelines_after_sidebar1 MAIN CONTENT pagelines_before_theloop pagelines_inside_top_theloop pagelines_inside_bottom_theloop pagelines_after_theloop POSTLOOP pagelines_loop_post_start pagelines_loop_page_title_after pagelines_loop_post_header_start pagelines_before_excerpt // 1.5.1 pagelines_after_excerpt pagelines_loop_before_post_content pagelines_loop_after_post_content pagelines_loop_post_end pagelines_loop_clipbox_start pagelines_loop_clip_start pagelines_loop_clip_excerpt_end pagelines_loop_clip_end pagelines_loop_clipbox_end COMMENT FORM pagelines_before_pl_comments pagelines_inside_top_pl_comments pagelines_inside_bottom_pl_comments pagelines_after_pl_comments POST NAVIGATION pagelines_before_postnav pagelines_inside_top_postnav pagelines_inside_bottom_postnav pagelines_after_postnav POST AUTHOR INFORMATION pagelines_before_postauthor pagelines_inside_top_postauthor pagelines_inside_bottom_postauthor pagelines_after_postauthor POSTS INFO pagelines_before_postsinfo pagelines__inside_top_postsinfo pagelines_inside_bottom_postsinfo pagelines_after_postsinfo CONTENT SHARING TOOL pagelines_before_sharebar pagelines_inside_top_sharebar pagelines_inside_bottom_sharebar pagelines_after_sharebar [/code]

Share this post


Link to post
Share on other sites
rpacker
That worked beautifully, thanks! A related question: the text seems to carry the same style as a post entry. Is there any way to change the text size, color, etc.?

Randall Packer

Multimedia Artist & Educator

http://www.randallpacker.com

Share this post


Link to post
Share on other sites
Rob
You can use Firebug for Firefox to identify CSS that you can test and write working code.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×