| 
	wordpress自定义文章类型的文章固定链接结构默认是http://域名/post_type/post_name/格式,比如自定义文章类型是product,那么文章URL就是http://域名/product/文章别名/,如果想要把固定链接更改为http://域名/post_type/post_id.html的格式怎么办?因为wordpress并没有在后台提供自定义文章类型的固定链接设置,因此需要通过代码或插件实现。 
	1、以product自定义文章类型为例,在当前主题的functions.php文件中添加以下代码: 
	add_filter('post_type_link', 'custom_product_link', 1, 3); 
	function custom_product_link( $link, $post = 0 ){ 
	    if ( $post->post_type == 'product' ){ 
	        return home_url( 'product/' . $post->ID .'.html' ); 
	    } else { 
	        return $link; 
	    } 
	} 
	add_action( 'init', 'product_rewrites_init' ); 
	function product_rewrites_init(){ 
	    add_rewrite_rule( 
	        'product/([0-9]+)?.html$', 
	        'index.php?post_type=product&p=$matches[1]', 
	        'top' ); 
	    add_rewrite_rule( 
	        'product/([0-9]+)?.html/comment-page-([0-9]{1,})$', 
	        'index.php?post_type=product&p=$matches[1]&cpage=$matches[2]', 
	        'top' 
	        ); 
	} 
	提示:请把代码中的product替换为自己的自定义文章类型。 
	2、添加好代码后,进入网站后台——设置——固定链接,点击“保存更改”后,修改生效,如果不点击保存更改是不会生效的。(责任编辑:最模板) | 



 Indigo简洁大气商城 Magent
							人气:570
							Indigo简洁大气商城 Magent
							人气:570
						 火红大气模板之shopex免费
							人气:3884
							火红大气模板之shopex免费
							人气:3884
						 shopex仿m18麦考林模板
							人气:411
							shopex仿m18麦考林模板
							人气:411
						 ecshop精仿okbuy好乐买2012免
							人气:3624
							ecshop精仿okbuy好乐买2012免
							人气:3624
						 ecshop成人用品仿爱之谷2
							人气:1462
							ecshop成人用品仿爱之谷2
							人气:1462
						 ecshop仿万表网2014网店模板
							人气:941
							ecshop仿万表网2014网店模板
							人气:941