Chinaunix首页 | 论坛 | 博客
  • 博客访问: 575841
  • 博文数量: 207
  • 博客积分: 10128
  • 博客等级: 上将
  • 技术积分: 2440
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-10 21:40
文章分类

全部博文(207)

文章存档

2009年(200)

2008年(7)

我的朋友

分类: 系统运维

2009-04-29 13:50:05

Using Custom Fields to Display Post Thumbnails



One of the most interesting features in WordPress is using Custom Fields, which can turn your WordPress blog into a fully customizable CMS website. I use custom fields to create image thumbnail for each post here on Noupe and on Devsnippets as well and display the thumbnails on the home page and the Archive page.

Follow the steps below and you will get it ready

  1. You need to be able to upload images to your server in order to do this. You can do this using your FTP Client or any WordPress plugins to help you upload your images through the admin area.
  2. Open a new post and scroll all the way down to the bottom where it says Custom Fields. Click on the plus button to expand it.
  3. Enter the word “image_thumb” in the “key” field, and enter the fill path of the image that you uploaded in the “Value” field.
  4. Do what you usually do in every post: add title, post text, choose a category and publish.
  5. Now open your index.php file that is in your current theme folder, search for this line:
  6. Add the following code above that line
    
    " alt="" />
    
    

Other great Solutions

Avoiding Duplicate Content

Duplicate content refers to two or more web pages that have the same, or almost the same, content. We must avoid duplicate content to not get penalized by search engines. But sometimes we need to show two (or more) lists of posts on one page, we usually do this by using (one standard loop and one from a certain category). This is done when you want to feature not only the very latest post written, but also posts from a certain category.

have_posts()) : $my_query->the_post();
  $do_not_duplicate = $post->ID;?>
    
  
    
  ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
   
  

Other Solutions

Login Box in your sidebar



When i was designing DevSnippets, i wanted the users to easily login through the front page and skip the login page. Many solutions are out there and i found a good one at , i will add the code here just in case we don’t find it in the future.

                
  • Control panel

    Identification

  • Of course later i wanted to make it even more easier and prettier to register and login through the front page and skip the login and register pages, so we coded a small widget using Prototype to switch between the login and registration box all on the front page. I will write a tutorial about this very soon.

    Creating a menu Showing Certain Categories



    If you would like to have a menu like the one we have here at noupe, to show certain categories, just add the line of code below and style it as you wish.

    The template tag, , displays a list of Categories as links. You can Include or Exclude Categories as you wish, just enter the category id and don’t forget to add the “include” or the “exclude” parameters to manage it.

    By default, wp_list_categories() generates nested unordered lists (ul) within a single list item (li) titled “Categories”. You can style that list item with a CSS selector.

    Other great Solutions

    • - This tutorial will explain how to create a horizontal menu bar showing the main categories and sub menus showing the sub-categories using CSS and javascript.


    • - The plugin generates the code necessary to create a Son of Suckerfish horizontal dropdown, vertical flyout or horizontal slider menu. You have control over what items (pages, categories, archives, blogroll etc.) appear in your dropdown via the plugins options page.

    Display Categories in a Dropdown box

    Sometimes you want to displays a list of categories in a select (i.e dropdown) box with no submit button. The easiest way to do this is use the template tag.

    ]*)>#", "", $select); echo $select; ?>

    Most Wanted Posts and Categories hacks

    How to exclude certain categories from being displayed in the loop.

    
    
    • The main goal of this plugin is to enhance WordPress’s functionalities by hiding some unwanted categories, from defined parts of the blog like: your search results, your RSS feed listing, your category listing, and also your entry page, if you want to.

    How to display posts from a certain category

    If you want to display certain posts from a certain category like the one i am using for the news section on Devsnippets.

    Post Author Related Solutions

    Having multiple authors on your blog is really fun, we need to have good solutions to have nice custom author pages, show their latest posts, highlight author Comments in WordPress posts, show their avatars and author bio below every post.

    Getting Author Page on your WordPress blog

    By default WordPress will use the author.php then the archive.php file then your index.php file to display the author info. That is, if you do not have an author.php file, WordPress will check for archive.php, and so on.

    So, if you want to change the look of your author pages, you need to create an author.php file if it doesn’t exist, by copying archive.php if that file exists, or index.php if it doesn’t.

    If you want to show the author’s main website, email contact, and biography, helping readers learn more about the author.

    Articles by 
    Author Website: 
    Author Email: 
    Author Bio: 
    

    Solution

    Display Author Bio below each Post

    If you want to have that handy little author bio box at the top of the article with an author photo, you can do the following:



    Solution

    • - How to put together a very basic “About the Author” section on your single posts and show a gravatars for every author.

    Separate Author comments from other comments

    When you have multiple authors on your blog, you will need to style the author comments differently, here is how you can do it:

  • comment_author_email == "anotherauthorname@domain.com") echo 'author2'; else if ($comment->comment_author_email == "thirdauthorname@domain.com") echo 'author3'; else echo $oddcomment; ?> item" id="comment-">
  • Display Twitter Messages on your blog

    If you want to display your Twitter status on your blog instead of using Twitter-hosted scripts to save loading time.

    How to

    • - Twitter Tools is a plugin that creates a complete integration between your WordPress blog and your Twitter account.
    • - This plugin allows you to pull in an rss feed from your twitter account and display it on your site.
    阅读(1923) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~