WordPress Tricks

Custom Post Type archive template with pagination and Advance Custom Field value

Here I am sharing you a basic template to show Custom Post Type posts with pagination and also the values from Advance Custom Field plugins.

If you face any issue to implement it, feel free to do comments in the comments section.

* Template Name: Custom Post Archive
* @package WordPress
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(  
        'post_type' => 'herb_study',
        'post_status' => 'publish',
        'posts_per_page' =>3, 
         'paged' => $paged

    $loop = new WP_Query( $args ); 
    while ( $loop->have_posts() ) : $loop->the_post(); 

<img src="<?php   echo get_field('Image',get_the_ID());?>"/>
<?php } ?>
 <?php endwhile;

<span class="pagination"> 
 echo paginate_links( array(
                   'total' => $loop->max_num_pages
               ) );

<?php get_footer(); ?>
WordPress Tricks

Solution of Fatal error: Uncaught Error: Call to undefined function gutenberg_block_template_part() in \wp-content\themes\blockbase-wpcom\header.php:16

So I tried to test the Zoologist theme by Automattic which is using Blockbase parent theme. But while trying to install, I found the theme showing this Fatal Error

Fatal Error Blockbase parent theme by Automattic


Please Install Gutenberg plugins by Gutenberg team . Click Here To Install Gutenberg Plugins and the issue will be solved

Gutenberg by Gutenberg Team
WordPress Tricks

If slug or portion of URL matched then redirect it to different URL using htaccess file.

Basically this is a solution of broken link in wordpress. As broken link cause issues in SEO, so you may need to redirect a bulk amount of urls to different url. So here I am sharing you a solution which basically I found working.

Client wanted to redirect all urls ( which was showing 404 error ) containing specific slug ( like category/success-story/) to be redirected to a different URL. Here is the code i used and put it in htaccess file of wordpress root folder.

RewriteEngine on
RewriteRule ^(.*)url-slug/url-childslug(.*)$ https://www.your-site-url/page/about [L,R=301]

Just replace the slugs and url as per your requirement.

WordPress Tricks

WordPress Blog Post Search Form Code: Only Post Search and Exclude pages and others

If you need to put a search form to show blog post based on the search term, you can use the code I shared. Generally normal search form may show you result from pages and other custom post type. But here I used the form which is used to show only blog posts.

wordpress blog post search form
Continue reading “WordPress Blog Post Search Form Code: Only Post Search and Exclude pages and others”
WordPress Tricks

Accepting Tips or Donations in your site: Buy Us or Buy me a coffee

Those who are creators, artists, teachers, service providers and have websites, they can use this Tip Jar WP plugins to accept tips or donations etc. Actually I found one of my client using this plugins and i helped her configuring it and did some css changes to make it fit by changing the width and font size. If you are using you can ask question in the comments section.

Continue reading “Accepting Tips or Donations in your site: Buy Us or Buy me a coffee”
WordPress Tricks

Sobe: WordPress lighthearted personal blogging theme by Automattic, Modifications or customizations with css.

Theme Sobe is a lighthearted personal blogging theme by Automattic for sharing life’s most memorable moments. You can see the Demo of theme Sobe. If you want to use it in your personal blogging site, you can download Theme Sobe from WordPress.com theme repository, or from here.

theme sobe wordpress modifications using css

Here, I will share with you some css customizations which you can use to modify the header font size, color, contents etc. If you have any questions feel free to ask in the comments section.

Continue reading “Sobe: WordPress lighthearted personal blogging theme by Automattic, Modifications or customizations with css.”
WordPress Tricks

Redirect Logged out users to different page based on Body Class : WordPress redirection using php and jQuery

Suppose you want your visitor not to see any specific pages and want them to redirect to login or register page, then you can do this using this following code. Here i used the body class of wordpress page. Using the Body class and using php and jquery you can redirect it .

   $classes = get_body_class();
if (in_array('my-profile',$classes)   || in_array('page-id-2324',$classes)    ) {

if( ! is_user_logged_in() ) {
 window.location.href = "https://yoursiteurl.com/register/";

WordPress Tricks

WordPress theme Twenty Twenty-One: Modifications and customizations of headers, fonts, styles and more

WordPress 5.6 comes with a brand new default theme: Twenty Twenty-One. Here I am sharing you some basic css or style modifications using which you can give it a look of your own. I have added the child theme below which you can download and use without any issue.

Download Twenty Twentyone Child theme.

wordpress theme twenty twenty-one
Continue reading “WordPress theme Twenty Twenty-One: Modifications and customizations of headers, fonts, styles and more”
WordPress Tricks

Previous and Next Post title from same category

Sometimes you may want to show the previous and next post title from same category just below your post. Here I am sharing you the code which i got from internet and used for someone which worked great. Here I am sharing you the corresponding css and php code.

CSS Code ( This code may need to tweak based on your theme)

div#opagination a[rel="prev"] {
    float: left;
    width: 50%;
div#opagination span {
    margin-left: 12px;
    margin-right: 12px;
div#opagination center {
    display: inline;
span.nextpost.txt {
    float: right;
span.prevpost.txt {
    float: left;
div#opagination a[rel="next"] {
    float: right;
	width: 50%;
div#opagination * {
    font-size: 15px;

div#opagination a span:last-child,div#opagination a span:last-child * {
    /* background: red; */
    display: block;
    font-size: 23px;
    font-weight: bold;
	clear: both;
div#opagination a span:first-child,div#opagination a span:first-child * {
    font-weight: bold;
    color: #ab9797 !important;

PHP code (That will go in your single.php file)

$post_id = $post->ID; // current post ID
$cat = get_the_category(); 
$current_cat_id = $cat[0]->cat_ID; // current category ID 

$args = array( 
    'category' => $current_cat_id,
    'orderby'  => 'post_date',
    'order'    => 'DESC'
$posts = get_posts( $args );
// get IDs of posts retrieved from get_posts
$ids = array();
foreach ( $posts as $thepost ) {
    $ids[] = $thepost->ID;
// get and echo previous and next post in the same category
$thisindex = array_search( $post_id, $ids );
$previd    = isset( $ids[ $thisindex - 1 ] ) ? $ids[ $thisindex - 1 ] : false;
$nextid    = isset( $ids[ $thisindex + 1 ] ) ? $ids[ $thisindex + 1 ] : false;
echo  '<div id="opagination">' ;
if (false !== $previd ) {
			?><a rel="prev" href="<?php echo get_permalink($previd) ?>"><span class="prevpost txt"><< Article plus récent </span><span><?php echo get_the_title($previd); ?></span></a><?php
if (false !== $nextid ) {
			?><a rel="next" href="<?php echo get_permalink($nextid) ?>"><span class="nextpost txt">Article plus ancien >></span> <span><?php echo get_the_title($nextid); ?> </span> </a><?php
			echo '</div>';

WordPress Tricks

HTML Tab without bootstrap : Tabbed menu with only css, jQuery and html

Tabbed menu without bootstrap ( using css, jquery and html)

In most of the cases we uses bootstrap, which is easy to use. But sometimes we may need to create tabbed menu without bootstrap. Here I am sharing you the related html, css and jQuery code using which you can use Tabbed menu without using bootstrap (screenshot above). You can use this in WordPress, Shopify or any other platform where you can use html,css and jQuery.

You can contact me at om2000_cuet in my skype or can ask question in comments section.

Continue reading “HTML Tab without bootstrap : Tabbed menu with only css, jQuery and html”