<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Taxonomy wordpress Archives - Hi You, I am Tade</title>
	<atom:link href="https://hoangthuc.com/tag/taxonomy-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://hoangthuc.com/tag/taxonomy-wordpress/</link>
	<description></description>
	<lastBuildDate>Wed, 15 Mar 2023 03:48:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://hoangthuc.com/wp-content/uploads/2024/02/logoTH-2-150x150.png</url>
	<title>Taxonomy wordpress Archives - Hi You, I am Tade</title>
	<link>https://hoangthuc.com/tag/taxonomy-wordpress/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Tạo template trong plugin wordpress</title>
		<link>https://hoangthuc.com/tao-template-trong-plugin-wordpress/</link>
					<comments>https://hoangthuc.com/tao-template-trong-plugin-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 10:01:22 +0000</pubDate>
				<category><![CDATA[Plugin wordpress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[plugin wordpress]]></category>
		<category><![CDATA[Taxonomy wordpress]]></category>
		<category><![CDATA[Thủ thuật wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=508</guid>

					<description><![CDATA[<p>Thông thường để tạo template cho trang bạn phải vào theme để tạo template. Nhưng vấn đề ở đây là khi bạn muốn thay đổi theme thì template vẫn không thay đổi. Giải pháp đưa ra là bạn tạo template trong plugin để tách ra khỏi theme. Như vầy dù bạn có thay đổi theme [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/tao-template-trong-plugin-wordpress/">Tạo template trong plugin wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Thông thường để tạo template cho trang bạn phải vào theme để tạo template. Nhưng vấn đề ở đây là khi bạn muốn thay đổi theme thì template vẫn không thay đổi. Giải pháp đưa ra là bạn tạo template trong plugin để tách ra khỏi theme. Như vầy dù bạn có thay đổi theme thì template vẫn giữ nguyên. Tiêu biễu như plugin <strong>Woocommerce</strong></p>
<p>Các loại template các bạn dùng <strong>custom post</strong>, <strong>archive</strong> và <strong>page</strong>.</p>
<p>Các hook được sử dụng: <strong>single_template, archive_template</strong> và <strong>page_template</strong></p>
<p>Tiến hành code.</p>
<p>1.Custom post</p>
<p>Đối với custom post ta dung hook <strong>single_template. &#8216; YOUR_CUSTOM_POST &#8216;</strong> là tên custom post của bạn dùng.<strong> </strong></p>
<pre class="brush: php; title: ; notranslate">
function get_custom_post_type_single($single_template) {
    global $post;
    if ($post-&gt;post_type == 'YOUR_CUSTOM_POST') {
        $single_template = dirname( __FILE__ ) . '/single-YOUR_CUSTOM_POST.php';
    }
    return $single_template;
}
add_filter( 'single_template', 'get_custom_post_type_single' );
</pre>
<p>2.Archive</p>
<p>Đối với trang archive ta dung hook archive_template. &#8216; YOUR_TAXONOMY &#8216; là tên taxonomy của bạn dùng.</p>
<pre class="brush: php; title: ; notranslate">
function get_custom_archive($archive_template){
    global $wpdb;
    $archive =$wpdb-&gt;last_result;
    if ( $archive&#x5B;0]-&gt;taxonomy==  'YOUR_TAXONOMY' ) {
        $archive_template = dirname( __FILE__ ) . '/archive-YOUR_TAXONOMY.php';
    }
    return $archive_template;
}
add_filter( &quot;archive_template&quot;, &quot;get_custom_archive&quot; ) ;
</pre>
<p>3.Page Template</p>
<p>Đối với page bạn phải chọn slug chính xác thì template mới được sử dụng.</p>
<pre class="brush: php; title: ; notranslate">
add_filter( 'page_template', 'wpa_page_template' );
function wpa_page_template( $page_template )
{
if ( is_page( YOUR_SLUG ) ) {
$page_template = dirname( __FILE__ ) . '/templates/template-YOUR_SLUG.php';
}
return $page_template;
}
</pre>
<p>Chúc các bạn thành công !</p>
<p>The post <a href="https://hoangthuc.com/tao-template-trong-plugin-wordpress/">Tạo template trong plugin wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/tao-template-trong-plugin-wordpress/feed/</wfw:commentRss>
			<slash:comments>122</slash:comments>
		
		
			</item>
		<item>
		<title>Xóa slug trên custom post và custom taxonomy: Phần 2</title>
		<link>https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-2/</link>
					<comments>https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-2/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Fri, 17 Mar 2017 20:25:06 +0000</pubDate>
				<category><![CDATA[Custom post wordpress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[Taxonomy wordpress]]></category>
		<category><![CDATA[Thủ thuật wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=483</guid>

					<description><![CDATA[<p>Nhằm giúp các bạn tối ưu đường dẫn 1 cách gọn nhất khi tạo các custom post mới. Mình có làm 1 tus cách xóa slug cho trang single và category khi tạo custom post, mà wordpress chỉ hổ trợ cho 2 loại là post và page. Phần 2 mình sẽ hướng dẫn về cách ẩn [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-2/">Xóa slug trên custom post và custom taxonomy: Phần 2</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><em>Nhằm giúp các bạn tối ưu đường dẫn 1 cách gọn nhất khi tạo các <strong>custom post</strong> mới. Mình có làm 1 tus cách xóa slug cho trang single và category khi tạo custom post, mà wordpress chỉ hổ trợ cho 2 loại là post và page.</em></p>
<p>Phần 2 mình sẽ hướng dẫn về cách ẩn slug trên taxonomy custom post khi show bài viết. Các bạn nào chưa xem phần 1 hướng dẫn về cách<strong><a href="https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-1/" target="_blank" rel="noopener"> ẩn slug trên custom post</a>.</strong></p>
<p>Phần này mình sẽ hướng dẫn theo 2 cách , thứ nhất là dung hook trong code wordpress, hai là dùng plugin wordpress. Cách 2 có thể dùng dễ dàng cho các bạn không rành về code wordpress.</p>
<p><strong>1.Dùng hook request để ẩn slug taxonomy</strong></p>
<pre class="brush: php; title: ; notranslate">

add_filter('request', 'rudr_change_term_request', 1, 1 );

function rudr_change_term_request($query){

$tax_name = 'report_category';
if( $query&#x5B;'attachment'] ) :
$include_children = true;
$name = $query&#x5B;'attachment'];
else:
$include_children = false;
$name = $query&#x5B;'name'];
endif;
$term = get_term_by('slug', $name, $tax_name);

if (isset($name) &amp;&amp; $term &amp;&amp; !is_wp_error($term)):

if( $include_children ) {
unset($query&#x5B;'attachment']);
$parent = $term-&gt;parent;
while( $parent ) {
$parent_term = get_term( $parent, $tax_name);
$name = $parent_term-&gt;slug . '/' . $name;
$parent = $parent_term-&gt;parent;
}
} else {
unset($query&#x5B;'name']);
}

switch( $tax_name ):
case 'category':{
$query&#x5B;'category_name'] = $name; // for categories
break;
}
case 'post_tag':{
$query&#x5B;'tag'] = $name; // for post tags
break;
}
default:{
$query&#x5B;$tax_name] = $name; // for another taxonomies
break;
}
endswitch;

endif;

return $query;

}

</pre>
<p>Note* Trong phần này mình dùng hàm <strong>rudr_change_term_request</strong> để filter hook <strong>request</strong></p>
<p><strong>2. Dùng plugin wp htaccess contro</strong>l</p>
<p>Các bạn vào setting &gt;&gt; htaccess control</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-485" src="https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_031902-hoangthuc.jpg" alt="" width="1177" height="572" srcset="https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_031902-hoangthuc.jpg 1177w, https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_031902-hoangthuc-300x146.jpg 300w, https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_031902-hoangthuc-900x437.jpg 900w" sizes="(max-width: 1177px) 100vw, 1177px" /></p>
<p>Chọn Remove Taxonomies and author base sau đó tắt các slug taxonomy mà bạn muốn.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-486" src="https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_032127-hoangthuc.jpg" alt="" width="943" height="555" srcset="https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_032127-hoangthuc.jpg 943w, https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_032127-hoangthuc-300x177.jpg 300w, https://hoangthuc.com/wp-content/uploads/2017/03/2017-03-18_032127-hoangthuc-900x530.jpg 900w" sizes="(max-width: 943px) 100vw, 943px" /></p>
<p>Sau đó save lại. nếu vẫn chưa hoạt động các bạn vào setting &gt;&gt; permalink bấm  save lại.</p>
<p style="text-align: center;">Chúc các bạn thành công !</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-2/">Xóa slug trên custom post và custom taxonomy: Phần 2</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-2/feed/</wfw:commentRss>
			<slash:comments>49</slash:comments>
		
		
			</item>
	</channel>
</rss>
