{"category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"category_posts":{"current_page":1,"data":[{"id":4,"title":"How to Create custom post type taxonomy category in WordPress","slug":"how-to-create-custom-post-type-taxonomy-category-in-wordpress","image":null,"description":"<p><\/p><div style=\"clear: both; text-align: center;\"><span style=\"background-color: rgb(254, 254, 254); color: rgb(58, 58, 58); font-family: system-ui, Roboto, Arial, sans-serif; font-size: 31px; text-align: left;\">Custom Taxonomy for Custom Post Types<\/span><\/div><p style=\"text-align: left;\"><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">Taxonomies are a great way to group things together and help us to search posts belonging to a specific group. In WordPress we generally use Categories and Tags as taxonomies. The steps given below explain how to create custom taxonomies for your CPT.<\/span>&nbsp;<\/p><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\">Step 1 : Register Custom Post Type<\/h3><p><span style=\"background-color: #fefefe;\"><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"color: #3a3a3a;\"><span style=\"font-size: 18px;\">Open functions.php&nbsp;file in your theme and Paste these Code, in our case we will register<\/span><\/span><\/span><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">&nbsp;<\/span><strong style=\"box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 18px; margin-top: 0.3em;\">Photogallery<\/strong><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">&nbsp;<\/span><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">as CPT.<\/span>&nbsp;<\/p>  <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0px; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\">\/\/ Photo Gallary Customs Post Register<br>function create_posttype()<br>{<br>    register_post_type(<br>        'photogallery',<br>        array(<br>            'labels' =&gt; array(<br>                'name' =&gt; __('Photo gallery'),<br>                'singular_name' =&gt; __('photogallery')<br>            ),<br>            'public' =&gt; true,<br>            'menu_position'       =&gt; 5,<br>            'supports'            =&gt; array('editor', 'title', 'thumbnail',),<br>            'has_archive' =&gt; true,<br>            'rewrite' =&gt; array('slug' =&gt; 'photogallery'),<br>            'taxonomies'  =&gt; array('photogallery', 'photogallery-category'),<br>        )<br>    );<br>}<br>add_action('init', 'create_posttype');<br><\/pre><\/div><br><div><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\">Making Custom Archive For Custom Post Type<\/h3><div><br><\/div><div><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">Create a file name&nbsp;<\/span><b>archive-photogallery.php&nbsp;<\/b>in theme's root directory and paste these code in it.&nbsp;<\/div><div><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\">Url: mywebsite.com\/photogallery<\/h3><\/div><div><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 21px;\"><br><\/span><\/div><div><div><span style=\"color: red;\"><b>Note:<\/b><\/span> <span style=\"color: #444444;\">(if url does't work please do that)<span face=\"Arial, &quot;Helvetica Neue&quot;, Helvetica, sans-serif\" style=\"background-color: white; font-size: 15px;\">This will re-write the htaccess file and then the re-write should work.<\/span><\/span><\/div><ol style=\"background-color: white; border: 0px; box-sizing: inherit; color: #242729; font-family: Arial, &quot;Helvetica Neue&quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; list-style-image: initial; list-style-position: initial; margin-bottom: var(--s-prose-spacing); margin-left: 30px; margin-right: 0px; margin-top: 0px; padding: 0px; vertical-align: baseline;\"><li style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: var(--s-prose-spacing-condensed); margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;\">Navigate to Settings -&gt; permalinks<\/li><li style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: var(--s-prose-spacing-condensed); margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;\">Change the permalink structure to&nbsp;<em style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;\">Default<\/em><\/li><li style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: var(--s-prose-spacing-condensed); margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;\">Save settings<\/li><li style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin-bottom: var(--s-prose-spacing-condensed); margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;\">Change to custom structure or post name (or any other structure)<\/li><li style=\"border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;\">Save Settings<\/li><\/ol><\/div><div><br><\/div>     <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0em; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\">&lt;!-- archive-photogallery.php --&gt;<br><br><span style=\"color: #557799;\">&lt;?php<\/span> get_header(); <span style=\"color: #557799;\">?&gt;<\/span><br>&lt;div id=\"primary\"&gt;<br>    &lt;div id=\"content\" role=\"main\"&gt;<br>        <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #996633;\">$mypost<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">array<\/span>(<span>'post_type'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> <span>'photogallery'<\/span>,);<br>        <span style=\"color: #996633;\">$loop<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> WP_Query(<span style=\"color: #996633;\">$mypost<\/span>); <span style=\"color: #557799;\">?&gt;<\/span><br>        <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">while<\/span> (<span style=\"color: #996633;\">$loop<\/span><span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">have_posts<\/span>()) <span style=\"color: #333333;\">:<\/span> <span style=\"color: #996633;\">$loop<\/span><span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">the_post<\/span>(); <span style=\"color: #557799;\">?&gt;<\/span><br>            &lt;article id=\"post-<span style=\"color: #557799;\">&lt;?php<\/span> the_ID(); <span style=\"color: #557799;\">?&gt;<\/span>\" <span style=\"color: #557799;\">&lt;?php<\/span> post_class(); <span style=\"color: #557799;\">?&gt;<\/span>&gt;<br>                &lt;header class=\"entry-header\"&gt;<br>                    &lt;div style=\"float: top; margin: 10px\"&gt;<br>                        <span style=\"color: #557799;\">&lt;?php<\/span> the_post_thumbnail(); <span style=\"color: #557799;\">?&gt;<\/span><br>                    &lt;\/div&gt;<br>                    &lt;strong&gt;Title: &lt;\/strong&gt;<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>&lt;br \/&gt;<br>                    &lt;br \/&gt;<br>                &lt;\/header&gt;<br>                &lt;div class=\"entry-content\"&gt;<br>                    &lt;!-- <span style=\"color: #557799;\">&lt;?php<\/span> the_content(); <span style=\"color: #557799;\">?&gt;<\/span> --&gt;<br>                &lt;\/div&gt;<br>                &lt;hr \/&gt;<br>            &lt;\/article&gt;<br>        <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">endwhile<\/span>;  <span style=\"color: #557799;\">?&gt;<\/span><br>    &lt;\/div&gt;<br>&lt;\/div&gt;<br><span style=\"color: #557799;\">&lt;?php<\/span> wp_reset_query(); <span style=\"color: #557799;\">?&gt;<\/span><br><span style=\"color: #557799;\">&lt;?php<\/span> get_footer(); <span style=\"color: #557799;\">?&gt;<\/span><br><\/pre><\/div>           <h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px; text-align: left;\">Step 2 : Implementation of Custom Function and Registering Custom Taxonomy<\/h3><\/div><div><br><\/div><div><span style=\"background-color: #fefefe;\"><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"color: #3a3a3a;\"><span style=\"font-size: 18px;\">Paste these Code in&nbsp;<\/span><\/span><\/span><span style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">functions.php as well<\/span><span style=\"background-color: #fefefe;\"><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"color: #3a3a3a;\"><span style=\"font-size: 18px;\">, in that case we will register<\/span><\/span><\/span><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">&nbsp;<\/span><strong style=\"box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 18px; margin-top: 0.3em;\">Photogallery's&nbsp;<\/strong><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">&nbsp;<\/span><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">custom Taxonomy<\/span><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">.<\/span>&nbsp;<\/div><div><br><\/div><div><br><\/div> <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0em; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\">\/\/Create category for Photo post type<br>function tr_create_my_taxonomy()<br>{<br>    register_taxonomy(<br>        'photogallery-categories',<br>        'photogallery',<br>        array(<br>            'label' =&gt; __('Photogallery Categories'),<br>            'rewrite' =&gt; array('slug' =&gt; 'photogallery-category'),<br>            'hierarchical' =&gt; true,<br>            'has_archive' =&gt; true<br>        )<br>    );<br>}<br>add_action('init', 'tr_create_my_taxonomy');<br><\/pre><\/div><div><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\">Making Custom Archive For Custom Taxonomy<\/h3><\/div><div><br><\/div><div><span face=\"system-ui, Roboto, Arial, sans-serif\" style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">Create a file name&nbsp;<\/span><b>taxonomy-photogallery-categories.php&nbsp;<\/b>in theme's root directory and paste these code in it.&nbsp;<\/div><div><br><\/div>  <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0em; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\"><span style=\"color: #557799;\">&lt;?php<\/span> get_header(); <span style=\"color: #557799;\">?&gt;<\/span><br>&lt;div class=\"custom_container\"&gt;<br>    &lt;div class=\"photo_subcat_posts_grid\"&gt;<br>        <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">if<\/span> (have_posts()) <span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">while<\/span> (have_posts()) <span style=\"color: #333333;\">:<\/span> the_post(); <span style=\"color: #557799;\">?&gt;<\/span><br>                &lt;div class=\"single-block auto\"&gt;<br>                    &lt;div class=\"img-box\"&gt;<br>                        &lt;a href=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_permalink(); <span style=\"color: #557799;\">?&gt;<\/span>\" title=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>\"&gt;<br>                            <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">if<\/span> (has_post_thumbnail()) {<br>                                the_post_thumbnail(<span style=\"background-color: #fff0f0;\">'custom-size'<\/span>);<br>                            } <span style=\"color: #008800; font-weight: bold;\">else<\/span> { <span style=\"color: #557799;\">?&gt;<\/span><br>                                &lt;img src=\"<span style=\"color: #557799;\">&lt;?php<\/span> bloginfo(<span style=\"background-color: #fff0f0;\">'template_directory'<\/span>); <span style=\"color: #557799;\">?&gt;<\/span>\/img\/default-img_final.gif\" alt=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>\" \/&gt;<br>                            <span style=\"color: #557799;\">&lt;?php<\/span> } <span style=\"color: #557799;\">?&gt;<\/span>&lt;\/a&gt;<br>                    &lt;\/div&gt;<br>                    &lt;h4&gt;&lt;a href=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_permalink(); <span style=\"color: #557799;\">?&gt;<\/span>\" title=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>\"&gt;<span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">echo<\/span> wp_trim_words(get_the_title(), <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>); <span style=\"color: #557799;\">?&gt;<\/span>&lt;\/a&gt;&lt;\/h4&gt;<br>                &lt;\/div&gt;<br>        <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">endwhile<\/span>;<br>        <span style=\"color: #008800; font-weight: bold;\">endif<\/span> <span style=\"color: #557799;\">?&gt;<\/span><br>    &lt;\/div&gt;<br>    &lt;div class=\"pagination1\"&gt;<br>        &lt;div class=\"pagi_inner\"&gt;<br>            <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">echo<\/span> paginate_links(<span style=\"color: #008800; font-weight: bold;\">array<\/span>(<br>                <span style=\"background-color: #fff0f0;\">'prev_text'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> __(<span style=\"background-color: #fff0f0;\">'&amp;laquo;'<\/span>, <span style=\"background-color: #fff0f0;\">'textdomain'<\/span>),<br>                <span style=\"background-color: #fff0f0;\">'next_text'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> __(<span style=\"background-color: #fff0f0;\">'&amp;raquo;'<\/span>, <span style=\"background-color: #fff0f0;\">'textdomain'<\/span>),<br><br>            )); <span style=\"color: #557799;\">?&gt;<\/span><br>        &lt;\/div&gt;<br>    &lt;\/div&gt;<br>&lt;\/div&gt;<br><span style=\"color: #557799;\">&lt;?php<\/span> get_footer(); <span style=\"color: #557799;\">?&gt;<\/span><br><\/pre><\/div><div><br><\/div><div><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\">Other Support Options:<\/h3><\/div><div><br><\/div><div><span style=\"background-color: #fefefe; color: #3a3a3a; font-size: 18px;\">To support custom post type post in different templaet<\/span><\/div><div><br><\/div>   <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0em; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\">\/\/ To Support Custom Post Format in different Template<br><br>function namespace_add_custom_types($query)<br>{<br>    if (is_single() || is_category() || is_tag() &amp;&amp; empty($query-&gt;query_vars['suppress_filters'])) {<br>        $query-&gt;set('post_type', array(<br>            'post', 'nav_menu_item', 'photogallery','videogallery'<br>        ));<br>        return $query;<br>    }<br>}<br>add_filter('pre_get_posts', 'namespace_add_custom_types');<br><\/pre><\/div><div><br><\/div><div><h3 style=\"background-color: #fefefe; box-sizing: border-box; color: #3a3a3a; font-family: system-ui, Roboto, Arial, sans-serif; font-size: 21px; line-height: 1.2em; margin: 26px 0px 4px;\"><span style=\"font-family: SolaimanLipi; font-size: 18px; font-weight: 400;\">Custom Post type Post Query<\/span><\/h3><\/div><div><br><\/div><div><br><\/div>  <!--HTML generated using hilite.me--><div style=\"background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0px; width: auto;\"><pre style=\"line-height: 125%; margin: 0px;\"><span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #996633;\">$args1<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">array<\/span>(<br>    <span style=\"background-color: #fff0f0;\">'post_type'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> <span style=\"background-color: #fff0f0;\">'photogallery'<\/span>,<br>    <span style=\"background-color: #fff0f0;\">'posts_per_page'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>,<br>    <span style=\"background-color: #fff0f0;\">'order'<\/span> <span style=\"color: #333333;\">=&gt;<\/span> <span style=\"background-color: #fff0f0;\">'DESC'<\/span>,<br>);<br><span style=\"color: #996633;\">$lastpost<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> WP_Query(<span style=\"color: #996633;\">$args1<\/span>);<br><span style=\"color: #008800; font-weight: bold;\">if<\/span> (<span style=\"color: #996633;\">$lastpost<\/span><span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">have_posts<\/span>()) <span style=\"color: #333333;\">:<\/span> <span style=\"color: #008800; font-weight: bold;\">while<\/span> (<span style=\"color: #996633;\">$lastpost<\/span><span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">have_posts<\/span>()) <span style=\"color: #333333;\">:<\/span> <span style=\"color: #996633;\">$lastpost<\/span><span style=\"color: #333333;\">-&gt;<\/span><span style=\"color: #0000cc;\">the_post<\/span>(); <span style=\"color: #557799;\">?&gt;<\/span><br>        &lt;li&gt;<br>            &lt;a href=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_permalink(); <span style=\"color: #557799;\">?&gt;<\/span>\" title=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>\"&gt;<br>                <span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">if<\/span> (has_post_thumbnail()) {<br>                    the_post_thumbnail();<br>                } <span style=\"color: #008800; font-weight: bold;\">else<\/span> { <span style=\"color: #557799;\">?&gt;<\/span><br>                    &lt;img src=\"<span style=\"color: #557799;\">&lt;?php<\/span> bloginfo(<span style=\"background-color: #fff0f0;\">'template_directory'<\/span>); <span style=\"color: #557799;\">?&gt;<\/span>\/img\/default-img_final.gif\" alt=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_title(); <span style=\"color: #557799;\">?&gt;<\/span>\" \/&gt;<br>                <span style=\"color: #557799;\">&lt;?php<\/span> } <span style=\"color: #557799;\">?&gt;<\/span>&lt;\/a&gt;<br>            &lt;a href=\"<span style=\"color: #557799;\">&lt;?php<\/span> the_permalink(); <span style=\"color: #557799;\">?&gt;<\/span>\"&gt;&lt;span class=\"media-body\"&gt;<span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">echo<\/span> wp_trim_words(get_the_title(), <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>); <span style=\"color: #557799;\">?&gt;<\/span>&lt;\/span&gt;&lt;\/a&gt;<br>        &lt;\/li&gt;<br><span style=\"color: #557799;\">&lt;?php<\/span> <span style=\"color: #008800; font-weight: bold;\">endwhile<\/span>;<br><span style=\"color: #008800; font-weight: bold;\">endif<\/span> <span style=\"color: #557799;\">?&gt;<\/span><br><\/pre><\/div>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-15 17:08:58","total_views":257,"status":"publish","created_at":"2022-11-15T17:08:58.000000Z","updated_at":"2023-12-12T11:15:31.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":5,"title":"How to include a file in shortcode function in wordpress","slug":"how-to-include-a-file-in-shortcode-function-in-wordpress","image":null,"description":"<p>hoew to<\/p><p><br><\/p>\r\n\r\n<pre><code class=\"language-php\">\/\/ Shortcode implementation\r\nfunction magic_stuff($atts) {\r\n\r\n   \/\/ turn on output buffering to capture script output\r\n\t\r\n   ob_start();\r\n\r\n   \/\/ include file (contents will get saved in output buffer)\r\n\t\r\n   include(TEMPLATEPATH.'\/wp-content\/prugins\/magic-plugin\/magic-code.php');\r\n\r\n   \/\/ save and return the content that has been output\r\n\r\n   $content = ob_get_clean();\r\n   return $content;\r\n}\r\n\/\/register the Shortcode handler\r\nadd_shortcode('magic', 'magic_stuff');<\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-15 17:12:19","total_views":231,"status":"publish","created_at":"2022-11-15T17:12:19.000000Z","updated_at":"2023-12-12T11:15:20.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":30,"title":"How to Display Publish Dates as \u201cTime Ago\u201d Without Plugin","slug":"how-to-display-publish-dates-as-time-ago-without-plugin","image":"1691945943.png","description":"<span style=\"background-color: white; color: #525252; font-size: 18px;\">For Post: Go to<\/span><span style=\"background-color: white; color: #525252; font-size: 18px;\">&nbsp;<\/span><strong style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\"><em style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">wp-content\/your-theme\/functions.php<\/em>&nbsp;file<\/strong><span style=\"background-color: white; color: #525252; font-size: 18px;\">&nbsp;<\/span><span style=\"background-color: white; color: #525252; font-size: 18px;\">and scroll all the way down.<\/span>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>\r\n\r\n<pre><code>\r\n\/\/ Calclute how many time ago posted\r\nfunction my_post_time_ago_function()\r\n{\r\n    return sprintf(esc_html__('%s ago', 'textdomain'), human_time_diff(get_the_time('U'), current_time('timestamp')));\r\n}\r\nadd_filter('the_time', 'my_post_time_ago_function');\r\n<\/code><\/pre>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p>\r\n\r\n<pre><code>&lt;?php echo my_post_time_ago_function(); ?&gt;<\/code><\/pre>\r\n\r\n<hr style=\"margin: 30px 0;\">\r\n<p style=\"text-align: left;\"><code><span style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;\">If you want same thing to apply for <b>comment<\/b> dates<\/span><span style=\"background-color: white; color: #525252; font-size: 18px; white-space: normal;\">, create a similar function:<\/span><\/code><\/p>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>\r\n\r\n<pre><code>\r\n\/\/ Calclute how many time ago Commented\r\nfunction my_comment_time_ago_function() {\r\nreturn sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_comment_time ( 'U' ), current_time( 'timestamp' ) ) );\r\n}\r\nadd_filter( 'get_comment_date', 'my_comment_time_ago_function' );\r\n<\/code><\/pre>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p>\r\n\r\n<pre><code>&lt;?php echo my_comment_time_ago_function(); ?&gt;<\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:50:02","total_views":263,"status":"publish","created_at":"2022-11-17T17:50:02.000000Z","updated_at":"2023-10-08T11:51:42.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":31,"title":"WordPress Post reading time without plugin","slug":"wordpress-post-reading-time-without-plugin","image":"1691945755.png","description":"<p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #656565; font-family: Roboto, sans-serif; font-size: 14px; outline: 0px; padding: 0px; vertical-align: baseline;\"><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">For Post: Go to<\/span><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">&nbsp;<\/span><strong style=\"background: 0px 0px; border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\"><em style=\"background: 0px 0px; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">wp-content\/your-theme\/functions.php<\/em>&nbsp;file<\/strong><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">&nbsp;<\/span><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">and scroll all the way down.<\/span><\/p><p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>  <pre><code><br>\/*Post Reading Time count *\/<br>if (!function_exists('your_function_name_reading_time')) :<br>  function your_function_name_reading_time($post_id)<br>  {<br>    $content = apply_filters('the_content', get_post_field('post_content', $post_id));<br>    $read_words = esc_attr(get_theme_mod('global_show_min_read_number', '10'));<br>    $decode_content = html_entity_decode($content);<br>    $filter_shortcode = do_shortcode($decode_content);<br>    $strip_tags = wp_strip_all_tags($filter_shortcode, true);<br>    $count = str_word_count($strip_tags);<br>    $word_per_min = (absint($count) \/ $read_words);<br>    $word_per_min = ceil($word_per_min);<br>    if (absint($word_per_min) &gt; 0) {<br>      $word_count_strings = sprintf(_n(<br>        '%s min  ',<br>        '%s min  ',<br>        number_format_i18n($word_per_min),<br>        'isha'<br>      ), number_format_i18n($word_per_min));<br>      if ('post' == get_post_type($post_id)) :<br>        echo esc_html($word_count_strings);<br>      endif;<br>    }<br>    if (absint($word_per_min) == Null) {<br>      echo '1 min';<br>    }<br>  }<br>endif;<br><\/code><\/pre>  <p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p> <pre><code><span>&lt;?php your_function_name_reading_time( get_the_ID() ); ?&gt;<\/span><\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:50:58","total_views":249,"status":"publish","created_at":"2022-11-17T17:50:58.000000Z","updated_at":"2023-10-08T00:13:43.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":32,"title":"Remove UI And LI Elements From wp_nav_menu","slug":"remove-ui-and-li-elements-from-wp-nav-menu","image":"1691945671.png","description":"You can remove or change the <b>&lt;ul&gt;<\/b> container and <b>&lt;li&gt;<\/b> that you get by default with wp_nav_menu (<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_nav_menu\" target=\"_blank\" rel=\"noopener\">codex<\/a>) through parameters, but you can\u2019t remove the <b>&lt;ul&gt;<\/b>&nbsp; and <b>&lt;li&gt;&nbsp;<\/b>elements that wrap each menu item. This is how you can actually remove them:\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">\r\n&lt;?php\r\n$menuParameters = array(\r\n'theme_location' =&gt; 'footer', \/\/ Change Menu name\r\n'container' =&gt; false,\r\n'echo' =&gt; false,\r\n'items_wrap' =&gt; '%3$s',\r\n'depth' =&gt; 0,\r\n);\r\n\r\necho strip_tags(wp_nav_menu( $menuParameters ), '<a>' );\r\n?&gt;\r\n<\/a><\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:52:34","total_views":331,"status":"publish","created_at":"2022-11-17T17:52:34.000000Z","updated_at":"2023-10-09T02:58:15.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":33,"title":"Limit the word count in the post title","slug":"limit-the-word-count-in-the-post-title","image":"1691946274.png","description":"Are you looking for Limit the word count in the post title to trim your Post Title Length in WordPress? While there\u2019s probably a plugin for this, we have created a quick code snippet that allows you to use wp_trim_words to trim your text in WordPress.\r\n\r\nWordPress 3.3+ has a core function called&nbsp;<code>wp_trim_words()<\/code>. This function will trim text to a specified number of words and return the result. Adding this snippet to your WordPress loop will let you easily trim the number of words displayed within&nbsp;<code>the_content<\/code>,&nbsp;<code>the_excerpt<\/code>,&nbsp;<code>the_title<\/code>&nbsp;or any other value you pass to this core function.\r\n\r\n<strong>Instructions:<\/strong>\r\n\r\nAll you have to do is add this code to your theme\u2019s PHP file where you want to show the title:\r\n<div class=\"containerx\">\r\n\r\nIf continue sign \"...\" needed at the end of title\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php echo wp_trim_words( get_the_title(), 10, '...' ); ?&gt;\r\n<\/code><\/pre>\r\n<div title=\"Edit &amp; Save To Grepper\"><\/div>\r\nIf continue sign \"...\" not needed at the end of title\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php echo wp_trim_words( get_the_title(), 10 ); ?&gt;<\/code><\/pre>\r\n<\/div>\r\n<h2>Parameters:<\/h2>\r\n<dl>\r\n \t<dt><tt><b>$text<\/b><\/tt><\/dt>\r\n \t<dd>(<i>string<\/i>) (<i>required<\/i>) Text to trim\r\n<dl>\r\n \t<dd>Default:&nbsp;<i>None<\/i><\/dd>\r\n<\/dl>\r\n<\/dd>\r\n<\/dl>\r\n<dl>\r\n \t<dt><tt><b>$num_words<\/b><\/tt><\/dt>\r\n \t<dd>(<i>integer<\/i>) (<i>optional<\/i>) Number of words\r\n<dl>\r\n \t<dd>Default: 55<\/dd>\r\n<\/dl>\r\n<\/dd>\r\n<\/dl>\r\n<dl>\r\n \t<dt><tt><b>$more<\/b><\/tt><\/dt>\r\n \t<dd>(<i>string<\/i>) (<i>optional<\/i>) What to append if&nbsp;<tt>$text<\/tt>&nbsp;needs to be trimmed.<\/dd>\r\n<\/dl>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-18 05:57:21","total_views":301,"status":"publish","created_at":"2022-11-18T05:57:21.000000Z","updated_at":"2023-10-13T00:16:12.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":35,"title":"Hide a div on clicking outside it with JavaScript\/jQuery","slug":"hide-a-div-on-clicking-outside-it-with-javascriptjquery","image":"1691946349.png","description":"Hey guys, today in this post we are going to learn about How to close a div container when clicking outside the target. We will use <strong>jQuery<\/strong> for that. <strong><em>jQuery<\/em><\/strong> is a fast, small, and feature-rich JavaScript library.\r\n\r\n<strong>We can use the following code:<\/strong>\r\n<em>1. A mouseup event is to first checked upon the document.<\/em>\r\n<em>3. The element is checked for 2 things, that the click does not land on the element by passing the is() method and the has() method with the click target.<\/em>\r\n\r\nThe is() method check the current element against the specified element. The click target is passed as a parameter and the whole result is negated to essentially check if the click was outside the element.\r\n\r\nThe has() method is used to return all the elements which match at least one of the elements passed to this method. The length property is then used on the result to check if any elements are returned. If there are no elements returned, it means that the click was outside the element.\r\n3. The element is hidden using the hide() method.\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-jQuery\">$(<span class=\"hljs-variable language_\">document<\/span>).<span class=\"hljs-title function_\">mouseup<\/span>(<span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">e<\/span>) \r\n{\r\n    <span class=\"hljs-keyword\">var<\/span> container = $(<span class=\"hljs-string\">\"YOUR CONTAINER SELECTOR\"<\/span>);\r\n\r\n    <span class=\"hljs-comment\">\/\/ if the target of the click isn't the container nor a descendant of the container<\/span>\r\n    <span class=\"hljs-keyword\">if<\/span> (!container.<span class=\"hljs-title function_\">is<\/span>(e.<span class=\"hljs-property\">target<\/span>) &amp;&amp; container.<span class=\"hljs-title function_\">has<\/span>(e.<span class=\"hljs-property\">target<\/span>).<span class=\"hljs-property\">length<\/span> === <span class=\"hljs-number\">0<\/span>) \r\n    {\r\n        container.<span class=\"hljs-title function_\">hide<\/span>();\r\n    }\r\n});<\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-26 16:28:15","total_views":333,"status":"publish","created_at":"2022-11-26T16:28:15.000000Z","updated_at":"2023-10-12T22:47:20.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}},{"id":36,"title":"Remove Custom Post Type Name from Permalink in WordPress","slug":"remove-custom-post-type-name-from-permalink-in-wordpress","image":null,"description":"If you are a WordPress developer and love to create custom post types to addon the new feature in your project then this article is very helpful for you.\r\n\r\nWhen you create a new custom post type in WordPress then you can see that by default, its slug will show in the permalink URL structure. Adding slug to permalink displays the post type of the current post and creates the URLs longer which is hard to remember. Also, it creates an issue to rank articles in Google.\r\n\r\nSo now I will cover all steps to remove slug from custom post type to make URL shorter and easy to remember.\r\n<h2 id=\"custom-post-type-in-wordpress\">Custom Post Type in WordPress<\/h2>\r\nRecently, I created a custom post type called&nbsp;<strong>\u201cPost Type\u201d<\/strong>&nbsp;for a company. This resulted in permalinks such as&nbsp;<code><strong>example.com\/post_type1\/post-title<\/strong><\/code>\r\n\r\n<span class=\"tadv-color\">As you can see, having permalinks like&nbsp;<code><strong>example.com\/post_type1\/post-title<\/strong><\/code>&nbsp;is not nearly as clean, also not easy to remember and search engine optimized.<\/span>\r\n\r\n<span class=\"tadv-color\">But having permalinks like&nbsp;<code><strong>example.com\/post-title<\/strong><\/code>&nbsp;is nearly as clean, easy to remember, and SEO friendly.<\/span>\r\n\r\nAs SEO (Search Engine Optimization) experts always suggest making URL shorter highly rank in Google.\r\n\r\nI hope now you are clear with the article\u2019s focused point. Now let\u2019s see the solution:\r\n<h2 id=\"remove-slug-from-custom-post-type\">Remove slug from custom post type<\/h2>\r\n<strong>Step-1:&nbsp;<\/strong><a title=\"Create your custom post type\" href=\"https:\/\/wesoftpress.com\/backup\/how-to-create-custom-post-type-taxonomy-category-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">Create your custom post type<\/a>&nbsp;if you are not already created it till now.\r\n\r\n<strong>Step-2:&nbsp;<\/strong>Copy and Paste the following code to your theme&nbsp;<strong>functions.php<\/strong>&nbsp;file to filter the permalink for our custom post type so that all published posts don\u2019t have the slug in their URLs:\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php \r\n\/**\r\n * Remove the slug from published post permalinks for our custom post types.\r\n *\/\r\nadd_filter( 'post_type_link', function( $post_link, $post, $leavename ) {\r\n\r\n\t$post_types = array(\r\n\t\t'post_type_1',\r\n\t\t'post_type_2'\r\n\t);\r\n\r\n\tif ( in_array( $post-&gt;post_type, $post_types ) &amp;&amp; 'publish' === $post-&gt;post_status ) {\r\n\t\t$post_link = str_replace( '\/' . $post-&gt;post_type . '\/', '\/', $post_link );\r\n\t}\r\n\r\n\treturn $post_link;\r\n\r\n}, 10, 3 );\r\n\r\n\/**\r\n * Some hackery to have WordPress match postname to any of our public post types.\r\n *\r\n * All of our public post types can have \/post-name\/ as the slug, so they better be unique across all posts\r\n * Typically core only accounts for posts and pages where the slug is \/post-name\/\r\n *\/\r\nadd_action( 'pre_get_posts', function( $query ) {\r\n\r\n\r\n\tif ( ! $query-&gt;is_main_query() || 2 != count( $query-&gt;query ) || ! isset( $query-&gt;query['page'] ) ) {\r\n        return;\r\n    }\r\n\r\n\t\/\/ 'name' will be set if post permalinks are just post_name, otherwise the page rule will match.\r\n\tif ( ! empty( $query-&gt;query['name'] ) ) {\r\n\r\n\t\t\t$post_types = array(\r\n\t\t\t'post', \/\/ important to  not break your standard posts\r\n\t\t\t'page', \/\/ important to  not break your standard pages\r\n\t\t\t'post_type_1',\r\n\t\t\t'post_type_12'\r\n\t\t);\r\n\r\n\t\t$query-&gt;set( 'post_type', $post_types );\r\n\r\n\t}\r\n\r\n} );\r\n?&gt;\r\n<\/code><\/pre>\r\nThat\u2019s it! Just replace &nbsp;\u201conline_services\u201d&nbsp;with the slug of your custom post type in both code samples. After this&nbsp;<strong>Go to&nbsp;<code>Settings<\/code>&nbsp;&gt;&nbsp;<code>Permalinks<\/code>&nbsp;<\/strong>and saving the permalink structure to end in&nbsp;<code>\/%postname%\/<\/code>&nbsp;may also be necessary.\r\n<h2 id=\"wrapping-words\">Wrapping Words!<\/h2>\r\nThanks for reading \ud83d\ude4f, I hope you found the&nbsp;<strong>Remove slug from custom post type in WordPress&nbsp;<\/strong>Without Plugin tutorial helpful for your project. Keep learning! If you face any problems \u2013 I am here to solve your problems.","meta_description":"remove custom post type name from url, remove custom post type name from wordpress","category_id":4,"user_id":1,"published_at":"2022-11-26 16:29:25","total_views":343,"status":"publish","created_at":"2022-11-26T16:29:25.000000Z","updated_at":"2024-08-21T17:04:30.000000Z","category":{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},"user":{"id":1,"name":"Admin","email":"admin@gmail.com","email_verified_at":null,"created_at":null,"updated_at":null}}],"first_page_url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=1","from":1,"last_page":1,"last_page_url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=1","links":[{"url":null,"label":"&laquo; Previous","active":false},{"url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=1","label":"1","active":true},{"url":null,"label":"Next &raquo;","active":false}],"next_page_url":null,"path":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress","per_page":12,"prev_page_url":null,"to":8,"total":8},"latest_posts":{"current_page":1,"data":[{"id":47,"title":"Estimated Reading Time Calculate in Laravel","slug":"estimated-reading-time-calculate-in-laravel","image":"1695704483.png","description":"<p style=\"margin-bottom: 1rem; font-size: 17px; line-height: 28px; font-family: Inter, sans-serif;\"><font color=\"#000000\"><br><\/font><\/p><p style=\"margin-bottom: 1rem; font-size: 17px; line-height: 28px; font-family: Inter, sans-serif;\"><font color=\"#000000\">Hi artisans, in this snippet, we are going to learn how to calculate estimated reading time in Laravel. We'll use Laravel Macro.<\/font><\/p><p style=\"margin-bottom: 1rem; font-size: 17px; line-height: 28px; font-family: Inter, sans-serif;\"><font color=\"#000000\">In Laravel, a macro is a way to extend the functionality of a class by adding custom methods to it at runtime. This means you can add new methods to a class without having to modify the class itself. Macros can be used on various Laravel classes such as Collection, Request, Response, etc.<\/font><\/p><div class=\"raw-html-embed\" style=\"color: rgb(161, 161, 168); font-family: Inter, sans-serif; font-size: 15px; background-color: rgb(20, 21, 25);\"><h2 id=\"step1\" class=\"step\" style=\"margin-bottom: 0.5em; font-family: Inter, sans-serif; line-height: 1.25; color: rgb(0, 0, 0); background-color: rgb(203, 203, 203); border-left: 5px solid rgb(104, 100, 100); border-top: 1px solid rgb(104, 100, 100); border-bottom: 1px solid rgb(104, 100, 100); display: inline-block; padding: 5px 7px; width: 704.672px; font-size: 20px !important;\">Create Reading Time Macro<\/h2><\/div><p style=\"margin-bottom: 1rem; font-size: 17px; color: rgba(187, 187, 187, 0.976); line-height: 28px; font-family: Inter, sans-serif; background-color: rgb(20, 21, 25);\">Open&nbsp;<code style=\"font-family: Menlo, monospace; font-size: 0.78em; --bg-opacity: 1; padding: 0.2rem 0.33rem; vertical-align: 1%; background-color: rgb(135, 135, 135); border: 1px solid rgb(135, 135, 135); border-radius: 5px; color: rgb(233, 233, 233) !important;\">app\\Providers\\AppServiceProvider.php<\/code>&nbsp;file and in the&nbsp;<code style=\"font-family: Menlo, monospace; font-size: 0.78em; --bg-opacity: 1; padding: 0.2rem 0.33rem; vertical-align: 1%; background-color: rgb(135, 135, 135); border: 1px solid rgb(135, 135, 135); border-radius: 5px; color: rgb(233, 233, 233) !important;\">boot()<\/code>&nbsp;method add this macro:<\/p><div class=\"code-toolbar\" style=\"position: relative; color: rgb(161, 161, 168); font-family: Inter, sans-serif; font-size: 15px; background-color: rgb(20, 21, 25);\"><pre class=\"language-php\" tabindex=\"0\" style=\"font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; max-height: 500px; border: 0px; border-radius: 4px; background: 0px 0px; tab-size: 2; color: rgb(179, 185, 197); padding: 0px; direction: ltr; word-spacing: normal; word-break: normal; line-height: 1.4; hyphens: none; -webkit-font-smoothing: subpixel-antialiased;\"><code class=\"language-php\" style=\"font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; color: rgb(179, 185, 197); direction: ltr; word-spacing: normal; line-height: 1.4; tab-size: 2; hyphens: none; -webkit-font-smoothing: subpixel-antialiased; display: block; padding: 1rem; overflow: auto; background-color: rgb(51, 51, 51); box-shadow: rgba(0, 0, 0, 0.15) 2px 4px 25px;\"><span class=\"token keyword\" style=\"color: rgb(255, 238, 173);\">use<\/span> <span class=\"token package\">Illuminate<span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">\\<\/span>Support<span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">\\<\/span>Str<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span>\r\n\r\n<span class=\"token comment\" style=\"color: rgb(119, 124, 133);\">\/\/ macro: reading time<\/span>\r\n<span class=\"token class-name static-context\" style=\"color: rgb(225, 166, 242);\">Str<\/span><span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">::<\/span><span class=\"token function\" style=\"color: rgb(255, 255, 255);\">macro<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token string single-quoted-string\" style=\"color: rgb(146, 209, 146);\">'readingTime'<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">,<\/span> <span class=\"token keyword\" style=\"color: rgb(255, 238, 173);\">function<\/span> <span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$text<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span> <span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">{<\/span>\r\n    <span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$totalWords<\/span> <span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">=<\/span> <span class=\"token function\" style=\"color: rgb(255, 255, 255);\">str<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">-&gt;<\/span><span class=\"token function\" style=\"color: rgb(255, 255, 255);\">wordCount<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$text<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span>\r\n    <span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$minutesToRead<\/span> <span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">=<\/span> <span class=\"token function\" style=\"color: rgb(255, 255, 255);\">round<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$totalWords<\/span> <span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">\/<\/span> <span class=\"token number\" style=\"color: rgb(119, 227, 142);\">200<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">,<\/span> <span class=\"token number\" style=\"color: rgb(119, 227, 142);\">1<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span>\r\n\r\n    <span class=\"token keyword\" style=\"color: rgb(255, 238, 173);\">return<\/span> <span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token keyword type-casting\" style=\"color: rgb(255, 238, 173);\">int<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token function\" style=\"color: rgb(255, 255, 255);\">max<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token number\" style=\"color: rgb(119, 227, 142);\">1<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">,<\/span> <span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$minutesToRead<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span> <span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">.<\/span> <span class=\"token string single-quoted-string\" style=\"color: rgb(146, 209, 146);\">' min'<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span>\r\n<span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">}<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span><\/code><\/pre><div class=\"toolbar\" style=\"position: absolute; top: 0.3em; right: 0.2em; transition: opacity 0.3s ease-in-out; opacity: 0;\"><div class=\"toolbar-item\"><button class=\"copy-to-clipboard-button\" type=\"button\" data-copy-state=\"copy\" style=\"border-radius: 0.5em; font-size: 0.8em; line-height: normal; border-width: 0px; border-style: initial; border-color: initial; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-optical-sizing: inherit; font-size-adjust: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; user-select: none; color: rgb(187, 187, 187); padding: 0px 0.5em; background: rgba(224, 224, 224, 0.2); box-shadow: rgba(0, 0, 0, 0.2) 0px 2px;\">Copy<\/button><\/div><\/div><\/div><p style=\"margin-bottom: 1rem; font-size: 17px; color: rgba(187, 187, 187, 0.976); line-height: 28px; font-family: Inter, sans-serif; background-color: rgb(20, 21, 25);\">Here, we extended Laravel&nbsp;<code style=\"font-family: Menlo, monospace; font-size: 0.78em; --bg-opacity: 1; padding: 0.2rem 0.33rem; vertical-align: 1%; background-color: rgb(135, 135, 135); border: 1px solid rgb(135, 135, 135); border-radius: 5px; color: rgb(233, 233, 233) !important;\">Str<\/code>&nbsp;class and 200 (words per min) is the average reading speed.<\/p><p style=\"margin-bottom: 1rem; font-size: 17px; color: rgba(187, 187, 187, 0.976); line-height: 28px; font-family: Inter, sans-serif; background-color: rgb(20, 21, 25);\">The average reading time can vary depending on factors such as reading speed, complexity of the material, and familiarity with the subject matter. However, a rough estimate for the average reading time for an adult is around 200-300 words per minute.<\/p><div class=\"raw-html-embed\" style=\"color: rgb(161, 161, 168); font-family: Inter, sans-serif; font-size: 15px; background-color: rgb(20, 21, 25);\"><h2 id=\"step2\" class=\"step\" style=\"margin-bottom: 0.5em; font-family: Inter, sans-serif; line-height: 1.25; color: rgb(0, 0, 0); background-color: rgb(203, 203, 203); border-left: 5px solid rgb(104, 100, 100); border-top: 1px solid rgb(104, 100, 100); border-bottom: 1px solid rgb(104, 100, 100); display: inline-block; padding: 5px 7px; width: 704.672px; font-size: 20px !important;\">Use the Marco<\/h2><\/div><p style=\"margin-bottom: 1rem; font-size: 17px; color: rgba(187, 187, 187, 0.976); line-height: 28px; font-family: Inter, sans-serif; background-color: rgb(20, 21, 25);\">Now, we can easily use the&nbsp;<code style=\"font-family: Menlo, monospace; font-size: 0.78em; --bg-opacity: 1; padding: 0.2rem 0.33rem; vertical-align: 1%; background-color: rgb(135, 135, 135); border: 1px solid rgb(135, 135, 135); border-radius: 5px; color: rgb(233, 233, 233) !important;\">readingTime()<\/code>&nbsp;Macro like Laravel&nbsp;<code style=\"font-family: Menlo, monospace; font-size: 0.78em; --bg-opacity: 1; padding: 0.2rem 0.33rem; vertical-align: 1%; background-color: rgb(135, 135, 135); border: 1px solid rgb(135, 135, 135); border-radius: 5px; color: rgb(233, 233, 233) !important;\">Str<\/code>&nbsp;methods anywhere in our application.<\/p><div class=\"code-toolbar\" style=\"position: relative; color: rgb(161, 161, 168); font-family: Inter, sans-serif; font-size: 15px; background-color: rgb(20, 21, 25);\"><pre class=\"language-php\" tabindex=\"0\" style=\"font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; max-height: 500px; border: 0px; border-radius: 4px; background: 0px 0px; tab-size: 2; color: rgb(179, 185, 197); padding: 0px; direction: ltr; word-spacing: normal; word-break: normal; line-height: 1.4; hyphens: none; -webkit-font-smoothing: subpixel-antialiased;\"><code class=\"language-php\" style=\"font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; color: rgb(179, 185, 197); direction: ltr; word-spacing: normal; line-height: 1.4; tab-size: 2; hyphens: none; -webkit-font-smoothing: subpixel-antialiased; display: block; padding: 1rem; overflow: auto; background-color: rgb(51, 51, 51); box-shadow: rgba(0, 0, 0, 0.15) 2px 4px 25px;\"><span class=\"token variable\" style=\"color: rgb(242, 119, 122);\">$readingTime<\/span> <span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">=<\/span> <span class=\"token function\" style=\"color: rgb(255, 255, 255);\">str<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token operator\" style=\"color: rgb(172, 141, 88);\">-&gt;<\/span><span class=\"token function\" style=\"color: rgb(255, 255, 255);\">readingTime<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">(<\/span><span class=\"token string double-quoted-string\" style=\"color: rgb(146, 209, 146);\">\"This is an article!\"<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">)<\/span><span class=\"token punctuation\" style=\"color: rgb(213, 216, 223);\">;<\/span> <span class=\"token comment\" style=\"color: rgb(119, 124, 133);\">\/\/ 1 min read<\/span><\/code><\/pre><div class=\"toolbar\" style=\"position: absolute; top: 0.3em; right: 0.2em; transition: opacity 0.3s ease-in-out; opacity: 0;\"><div class=\"toolbar-item\"><button class=\"copy-to-clipboard-button\" type=\"button\" data-copy-state=\"copy\" style=\"border-radius: 0.5em; font-size: 0.8em; line-height: normal; border-width: 0px; border-style: initial; border-color: initial; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-optical-sizing: inherit; font-size-adjust: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; user-select: none; color: rgb(187, 187, 187); padding: 0px 0.5em; background: rgba(224, 224, 224, 0.2); box-shadow: rgba(0, 0, 0, 0.2) 0px 2px;\">Copy<\/button><\/div><\/div><\/div><p style=\"margin-bottom: 1rem; font-size: 17px; color: rgba(187, 187, 187, 0.976); line-height: 28px; font-family: Inter, sans-serif; background-color: rgb(20, 21, 25);\">That's all. Happy coding \u2764\ufe0f!<\/p>","meta_description":null,"category_id":5,"user_id":1,"published_at":"2024-12-27 11:39:12","total_views":0,"status":"publish","created_at":"2024-12-27T11:39:12.000000Z","updated_at":"2024-12-27T15:58:44.000000Z"},{"id":46,"title":"1409. Two Gangsters - Problem Solution & Logic","slug":"1409-two-gangsters-problem-solution-logic","image":null,"description":"<p>#include &lt;cstdio&gt;<\/p><p><br><\/p><p>using namespace std;<\/p><p><br><\/p><p>int main(){<\/p><p>&nbsp; &nbsp; int x,y;<\/p><p>&nbsp; &nbsp; scanf(\"%d %d\",&amp;x,&amp;y);<\/p><p>&nbsp; &nbsp; printf(\"%d %d\\n\",y-1,x-1);<\/p><p><br><\/p><p>&nbsp; &nbsp; return 0;<\/p><p>}<\/p>","meta_description":null,"category_id":5,"user_id":1,"published_at":"2024-06-08 09:41:23","total_views":0,"status":"publish","created_at":"2024-06-08T09:41:23.000000Z","updated_at":"2024-06-08T09:41:23.000000Z"},{"id":45,"title":"1293. Eniya - Problem Solution & Logic","slug":"1293-eniya-problem-solution-logic","image":null,"description":"<pre style=\"color: rgb(255, 238, 221); font-size: 13.524px; background-color: rgb(68, 21, 0);\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n\r\n{\r\n    int n,b,c;\r\n    cin&gt;&gt;n&gt;&gt;b&gt;&gt;c;\r\n    cout&lt;&lt;2*n*b*c&lt;&lt;endl;\r\n    return 0;\r\n}<\/pre>","meta_description":null,"category_id":5,"user_id":1,"published_at":"2024-06-08 09:00:54","total_views":0,"status":"publish","created_at":"2024-06-08T09:00:54.000000Z","updated_at":"2024-06-08T09:00:54.000000Z"},{"id":44,"title":"1264. Workdays - Problem Solution & Logic","slug":"1264-workdays-problem-solution-logic","image":null,"description":"<p>#include &lt;cstdio&gt;<\/p><p><br><\/p><p>using namespace std;<\/p><p><br><\/p><p>int main(){<\/p><p>&nbsp; &nbsp; long long N,M;<\/p><p>&nbsp; &nbsp; scanf(\"%lld %lld\",&amp;N,&amp;M);<\/p><p>&nbsp; &nbsp;&nbsp;<\/p><p>&nbsp; &nbsp; printf(\"%lld\\n\",N*(M+1));<\/p><p>&nbsp; &nbsp;&nbsp;<\/p><p>&nbsp; &nbsp; return 0;<\/p><p>}<\/p><div><br><\/div>","meta_description":null,"category_id":5,"user_id":1,"published_at":"2024-06-08 07:40:35","total_views":0,"status":"publish","created_at":"2024-06-08T07:40:35.000000Z","updated_at":"2024-06-08T07:40:35.000000Z"},{"id":37,"title":"Timus 1068. Sum - Problem Solution & Logic","slug":"timus-1068-sum-problem-solution-logic","image":null,"description":"Almost every online judge has a \u201cA+B\u201d problem. The first problem (easiest) is often present to allow testing if online judges are working (of course they are!)\r\n\r\nThis problem can be found at Timus Online Judge.\r\n\r\nOf course, almost every registered users will AC this simple problem after immediate registration, to boost their confidence.\r\n\r\nThis problem, is so simple, but don\u2019t have so much details\u2026 for example, the range of inputs are unknown.\r\n\r\nThe Solution of the problem in C++ is :\r\n\r\n<pre><code>\r\n#include<stdio.h>\r\n\r\nint main(){\r\n    int a, b;\r\n    scanf(\"%d %d\", &amp;a, &amp;b);\r\n    printf(\"%d\\n\", a+b);\r\n    return 0;\r\n}\r\n<\/stdio.h><\/code>\r\n<\/pre>","meta_description":null,"category_id":5,"user_id":1,"published_at":"2022-11-26 16:30:45","total_views":339,"status":"publish","created_at":"2022-11-26T16:30:45.000000Z","updated_at":"2023-10-10T14:54:53.000000Z"},{"id":36,"title":"Remove Custom Post Type Name from Permalink in WordPress","slug":"remove-custom-post-type-name-from-permalink-in-wordpress","image":null,"description":"If you are a WordPress developer and love to create custom post types to addon the new feature in your project then this article is very helpful for you.\r\n\r\nWhen you create a new custom post type in WordPress then you can see that by default, its slug will show in the permalink URL structure. Adding slug to permalink displays the post type of the current post and creates the URLs longer which is hard to remember. Also, it creates an issue to rank articles in Google.\r\n\r\nSo now I will cover all steps to remove slug from custom post type to make URL shorter and easy to remember.\r\n<h2 id=\"custom-post-type-in-wordpress\">Custom Post Type in WordPress<\/h2>\r\nRecently, I created a custom post type called&nbsp;<strong>\u201cPost Type\u201d<\/strong>&nbsp;for a company. This resulted in permalinks such as&nbsp;<code><strong>example.com\/post_type1\/post-title<\/strong><\/code>\r\n\r\n<span class=\"tadv-color\">As you can see, having permalinks like&nbsp;<code><strong>example.com\/post_type1\/post-title<\/strong><\/code>&nbsp;is not nearly as clean, also not easy to remember and search engine optimized.<\/span>\r\n\r\n<span class=\"tadv-color\">But having permalinks like&nbsp;<code><strong>example.com\/post-title<\/strong><\/code>&nbsp;is nearly as clean, easy to remember, and SEO friendly.<\/span>\r\n\r\nAs SEO (Search Engine Optimization) experts always suggest making URL shorter highly rank in Google.\r\n\r\nI hope now you are clear with the article\u2019s focused point. Now let\u2019s see the solution:\r\n<h2 id=\"remove-slug-from-custom-post-type\">Remove slug from custom post type<\/h2>\r\n<strong>Step-1:&nbsp;<\/strong><a title=\"Create your custom post type\" href=\"https:\/\/wesoftpress.com\/backup\/how-to-create-custom-post-type-taxonomy-category-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\">Create your custom post type<\/a>&nbsp;if you are not already created it till now.\r\n\r\n<strong>Step-2:&nbsp;<\/strong>Copy and Paste the following code to your theme&nbsp;<strong>functions.php<\/strong>&nbsp;file to filter the permalink for our custom post type so that all published posts don\u2019t have the slug in their URLs:\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php \r\n\/**\r\n * Remove the slug from published post permalinks for our custom post types.\r\n *\/\r\nadd_filter( 'post_type_link', function( $post_link, $post, $leavename ) {\r\n\r\n\t$post_types = array(\r\n\t\t'post_type_1',\r\n\t\t'post_type_2'\r\n\t);\r\n\r\n\tif ( in_array( $post-&gt;post_type, $post_types ) &amp;&amp; 'publish' === $post-&gt;post_status ) {\r\n\t\t$post_link = str_replace( '\/' . $post-&gt;post_type . '\/', '\/', $post_link );\r\n\t}\r\n\r\n\treturn $post_link;\r\n\r\n}, 10, 3 );\r\n\r\n\/**\r\n * Some hackery to have WordPress match postname to any of our public post types.\r\n *\r\n * All of our public post types can have \/post-name\/ as the slug, so they better be unique across all posts\r\n * Typically core only accounts for posts and pages where the slug is \/post-name\/\r\n *\/\r\nadd_action( 'pre_get_posts', function( $query ) {\r\n\r\n\r\n\tif ( ! $query-&gt;is_main_query() || 2 != count( $query-&gt;query ) || ! isset( $query-&gt;query['page'] ) ) {\r\n        return;\r\n    }\r\n\r\n\t\/\/ 'name' will be set if post permalinks are just post_name, otherwise the page rule will match.\r\n\tif ( ! empty( $query-&gt;query['name'] ) ) {\r\n\r\n\t\t\t$post_types = array(\r\n\t\t\t'post', \/\/ important to  not break your standard posts\r\n\t\t\t'page', \/\/ important to  not break your standard pages\r\n\t\t\t'post_type_1',\r\n\t\t\t'post_type_12'\r\n\t\t);\r\n\r\n\t\t$query-&gt;set( 'post_type', $post_types );\r\n\r\n\t}\r\n\r\n} );\r\n?&gt;\r\n<\/code><\/pre>\r\nThat\u2019s it! Just replace &nbsp;\u201conline_services\u201d&nbsp;with the slug of your custom post type in both code samples. After this&nbsp;<strong>Go to&nbsp;<code>Settings<\/code>&nbsp;&gt;&nbsp;<code>Permalinks<\/code>&nbsp;<\/strong>and saving the permalink structure to end in&nbsp;<code>\/%postname%\/<\/code>&nbsp;may also be necessary.\r\n<h2 id=\"wrapping-words\">Wrapping Words!<\/h2>\r\nThanks for reading \ud83d\ude4f, I hope you found the&nbsp;<strong>Remove slug from custom post type in WordPress&nbsp;<\/strong>Without Plugin tutorial helpful for your project. Keep learning! If you face any problems \u2013 I am here to solve your problems.","meta_description":"remove custom post type name from url, remove custom post type name from wordpress","category_id":4,"user_id":1,"published_at":"2022-11-26 16:29:25","total_views":343,"status":"publish","created_at":"2022-11-26T16:29:25.000000Z","updated_at":"2024-08-21T17:04:30.000000Z"},{"id":35,"title":"Hide a div on clicking outside it with JavaScript\/jQuery","slug":"hide-a-div-on-clicking-outside-it-with-javascriptjquery","image":"1691946349.png","description":"Hey guys, today in this post we are going to learn about How to close a div container when clicking outside the target. We will use <strong>jQuery<\/strong> for that. <strong><em>jQuery<\/em><\/strong> is a fast, small, and feature-rich JavaScript library.\r\n\r\n<strong>We can use the following code:<\/strong>\r\n<em>1. A mouseup event is to first checked upon the document.<\/em>\r\n<em>3. The element is checked for 2 things, that the click does not land on the element by passing the is() method and the has() method with the click target.<\/em>\r\n\r\nThe is() method check the current element against the specified element. The click target is passed as a parameter and the whole result is negated to essentially check if the click was outside the element.\r\n\r\nThe has() method is used to return all the elements which match at least one of the elements passed to this method. The length property is then used on the result to check if any elements are returned. If there are no elements returned, it means that the click was outside the element.\r\n3. The element is hidden using the hide() method.\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-jQuery\">$(<span class=\"hljs-variable language_\">document<\/span>).<span class=\"hljs-title function_\">mouseup<\/span>(<span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">e<\/span>) \r\n{\r\n    <span class=\"hljs-keyword\">var<\/span> container = $(<span class=\"hljs-string\">\"YOUR CONTAINER SELECTOR\"<\/span>);\r\n\r\n    <span class=\"hljs-comment\">\/\/ if the target of the click isn't the container nor a descendant of the container<\/span>\r\n    <span class=\"hljs-keyword\">if<\/span> (!container.<span class=\"hljs-title function_\">is<\/span>(e.<span class=\"hljs-property\">target<\/span>) &amp;&amp; container.<span class=\"hljs-title function_\">has<\/span>(e.<span class=\"hljs-property\">target<\/span>).<span class=\"hljs-property\">length<\/span> === <span class=\"hljs-number\">0<\/span>) \r\n    {\r\n        container.<span class=\"hljs-title function_\">hide<\/span>();\r\n    }\r\n});<\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-26 16:28:15","total_views":333,"status":"publish","created_at":"2022-11-26T16:28:15.000000Z","updated_at":"2023-10-12T22:47:20.000000Z"},{"id":34,"title":"How to Fix Android License Status Unknown In Flutter?","slug":"how-to-fix-android-license-status-unknown-in-flutter","image":null,"description":"<div itemprop=\"text\"><p>follow these steps:<\/p>  <li>open SDK Manager<\/li><li>go to SDK tools<\/li><li>Install \"Android sdk command line tool(latest)\"<\/li><\/div><div style=\"clear: both; text-align: center;\"><br><\/div><div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/xJ5MX.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" data-original-height=\"483\" data-original-width=\"772\" height=\"250\" src=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/xJ5MX-300x188.png\" width=\"400\"><\/a><\/div><div style=\"clear: both; text-align: center;\"><br><\/div><div><br><\/div> <li>check it and apply and let the studio download the package <\/li><li>once done run the command <span style=\"background-color: #4c1130; color: white;\">flutter doctor<\/span> and it should now prompt you to run <span style=\"background-color: #4c1130; color: white;\">flutter doctor --android-licenses<\/span>once you run the license command accept all licenses by <span style=\"color: #cc0000;\">hitting y<\/span> and it should solve the problem<\/li><div><br><\/div><p style=\"text-align: left;\"><b>  This Will Solve The Issue-<\/b><\/p><div>&nbsp;IF the Issue Is Still There&nbsp; - follow these steps:<\/div><div><div itemprop=\"text\"><li>open SDK Manager<\/li><li>under SDK tools uncheck hide obsolete packages at the bottom<\/li><li>then you should see an option called \"Android SDK Tools (Obsolete)\"<\/li><\/div><p>&nbsp;<\/p><div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/Pii3f.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" data-original-height=\"1446\" data-original-width=\"2026\" height=\"285\" src=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/Pii3f-300x214.png\" width=\"400\"><\/a><\/div><br><p><\/p><div itemprop=\"text\">  <li>check it and apply and let the studio download the package <\/li><li>once done run the command <span style=\"background-color: #4c1130; color: white;\">flutter doctor<\/span> and it should now prompt you to run <span style=\"background-color: #4c1130; color: white;\">flutter doctor --android-licenses<\/span>once you run the license command accept all licenses by <span style=\"color: #cc0000;\">hitting y<\/span> and it should solve the problem<\/li>  <div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/HVhD5.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" data-original-height=\"904\" data-original-width=\"1336\" height=\"271\" src=\"https:\/\/wesoftpress.com\/backup\/wp-content\/uploads\/2021\/05\/HVhD5-300x203.png\" width=\"400\"><\/a><\/div><br><div style=\"clear: both; text-align: center;\"><br><\/div><p style=\"text-align: left;\"><\/p>    <\/div><\/div>","meta_description":null,"category_id":7,"user_id":1,"published_at":"2022-11-26 16:26:19","total_views":314,"status":"publish","created_at":"2022-11-26T16:26:19.000000Z","updated_at":"2023-10-09T00:41:04.000000Z"},{"id":33,"title":"Limit the word count in the post title","slug":"limit-the-word-count-in-the-post-title","image":"1691946274.png","description":"Are you looking for Limit the word count in the post title to trim your Post Title Length in WordPress? While there\u2019s probably a plugin for this, we have created a quick code snippet that allows you to use wp_trim_words to trim your text in WordPress.\r\n\r\nWordPress 3.3+ has a core function called&nbsp;<code>wp_trim_words()<\/code>. This function will trim text to a specified number of words and return the result. Adding this snippet to your WordPress loop will let you easily trim the number of words displayed within&nbsp;<code>the_content<\/code>,&nbsp;<code>the_excerpt<\/code>,&nbsp;<code>the_title<\/code>&nbsp;or any other value you pass to this core function.\r\n\r\n<strong>Instructions:<\/strong>\r\n\r\nAll you have to do is add this code to your theme\u2019s PHP file where you want to show the title:\r\n<div class=\"containerx\">\r\n\r\nIf continue sign \"...\" needed at the end of title\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php echo wp_trim_words( get_the_title(), 10, '...' ); ?&gt;\r\n<\/code><\/pre>\r\n<div title=\"Edit &amp; Save To Grepper\"><\/div>\r\nIf continue sign \"...\" not needed at the end of title\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">&lt;?php echo wp_trim_words( get_the_title(), 10 ); ?&gt;<\/code><\/pre>\r\n<\/div>\r\n<h2>Parameters:<\/h2>\r\n<dl>\r\n \t<dt><tt><b>$text<\/b><\/tt><\/dt>\r\n \t<dd>(<i>string<\/i>) (<i>required<\/i>) Text to trim\r\n<dl>\r\n \t<dd>Default:&nbsp;<i>None<\/i><\/dd>\r\n<\/dl>\r\n<\/dd>\r\n<\/dl>\r\n<dl>\r\n \t<dt><tt><b>$num_words<\/b><\/tt><\/dt>\r\n \t<dd>(<i>integer<\/i>) (<i>optional<\/i>) Number of words\r\n<dl>\r\n \t<dd>Default: 55<\/dd>\r\n<\/dl>\r\n<\/dd>\r\n<\/dl>\r\n<dl>\r\n \t<dt><tt><b>$more<\/b><\/tt><\/dt>\r\n \t<dd>(<i>string<\/i>) (<i>optional<\/i>) What to append if&nbsp;<tt>$text<\/tt>&nbsp;needs to be trimmed.<\/dd>\r\n<\/dl>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-18 05:57:21","total_views":301,"status":"publish","created_at":"2022-11-18T05:57:21.000000Z","updated_at":"2023-10-13T00:16:12.000000Z"},{"id":32,"title":"Remove UI And LI Elements From wp_nav_menu","slug":"remove-ui-and-li-elements-from-wp-nav-menu","image":"1691945671.png","description":"You can remove or change the <b>&lt;ul&gt;<\/b> container and <b>&lt;li&gt;<\/b> that you get by default with wp_nav_menu (<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_nav_menu\" target=\"_blank\" rel=\"noopener\">codex<\/a>) through parameters, but you can\u2019t remove the <b>&lt;ul&gt;<\/b>&nbsp; and <b>&lt;li&gt;&nbsp;<\/b>elements that wrap each menu item. This is how you can actually remove them:\r\n<pre style=\"position: relative;\"><code class=\"hljs lang-php\">\r\n&lt;?php\r\n$menuParameters = array(\r\n'theme_location' =&gt; 'footer', \/\/ Change Menu name\r\n'container' =&gt; false,\r\n'echo' =&gt; false,\r\n'items_wrap' =&gt; '%3$s',\r\n'depth' =&gt; 0,\r\n);\r\n\r\necho strip_tags(wp_nav_menu( $menuParameters ), '<a>' );\r\n?&gt;\r\n<\/a><\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:52:34","total_views":331,"status":"publish","created_at":"2022-11-17T17:52:34.000000Z","updated_at":"2023-10-09T02:58:15.000000Z"},{"id":31,"title":"WordPress Post reading time without plugin","slug":"wordpress-post-reading-time-without-plugin","image":"1691945755.png","description":"<p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #656565; font-family: Roboto, sans-serif; font-size: 14px; outline: 0px; padding: 0px; vertical-align: baseline;\"><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">For Post: Go to<\/span><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">&nbsp;<\/span><strong style=\"background: 0px 0px; border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\"><em style=\"background: 0px 0px; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">wp-content\/your-theme\/functions.php<\/em>&nbsp;file<\/strong><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">&nbsp;<\/span><span face=\"&quot;Merriweather Sans&quot;, sans-serif\" style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-size: 18px; outline: 0px; padding: 0px; vertical-align: baseline;\">and scroll all the way down.<\/span><\/p><p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>  <pre><code><br>\/*Post Reading Time count *\/<br>if (!function_exists('your_function_name_reading_time')) :<br>  function your_function_name_reading_time($post_id)<br>  {<br>    $content = apply_filters('the_content', get_post_field('post_content', $post_id));<br>    $read_words = esc_attr(get_theme_mod('global_show_min_read_number', '10'));<br>    $decode_content = html_entity_decode($content);<br>    $filter_shortcode = do_shortcode($decode_content);<br>    $strip_tags = wp_strip_all_tags($filter_shortcode, true);<br>    $count = str_word_count($strip_tags);<br>    $word_per_min = (absint($count) \/ $read_words);<br>    $word_per_min = ceil($word_per_min);<br>    if (absint($word_per_min) &gt; 0) {<br>      $word_count_strings = sprintf(_n(<br>        '%s min  ',<br>        '%s min  ',<br>        number_format_i18n($word_per_min),<br>        'isha'<br>      ), number_format_i18n($word_per_min));<br>      if ('post' == get_post_type($post_id)) :<br>        echo esc_html($word_count_strings);<br>      endif;<br>    }<br>    if (absint($word_per_min) == Null) {<br>      echo '1 min';<br>    }<br>  }<br>endif;<br><\/code><\/pre>  <p style=\"background: 0px 0px rgb(255, 255, 255); border: 0px; color: #525252; font-family: &quot;Merriweather Sans&quot;, sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p> <pre><code><span>&lt;?php your_function_name_reading_time( get_the_ID() ); ?&gt;<\/span><\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:50:58","total_views":249,"status":"publish","created_at":"2022-11-17T17:50:58.000000Z","updated_at":"2023-10-08T00:13:43.000000Z"},{"id":30,"title":"How to Display Publish Dates as \u201cTime Ago\u201d Without Plugin","slug":"how-to-display-publish-dates-as-time-ago-without-plugin","image":"1691945943.png","description":"<span style=\"background-color: white; color: #525252; font-size: 18px;\">For Post: Go to<\/span><span style=\"background-color: white; color: #525252; font-size: 18px;\">&nbsp;<\/span><strong style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\"><em style=\"background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">wp-content\/your-theme\/functions.php<\/em>&nbsp;file<\/strong><span style=\"background-color: white; color: #525252; font-size: 18px;\">&nbsp;<\/span><span style=\"background-color: white; color: #525252; font-size: 18px;\">and scroll all the way down.<\/span>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>\r\n\r\n<pre><code>\r\n\/\/ Calclute how many time ago posted\r\nfunction my_post_time_ago_function()\r\n{\r\n    return sprintf(esc_html__('%s ago', 'textdomain'), human_time_diff(get_the_time('U'), current_time('timestamp')));\r\n}\r\nadd_filter('the_time', 'my_post_time_ago_function');\r\n<\/code><\/pre>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p>\r\n\r\n<pre><code>&lt;?php echo my_post_time_ago_function(); ?&gt;<\/code><\/pre>\r\n\r\n<hr style=\"margin: 30px 0;\">\r\n<p style=\"text-align: left;\"><code><span style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-size: 18px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;\">If you want same thing to apply for <b>comment<\/b> dates<\/span><span style=\"background-color: white; color: #525252; font-size: 18px; white-space: normal;\">, create a similar function:<\/span><\/code><\/p>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Insert this hook:<\/p>\r\n\r\n<pre><code>\r\n\/\/ Calclute how many time ago Commented\r\nfunction my_comment_time_ago_function() {\r\nreturn sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_comment_time ( 'U' ), current_time( 'timestamp' ) ) );\r\n}\r\nadd_filter( 'get_comment_date', 'my_comment_time_ago_function' );\r\n<\/code><\/pre>\r\n<p style=\"background: 0px 0px #ffffff; border: 0px; color: #525252; font-family: 'Merriweather Sans', sans-serif; font-size: 18px; margin: 14px 0px 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">Use this function anywhere in your template:<\/p>\r\n\r\n<pre><code>&lt;?php echo my_comment_time_ago_function(); ?&gt;<\/code><\/pre>","meta_description":null,"category_id":4,"user_id":1,"published_at":"2022-11-17 17:50:02","total_views":263,"status":"publish","created_at":"2022-11-17T17:50:02.000000Z","updated_at":"2023-10-08T11:51:42.000000Z"}],"first_page_url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=1","from":1,"last_page":2,"last_page_url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=2","links":[{"url":null,"label":"&laquo; Previous","active":false},{"url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=1","label":"1","active":true},{"url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=2","label":"2","active":false},{"url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=2","label":"Next &raquo;","active":false}],"next_page_url":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress?page=2","path":"https:\/\/backend.wesoftpress.com\/api\/blog\/category\/wordpress","per_page":12,"prev_page_url":null,"to":12,"total":17},"categories":[{"id":3,"name":"Ununtu","slug":"ununtu","description":null,"created_at":"2022-11-15T17:03:42.000000Z","updated_at":"2022-11-15T17:03:42.000000Z"},{"id":4,"name":"WordPress","slug":"wordpress","description":null,"created_at":"2022-11-15T17:07:35.000000Z","updated_at":"2022-11-15T17:07:35.000000Z"},{"id":5,"name":"Problem Solving","slug":"problem-solving","description":null,"created_at":"2022-11-15T18:03:22.000000Z","updated_at":"2022-11-15T18:03:22.000000Z"},{"id":7,"name":"Flutter","slug":"flutter","description":null,"created_at":"2022-11-26T16:25:35.000000Z","updated_at":"2022-11-26T16:25:35.000000Z"}],"tags":[{"id":1,"name":"tag1","slug":"tag1","description":null,"created_at":"2022-11-07T07:45:36.000000Z","updated_at":"2022-11-07T07:45:36.000000Z"},{"id":2,"name":"tag2","slug":"tag2","description":null,"created_at":"2022-11-07T07:45:39.000000Z","updated_at":"2022-11-07T07:45:39.000000Z"}]}