How to let the post show from lowest to highest?

If you want your posts show from lowest to highest, it is very simple, just add: <!–p query_posts($query_string.’&order=ASC’);–> for example, the following code will let all your post show from lowest to highest: <!–p query_posts($query_string.’&order=ASC’);–> <!–p if (have_posts()) : while (have_posts()) : the_post();–>

List 50 posts of wordpress.

If you want to list 50 posts, use the following code: <ul>  <?php  global $post;  $myposts = get_posts(‘numberposts=-1’);  foreach($myposts as $post) :  ?>     <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>  <?php endforeach; ?>  </ul> if you want to list all the posts, use the following codes: <ul>  <?php  global $post;  $myposts = get_posts(‘numberposts=5’);  foreach($myposts as […]

WordPress Random posts

Display a list of 15 posts selected randomly by using the MySQL RAND() function for the orderby parameter value:  <ul><li><h2>A random selection of kingphp posts</h2>     <ul>  <?php  $rand_posts = get_posts(‘numberposts=15&orderby=rand’);  foreach( $rand_posts as $post ) :  ?>     <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>  <?php endforeach; ?>     </ul>  </li></ul>  more: http://codex.wordpress.org/Template_Tags/get_posts#Random_posts

Retrieve a Particular Post or Page

Retrieve a Particular Post <?php // retrieve one post with an ID of 5 query_posts(‘p=5’);      ?> If you want to use the Read More functionality with this query, you will need to set the global $more variable to 0. <?php // retrieve one post with an ID of 5 query_posts(‘p=5’);       global $more; // set […]

Add Random Posts in a Page

get_posts() can be used to collect and display any number of random posts you want. Here’s an example that lists the titles (as links) of four random posts: <ul><li><h2>Some Random Posts</h2> <ul> <?php $rand_posts = get_posts(‘numberposts=4&orderby=RAND()’); foreach( $rand_posts as $post ) : ?> <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> </li></ul>

Get certain number posts

<?php $posts = get_posts( “category=1&numberposts=10″ ); ?> <?php if( $posts ) : ?> <ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <li> <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?>   category=1&numberposts=10, means category 1, and list 10 posts add the code at […]

PHP image link rotation

The script is for my vbulletin forum in PHP which we can stick our affiliate banners with their links so that they rotate on refresh. The code is as follows: $total = “6”; //6 – change to how many images you have $file_type = “.jpg”; //change to file type $image_folder = “random”; //location of folder […]

How to use htaccess to change site.com/directory/ to site.com/ ?

If you only want https://kingphp.com/money directory become https://kingphp.com, use:RewriteRule ^catalog/$ / [L] If you want all directories become https://kingphp.com, use: RewriteEngine On RewriteBase / RewriteRule ^([^/]+)$ /catalog/$1 [L] RewriteRule ^$ /catalog/ [L] Note:If you have other subfolders in there (in that catalog dir, you’ll need some additional rule for that also. This will rewrite your […]

How to use mod rewrite forward to a new domain?

For examples, when we visit www.google.com, we want it redirect to https://kingphp.com, we can use the following code: Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] The code posted above should be used on the old server.