How To Embed A Page Into Another Page In WordPress
Using the following snippet, you will be able to embed a page into another page in your WordPress blog.
1 2 3 4 |
<?php $recent = new WP_Query("page_id=**ID**"); while($recent->have_posts()) : $recent->the_post();?> <h3><?php the_title(); ?></h3> <?php the_content(); ?> <?php endwhile; ?> |
Snippet Source/Credit: CSS Tricks
How To Rearrange Categories Order In WordPress
Adding the following snippet to your theme’s functions.php file, you will be able to rearrange WordPress categories order, completely the way you want it.
1 2 3 4 5 6 7 8 9 10 11 |
<?php $categories = get_terms('books_category'); for( $i=0; $i<sizeof($categories); $i++ ){ if ( $categories[$i]->name == 'New Publications' ) : $latest = array($categories[$i]); unset($categories[$i]); endif; } if( isset($latest) ) array_splice( $categories, 0, 0, $latest ); ?> |
Snippet Source/Credit: Sebastian
How To Make Your Search Results Unlimited In WordPress
Start by finding the below code in your search.php file:
1 2 |
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> |
Once you found it, simply replace it with:
1 2 3 |
<?php $posts=query_posts($query_string . '&posts_per_page=-1'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> |
Snippet Source/Credit: WPHacks
How To Prevent WordPress To Compress JPG Files
Copy and paste the following snippet in your theme’s functions.php file and it will let you prevent WordPress to compress your jpg files.
1 |
add_filter('jpeg_quality', function($arg){return 100;}); |
Snippet Source/Credit: WP Snippets
How To Display An Advert After The First Post In WordPress
The following snippet will let you display an advert after the first post in WordPress.
1 2 3 4 5 6 7 |
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); $loopcounter++; ?> // the loop stuffs <?php if ($loopcounter <= 1) { include (TEMPLATEPATH . '/ad.php'); } ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?> |
Snippet Source/Credit: WPLift