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… Read moreWordPress Random posts
<?php echo realpath(‘./’)?> very simple, right?
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… Read moreRetrieve a Particular Post or 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… Read moreAdd Random Posts in a Page
<?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>… Read moreGet certain number posts
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… Read morePHP image link rotation
If you only want http://kingphp.com/money directory become http://kingphp.com, use:RewriteRule ^catalog/$ / [L] If you want all directories become http://kingphp.com, use: RewriteEngine On RewriteBase / RewriteRule ^([^/]+)$ /catalog/$1 [L] RewriteRule ^$ /catalog/ [L] Note:If you have other subfolders in there (in… Read moreHow to use htaccess to change site.com/directory/ to site.com/ ?
For examples, when we visit www.google.com, we want it redirect to http://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.
For example, if we want to redirct http://kingphp.com/php/ to http://kingphp.com/wordpress/ We could use mod_rewrite. Put this in your .htaccess file Options +FollowSymLinks RewriteEngine On RewriteRule /php/(\w+).html /wordpress/$1.html [R=301,L]
If a server hosting 2 domains, we can use this .htaccess (on the root) to point the 2 different domains to 2 Directories on the same server: RewriteEngine On RewriteBase / # pointing for the domain domain1.com to folder1 ReWriteCond… Read moreUsing .htaccess pointing domain to specific directory