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 $more to 0 in order to only get the first part of the post
$more = 0;

// the Loop
while (have_posts()) : the_post();
  // the content of the post
  the_content(’Read the full post »’);
endwhile;
?>
Retrieve a Particular Page
To retrieve a particular page, you could use the following:

<?php
query_posts(’page_id=7′);      //retrieves page 7 only
?>

or

<?php
query_posts(’pagename=about’); //retrieves the about page only
?>

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
$start = “1″; //which image you want to load first
$random = mt_rand($start, $total);
$image_name = $random . $file_type;
echo “\“;

.htaccess redirect ALL traffic to another domain

.htaccess code:
redirect 302 / http://www.mynewdomain.com

you can also redirect access via PHP, using the header() function:

// Permanent redirect:
header('HTTP/1.1 301 Moved Permanently', true);
header('Location: http://www.location.com/');
// Temporary redirect (note that sending the 'Location' header automatically sends a 302 redirect unless it is explicitly overwritten, as it is above):
header('Location: http://www.location.com/');

How to detect the numbers of used nodes in php web host?

It is very simple, only one sentence:

print system(”find . -printf \”%i\n\” | sort -u | wc -l”);

Redirect by PC or mobile access

php code as follows:

$iswap = isset($_SERVER[’HTTP_ACCEPT’])? $_SERVER[’HTTP_ACCEPT’]:”;
if(strpos($iswap,”wap”)>0)
{
@header(”Location: /wap/”);
}

Add php code into html for lunarpage.com

Add php code into html for lunarpage.com linux host.

try this line in a blank .htaccess

AddType application/x-httpd-php php html

Add php code into html for php5

AddType application/x-httpd-php5 .html .htm .php
AddHandler application/x-httpd-php5 .html .htm .php

PHP to detect mobile phones

The most efficient way to detect mobile phones with PHP, this simply queries the accept headers, the user agent and checks for any tell tale signs that the browser we’re sniffing is a mobile device. Read the rest of this entry »

Get current url

<?php
//get the current page URL that is shown in the browser URL window

function curPageURL() {
 $pageURL = ‘http’;
 if ($_SERVER[”HTTPS”] == “on”) {$pageURL .= “s”;}
 $pageURL .= “://”;
 if ($_SERVER[”SERVER_PORT”] != “80″) {
  $pageURL .= $_SERVER[”SERVER_NAME”].”:”.$_SERVER[”SERVER_PORT”].$_SERVER[”REQUEST_URI”]; Read the rest of this entry »

Php test Navigation engine laguage, and Syetem language

Php test Navigation engine laguage

Php test Syetem lang

Read the rest of this entry »