PHP Code Snippets/Functions

How to add antispambot function using shortcode

In this tutorial, you will learn how to add anti-spam bot in your website. note: by adding this code we will then have this shortcode [sm_antispam_script email=”youremail@gmail.com”] Here is how you can check if the code above is working. That is the end of the tutorial. If you have any questions, just contact the author […]

PHP Code Snippets/Functions Reusable Custom Blocks

How to make a custom patterns?

register_block_pattern( string $pattern_name, array $pattern_properties ) This is how to registered a custom block pattern. Copy and paste the code above, to functions.php The ‘content’ is where we can put or write the design layout of the pattern, this is how to get code on the page editor. see the screenshot below.

PHP Code Snippets/Functions

How to display all the child of the parent page

Parameter: ‘child_of’ – (int) Page ID to return child and grandchild pages of. ‘exclude’ – (int[]) Array of page IDs to exclude. ‘sort_column’ – (string) What columns to sort pages by, comma-separated. ‘sort_order’ – (string) How to sort retrieved pages. Accepts ‘ASC’, ‘DESC’. For more information about the get_pages function, you can visit here. $args = array( ‘exclude’ => […]

PHP Code Snippets/Functions

Display Custom Post Type.

This snippet is a loop used for displaying custom posts. Replace variables/IDs/names/attributes as needed. <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $loopb = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘paged’ => $paged, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’ ) ); $ctr = 0; while ( $loopb->have_posts() ) : $loopb->the_post(); $post_ID = […]