How to write IE specific PHP

if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || (ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT"))) AND (!ereg("MSIE", getenv("HTTP_USER_AGENT")) AND (!ereg("Konqueror", getenv("HTTP_USER_AGENT"))))) $browser = "Netscape";
elseif(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $browser = "MSIE";
elseif(ereg("Lynx", getenv("HTTP_USER_AGENT"))) $browser = "Lynx";
elseif(ereg("Opera", getenv("HTTP_USER_AGENT"))) $browser = "Opera";
elseif(ereg("WebTV", getenv("HTTP_USER_AGENT"))) $browser = "WebTV";
elseif(ereg("Konqueror", getenv("HTTP_USER_AGENT"))) $browser = "Konqueror";
elseif((eregi("bot", getenv("HTTP_USER_AGENT"))) || (ereg("Google", getenv("HTTP_USER_AGENT"))) || (ereg("Slurp", getenv("HTTP_USER_AGENT"))) || (ereg("Scooter", getenv("HTTP_USER_AGENT"))) || (eregi("Spider", getenv("HTTP_USER_AGENT"))) || (eregi("Infoseek", getenv("HTTP_USER_AGENT")))) $browser = "Bot";
else $browser = "Other";

this will return the browser name in $browser

and you can have a test at http://www.botsvsbrowsers.com/SimulateUserAgent.asp.

example:

if(ereg(“Google”, getenv(“HTTP_USER_AGENT”))) $browser = “Bot”;
else $browser = “Other”; 

echo $browser;

Plugin for limit the size of the post in the main page in WordPress

The  plugin  for WordPress in order to control the maximum amount of characters displayed for an entry on the main page. If the set limit is surpassed a link to a page with the whole content will appear and the text on the entry will be chopped to that amount of characters, otherwise the content will be showed unchanged. Continue reading “Plugin for limit the size of the post in the main page in WordPress”

Show post titles at category, and show your own words at homepage.

<?php get_header(); ?>

<?php if (is_home())

echo ”
Welcome, add your own words here!

“; ?>

<?php if (!is_home())

{ ?>
<ul>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<a href=”<?php echo get_permalink()?>”><?php the_title(); ?></a>
</li>
<?php endwhile; endif; ?>
<ul>

<?php }  ?>

<?php get_footer(); ?>

How show wordpres categories?

Method a:

wp_list_categories().

Usage
 <?php wp_list_cats(‘arguments’); ?> 

Examples
Default Usage
By default, the tag:

optionall – Does not display a link to all Categories
all – Text to display for link to all Categories
sort_column – Sorts by Category ID
sort_order – Sorts in ascending order
file – Displays the Categories using the index.php template
list – Sets the Categories in an unordered list (<ul><li>)
optioncount – Does not display the count of posts within each Category
hide_empty – Does not display links to Categories which have no posts
use_desc_for_title – Uses the Category description as the link title
children – Shows the children (sub-Categories) of every Category listed
hierarchical – Displays the children Categories in a hierarchical order under its Category parent Continue reading “How show wordpres categories?”