Filter WordPress menu

// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items) {
// gets passed a string of <li>’s
$homelink = ‘<li><a href=”‘ . home_url( ‘/’ ) . ‘”>’ . __(‘Home’) . ‘</a></li>’;
$items = $homelink . $items;
return $items;
}

add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ );

Another Example

function new_nav_menu_items($items) {
$cat_menu_list = wp_list_categories( ‘echo=0&title_li=&child_of=124′ );
$items = $items . $cat_menu_list;
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ );

Posted in Wordpress | Tagged , | Comments Off

MYSql copy tables

create table tablename_new like tablename; -> this will copy the structure…

insert into tablename_new select * from tablename; -> this would copy all the data

Posted in MySQL | Tagged , | Comments Off

Find and replace in MYSQL

Updating Data in MYSql

update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘);

For moving wordpress installs to repair the guid

UPDATE wp_posts SET guid = replace( guid, 'web/', '' ) ;

Posted in MySQL, Wordpress | Tagged , , , , | Comments Off

WordPress Super Loop

// if everything is in place and ready, let’s start the loop

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

// to display ‘n’ number of posts, we need to execute the loop ‘n’ number of times
// so we define a numerical variable called ‘$count’ and set its value to zero
// with each iteration of the loop, the value of ‘$count’ will increase by one
// after the value of ‘$count’ reaches the specified number, the loop will stop
// *USER: change the ‘n’ to the number of posts that you would like to display

<?php static $count = 0;
if ($count == “n”) { break; }
else { ?>

// to exclude all posts from categories ‘x’, ‘y’, ‘z’ unless in single-post view
// create an ‘if’ statement for each of the three specified categories as follows:
// if the post is in category ‘x’ and this is not a single-post view, exit the loop
// if the post is in category ‘y’ and this is not a single-post view, exit the loop
// if the post is in category ‘z’ and this is not a single-post view, exit the loop
// if no conditions are met, continue the loop; otherwise restart loop with next post
// if none of these conditions are met, run the loop; otherwise restart at the next post
// *USER: change the ‘x’, ‘y’, ‘z’ to the numbers of the categories you want to exclude

<?php if ( in_category(‘x’) && !is_single() ) continue; ?>
<?php if ( in_category(‘y’) && !is_single() ) continue; ?>
<?php if ( in_category(‘z’) && !is_single() ) continue; ?>

// use this to display posts from category ‘x’ in single and archive views only
<?php if ( in_category(‘x’) && !is_single() && !is_archive() ) continue; ?>

// use this to display posts from category ‘x’ in single and category views only
<?php if ( in_category(‘x’) && !is_single() && !is_category() ) continue; ?>

// use this to display posts from category ‘x’ in single, category, and archive views only
<?php if ( in_category(‘x’) && !is_single() && !is_category() && !is_archive() ) continue; ?>

// now, if all conditions have been satisfied, the post is displayed
// for CSS styling and layout purposes, we wrap the post content in a div
// we then display the entire post content via the ‘the_content()’ function
// *USER: change to ‘<?php the_excerpt(); ?>’ to display post excerpts instead

<div>
<?php the_content(); ?>
</div>

// here, we continue with the limiting of the number of displayed posts
// each iteration of the loop increases the value of ‘$count’ by one
// the final two lines complete the loop and close the if statement

<?php $count++; } ?>
<?php endwhile; ?>
<?php endif; ?>

from http://perishablepress.com/press/2007/08/06/super-loop-exclude-specific-categories-and-display-any-number-of-posts/

Posted in Wordpress | Tagged , | Comments Off

Moving Virtuemart

When moving virtuemart from a build directory

Edit administrator\components\com_virtuemart\virtuemart.cfg.php
define( ‘URL’, str_replace(“/administrator/”,”/”,JURI::base()));
define( ‘SECUREURL’, str_replace(“/administrator/”,”/”,JURI::base()));

Posted in Joomla | Tagged , | Comments Off

Chmod Web directories from the command line

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 755

these guys rock

http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively

Posted in Unix | Tagged , | Comments Off

Background Image to the bottom of a page

html {
min-height: 100%;
height: auto;
}

body {
background:url(/images/bg-image.jpg) right bottom no-repeat;
}

Posted in CSS | Tagged | Comments Off

Browsers View for Sites

http://browsersize.googlelabs.com/

Posted in CSS | Tagged , , | Comments Off

css pipe seperated menu

<ul id=”footer-navigation”>
<li><a href=”#”>Top</a></li>
<li><a href=”#”>Valid XHTML</a></li>
<li><a href=”#”>Valid CSS</a></li>
<li><a href=”#”>Get Firefox</a></li>
</ul>

#footer-navigation {
margin-left: 0;
padding-left: 0;
list-style-type: none;
}

#footer-navigation li {
display: inline;
}

#footer-navigation li:after {
content: ” | “;
}

#footer-navigation li:last-child:after {
content: “”;
}

Posted in CSS | Tagged , , | Comments Off

XML over POST with php

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, “http://websiteURL”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, “XML=”.$xmlcontent.”&password=”.$password.”&etc=etc”);
$content=curl_exec($ch);

Posted in PHP | Tagged , , , | Comments Off