English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag

Category: Wordpress Tips


Now, How About We Remove The Arrow Images From Our Non- Drop Down Menu Items

All you have to do is override the <li> tags background css attribute. It’s easy, watch..

{code type=php}
&lt;li style=”background:none;”&gt;
//Insert your link url or relative url, and your link text below
&lt;a href=”http://EXAMPLE.COM”&gt;EXAMPLE LINK TEXT&lt;/a&gt;
&lt;/li&gt;
{/code}

& Bam, those drop down arrows are gone from the link.

 

It is entirely possible to add your own links to the buddypress bar without modifying core files. It is also possible to add your own drop down menus complete with flyout menus. Let me show you how..

First, lets tackle adding a simple link to the buddypress admin bar.

What I’m going to do is tap into the buddypress admin bar and add a link using a php file placed in the ‘/wp-content/plugins/’ folder and activated via the plugins menu. Create a file in your /plugins/ dir and name it erocks-admin-bar-mods.php then drop the following code into it. After this, go to your plugins page, and activate the BP Nav Bar Mods Plugin.

Lets create that simple link!

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add Link
Plugin URI: http://erikshosting.com
Description: Add A Simple Link To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*///Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Now Lets Add Multiple Links To The Buddypress Bar..

Pay Special Attention to Enclosing The Href In <li> Tags Each Time.

{code type=php}

<?php
/*
Plugin Name: BP Nav Bar Mods – Add Multiple Links
Plugin URI: http://erikshosting.com
Description: Add Multiple Link To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>
<li>
<!– Insert your 1st link url or relative url, and your link text below –>
<a href=”http://EXAMPLE1.COM”>EXAMPLE LINK TEXT1</a>
</li>
<li>
<!– Insert your 2nd link url or relative url, and your link text below –>
<a href=”http://EXAMPLE2.COM”>EXAMPLE LINK TEXT2</a>
</li>

<li>
<!– Insert your 3nd link url or relative url, and your link text below –>
<a href=”http://EXAMPLE3.COM”>EXAMPLE LINK TEXT3</a>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

So you see its easy to add multiple links, you just have to repeat the format..

Next Lets Add A Drop Down Menu To The Buddypress Bar

All we gotta do is make use of a <ul> tag inside of your parent items <li> tag. Just like this..

{code type=php}

<?php
/*
Plugin Name: BP Nav Bar Mods – Add Drop Down Menu
Plugin URI: http://erikshosting.com
Description: Add A Drop Down Menu To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your parent link url or relative url, and your link text below –>
<a href=”http://EXAMPLE1.COM”>TOP PARENT MENU LINK TEXT</a>

//Start The Drop Down Menu By Not Closing The LI Tag From The Item Above, & By Starting A UL Tag Below
<ul>

<li>
<!– Insert your 1st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE2.COM”>EXAMPLE LINK TEXT2</a>
</li>

<li>
<!– Insert your 2nd dropdown menu sub item l link url or relative url, and your link text below –>
<a href=”http://EXAMPLE3.COM”>EXAMPLE LINK TEXT3</a>
</li>

<!– Below Ends The Drop Down Menu By Closing The UL and LI Tags –>
</ul>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Pretty Easy.

What About Flyout Menus? You Know, Sub-Sub-Menus?

No Problem, thats just more easy work with the <li> and <ul> tags.. We just repeat what we did above, but go another level with the <ul> and <li> tags. Watch..

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add Drop Down With Flyout
Plugin URI: http://erikshosting.com
Description: Add Drop Down With Flyout Menu To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*///Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your parent link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>TOP PARENT MENU LINK TEXT</a>

<!– Start The Drop Down Menu By Not Closing The LI Tag From The Item Above, & By Starting A UL Tag Below –>
<ul>

<li>
<!– Insert your 1st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Insert your 2st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Start The Flyout Menu Off The Item Below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>

<!– Instead of Closing the LI tag, Start a UL tag To Create The Flyout Menu –>
<ul>

<li>
<!– Insert your 1st flyout menu sub- sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Insert your 2st flyout menu sub- sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<!– Below Ends The Flyout Menu By Closing The UL And LI Tags –>
</ul>
</li>

<!– Go Back To The Drop Down Menu And Add Another Item –>
<li>
<a href=”http://EXAMPLE4.COM”>EXAMPLE LINK TEXT4</a>
</li>

<!– Below Ends The Drop Down Menu By Closing The UL and LI Tags –>
</ul>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Real easy. You can add multiple flyout menus, just continue repeat the format.

 

*Code snippet for custom walker near bottom. Narrative near top*

I was recently working on a clients project where I needed to draw the primary nav of site#1 onto site #2-5, while retaining its ability to be edited via site#1’s wp menu editor panel.

So what I did was put a php include onto each site that called a seperate php file that had my iframe code in it. This Iframe framed the primary nav menu of the first site, while the 2nd site called the frame file as an include, and the menu was available to the 2nd site as well…

Now for the next problem, the links on the menu were set with the ‘target’ attribute of ‘_self’, meaning that when clicked, they took us to the link in the iframe and not in the full browser window showing the 2nd site. So the obvious solution would be to change the target attribute to ‘_top’.

Turns out that the wordpress Menus Control Panel, has an advanced screen option of ‘link target’ this allows you the options of ‘current window’ or ‘new window’, meaning ‘_self’ and ‘_blank’, respectively. The fact that ‘_parent’ wasn’t included as an option blew me away. So i added a ticket to the wordpress trac and slept on it.

Next day I see in the trac ticket, the begining of an argument about how frames are “too 1995″ and if the  _parent or _top option was necessary for casual users…..

I’m not going to get into how much of an excuse this is for not fixing a glaring omission, but I’m also not going to wait around to see if i can finish my project.

So, I modified the primary menus walker to output slightly different html.

I did this by defining a custom walker in my themes functions.php file, and then calling it as an $arg in my themes header.php where it called the wp_nav_menu function..

So to begin i grabbed wordpress’s default walker code from line #67-92 of /wp-includes/nav-menu-template.php. Then I copied this into my themes functions.php file. I then surrounded this block of code in a class function and remembered to place the } after the block. You can see the default wordpress walker (with the target=”_top” attribute added) and my custom function name surrounding it below. So drop the following code into your themes functions.php file

{code type=php}
class erockscustom_walker extends Walker_Nav_Menu
{

function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( “\t”, $depth ) : ”;

$class_names = $value = ”;

$classes = empty( $item->classes ) ? array() : (array) $item->classes;

$class_names = join( ‘ ‘, apply_filters( ‘nav_menu_css_class’, array_filter( $classes ), $item ) );
$class_names = ”;

$output .= $indent . ‘<li id=”menu-item-‘. $item->ID . ‘”‘ . $value . $class_names .’>';

$attributes  = ! empty( $item->attr_title ) ? ‘ title=”‘  . esc_attr( $item->attr_title ) .'”‘ : ”;
$attributes .= ! empty( $item->target )     ? ‘ target=”‘ . esc_attr( $item->target     ) .'”‘ : ”;
$attributes .= ! empty( $item->xfn )        ? ‘ rel=”‘    . esc_attr( $item->xfn        ) .'”‘ : ”;
$attributes .= ! empty( $item->url )        ? ‘ href=”‘   . esc_attr( $item->url        ) .'”‘ : ”;

$item_output = $args->before;
$item_output .= ‘<a target=”_top”‘. $attributes .’>';
$item_output .= $args->link_before . apply_filters( ‘the_title’, $item->title, $item->ID ) . $args->link_after;
$item_output .= ‘</a>';
$item_output .= $args->after;

$output .= apply_filters( ‘walker_nav_menu_start_el’, $item_output, $item, $depth, $args );
}
}
{/code}

Then I dropped the argument into wp_nav_menu (where the wp3 custom menu is called in your themes header.php), like so:

{code type=php}

<?php $args=array(‘walker’ => new erockscustom_walker()); wp_nav_menu($args); ?>

{/code}

AND BAM! links open in the top window, and everything works as it should!

 

So I found an error on a clients server. They were getting the “Upload Failed! Cannot Create Folder” “Is Parent Directory Writeable”.

And yes the folder was writeable. It was the /blogs.dir/1/files folder. of course I checked it and saw it had the appropriate 775 permissions. So I searched the forums and then contacted their servers customer support.

Turns out the folder AND ALL SUBFOLDERS RECURSIVELY were not ‘owned’ by anyone. (WTF?) This ment that even though 775 permission allowed the owner to write, the server was not the owner…..

What needed to happen was the blogs.dir/ dir and all its subfolders had to be modded by customer support at the hosting company to be owned by ‘apache’. Now that the server was the owner, the server could write to the files.

*Note on non-apache machines, the owner should the name of the main ftp user

Sometimes I wonder why people pick the Hosts that they do. I geuss it comes down to money… My advice, buck up and spend a few dollars on a good server.

 

To reorder those buddypress tabs on the profile and activity page, drop the following code into your /plugins/bp-custom.php

{code type=php}
function erocks_change_bp_tag_position()
{
global $bp;

$bp->bp_nav[‘profile’][‘position’] = 10;
$bp->bp_nav[‘posts’][‘position’] = 20;
$bp->bp_nav[‘activity’][‘position’] = 30;
$bp->bp_nav[‘blogs’][‘position’] = 40;
$bp->bp_nav[‘friends’][‘position’] = 50;
$bp->bp_nav[‘messages’][‘position’] = 60;
$bp->bp_nav[‘groups’][‘position’] = 70;
$bp->bp_nav[‘settings’][‘position’] = 80;

}
add_action( ‘bp_init’, ‘erocks_change_bp_tag_position’, 999 );

{/code}

 

So you already picked your permalink structure..

..Now you have thousands of posts and wish you hadn’t organized them by something silly like /%mood-your-in-when-publishing-this-post%/%post-id%/…
You could change your permalink structure, but what happens to all your inbound links? All the thousands of links you have referenced in various forums, support threads, and video game screen shot forums? You’d need to write a thousand 301 redirects to keep everything going smoothly… no dice.

Well, if you download and activate ‘platinum seo pack’ from the wordpress extend plugin repository, BEFORE you change your structure, it will automatically create 301 redirects for you.

Wait, let me guess, your reading this thread because you ALREADY changed your permalink structure..

..Now the sky has fallen and everyone you see at the yoghurt shop tells you about the 404 errors they get when trying to check the latest screenshot of you p3vvning (or however the cool kids spell it) that 6 year old in frogger3D..

..Good news. You’re not boned.

Just change the permalink structure back to whatever lameness it was before, install and activate platinum seo pack, and then re-engage the stimulator, I mean set your new permalinks.

 

I was working on a client project, when I noticed that one of their sub-directory sites was redirecting its frontpage to the dashboard!

I looked through the htaccess for quite some time before I realized that this was an easy setting on the super admin options menu. If you get stuck where you site only redirects to the dashboard. try checking that you don’t have anything in the ‘Dashboard Site’ option of ‘super-admin’->’options’.

 

So, I was working with the login-with-ajax wordpress plugin, When I noticed that it displays differently in chrome. I was blown away that firefox and internet explorer would both show the appropriate  css styling and that chrome should some entirely different placing of the div via css.

So what I needed was a way to have two different style classes for each browser set..

So I did some research and found that we can use the webkit difference of chrome and safari to firefox and IE. So, if you want a chrome/safari specific css style override just frame it in the below code, and drop it in below the old line# in your stylesheet.

{code type=css}
#div1 {old rules for:IE,Firefox;}
@media screen and (-webkit-min-device-pixel-ratio:0) {
#div1 {new rules for:Chrome,Safari;}
}
{/code}
 

Want to use a WordPress plugins shorttag inside your template files?

Use this nifty php snippet to call the shorttag properly!

So, I know that many of you use shorttags for plugins, simply drop the short-tag onto a post or page and voila! the plugin function is included.

Some times you just want to paste a plugins short-tag directly into your wordpress template files.. If you have tried this before you’ll notice that it simply outputs the shorttag, and nothing is included..

IF however, you want that plugin function to be called somewhere else, like in your template files themselves, then you must use a php snippet to call the shorttag.

So, Use this code to call short tags/ short codes in your themes template files:

{code type=php}<?php echo do_shortcode(“[your-shorttag]”); ?>{/code}

This will simply run the plugins shortag in your template files as if it was a real wordpress engine short code