Chinaunix首页 | 论坛 | 博客
  • 博客访问: 341697
  • 博文数量: 71
  • 博客积分: 2129
  • 博客等级: 大尉
  • 技术积分: 835
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-18 16:03
文章分类

全部博文(71)

文章存档

2014年(22)

2013年(18)

2012年(24)

2010年(7)

我的朋友

分类: PHP

2014-03-13 14:48:56

I code a little wordpress plugin to add rich snippets support for breadcrumbs for someone.
1. use jQuery

Paste the following code in a javascript file,such as:cwp-flat-ui-seo.js

    jQuery(function(){   
        jQuery('.breadcrumb').attr({'itemscope':'itemscope','itemtype':''}).find('a').attr({'itemprop':'url'});   
        jQuery('.breadcrumb a').each(function(){   
            var content_in_tag_a=jQuery(this).html();   
            jQuery(this).html('').append(''+content_in_tag_a).prepend('');   
            });   
      
        /*下面的仅仅是测试用的!*/  
        /*alert('aaa');*/  
      
    /*END*/  
    });  

2.PHP code for the plugin

        /*
    **************************************************************************  
    Plugin Name: Coolwp  XXX add-on  
    Plugin URI:  
    Description: 这是一个塑料磁力泵.....  
    Version: 1.0  
    Author: Suifengtec  
    Author URI:  
    Domain Path: /lang/  
    **************************************************************************  
    */  
    define('CWP_PLUGIN_XXX_ADD_ON_VER','1.0');   
    add_action('wp_enqueue_scripts','cwp_flat_ui',999);   
    function cwp_flat_ui(){   
    wp_register_style('cwp-flat-ui', plugins_url('css/css.css', __FILE__) ,false, CWP_PLUGIN_XXX_ADD_ON_VER, 'all' );    //you may ignore this css file
    wp_register_script('cwp-flat-ui-seo', plugins_url('js/cwp-flat-ui-seo.js', __FILE__), array('jquery'),CWP_PLUGIN_XXX_ADD_ON_VER,true);   //it is!
    wp_enqueue_style( 'cwp-flat-ui');   //you may ignore this css file
    wp_enqueue_script('cwp-flat-ui-seo');   //it is!
    }   

Notice: Your breadcrumbs navigation should be wrapped in a div which has a class "breadcrumbs", under normal circumstances is that, if your theme is not in case , you need to modify the selector in the above js code.

Thanks! bear with my poor english.
阅读(1376) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~