<?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>wordpress nâng cao Archives - Hi You, I am Tade</title>
	<atom:link href="https://hoangthuc.com/tag/wordpress-nang-cao/feed/" rel="self" type="application/rss+xml" />
	<link>https://hoangthuc.com/tag/wordpress-nang-cao/</link>
	<description></description>
	<lastBuildDate>Wed, 15 Mar 2023 03:49:17 +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>wordpress nâng cao Archives - Hi You, I am Tade</title>
	<link>https://hoangthuc.com/tag/wordpress-nang-cao/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Sử dụng media của wordpress để tải hình ảnh</title>
		<link>https://hoangthuc.com/su-dung-media-cua-wordpress-de-tai-hinh-anh/</link>
					<comments>https://hoangthuc.com/su-dung-media-cua-wordpress-de-tai-hinh-anh/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Wed, 20 Jun 2018 10:10:17 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[Thủ thuật wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=547</guid>

					<description><![CDATA[<p>Hôm nay mình sẽ hướng dẫn cách sử dụng nút media trong quản trị wordpress để upload hình ảnh. Cốt lỏi của vấn đề là sử dụng đối tượng meta_image_frame trong thư viện wordpress. Mình sẽ tiến hành từng bước để các bạn nắm rõ: Bước 1: Tạo layout dạng HTML vu vơ và có các [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/su-dung-media-cua-wordpress-de-tai-hinh-anh/">Sử dụng media của wordpress để tải hình ảnh</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-548" src="https://hoangthuc.com/wp-content/uploads/2018/06/2018-06-20_164632.jpg" alt="" width="1432" height="144" srcset="https://hoangthuc.com/wp-content/uploads/2018/06/2018-06-20_164632.jpg 1432w, https://hoangthuc.com/wp-content/uploads/2018/06/2018-06-20_164632-300x30.jpg 300w, https://hoangthuc.com/wp-content/uploads/2018/06/2018-06-20_164632-900x91.jpg 900w" sizes="(max-width: 1432px) 100vw, 1432px" /></p>
<p>Hôm nay mình sẽ hướng dẫn cách sử dụng nút media trong quản trị wordpress để upload hình ảnh.</p>
<p>Cốt lỏi của vấn đề là sử dụng đối tượng <strong>meta_image_frame</strong> trong thư viện wordpress. Mình sẽ tiến hành từng bước để các bạn nắm rõ:</p>
<p>Bước 1: Tạo layout dạng HTML vu vơ và có các nút <strong>Media button</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;wrap&quot; id=&quot;theme_option&quot;&gt;
   
    &lt;div class=&quot;container-fluid&quot;&gt;
        &lt;div class=&quot;Logo&quot;&gt;
            &lt;div class=&quot;box-title&quot; data-toggle=&quot;collapse&quot; href=&quot;#logo&quot; aria-expanded=&quot;false&quot; aria-controls=&quot;logo&quot;&gt;Logo &lt;span class=&quot;dashicons dashicons-arrow-right-alt2 navbar-right&quot;&gt;&lt;/span&gt;&lt;/div&gt;
            &lt;div id=&quot;logo&quot; aria-expanded=&quot;false&quot; class=&quot;collapse in&quot;&gt;
                &lt;div id=&quot;images-container&quot; class=&quot;form-group&quot;&gt;
                    &lt;div class=&quot;input-group&quot;&gt;
                        &lt;input type=&quot;text&quot; name=&quot;wp_theme_logo_image&quot; id=&quot;logo-image&quot; class=&quot;form-control&quot; value=&quot;&quot;&gt;
                        &lt;div class=&quot;input-group-addon&quot;&gt;
                            &lt;input type=&quot;button&quot; class=&quot;logo-image-button btn btn-primary &quot; value=&quot;Chọn hình&quot;&gt;
                            &lt;input type=&quot;button&quot; class=&quot;remove-logo btn btn-primary&quot; value=&quot;Xóa&quot;&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;&lt;!-- end images container --&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>&nbsp;</p>
<p>Bước 2: Khai báo thư viện <strong>Media </strong>và Script để gọi</p>
<pre class="brush: php; title: ; notranslate">
function wp_artisans_theme_back_end()
{
    wp_enqueue_media();
    wp_enqueue_script('custom', WP_PLUGIN_URL . '/Tester/bootstrap/js/admin_custom.js', array(),'',true );
}
add_action( 'admin_enqueue_scripts2', 'wp_artisans_theme_back_end' );
</pre>
<p>File Script</p>
<pre class="brush: xml; title: ; notranslate">
jQuery(document).ready(function($){
  // add image uploader functionality
        var meta_image_frame;
      $('.logo-image-button').live('click', function(e){
            e.preventDefault();

            if( meta_image_frame ){
             meta_image_frame.open();
                return;
            }

            meta_image_frame = wp.media.frames.file_frame = wp.media({
                title: 'Add Images',
                button: {text: 'Add to Images'},
                library: { type: 'image'}
            });

            meta_image_frame.on('select', function(){
                var media_attachment = meta_image_frame.state().get('selection').first().toJSON();

                   var url = '';

                $('#logo-image').val(media_attachment.url);
            });

            meta_image_frame.open();

      });
$('.remove-logo').click(function(){
$('#logo-image').val('');   
})
    
})
</pre>
<p>Lưu ý:</p>
<p>Bạn cần gọi hook <strong>admin_enqueue_scripts2  </strong></p>
<p>Đến đây là xong !</p>
<p>&nbsp;</p>
<p>Chúc các bạn may mắn.</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/su-dung-media-cua-wordpress-de-tai-hinh-anh/">Sử dụng media của wordpress để tải hình ảnh</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/su-dung-media-cua-wordpress-de-tai-hinh-anh/feed/</wfw:commentRss>
			<slash:comments>49</slash:comments>
		
		
			</item>
		<item>
		<title>Plugin lấy tin tự động version 2.1</title>
		<link>https://hoangthuc.com/plugin-lay-tin-tu-dong-version-2-1/</link>
					<comments>https://hoangthuc.com/plugin-lay-tin-tu-dong-version-2-1/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sun, 13 Aug 2017 19:31:25 +0000</pubDate>
				<category><![CDATA[Plugin wordpress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Lấy tin tự động]]></category>
		<category><![CDATA[plugin wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=514</guid>

					<description><![CDATA[<p>Chào các bạn. Hôm nay mình muốn thông báo là mình đã nâng cấp Plugin lấy tin lên 1 tầm cao mới là version 2.1 Đối với bản version 2.1 mình có nâng cấp, thêm mới 1 số chức năng so với bản trước đây và cũng lược bỏ 1 số thành phần. Các bạn có [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/plugin-lay-tin-tu-dong-version-2-1/">Plugin lấy tin tự động version 2.1</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Chào các bạn. Hôm nay mình muốn thông báo là mình đã nâng cấp <strong>Plugin lấy tin</strong> lên 1 tầm cao mới là <strong>version 2.1</strong></p>
<p>Đối với bản version 2.1 mình có nâng cấp, thêm mới 1 số chức năng so với bản trước đây và cũng lược bỏ 1 số thành phần. Các bạn có thể xem bản củ <strong><a href="https://hoangthuc.com/plugin-lay-tin-tu-dong-tu-website-khac/" target="_blank" rel="noopener">Plugin lấy tin ở đây</a>.</strong></p>
<p>Đầu tiên mình sẽ trình bày về những phần được mình nâng cấp và bổ sung nhe.</p>
<p><strong>1.Giao diện plugin</strong></p>
<p>_ Được mình tối ưu đơn giản hết mức có thể. Gồm 2 phần chính là <strong>Test Site</strong> và <strong>Show Post</strong></p>
<p>_ Test Site: Kiểm tra site mới và kiểm tra tin lấy về. Phần Test site này là phần mình bổ sung mới so với bản trước đây, bạn có thể test theo danh sách và theo trang single.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-515" src="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020257.jpg" alt="" width="937" height="430" srcset="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020257.jpg 937w, https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020257-300x138.jpg 300w, https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020257-900x413.jpg 900w" sizes="(max-width: 937px) 100vw, 937px" /></p>
<p>_ Show Post: Phần này thì mình chỉ thay đổi giao diện một chút và gôm lại 2 phần là lưu tin theo danh sách và lưu từng tin lại thành một.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-516" src="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020612.jpg" alt="" width="1188" height="646" srcset="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020612.jpg 1188w, https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020612-300x163.jpg 300w, https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_020612-900x489.jpg 900w" sizes="(max-width: 1188px) 100vw, 1188px" /></p>
<p><strong>2.Quản lý và cài đặt</strong></p>
<p>_ Mình đã thay đổi phần quản lý và cài đặt thành quản lý của wordpress. Các bạn có thể cấu hình và cà đặt dễ hơn như trong post.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-517" src="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_021001.jpg" alt="" width="825" height="379" srcset="https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_021001.jpg 825w, https://hoangthuc.com/wp-content/uploads/2017/08/2017-08-14_021001-300x138.jpg 300w" sizes="(max-width: 825px) 100vw, 825px" /></p>
<p><strong>3.Tính năng mới và tốc độ.</strong></p>
<p>_ So với bản trước đây thì version 2.1 có thể lấy được 1 lúc nhiều link trong 1 site. Và đặc biệt hơn là có thể lấy nhiều site cùng 1 lúc.</p>
<p>_ Tốc độ cũng được mình cải thiện lên khá nhiều nếu không nói là nhanh hơn.</p>
<p>_ Chắc các bạn đang thắc mắc tại sao version này lại không có phần edit link lỗi. Câu trả lời là mình đã auto fix cho các bạn luôn rồi. Khi các  bạn lấy link về thì sẽ được plugin tự động chỉnh sửa link không phải sửa thủ công như version củ nữa.(Cám ơn mình đi)</p>
<p>Bên cạnh những phần bổ sung thì cung có những phần mình lược bỏ.</p>
<p>_ Mình bỏ phần set trạng thái bài viết, danh mục bài viết.(Phần này mình thấy trong quan lý post cũng có và cũng khá tiện nên mình lược bỏ luôn)</p>
<p>_ Phần lưu trữ link lấy về.(Phần này do mình lấy tin về thấy tốc độ nhanh quá nên bỏ luôn =))  )</p>
<p><strong>Đánh giá chung:</strong></p>
<p><strong>*Ưu điểm</strong></p>
<p><em>_ Dĩ nhiên bản nâng cấp nó phải ok hơn cái củ rồi, mình tập trung chủ yếu vào 2 phần là lấy nhiều tin hơn và làm cho tốc độ lấy nhanh hơn.</em></p>
<p><em>_ Giao diện thì nhìn cũng thoáng hơn và dễ sử dựng hơn trước.(Mình tự đánh giá nhé)</em></p>
<p><strong>*Nhược điểm</strong></p>
<p><em>_ Mình chưa nghỉ ra =)) đùa đó. Nó vẫn còn thiếu nhiều thứ như trạng thái, danh mục , Tag, Slug.</em></p>
<p><em>_ Nhưng trên cơ bản thì mình cũng khá hài long rồi vì nó đúng tiêu chí ban đầu trước khi mình nâng cấp.</em></p>
<p><strong>*Video hướng dẫn</strong></p>
<p><a href="https://www.youtube.com/watch?v=CMabgiBQWqM">https://www.youtube.com/watch?v=CMabgiBQWqM</a></p>
<p style="text-align: center;">Chúc các bạn một ngày vui vẻ.</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/plugin-lay-tin-tu-dong-version-2-1/">Plugin lấy tin tự động version 2.1</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/plugin-lay-tin-tu-dong-version-2-1/feed/</wfw:commentRss>
			<slash:comments>54</slash:comments>
		
		
			</item>
		<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 loading="lazy" 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 loading="lazy" 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>
		<item>
		<title>Xóa slug trên custom post và custom taxonomy: Phần 1</title>
		<link>https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-1/</link>
					<comments>https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-1/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sat, 11 Mar 2017 02:51:34 +0000</pubDate>
				<category><![CDATA[Custom post wordpress]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[Custom post wp]]></category>
		<category><![CDATA[Thủ thuật wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=476</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. Đầu tiên về custom post (nếu bạn nào chưa [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/xoa-slug-tren-custom-post-va-custom-taxonomy-phan-1/">Xóa slug trên custom post và custom taxonomy: Phần 1</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>Đầu tiên về <strong><a href="https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/" target="_blank" rel="noopener">custom post</a></strong> (nếu bạn nào chưa biết về custom post có thể xem bài viết trước của mình).</p>
<p><strong>1.Xóa slug trên custom post trong trang single:</strong></p>
<p>Link custom post single ban đầu: https://hoangthuc.com/report/bao-cao-thu-chi/</p>
<p>Link custom post single cần thay thành: https://hoangthuc.com/bao-cao-thu-chi/</p>
<p>Custom post type mình làm ở đây là &#8220;report&#8221; nếu làm bạn có thể tùy biến custom post này. Các bạn vào file fucntions.php và thêm đoạn code có định dạng bên dưới.</p>
<pre class="brush: php; title: ; notranslate">
// remove slug custom_post type
function na_remove_slug( $post_link, $post, $leavename ) {

    if ( 'report' != $post-&gt;post_type || 'publish' != $post-&gt;post_status ) {
        return $post_link;
    }

    $post_link = str_replace( '/' . $post-&gt;post_type . '/', '/', $post_link );

    return $post_link;
}
add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
</pre>
<p>Note* Trong phần này bạn sẽ dung hàm <strong>na_remove_slug </strong>để filter vào hook<strong> post_type_link</strong></p>
<p><strong>2. Xữ lý lỗi 301 redirect khi chuyển:</strong></p>
<p>Trong quá trình remove slug như bước 1 wp sẽ xuất hiện lỗi 301 không tìm thấy trang. Cách xữ lý.</p>
<pre class="brush: php; title: ; notranslate">
function na_parse_request( $query ) {

    if ( ! $query-&gt;is_main_query() || 2 != count( $query-&gt;query ) || ! isset( $query-&gt;query&#x5B;'page'] ) ) {
        return;
    }

    if ( ! empty( $query-&gt;query&#x5B;'name'] ) ) {
        $query-&gt;set( 'post_type', array( 'post', 'report', 'page' ) );
    }
}
add_action( 'pre_get_posts', 'na_parse_request' );
</pre>
<p>Sau đó các bạn và <strong>Setting</strong> =&gt; <strong>Permalink</strong> và <strong>Save button</strong> lại để hoàn tất.</p>
<p>&nbsp;</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-1/">Xóa slug trên custom post và custom taxonomy: Phần 1</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-1/feed/</wfw:commentRss>
			<slash:comments>49</slash:comments>
		
		
			</item>
		<item>
		<title>Hiển thị thời gian kể từ ngày đăng trong wordpress</title>
		<link>https://hoangthuc.com/hien-thi-thoi-gian-ke-tu-ngay-dang-trong-wordpress/</link>
					<comments>https://hoangthuc.com/hien-thi-thoi-gian-ke-tu-ngay-dang-trong-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Sun, 22 May 2016 16:41:03 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[Thủ thuật wordpress]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=427</guid>

					<description><![CDATA[<p>Đây là một đoạn code nhỏ trong wordpress cho phép bạn hiển thị thời gian từ ngày đăng bài đến hiện tại. Các bạn có thể thêm nó vào file function.php /** * Display time since post was published * * @uses human_time_diff() Return time difference in easy to read format * @uses get_the_time() Get [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/hien-thi-thoi-gian-ke-tu-ngay-dang-trong-wordpress/">Hiển thị thời gian kể từ ngày đăng trong wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Đây là một đoạn code nhỏ trong wordpress cho phép bạn hiển thị thời gian từ ngày đăng bài đến hiện tại. Các bạn có thể thêm nó vào file function.php</p>
<pre class="brush: php; title: ; notranslate">

/**
 * Display time since post was published
 *
 * @uses	human_time_diff()  Return time difference in easy to read format
 * @uses	get_the_time()  Get the time the post was published
 * @uses	current_time()  Get the current time
 *
 * @return	string  Timestamp since post was published
 *
 * @author c.bavota
 */
function get_time_since_posted() {

	$time_since_posted = human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ago';

	return $time_since_posted;

}

</pre>
<p>Bây giờ các bạn có thể sử dụng hàm get_time_since_posted() để hiển thị thời gian từ ngày đăng bài cho đến hiện tại trong loop wordpress.<br />
Tham khảo hàm human_time_diff() tại <a href="http://codex.wordpress.org/Function_Reference/human_time_diff">http://codex.wordpress.org/Function_Reference/human_time_diff<br />
</a></p>
<p>The post <a href="https://hoangthuc.com/hien-thi-thoi-gian-ke-tu-ngay-dang-trong-wordpress/">Hiển thị thời gian kể từ ngày đăng trong wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/hien-thi-thoi-gian-ke-tu-ngay-dang-trong-wordpress/feed/</wfw:commentRss>
			<slash:comments>48</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress nâng cao 1: Custom post type</title>
		<link>https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/</link>
					<comments>https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Mon, 09 May 2016 01:15:21 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=394</guid>

					<description><![CDATA[<p>Trong wordpress có 2 loại custom post đã được mặc định sẳn là post và page. Post cho bài viết và page cho trang .Vậy nếu muốn tạo thêm 1 custom post ta làm thế nào. Bài viết sau sẽ hướng dẫn các bạn tạo 1 custom post đợn giản nhất. Trước hết mình xin [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/">WordPress nâng cao 1: Custom post type</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Trong wordpress có 2 loại <strong>custom post</strong> đã được mặc định sẳn là <strong>post</strong> và <strong>page</strong>. Post cho bài viết và page cho trang .Vậy nếu muốn tạo thêm 1 custom post ta làm thế nào. Bài viết sau sẽ hướng dẫn các bạn tạo 1 custom post đợn giản nhất.</p>
<p>Trước hết mình xin giới thiệu cách tạo custom post đơn giản nhất có thể dành cho người không chuyên về code đó là dùng plugin. Các plugin cho phép bạn tạo mọi thứ về custom post như taxonomy, field , post type,&#8230;</p>
<p><strong><a href="https://wordpress.org/plugins/custom-post-type-ui/" target="_blank" rel="noopener">Custom post type UI</a></strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-396" src="https://hoangthuc.com/wp-content/uploads/2016/05/custom-post-type-UI.jpg" alt="custom-post-type-UI" width="772" height="249" srcset="https://hoangthuc.com/wp-content/uploads/2016/05/custom-post-type-UI.jpg 772w, https://hoangthuc.com/wp-content/uploads/2016/05/custom-post-type-UI-300x97.jpg 300w" sizes="(max-width: 772px) 100vw, 772px" /></p>
<p><strong><a href="https://wordpress.org/plugins/types/" target="_blank" rel="noopener">Type</a></strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-395" src="https://hoangthuc.com/wp-content/uploads/2016/05/types.jpg" alt="types" width="772" height="250" srcset="https://hoangthuc.com/wp-content/uploads/2016/05/types.jpg 772w, https://hoangthuc.com/wp-content/uploads/2016/05/types-300x97.jpg 300w" sizes="(max-width: 772px) 100vw, 772px" /></p>
<p>Đây là 2 plugin mình đã sử dụng qua và theo đánh giá của mình thì rất đầy đủ.</p>
<p>Và cách thứ 2 mình muốn hướng dẫn đó là code. Các bạn có thể tích hợp trong plugin, hoặc theme.</p>
<p>Khởi tạo custom post type</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
 if( ! function_exists( 'Domain_create_post_type' ) ) :
 function Domain_create_post_type() {
 $labels = array(
 'name' =&gt; 'Domain',
 'singular_name' =&gt; 'Domain',
 'add_new' =&gt; 'Add Domain',
 'all_items' =&gt; 'All Domain',
 'add_new_item' =&gt; 'Add Domain',
 'edit_item' =&gt; 'Edit Domain',
 'new_item' =&gt; 'New Domain',
 'view_item' =&gt; 'View Domain',
 'search_items' =&gt; 'Search Domain',
 'not_found' =&gt; 'No Domain found',
 'not_found_in_trash' =&gt; 'No Domain found in trash',
 'parent_item_colon' =&gt; 'Parent Domain'
 //'menu_name' =&gt; default to 'name'
 );
 $args = array(
 'labels' =&gt; $labels,
 'public' =&gt; true,
 'has_archive' =&gt; true,
 'publicly_queryable' =&gt; true,
 'query_var' =&gt; true,
 'rewrite' =&gt; true,
 'capability_type' =&gt; 'post',
 'hierarchical' =&gt; false,
 'supports' =&gt; array(
 'title',
 'editor',
 ),
 'menu_position' =&gt; 5,
 'menu_icon' =&gt; 'dashicons-clipboard',
 'exclude_from_search' =&gt; false,
 'register_meta_box_cb' =&gt; 'domain_add_post_type_metabox'
 );
 register_post_type( 'domain', $args );

register_taxonomy( 'domain_category', // register custom taxonomy - category
 'domain',
 array(
 'hierarchical' =&gt; true,
 'labels' =&gt; array(
 'name' =&gt; 'Domain category',
 'singular_name' =&gt; 'Domain category',
 )
 )
 );
 register_taxonomy( 'domain_tag', // register custom taxonomy - tag
 'domain',
 array(
 'hierarchical' =&gt; false,
 'labels' =&gt; array(
 'name' =&gt; 'Domain tag',
 'singular_name' =&gt; 'Domain tag',
 )
 )
 );
 }
 add_action( 'init', 'Domain_create_post_type' );
endif;

 function domain_add_post_type_metabox() { 
 add_meta_box( 'domain_metabox', 'Information', 'domain_metabox', 'domain', 'normal' );
 }


 function domain_metabox() {
 global $post;
 $registrar = get_post_meta($post-&gt;ID, 'registrar', true);

echo '&lt;div class=&quot;form-horizontal&quot; &gt; 
&lt;div class=&quot;form-group&quot;&gt; 
&lt;label for=&quot;inputEmail3&quot; class=&quot;col-sm-2 control-label&quot;&gt;Registrar&lt;/label&gt; 
&lt;div class=&quot;col-sm-10&quot;&gt; &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;registrar&quot; value=&quot;'.$registrar .'&quot; &gt; 
&lt;/div&gt; &lt;/div&gt;
&lt;/div&gt;'; 

function domain_post_save_meta( $post_id, $post ) { 
 $domain_post_meta&#x5B;'registrar'] = strtotime($_POST&#x5B;'registrar']);
 foreach( $domain_post_meta as $key =&gt; $value ) { 
 $value = implode(',', (array)$value); 
 if( get_post_meta( $post-&gt;ID, $key, FALSE ) ) { 
 update_post_meta($post-&gt;ID, $key, $value);
 } else { 
 add_post_meta( $post-&gt;ID, $key, $value );
 }
 if( !$value ) { 
 delete_post_meta( $post-&gt;ID, $key );
 }
 }
 }
 add_action( 'save_post', 'domain_post_save_meta', 1, 2 ); 
?&gt;
</pre>
<p>Trong đây mình có làm phần tích hợp <strong><a href="https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/">meta box</a></strong> nếu các bạn thấy không cần thiết thì bỏ ra nhé.</p>
<p>Chúc các bạn thành công !</p>
<p>&nbsp;</p>
<p>The post <a href="https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/">WordPress nâng cao 1: Custom post type</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/wordpress-nang-cao-1-custom-post-type/feed/</wfw:commentRss>
			<slash:comments>112</slash:comments>
		
		
			</item>
		<item>
		<title>Cách tạo meta box trong custom post wordpress</title>
		<link>https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/</link>
					<comments>https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Hoàng Thức]]></dc:creator>
		<pubDate>Thu, 05 May 2016 18:25:06 +0000</pubDate>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress nâng cao]]></category>
		<category><![CDATA[wordpress nâng cao]]></category>
		<guid isPermaLink="false">https://hoangthuc.com/?p=391</guid>

					<description><![CDATA[<p>Post meta hay còn gọi là custom field được wordpress cấu hình sẳn nó là những giá trị text field cho phép nhập các giá trị text. Nhưng khi ta muốn tùy biến các text field này thành các dạng dữ liệu như ngày tháng năm,  số hoặc chuyển từ kiểu text field sang kiểu select [&#8230;]</p>
<p>The post <a href="https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/">Cách tạo meta box trong custom post wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Post met</strong>a hay còn gọi là <strong>custom field</strong> được wordpress cấu hình sẳn nó là những giá trị text field cho phép nhập các giá trị text. Nhưng khi ta muốn tùy biến các text field này thành các dạng dữ liệu như ngày tháng năm,  số hoặc chuyển từ kiểu text field sang kiểu select ta sẽ sử dụng một phương thức gọi là meta box. Các biến giá trị trong <strong>meta box</strong> sẽ được gọi là <strong>post meta</strong>. Và không lòng vòng nữa đây là phần code:</p>
<p><strong>1.Khỏi tạo Meta Box </strong></p>
<pre class="brush: php; title: ; notranslate">

function wpdocs_register_meta_boxes() {
add_meta_box( 'meta-box-id', __( 'INFO', 'WA' ), 'wpdocs_my_display_callback', 'post' );
}
add_action( 'add_meta_boxes', 'wpdocs_register_meta_boxes' );

</pre>
<p>ở đây ta chú ý post type là &#8220;<strong>post</strong>&#8221; nhé các bạn có thể tùy chỉnh theo từng loại post type ví dụ &#8220;<strong>page</strong>&#8221; cho trang.</p>
<p><strong>2.Nội dung hàm hiển thị Meta box</strong></p>
<pre class="brush: php; title: ; notranslate">

function wpdocs_my_display_callback( ) {
global $post;
$meta_post_title = get_post_meta($post-&gt;ID, 'meta_post_title', true);
$post_desc = get_post_meta($post-&gt;ID, 'post_desc', true);
?&gt;
&lt;table class=&quot;form-table&quot;&gt;
&lt;tr&gt;
&lt;th&gt;
&lt;label&gt;Title&lt;/label&gt;
&lt;/th&gt;
&lt;td&gt;
&lt;textarea name=&quot;meta_post_title&quot; class=&quot;large-text&quot;&gt;&lt;?php echo $meta_post_title; ?&gt;&lt;/textarea&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th&gt;
&lt;label&gt;Description&lt;/label&gt;
&lt;/th&gt;
&lt;td&gt;
&lt;textarea name=&quot;post_desc&quot; class=&quot;large-text&quot;&gt;&lt;?php echo $post_desc; ?&gt;&lt;/textarea&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;?php
}

</pre>
<p><strong>3. Hàm lưu lại giá trị</strong></p>
<pre class="brush: php; title: ; notranslate">

add_action( 'save_post', 'wpdocs_save_meta_box' );
function wpdocs_save_meta_box() {
global $post;
$quote_post_meta&#x5B;'meta_post_title'] = $_POST&#x5B;'meta_post_title'];
$quote_post_meta&#x5B;'post_desc'] = $_POST&#x5B;'post_desc'];

foreach( $quote_post_meta as $key =&gt; $value ) { // cycle through the $quote_post_meta array
$value = implode(',', (array)$value); // if $value is an array, make it a CSV (unlikely)
if( get_post_meta( $post-&gt;ID, $key, FALSE ) ) { // if the custom field already has a value
update_post_meta($post-&gt;ID, $key, $value);
} else {
add_post_meta( $post-&gt;ID, $key, $value );
}
if( !$value ) {
delete_post_meta( $post-&gt;ID, $key );
}
}
}

</pre>
<p>Chúc các bạn thành công nhé !</p>
<p>The post <a href="https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/">Cách tạo meta box trong custom post wordpress</a> appeared first on <a href="https://hoangthuc.com">Hi You, I am Tade</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hoangthuc.com/cach-tao-meta-box-trong-custom-post-wordpress/feed/</wfw:commentRss>
			<slash:comments>104</slash:comments>
		
		
			</item>
	</channel>
</rss>
