Host Unlimited Web Sites for Only $10 per Month! 东道国无限的网站只有10元,每月!
Powered by MaxBlogPress 由maxblogpress

很容易的WordPress主题哈克:显示类别图片| jtpratt的博客失误
jtpratt的博客失误


Home » Very Easy Wordpress Theme Hack: Show Category Images »很容易的WordPress主题哈克:显示类图像



Posted in: 张贴在:

博客安装类的形象博客-错误类的形象在WordPress类的形象
4,864 views 4864的意见


Please note: This page was originally written in English.请注意:此页中,原本以英文书写。

The original post can be viewed原来的文章可以看 here这里 .

Please note: This page was originally written in English.

The text has been translated using an online service such as Google or Babelfish.

The original post can be viewed here.


I’m going to show you how to add some simple PHP code to your Wordpress template and make linked images appear instead of text for your categories in posts.我要告诉您如何添加一些简单的PHP代码到您的WordPress模板,使联系图片显示的文字,而是为您的类别的职位。 All you need to know is simple PHP, some basic HTML, and how to make your own graphics.所有您需要知道的是简单的PHP中,一些基本的HTML ,以及如何使自己的图形。

**UPDATE** May 2008 **更新** 2008年5月
As the last comment at the end of this page shows there is now a作为最后的评论在本月底页显示现在是一 Category Icons Wordpress Plugin 类别图标wordpress插件 you can download to install to manage your category icons right in your dashboard.您也可以下载安装到管理您的类别图标的权利,在您的控制台。 If you prefer to hack your theme, the code below will work just fine!如果您喜欢哈克您的主题,下面的代码将工作只是罚款! The cool thing about the plugin is that they give you ways to do one or multiple category icons, but also a methods for putting icons with your categories in the side bar as well!冷静的事,关于插件的是,他们给你如何做一个或多个类别的图标,但也是一个方法,把图标与您的类别在一边,大律师公会,以及! I’m always very grateful when a good plugin come along!我一直非常感激,当一个很好的插件来! Now back to the original post…现在回到原来的职位…

Have you ever wanted to hack Wordpress and just make it do something you always wanted it to do?您是否曾经想入侵的WordPress和公正,使做点事你总是希望它做什么呢? I think of things I want it to do all the time but don’t always have the hours to devote to finding the answer.我认为对的事情,我想它做的所有的时间,但并不总是有时间投入到寻找答案。 I’ve searched for PHP code snippets for Wordpress and tutorials and how-to articles as well and haven’t seen much that really helped me.我已经搜查PHP代码的片段内容,在WordPress和教程和如何使用的文章,以及和没有看过太多真的帮了我。 Until today - when I read直到今天-当我看到 the tutorial page at WPDesigner today补习页wpdesigner今天 . I didn’t get exactly the code I needed, but pretty close.我并没有得到完全的代码我需要,但相当接近。 I just needed to hack it a bit to get it to do what I wanted.我只是需要开刀,这一点得到它做什么我想。

First, this Wordpress tutorial hack assumes a few things.第一,这在WordPress补习哈克上台几件事。

  1. You’ve modified your Wordpress template code before您修改了您的WordPress模板代码之前,
  2. You can modify simple PHP您可以修改简单的PHP
  3. You can write simple HTML你可以写简单的HTML
  4. You can make your own graphics你可以作出自己的图形

First things first - here’s the code:第一件事第一-这里的代码如下:

 <h3><b>Posted in:</b></h3> <?php foreach((get_the_category()) as $cat)  {  $catname =$cat->category_nicename;  echo "<a href\"/category/";  echo $catname;  echo "/\">";  echo "<img src\"/wp-content/cat-icons/";  echo $catname;  echo ".png\" alt=\"$catname category image\" border=\"0\" /></a>\n";  } ?><br /> <h3>快来的<b>张贴在: < / b > < / H3的> < ? PHP的foreach ( ( get_the_category ( ) )作为元,猫) ( $ catname = $猫“ -> c ategory_nicename;回声” <一h ref\ “ /类别/ “ ;回声元catname ;回声” / \ “ > ” ;回声“ <国际管理集团钢骨混凝土\ ” / wp-content/cat-icons / “ ;回声元catname ;回声” 。巴纽\ “按Alt = \ ” $ catname类形象\ “边境= \ ”零\ “ / > < /一> \ n ” ; ) ? > <br /> 

I hacked this code from this tutorial page on WPdesigner i砍死此代码从本教程的网页wpdesigner . The code they had was only good to display one category per post.该守则,他们只是很好的展示一类%后。 I hacked it because my blogs all have posts assigned to multiple categories. i砍死的,因为我的Blog都有职位分配给多个类别。 Also, I wanted the images to all be linked so people can just click them and go right to that category page.此外,我希望所有的图像联系起来,以便人们可以,只要按一下他们走的权利,这一类的网页。 Let’s look at the pieces of this code you might need to modify.让我们看看在这件代码,您可能需要修改。

In line 1, you might want change “Posted in:” to alternate text like “Filed under:”, etc.在1号线,您可能会想要改变“张贴在: ”以替代文字一样, “提起下: ”等。

In line 5, if your permalink structure is different than the default, you may need to change /category/ to what you are using.在5号线,如果您的永久结构是不同的,比默认情况下,您可能需要变更/类别/什么您所使用的。

In line 8 change /wp-content/cat-icons/ to wherever you will be storing your category icons in your site.在8号线变更/ wp-content/cat-icons /您在何处,将储存您的图象类别,在您的网站。

In line 10, if you are using gif’s or jpg’s change .png to your graphic file format.在第10行,如果您正在使用的GIF的或JPG的改变。巴纽到您的图形文件格式。

Now all you have to do is create one image for every category you have an place them in the folder you just created on the server.现在,所有您需要做的就是建立一个形象,每一个类你有一个地方,他们在该文件夹中您刚刚创建的服务器上。 Make sure that the graphics are named exactly as your categories, and if your categories have multiple words just add a hyphen in between each word.作出肯定的是,图形命名,正是由于您的类别,如果您的类别有多个的话只是添加一个连字符之间的每个字。 That’s it!这样就大功告成了! All you have to decide now is where you want these category icons to appear, before or after your post - and add them into the appropriate place.所有你必须决定,现在是您想要这些类别的图标出现,之前或之后,您的帖子-并将它们添加到适当的地方。 I placed mine just after the title of the post on my single post pages - as you can see at the top of the post on this page. i放在煤矿刚刚结束的标题后对我的单后的页面-你可以看到在顶部的职位在此页中。 You can hack this category icon code a hundred other ways to do what you want.您可以哈克这一类的图标代码100其他的方法可以做到你想要的。 I think in the future I’m going to use it to replace the text category links in my sidebar.我认为在未来的,我会用它来取代文本分类链接在我的工具栏。 The only caveat to this (and the code hack above) would be the fact that if you don’t have an image a text link will display (in FF, or broken image in IE).唯一的警告,这(和代码哈克以上)将成为事实,就是如果你没有一个形象的文本链接将显示(在FF ,或破碎的形象,在IE ) 。 So - if you create new categories in the future, make sure you create a new image for each.所以-如果您创建新的类别在未来的日子,请务必建立一个新的形象,为每个。

My Blogging Mistake for this post is that I didn’t decide to customize and hack my Wordpress Theme before now to create my own layout.我的博客错误,这个职位是,我并没有决定要自定义和哈克我的WordPress的主题之前,现在创建自己的布局。 Do you have a question or a new way to hack up this wordpress category icon PHP code?你有问题或一条新的途径哈克这在WordPress类图标的PHP代码? Comments and post it now!评论和邮政现在!


18 Responses to “Very Easy Wordpress Theme Hack: Show Category Images” 18的反应“是很容易的WordPress主题哈克:显示类的图片”

  1. The Smorgasbord 该smorgasbord Has the following to say...有下列说...

    This was very easy to do - thanks for the code and the tip!这是很容易的事-感谢守则及提示!

    The Smorgasbord’s last blog post.. 该smorgasbord的最后的博客帖子.. Convert Vinyl Records to MP3 转换乙烯基纪录的MP3

  2. 50 tips y trucos para optimizar Blogger y WP | Blog en Serio 50秘诀y trucos第optimizar的Blogger y可湿性粉剂|博客恩serio Has the following to say...有下列说...

    [...] Imágenes para las categorías [...] [ … … ] ,图片搜索第拉斯维加斯类别[ … … ]

  3. Blogbuster: блоги, blogs, blogging, RSS, Wordpress, социальное blogbuster : блоги ,博客,博客的RSS ,在WordPress , социальное Has the following to say...有下列说...

    25 неотстойных хаков для WordPress 25 неотстойных хаков для的WordPress

    Динамическое слайдшоу в шапке — позволяет крутить картинки в шапке вашего блока, придает динамику; демоверсия. динамическое слайдшоу в шапке -п озволяетк рутитьк артинкив ш апкев ашегоб лока, п ридаетд инамику; д емоверсия。
    Пузырь комментариев — гр… пузырь комментариев -г р…

  4. 25 hacks para dinamizar seu Wordpress! 25骇客第dinamizar请输入您的WordPress ! — Bytes a Go-go! -字节一去! Has the following to say...有下列说...

    [...] Imagens para categorias. [ … … ]图片第类别。 Adiciona imagens para cada categoria do seu blog e são mostradas no post se você preferir. adiciona图片第在无法种类做请输入您的博客e圣保罗mostradas没有邮政本身左侧preferir 。 [...] [ … … ]

  5. Blog Verde » 25 Hacks pra dinamizar o Wordpress 博客佛得角» 25骇客的PRA dinamizar o在WordPress Has the following to say...有下列说...

    [...] Imagens para categorias. [ … … ]图片第类别。 Adiciona imagens para cada categoria do seu blog e são mostradas no post se você preferir. adiciona图片第在无法种类做请输入您的博客e圣保罗mostradas没有邮政本身左侧preferir 。 [...] [ … … ]

  6. 63 Essential Wordpress Hacks, Tutorials, Help Files and Cheats | Speckyboy - Wordpress and Design 63 WordPress所必需的技巧,指南,帮助文件和作弊| speckyboy -在W ordPress和设计 Has the following to say...有下列说...

    [...] Show Category Images (Source: [...] [ … … ]显示类图像(资料来源: [ … … ]

  7. 63 essenziali Wordpress Hacks, Tutorials, Help Files e Cheats : technorati.it 63 essenziali的WordPress的窍门,教程,帮助文件e作弊: technorati.it Has the following to say...有下列说...

    [...] Show Category Images (Source: [...] [ … … ]显示类图像(资料来源: [ … … ]

  8. Wordpress Tutorials/Hacks « The house of software freeware 在WordPress教程/骇客«众议院软件免费 Has the following to say...有下列说...

    [...] Show Category Images (Source: [...] [ … … ]显示类图像(资料来源: [ … … ]

  9. Mastering Your WordPress Theme Hacks and Techniques 掌握您的WordPress主题的窍门和技巧 Has the following to say...有下列说...

    [...] 10)Show Category Images- How to add some simple PHP code to your WordPress template and make linked images appear instead of text for your categories in posts. [ … … ] 10 )显示类图像-如何添加一些简单的P HP代码到您的W ordPress模板,使联系图片显示的文字,而是为您的类别的职位。 [...] [ … … ]

  10. letrodectus letrodectus Has the following to say...有下列说...

    Great hack!伟大的黑客! thanks谢谢 =

  11. 63 Essential Wordpress Hacks, Tutorials, Help Files and Cheats | Speckyboy - Wordpress and Design » 쟈스민(JASMIN) 63 WordPress所必需的技巧,指南,帮助文件和作弊| speckyboy -在W ordPress和设计» 쟈 스 민 ( j asmin) Has the following to say...有下列说...

    [...] Show Category Images (Source: [...] [ … … ]显示类图像(资料来源: [ … … ]

  12. paidnetpedia.com paidnetpedia.com Has the following to say...有下列说...

    [...] sticky”- When we need to have certain articles ’stay at the top’ longer than others. [ … … ]粘“ -当我们需要有一定的文章'留在顶端'的时间比别人。 10)Show Category Images- How to add some simple PHP code to your WordPress template and make linked images appear instead [...] 10 )显示类图像-如何添加一些简单的P HP代码到您的W ordPress模板,使联系的图片出现,而是[ … … ]

  13. Submarine 潜艇 Has the following to say...有下列说...

    Hi

    here is a plugin that do the job :这里是一个插件这样的工作:

    Category Icons Plugin类别图标插件 .

  14. Remkus remkus Has the following to say...有下列说...

    That is a very nice Hack!这是一个很好的黑客! I realize there is a plugin now, but I think I am going to just edit this in one of my projects.我知道有一个插件现在,但我觉得我要刚才编辑这在我的一个项目。 Thanks for writing it down!感谢写作!

  15. What is Category Icons ? 什么是类的图标? « Category Icons «类图标 Has the following to say...有下列说...

    [...] : JTPRATT’s Blogging Mistakes ( here & here ), Performancing Helping Bloggers [...] [ … … ] : jtpratt的博客的错误(在这里&这里) , performancing帮助博客[ … … ]

  16. 155 Wordpress Resources, Tutorials, Plugins, Themes, AJAX, Podcasting…WP Monster List | Speckyboy - Wordpress and Design 155的WordPress资源,教程,插件,主题,阿贾克斯,播客…可湿性粉剂怪物列表| speckyboy -在W ordPress和设计 Has the following to say...有下列说...

    [...] 84. [ … … ] 84 。 No More CSS Hacks.没有更多的CSS技巧。 85. 85 。 Create a Dynamic Sticky.创建动态棘手。 86. 86 。 Styling Individual Posts Using the_ID.造型个别职位,使用the_id 。 87. 87 。 Show Category Images.显示类的图片。 88. 88 。 Separate WordPress Comments and Trackbacks.单独的WordPress的评论和trackbacks 。 89. 89 。 Customize your WordPress Login.自定义您的WordPress登录。 90. 90 。 Date Image [...]日期形象[ … … ]

  17. 155个 WordPress 资源、指导、插件、主题、AJAX、播客…… —— WP 详细清单(译) | 晴天里的一道�… 155个在WordPress资源,指导,插件,主题,阿贾克斯,播客… … -可湿性粉剂详细清单(译) |晴天里的一道… Has the following to say...有下列说...

    [...] 84. [ … … ] 84 。 No More CSS Hacks 85.没有更多的CSS技巧85 。 Create a Dynamic Sticky 86.创建动态粘86 。 Styling Individual Posts Using the_ID 87.造型个别职位,使用the_id 87 。 Show Category Images 88.显示类图像88 。 Separate WordPress Comments and Trackbacks 89.单独的WordPress的评论和trackbacks 89 。 Customize your WordPress Login 90.自定义您的WordPress登录90 。 Date Image [...]日期形象[ … … ]

  18. 155个 WordPress 资源、指导、插件、主题、AJAX、播客…… —— WP 详细清单 | Awesomer 155个在WordPress资源,指导,插件,主题,阿贾克斯,播客… … -可湿性粉剂详细清单| a wesomer Has the following to say...有下列说...

    [...] Hacks84. [ … … ] hacks84 。 No More CSS Hacks85.没有更多的CSS hacks85 。 Create a Dynamic Sticky86.创建动态sticky86 。 Styling Individual Posts Using the_ID87.造型个别职位,使用the_id87 。 Show Category Images88.显示类images88 。 Separate WordPress Comments and Trackbacks89.单独的WordPress的意见和trackbacks89 。 Customize your WordPress Login90.自定义您的WordPress login90 。 Date Image [...]日期形象[ … … ]

Question or Comment??问题或意见吗? Spill it Now...溢漏,现在...

跳跃的喜悦,为超过评论!

We Reward Comments!我们悬赏的评论!


We dofollow links, and get your latest blog post as a byline under every new comment from the "CommentLuv" plugin!我们dofollow联系,并获得最新的博客帖子作为一个署名下,每一个新的评论从“ commentluv ”插件! Top commenters for every month are listed on every page of this site in a sidebar widget linked back to your URL!顶端提意见,每一个月中列出的每一页上这个网站,在工具栏的小装置相连回到您的网址! We would like to reward you for becoming part of our community!我们想奖励你的一部分,成为我们的社会! Your comment is valuable not only to us, but also all the other readers of this blog!您的评论是有价值的,不仅给我们,而且所有其他的读者,这博客!


Click to add smilies to your post! 按一下以新增的笑脸到您的帖子! == [ ]^ = (= ( (= ( |= )规例= | 8= 0= ) 〜= 00= (= ; ;= ) ]= ; ; ;