RocketTheme tips and tricks

RocketTheme forums: http://www.rockettheme.com/forum/ (PHPBB3)

Re: How Do I Set RokStories to Show in Front Page Only?

Appearance->Widgets and in the “Default Settings” override drag the RokStories widget to the disabled widgets area. Then switch to the “Front Page” override and drag the “rokStories” widget back. This will enable it on the home page but not any of the other pages.
Posted in RocketTheme. No Comments »

Contact Form 7 field widths narrower

To narrow or shorten the field widths for Contact Form 7, this is an example of making the name shorter: (you can do this to widen it too)

<p>Your Name (required)<br />
[text* your-name 25/] </p>

The key is the bolded 25/ which sets the field width.

Genesis – Remove 2nd sidebar

To remove the second sidebar permanently using the Genesis frameworks:

In your child theme’s functions.php file add this to the bottom:

genesis_unregister_layout( ‘content-sidebar-sidebar’ );
genesis_unregister_layout( ‘sidebar-sidebar-content’ );
genesis_unregister_layout( ‘sidebar-content-sidebar’ );

This will remove that extra side on all pages on your entire WordPress website, including the options on the individual pages and posts, making it less confusing for the client.

How to make a widget show up on a single page or post

Two plugins to do this:

Genesis Simple Sidebars

Widget Context

This frees you from having to display (or not show) widget areas on various pages and posts using code.

How to clean up text with PHP – remove line breaks, paragraphs and tabs and replace with an empty space

For some text, like Meta description tags and excerpts, you may not want to have paragraph formatting, empty lines, breaks in the text. Especially when you are extracting this text automatically to generate the Meta description.

This is a simple regular expression to remove line breaks, paragraphs and tabs, and replace them with an empty space.

$text = preg_replace(“/\r\n+|\r+|\n+|\t+/i”, ” “, $text);

How to extract H1 tags from a page to pull headings from posts and pages:

preg_match_all('|<h[^>]+>(.*)</h[^>]+>|iU', $html, $headings);

Clear all or clear both to have text and left aligned or right aligned images below each paragraph

<p style="clear:both;">previous paragraph</p>
<p style="clear:both;">next paragraph</p>

<br style="clear:both;" />

<hr style-"clear:both;" />

Cannot see updates to WordPress website – sticky cache

Here’s how to clear your browser cache without going into your menus. This applies to Firefox, Internet Explorer, Safari and Chrome.

Note: CSS changes can cause a really sticky cache when background images are changed, they tend not to update unless you clear your cache.

Top 3 WordPress custom themes development systems or frameworks

When you customize WordPress pages and themes, it can be hard to remember what you’ve done a year or two later. That’s one reason why it’s good to use a WordPress development system or “Frameworks”. You don’t have to edit PHP, code like changing the functions.php to do things. Often you’ll find what you need in the theme/frameworks configuration screen.

A good WordPress backend has options to change page titles, use custom post types easily so that you can “target” various pages you want to customized without editing PHP.

This makes it so that you can see, your client can see, and you can more easily find your customizations later.

Another huge reason why is so that your WordPress theme updates don’t overwrite your custom WordPress pages so they don’t go away silently or worse yet…break your PHP code.

My top 3 WP frameworks are:

Genesis - good SEO for WordPress with page by page Meta Titles and tags. If you want to remove the WordPress H1 page title from the top of the page click here.

WooThemes - good modern WordPress themes with highly flexible options in the frameworks

RocketTheme - amazing themes and powerful plugins. To use the “Gantry” frameworks, which was created for Joomla, lots of it is done using widgets, however you’ll want a Gantry tutorial on positioning because these widgets are movable on a page using a unique system with sliders and number of widgets in a row. Gantry is using the standard 960px layout, and can be made fluid or liquid as well.

Timthumb exploit in WordPress – how to find if you have it

Timthumb.php is sometimes named thumb.php or even maybe thumbnail.php, resize.php, crop.php or something else.

The quickest way to find it is to look inside your theme folder. WordPress by itself has a thumbnailer which does not have the vulnerability, so you may not have it. Usually it’s the theme’s author that may decide to use Tim Thumb to resize images.

If you can’t find it and are still concerned, and you use Cpanel file manager search your public_html folder for “thumb”.

If you really want to find and update TimThumb.php even if it’s using another name, SSH in to your server (if you can) and issue this command (from: http://wordpress.shadowlantern.com/2011/08/timthumb-php-is-vulnerable/)

find ~/public_html -type f -wholename “*wp-content*” -name “*.php” -print0 | xargs -0 grep -Hl “TimThumb”

PS. Here’s the updated TimThumb file that is patched:

http://code.google.com/p/timthumb/source/browse/trunk/timthumb.php

WordPress Auth_Key Secure_Auth_Key and Salt generator

This is an official WordPress secret auth key and secure auth key salt generator. Just click the link and it will make unique keys for your wp-config.php file.

https://api.wordpress.org/secret-key/1.1/salt/

If you reload the page or click this link again, you’ll get another unique WP salt. This is how to have your own WordPress salt that no one else has (likely).

Apache security – response headers – hide apache version

While this does fall into WordPress tips and tricks, it’s more of a WordPress security tip:

How to set: ServerSignature Off ServerTokens Prod

 

 

 

Paragraph spaces in WordPress editor – how to remove space between paragraphs

If you press and hold the “Shift” key while you hit the “Enter” key it the WordPress editor will give you the secret next line instead of the new paragraph!

If you simply hit the “Enter” or “Return” key on your keyboard it will create a new paragraph.

Reset your password in WordPress using PHPMyAdmin

from: http://codex.wordpress.org/Resetting_Your_Password

Reset your password in WordPress by PHPMyAdmin:

Begin by logging into phpMyAdmin and click databases.

Image #2

  • A list of databases will appear. Click your WordPress database.

Image #3

  • All the tables in your database will appear. If not, click Structure.
  • Look for wp_users.
  • Click on the icon for browse.
  • Locate your Username under user_login
  • Click edit

Image #4

  • Your user_id will be shown, click on Edit
  • Next to the user_pass is a long list of numbers and letters.
  • Select and delete these and type in your new password.
  • Type in the password you want to use. Just type it in normally, but remember, it is case-sensitive.
  • In this example, the new password will be ‘rabbitseatcarrots’
  • Once you have done that, click the dropdown menu indicated, and select MD5 from the menu.

Image #5

  • Check that your password is actually correct, and that MD5 is in the box.
  • Click the ‘Go’ button to the bottom right.
  • Test the new password on the login screen. If it doesn’t work, check that you’ve followed these instructions exactly.

Hide page titles in Wordpess using Genesis and a Child theme

How to hide your page titles by adding a function to your child theme’s functions.php file:

add_action('get_header', 'child_remove_page_titles');
function child_remove_page_titles() {
  if (is_front_page()) {
  remove_action('genesis_post_title', 'genesis_do_post_title');
  }
}

How to work with Genesis theme framework

NOTE: If you have made any changes directly to files in the /genesis/ folder, upgrading will overwrite these changes. Therefore, we recommend that you NEVER make changes this way. Alternatively, use the CSS in the child theme folder to make stylistic modifications, and use the proper PHP files in the child theme folder, along with the Genesis Hook system, to make functional/output modifications.

Generally with Genesis you can make changes to your child theme’s functions.php file to remove sidebars sitewide.

Here’s the complete list of Genesis plugins available from WordPress:

http://wordpress.org/extend/plugins/search.php?q=genesis

Here’s the link to download all Genesis themes (you’ll have to be logged in):

http://www.studiopress.com/support/forumdisplay.php?f=72

 

Contact Form 7 breaks after updating or upgrading WordPress to version 3

A client reported that WordPress with Contact Form 7 lost his contact form database after upgrading WP from version 2.x to version 3.

The author of Contact Form 7 has now updated his code so that the form is fully compatible with WP v3.

In case the upgrades don’t go smoothly:

I’d copy the actual contact form code into text files before upgrading WP. Then upgrade contact form 7, then see if they dissappear. In that case I’d paste them back in to the desired form from scratch an

Atahualpa tips and tricks

Here’s my tips for working with the very powerful theme Atahualpa.

Firstly this template is unlike most, it has your options in the WP backend Admin->Atahualpa Theme Options->here there are more than 200 options to set.  This generally does not require you to edit PHP files and FTP them to your server,  or edit CSS. This also doesn’t require Child Themes or additional template pages to create, specify and use.

To add google analytics website verification or webmaster tools verification to Atahualpa:

Admin->Atahualpa Theme Options->HTML Inserts: Header->Paste your google or ykey (yahoo key) in here.

A typical install of mine uses these CSS inserts in Admin->Add HTML/CSS Inserts:

ul.rMenu li a {width:148px; text-align:center;} /* custom menu centered */
li.cat-item {background-image: url(/wp-content/themes/atahualpa/images/bullets/Filagree_30px.gif);background-repeat: no-repeat; background-position: 0em;} /* custom menu icon */
h4 {margin:0.33em 0 -0.8em;} /* custom H4 */
td#middle a {color:red;} /* red links on page but only content area */
td#middle {border-left:1px ridge #FDF1CE;} /* ? */
div.widget_categories ul li a {margin-left: 19px;} /* using widget for categories as menu item – customized */
div.widget_categories ul li {margin-left: 5px; margin-bottom: 8px;} /* using widget for categories as menu item – customized */
div.widget_categories ul {margin-bottom: 35px;} /* using widget for categories as menu item – customized */
.post img.alignleft {float: left; margin: 0px 10px 5px 0;} /* atahualpa by default drops image down 10 pixels next to text, this overrides the setting in css.php for a 0px top margin site wide for left aligned image  */
.post img.alignright {float: right; margin: 0px 0 5px 10px; } /* same thing as above for right aligned image, this is from the atahualpa forum: http://forum.bytesforall.com/showthread.php?t=4416&highlight=alignleft  */
.post img.aligncenter {display: block;margin: 0px auto;} /* same thing as above for center aligned image  */

Plugins:

I am also using “Thumbnail  for Excerpts” which places the post’s first image as a thumbnail on the category, archive or other pages with post excerpts. If you do not have an image in the blog post, then you can explicitly specify one in the post excerpt.

“WP Events Calendar” doesn’t work for me with Atalhualpa, it does with other themes. It is possible this has been fixed or is a case of incompatibilities because I’ve not re-tried this on a default install.

To set the width of the top horizontal navigation menu and center it and the text menu items:
(in Atahualpa HTML/CSS Inserts)
ul.rMenu li a {width:148px; text-align:center;}

2 alternate ways to do the same thing from the Atahualpa forum:

http://forum.bytesforall.com/showthread.php?t=122

To add a background image to the horizontal menu bar, you have to set the height higher to see it from under the li items.
div#menu1 {background-image: url(/wp-content/themes/atahualpa/images/header/banner_964px.gif);}

To remove the “< Previous Post” “Next Post >” links at the top or the bottom of your post pages:
Admin->Atahualpa Theme Options->Next/Previous Navigation->Location of Next/Previous Page Navigation on MULTI Post Pages->set it to “None”
Admin->Atahualpa Theme Options->Next/Previous Navigation->Location of Next/Previous Page Navigation on SINGLE Post Pages->set it to “None”

To show different category listings and indent them as a navigation menu:
from the Atahualpa forum and the master himself…Flynn : http://forum.bytesforall.com/showthread.php?t=2373

To indent sub items set check the “Show Hierarchy” checkbox inside the Category widget

You can use the default Categories widget multiple times but it will always display all categories.

To display several instances showing different categories, install and use multiple instances of the PHP code widget, drop a few of them into the sidebar, click on their Edit links to give each one a title, such as “Party Themes”, and put this into each one

<ul>
<?php wp_list_categories(‘show_count=1&title_li=&include =3,7,22‘); ?>
</ul>

3,7,22 means display posts of categories with the ID’s 3, 7 and 22.

Put the numbers in ascending order here. Look up the ID’s of categories at WP Admin -> Posts -> Categories -> Edit -> Watch browser status bar at bottom of browser window for “…&cat_ID=XX

Updating Atahualpa:

Atahualpa keeps in’s settings in the WordPress database, so you won’t lose your settings by overwriting your theme file, like doing an auto-update of Atahualpa. However early versions since 3.4.7 kept their settings (theme options) in one single option named bfa_ata4.

In this case (from Atahualpa 3.4.4 to 3.7.3):

  • Install a second version of the theme with it’s version number in the theme folder, this way you can run the new theme next to the old version and test activate the new one.
  • You’ll find that you need to copy your image and remove the default other (rotating) images from the /images/header folder.
  • Also if you have a favicon, copy your custom favicon from the old /images/favicon folder to the new one.
  • If you have lost your excerpt thumbnails and are running the plugin “thumbnail for excerpts”, it won’t work with the new Atahualpa, you’ll need to run another plugin like  “easy add thumbnail” to automatically use the first post image for the excerpt thumbnail. You may also want to do this if you’ve started from an older WordPress and have not or don’t want to specify the excerpt thumbnails for each post manually.

To move Atahualpa from one blog or website to another:

To export from the old website: Atahualpa theme options->Export/Import Settings->Export and download Atahualpa settings file.

To import to the new website:

Atahualpa version 3.6.5 and up: Atahualpa theme options->Export/Import Settings->Atahualpa import settings (paste export file contents into this box)

If your PHP code is now broken:

Since 3.6.5 PHP code cannot be used anymore in Atahualpa HTML/CSS Inserts, this is because PHP file functions cannot be used anymore in themes listed on wordpress.org. At the time I wrote this, Atahualpa is currently the most downloaded free theme from WordPress.org!

Paragraph spaces in WordPress editor – how to make space between paragraphs

To create paragraph spaces in TinyMCE or <p> </p> tinymce wordpress:

A WordPress style is <p><br “class=spacer_” /></p>, however this is not in my stylesheet,  it comes from using TinyMCE advanced as an editor plugin in the backend.

A quick way to do it is:

<p>&nbsp;</p>

but this will give full line height spaces between paragraphs.

I use this instead because I can adjust the line-height, thus distance between the paragraphs:

In the code:

<p class="spacer">&nbsp;</p>

In the stylesheet:

.spacer {
 line-height: 0.7em;
}

WordPress how to redirect error 404 page to home page or any page

My WordPress theme didn’t have a 404.php page included and I wanted to make any error 404 “page not found” go to the home page. This method would go to any page you specify. This is a somewhat hard coded solution and it is a permanent redirect in this case.

Contents of 404.php:

<?php
header("Status: 301 Moved Permanently");

header("Location:http://www.mywebsite.com");

?>

WordPress How to Tell if a Page is Loaded

If you would like to do something special on a page with code and know if it’s not a post, you can use a conditional test to find out if a page is loaded:

<?php if (!is_page()) {do this} ?>
Posted in Wordpress Tips. No Comments »

Linking to any page, post or category in wordpress

If you cannot link to a page you added properly, plugin “page links to” will do it. Install and edit page, don’t worry about the “permalink” at the top, scroll to the bottom and create your link. In my case I needed a category page and wordpress’ “Permalink” editor strips out index.php?cat=7 links and /category/my-category links when you try to add them. (it parses out the ? and the /)

from the wordpress codex: http://codex.wordpress.org/Linking_Posts_Pages_and_Categories

There are two ways to make internal links from one content page to another in WordPress. One uses permalinks and one does not. The method that does not use permalinks works regardless of whether permalinks are enabled for your site.

Contents

[hide]

Linking Without Using Permalinks

If you are not using Permalinks, how do you link to your pages, posts, and categories?

Using the numeric values found in the ID column of the Posts, Categories, and Pages Administration, you can create links as follows.

Posts

To link to a Post, find the ID of the target post on the Posts administration panel, and insert it in place of the ’123′ in this link:

<a href="index.php?p=123">Post Title</a>

Categories

To link to a Category, find the ID of the target Category on the Categories administration panel, and insert it in place of the ’7′ in this link:

<a href="index.php?cat=7">Category Title</a>

Pages

To link to a Page, find the ID of the target Page on the Pages administration panel, and insert it in place of the ’42′ in this link:

<a href="index.php?page_id=42">Page title</a>

Date-based Archives

  • Year: <a href=”index.php?m=2006″>2006</a>
  • Month: <a href=”index.php?m=200601″>Jan 2006</a>
  • Day: <a href=”index.php?m=20060101″>Jan 1, 2006</a>

Links On External Sites

If you are providing a link to your site from outside of your site, be sure to specify a full URL to the correct location:

<a href="http://example.com/index.php?p=123">post title</a>

If you have installed WordPress to a subfolder, such as wordpress, don’t forget to add the folder to the link URL:

<a href="http://example.com/wordpress/index.php?p=123">post title</a>

Linking Using Permalinks

If you are using permalinks, you can use all of the above non-permalink techniques, which will work with permalinks enabled or not. If you have enabled permalinks, you have a few additional options for providing links that readers of your site will find a bit more user-friendly than the cryptic numbers.

The complexity of the URL depends on the complexity of your permalink configuration. If your permalink configuration (set on the Options > Permalinks Administration Panel) contains many Structure Tags, then the URL will be more difficult to construct.

Posts

For posts, replace each Structure Tag in your permalink structure with the data appropriate to a post to construct a URL for that post. For example, if the permalink structure is:

/index.php/archives/%year%/%monthnum%/%day%/%postname%/

Replacing the Structure Tags with appropriate values may produce a URL that looks like this:

<a href="/index.php/archives/2005/04/22/my-sample-post/">My Sample Post</a>

To obtain an accurate URL for a post it may be easier to navigate to the post within the WordPress blog and then copy the URL from one of the blog links that WordPress generates.

Review the information at Using Permalinks for more details on constructing URLs for individual posts.

Categories

To produce a link to a Category using permalinks, obtain the Category Base value from the Options > Permalinks Administration Panel, and append the category name to the end.

For example, to link to the category “testing” when the Category Base is “/index.php/categories”, use the following link:

<a href="/index.php/categories/testing/">category link</a>

You can specify a link to a subcategory by using the subcategory directly (as above), or by specifying all parent categories before the category in the URL, like this:

<a href="/index.php/categories/parent_category/sub_category/">subcategory link</a>

Pages

Pages have a hierarchy like Categories, and can have parents. If a Page is at the root level of the hierarchy, you can specify just the Page’s “page slug” after the static part of your permalink structure:

<a href="/index.php/a-test-page">a test page</a>

Once again, the best way to verify that this is the correct URL is to navigate to the target Page on the blog and compare the URL to the one you want to use in the link.

Date-based Archives

  • Year: <a href=”/index.php/archives/2006″>2006</a>
  • Month: <a href=”/index.php/archives/2006/01/”>Jan 2006</a>
  • Day: <a href=”/index.php/archives/2006/01/01/”>Jan 1, 2006</a>

Links on External Sites

Permalink structures should begin with a slash, meaning that they are anchored at the root of the site’s URL. You should be able to prepent the protocol and server name to any link that begins with a slash to build a successful full URL.

For example, this category link:

<a href="/index.php/categories/parent_category/sub_category/">subcategory link</a>

Becomes this category link using a full URL:

<a href="http://example.com/index.php/categories/parent_category/sub_category/">subcategory link</a>

Combining Links with Template Tags

You can customize your links in the header, footer, or sidebar to be combinations of link types. This example features links to two categories, the main index page, a post, a static page, and uses the Pages template tag.

Note carefully that the wp_list_pages() template tag generates its own List Item (LI) so it doesn’t need to be wrapped in a LI tag. This template tag is also set to list only the parent Pages and not their subPages or “children”.

<ul id="linklist">
 <li>
  <?php _e('Check It Out'); ?>
  <ul id="pageslist">
   <li>
    <a title="Home Page" href="index.php">Home</a>
   </li>
   <li>
    <a title="Blog" href="index.php?cat=7">Blog</a>
   </li>
   <li>
    <a title="Life Story" href="index.php?p=12">My Life Story</a>
   </li>
   <?php wp_list_pages('exclude=4&depth=1&sort_column=menu_order&title_li='); ?>
   <li>
    <a title="Links and Resources" href="index.php?cat=33">Links</a>
   </li>
   <li>
    <a title="Site Map" href="sitemap.php">Site Map</a>
   </li>
  </ul>
 </li>
</ul>

Using such a customized list, you can also add CSS classes to change the look of each of the links, or style the entire section. It’s up to you.

Absolute versus Relative Links

Absolute links define absolutely where to find the target of the link.
Relative links define the location of another document in relation to the current document.

Absolute Link Examples

Full URIs of the form http://example.com/wordpress/index.php are absolute links.

Absolute links can also point to your own server. When doing so, you may safely omit the http://domain.com prefix, and link to the target with a full path:

/wordpress/index.php

The leading slash means “At the very top of this domain is a directory named wordpress, and inside this directory is a file named index.php“.

A document at

http://example.com/wordpress/index.php

contains a link of the form

/wordpress/index.php

The link above, when clicked, will take the viewer to

http://example.com/wordpress/index.php

Relative Link Examples

Relative links do not start with a slash:

wordpress/index.php

The lack of a leading slash means “Inside the current directory is a sub-directory named wordpress, and inside that directory is a file named index.php“.

A document at

http://example.com/wordpress/index.php

contains a link of the form

wordpress/index.php

The link above, when clicked, will take the viewer to

http://example.com/wordpress/wordpress/index.php

Let us consider the case where in our blog where we are editing

http://example.org/blog/2009/01/04/nurds-on-the-loose

From it we can make links

  1. <a href=”../01/happy-new-year”>New Years Announcement</a>
  2. <a href=”../../01/01/happy-new-year”>New Years Announcement</a>
  3. <a href=”../../../2009/01/01/happy-new-year”>New Year’s Announcement</a>
  4. <a href=”../../../2008/12/25/merry-christmas”>Christmas Announcement</a>

Note 1, 2, and 3 are all valid to achieve the same link. However with 4 there is no shortcut, as we must “climb” all the way into the previous year.

The links are all relative and we need not hardwire in any more knowledge than is necessary, which also will help portability if one day we export the blog elsewhere. (What happens if one day we however pick a different permalink structure via the administration panels is unknown…)

However, the above assumes we are always viewing a single post. If in fact we are viewing that same post in an archive, well, then all our assumptions of where we are now are wrong! So we see that however smart relative linking looks, it has a fatal flaw and cannot be chosen!

For more information on absolute and relative links, see the WebReference Tutorial on Absolute and Relative Links.

Dynamic Linking in Templates

Whether you use permalinks or not, in templates you can link to pages or posts dynamically by referring to its unique numerical ID (seen in several pages in the admin interface) with <a href="<?php echo get_permalink(ID); ?>">This is a link</a>. (as shown in Template_Tags/get_permalink)

This is a convenient way to create page menus as you can later change page slugs without breaking links, as IDs will stay the same. However, this might increase database queries.

Dynamic page menus can also be created by utilizing Template_Tags/wp_list_pages child_of parameter or some of the many available plugins.

RSS

It seems that only fully qualified links (http:…) are guaranteed to work in all RSS reading environments…

Resources

Posted in Wordpress Tips. 2 Comments »

Worpdress How to show the last 5 posts

Show the last 5 posts or whatever number you specify using the following code, it loops through all of the posts.

First method I devised:

              <ul id="recent-items">
              <?php
                  $recentPosts = new WP_Query();
                  $recentPosts->query('showposts=10');
              ?>
<!--t added set the incremental counter<=? to the number of recent posts you want to see-->
              <?php $counter = 1; while ($recentPosts->have_posts() && $counter <= 10) : $recentPosts->the_post(); ?>
                  <a class="archive-content_footer" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?> - <?php the_date(); ?></a>
                  <?php // the_excerpt() ?>
                  <?php $counter++ ?>
                  <p>&nbsp;</p>
                  <hr>
              <?php endwhile; ?>
               </ul>

Second method officially shown on the wordpress codex (however the_date() didn’t work with this for some reason):

              <ul id="recent-items">
             <?php
             global $post;
             $myposts = get_posts('numberposts=5');
             foreach($myposts as $post) :
             ?>
    <div id="posttitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php the_date('Y-m-d', '<h3>', '</h3>'); ?></a></div>
 <?php endforeach; ?>
 </ul>
Posted in Wordpress Tips. No Comments »

Which pages are based on what templates in WordPress?

This depends upon your specific template. Custom page and post templates can be defined merely by putting them up on the website in the Theme’s folder with the title “content.php” which overrides wp-content.php.

The Default Template for my Blog pages is “Single.php” based on the inove template.

A new template can be created for pages (not posts) by creating it (or copying the code from something like “archive.php”, uploading it to the server and then selecting it in the dropdown menu “Template” on the page edit screen. This can be done for posts if you use the plugin “Custom Post Templates”.

Contact Form 7 – Thank You page after submit

WordPress’ wonderful plugin Contact Form 7 has not supported loading a Thank You page after the user clicks Submit. (As of Aug. 2009)

Here is a way to force Contact Form 7 to load a custom page after the user submits the form:
(note that it will change the submit form results for every contact form on the website, until code is added to the javascript to handle multiple Contact Forms on one WordPress website)

Edit this file: /wp-content/plugins/contact-form-7/contact-form-7.js
line: 91 add one line here, immediately after the code:

    if (1 == data.mailSent) {

add this:

location.href="http://mywebsite/my-thank-you-page/";

My favorite WordPress Plugins

Contact Form 7 – Super easy and functional contact form for website email.
Tip: You can run more than one form and customize each by creating a new one and referencing the appropriate one from the page you want the form on.

Gravity Forms – This is the hopped up version of Contact Form, it can dynamically populate your contact form, it can send your submissions to your newsletter server and more.

akismet – Stock plugin with WP, you have to create an account on wordpress.com to get an API Key then go  back to your  self hosted WP and install that key to get it to work. You can get fancy and use it to update status upon submitting a comment using AJAX.

ArtPal
Tips: Won’t work on WordPress MU (6-2009),  also had problems on Bluehost but don’t know why yet. Otherwise, I love this plugin thanks freerobby.com!

google sitemap generator – Creates sitemap.xml every time you add to your blog and submits to Tier 1 search engines.

NextGEN Gallery
Tips: Use instead of the recommended

to get started, that worked for me. Another possible bug, after installing on WP 2.8 beta 2, the gallery was working but quit for some reason. I’ll  update to WordPress 2.8 on June 10, the day the final release comes out and maybe look at this issue again.

TinyMCE Advanced
Tips: Go to Admin->Settings->TinyMCEAdvanced and drag your toolbuttons to and from the toolbar,  I allow it to not strip <br> and <p> tags added manually into the HTML editor.

SEO Title Tag

Posted in Wordpress Tips. No Comments »

WordPress Plugin Compatibility checker

Here’s a great WP website that has a compatibility chart of various plugins with various versions of WordPress:
WordPress Plugin Compatibility Check

Login to WordPress redirects to another wp-admin

If  your WP login redirects to a different installation of WordPress and you cannot log in to the correct wp-admin:

In my case it was a matter of exporting a blog from WPMU to a stand alone blog on another server to replicate the entire wordpress installation with all of the posts and pages intact.

Apparently it exported the blog address. I could access the wordpress blog as a user, but couldn’t login as the admin.

Another time I changed the Admin->Settings->General->”Wordpress address (URL)” from a domain name to an IP/directory which threw it into a tizzy. Every time I tried to log in to it would redirect me. No way to fix this in WordPress Admin panel.

This fixed it:
Edit the WordPress Database on the server you’d like to login to. Find out by looking at your /wp-config.php file. Then using Cpanel then PHPMyAdmin, open the database and go to the table wp_options->option_name and the value is the blog that it’s redirecting to!
Change this value to the WP install that you’d like to log in to, even using http://174.34.141.10/~myaccount if you have to.

If this doesn’t actually finish a successful login, and it did make the redirect go to the proper blog, but the redirect is still there it could be caused by a config file, not the database.

Alternatively, this may help:

Defining the cookie stuff:

define(‘ADMIN_COOKIE_PATH’, ‘/’);
define(‘COOKIE_DOMAIN’, ”);
define(‘COOKIEPATH’, ”);
define(‘SITECOOKIEPATH’, ”);

Worked for me too – 2.7, with multiple domains and blogs.

Posted in wordpress fix. 20 Comments »

Using custom styles in WordPress and tinyMCE

You can use the kitchen sink editor and have your styles appear in the “Styles” drop down directly in the page editor.

http://www.laptoptips.ca/projects/tinymce-advanced/

After you install the plugin, it’ll put a new button on the wp admin toolbar where you can configure stuff. Drag the new ‘styles’ dropdown to the tinymce toolbar, add new styles to the css file in the plugin directory, Ctrl + F5 to get everything to reload, and there you have it. If the style does not show up, dump your browser cache, then reload.

To Hide or unlink pages from the main menu in WordPress

To hide a page or post from the navigation menu in WordPress do this usually in your theme’s sidebar.php or header.php if you are using pages on your menu. Note: most people are not using pages, posts are default for the navigation menu:

<ul>
<li><a href="<?php bloginfo('url'); ?>">Home</a></li>
<?php wp_list_pages('title_li=&depth=1&exclude=8'); ?>
</ul>

Really, the key part is "&exclude=8", find the page you want to hide or unlink from the menu by clicking on it and reading the location in the URL bar up top in your browser, or inspect it in WordPress on the backend.

The number or page name (usually the "slug") is the important part. If you want to exclude more than one, use a comma.

ex: wp_list_pages('title_li=&depth=1&exclude=6,8')

If you cannot find the page_id, here’s a tip:

To find the page id instead of the slug or page name on newer WordPress installs, go to the backend, click on the pages (or posts) edit menu, hover you mouse over the page name and look at your status bar in the bottom of your browser window, it will end in a number. That number is your page_id. This page_id is a way to load that page. You can substitute it for the slug to find any page on your blog.

ie: www.myblog.com/new-page will also load with www.myblog.com/?page_id=3

from: http://codex.wordpress.org/Template_Tags/wp_list_pages

Posted in Wordpress Tips. No Comments »

How to hide your text blog title that appears over the banner in WordPress

To hide the WordPress page title which lays over the top of your banner image:

In your /themes/style.css file:
#header h1 { display:none }

This will allow your blog title to show in the window title and as the  link in google and other seach engine results while not allowing it to overlay your new banner.

Posted in Wordpress Tips. 2 Comments »

Worpdress page title – how to reverse it

To reverse the WordPress page title, that is the blog title and the blog name:

In your Themes directory header.php

For WordPress 2.5 and up:
<title>
 <?php wp_title('--',true,'right'); ?>
 <?php bloginfo('name'); ?>
 </title>
Posted in Wordpress Tips. No Comments »

Making a custom print page layout for WordPress blogs

You can make a custom page layout that is called only when the person wants to print the page or print preview it.

Note: Some WordPress themes have a print.css stylesheet already created, so look for that in the theme directory first.

You must call the print stylesheet in the case of the browser being told to print the page. Do this by adding this to the <head> of your header.php:

<link rel="stylesheet" type="text/css" media="print"
href="<?php bloginfo('stylesheet_directory'); ?>/print.css" />

This is an example of a stylesheet for printing taken from the WordPress codex at:

http://codex.wordpress.org/Styling_for_Print

This example has been modified to hide Flash on the printout among other things:

--BEGINprint.css stylesheet--
/* t added created print stylesheet from scratch for this theme */
/* print style sheet is here */

@media print {
body {background:white;
     font-size:10pt;
     margin:0 }

/* t added to hide flash on printout      */
/* t added for custom flash style */
.flash{
    text-align: center;
    display: none;
}

#sidebar { display:none }
#header { height:75px }
#content{ margin-left:0;
     float:none;
     width:auto }
.demo .red { color:black;
     font-weight:bold }
#content a { font-weight:bold;
     color:#000066;
     text-decoration:underline }
#content{ margin-left:0;
     float:none;
     width:auto }
#footer, .ad { display:none }
h1, h2, h3, h4, h5, h6 { page-break-after:avoid;
     page-break-inside:avoid }
h3 { margin-left:10px;
     margin-bottom:0px;
     padding-bottom:0px }
blockquote, table, pre { page-break-inside:avoid }
ul, ol, dl  { page-break-before:avoid }
img.centered { display: block;
     margin-left: auto;
     margin-right: auto; }
img.right { padding: 4px;
     margin: 0 0 2px 7px;
     display: inline; }
img.left { padding: 4px;
     margin: 0 7px 2px 0;
     display: inline; }
.right { float: right; }
.left { float: left }
img { page-break-inside:avoid;
     page-break-after:avoid; }
}
--END print.css stylesheet--
Posted in Wordpress Tips. No Comments »

Removing a linked page title on a WordPress blog or changing the title

The page title on WordPress blogs is coded in the file is “page.php”. Search for the line with “<?php the_permalink() ?>” and then you can remove that link, or edit it and add some text.

To change the page title for Posts, edit the file “index.php” and search for the line with “<?php the_permalink() ?>”, then edit as desired.

Posted in Wordpress Tips. No Comments »

Moving a WordPress Blog from MU to the regular WordPress single blog install

To move the posts, pages, pictures, information, and settings of an existing, populated blog whether it’s on the single instance WordPress installation or WordPress MU with lots of blogs. This also applies to moving a wordpress blog from one server to another, or copying a wordpress blog:

You can use Admin->”Tools”->Export.

Then setup your new blog on your new server, Admin->”Tools”->”Import”->”Wordpress”.

This part on also applies to setting up a virgin wordpress install and converting it to a page based CMS instead of a post based website.

Then copy your theme over to the new location (server), this even copies a customized theme properly with images! (Copy the entire theme directory and subdirectories)
Now do your backend configuration by logging into blogURL/wp-admin.

Typical configuration Items I do:
1) Admin->Settings->Permalinks->/%postname%/ (this changes all page names to the slug instead of page?=)
2) Admin->Settings->Reading->Static Page->Home, Posts Page->Blog
3) Admin->Settings->Miscellaneous->Store uploads in this folder->wp-content/uploads (On the front end they will be in http://174.34.141.10/~blogname/wp-content/uploads/test.gif)

4) Admin->Settings->Miscellaneous->Full URL path to files->leave blank unless you don’t have a domain name in that case do this->http://174.34.141.10/~acctnam (you will have to temporarily link your images with /~acctname/wp-content/uploads/imagename.jpg. Remove the italicized /~acctname)/ part when changing to a blog with a Domain Name instead of IP/~acctname!
5) Admin->Settings->Miscellaneous->Uncheck “Organize my uploads…”
6) Copy all plugins to /public_html/wp-content/plugins and activate in Admin->Plugins
7) Configure each plugin as you active them Admin->Tools->pluginname (usually)
8) Check your images to make sure the path is the same, if not, make sure they are on the new server in the same location, check step 4 and 5 and check browser link to make sure URL base part is parsed correctly by step 4 and 5.
9) Admin->Settings->Writing->Default Post Category, set it to what got imported, should be set to the same Category  as your original blog.

This way you can migrate from a multi blog WordPress MU to a single blog, a WordPress single instance blog to another server, and possibly even from a single WordPress blog to add it to an MU installation with many blogs already.

Posted in Wordpress Tips. No Comments »

WordPress Submenus or subpages how to list child page links

From: http://codex.wordpress.org/Template_Tags/wp_list_pages
To list a child page menu while only on the parent page, in other words to display a submenu:

Put this inside the the_post() section of the page.php template of your WordPress theme after the_content(), or put it in a copy of the page.php template that you use for pages that have sub-pages (index.php is the template you want if you are using pages instead of posts):

<?php  $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');  if ($children) { ?>  <ul>  <?php echo $children; ?>  </ul>  <?php } ?>

A problem with WordPress 2.7 not showing submenus:
from: http://wordpress.org/support/topic/238967
There seems to be major issues with adding submenus in custom top-level menus with WPMU 2.7 I have a set of plugins that need to go into their own top-level menu, so one of the plugins does nothing but create the menu structure for the others. This used to work fine till 2.6.5 (the last stable version), but stopped working in the release 2.7

The problem is that the link that’s generated for the submenu is not of the form
admin.php?page=submenu.php,
but instead, it’s of the form
toplevelmenu.php?page=submenu.php

As a result, even though the menu items are added, clicking on them leads to a 404. This breaks several other plugins (one that I could immediately spot is Buddypress Friends plugin).

I searched in the forums, and found posts about similar behaviour for others as well, but it seemed unresolved (or had inexplicably resolved itself). After tracing through the code, it seems that there’s a little bug in the code in menu-header.php (fixing it worked for me – my plugins as well as the others started working).

on line 122:
$parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . “/{$item[2]}”) && !is_dir(WP_PLUGIN_DIR . “/{$item[2]}”) ) || file_exists($item[2]) || ( file_exists( WPMU_PLUGIN_DIR . “/{$item[2]}” ) && ! is_dir( WPMU_PLUGIN_DIR . “/{$item[2]}” ) );

should be:

$parent_exists = !$admin_is_parent && ((file_exists(WP_PLUGIN_DIR . “/{$item[2]}”) && !is_dir(WP_PLUGIN_DIR . “/{$item[2]}”) ) || file_exists($item[2]) || ( file_exists( WPMU_PLUGIN_DIR . “/{$item[2]}” ) && ! is_dir( WPMU_PLUGIN_DIR . “/{$item[2]}” ) ));

(note the different grouping of conditions).
Like I said, this fixed the problem for me, and doesn’t seem to break anything (at least nothing that I’ve found yet). I’m posting this so that others can also take a look. Hopefully, it will help others with similar issues.


Listing Subpages of Subpages:
http://wordpress.org/support/topic/181936


Posted in Wordpress Tips. No Comments »

Worpress Sidebar Menus – Horizontal or Vertical?

Have been through lots of WordPress themes, and they almost always contain horizontal menus across the top as a top menu, or top navigation bar.

Instead, if you want to run your navbar down the left side as a vertical sidebar menu, you are very limited in theme choices.

I re-use a theme and re-theme it until I find a good solution, and a good and straightforward one.

Here’s what I’ve collected so far on the subject:


Try placeing this code in your header or where ever your menu is called from. You should have something like this right now?

<ul class="menu">
      <?php wp_list_pages('depth=1&sort_column=menu_order&title_li='); ?>
</ul>

try making it this:

<div class="menu">
	<ul>
		<?php wp_list_pages('depth=1&sort_column=menu_order&title_li='); ?>
	</ul><br />
<?php
	if($post->post_parent)
		$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
	if ($children) { ?>

	<ul>
		<?php echo $children; ?>
		<?php } ?>
	</ul>
</div>

By replacing the code you mentioned it changes the horizontal menu into a vertical menu,see http://blog.narrowminds.nl/ to view what I mean.

I have already tried drop down menu plugins but I could not find a plugin that is really easy editable (css) to make the lay-out the way I want it.


Posted in Wordpress Tips. No Comments »

Moving WordPress MU to another server

WordPress MU is created to run in the root directory, not a subdirectory or folder!Three things to change when moving your WordPress MU install.
- Database
- wp-config (base setting, should be /)
- htaccess (rewrite base, should also be /)

WordPress API for Templates

WordPress API for functions

WordPress Template Tags

The API for WordPress functions is here.

Post, Page, Attachment and Bookmarks Functions
Category, Tag and Taxonomy Functions
User and Author Functions
Feed Functions
Comment, Ping, and Trackback Functions
Action, Filter, and Plugin Functions
Theme-Related Functions
Formatting Functions
Miscellaneous Functions
Classes
WordPress Variable Report
WordPress Hooks Table








Child Themes in WordPress

Child Themes in WordPress work like copies of an existing theme, which are editable, but don’t change the theme they are based on. It’s an instance of that theme, so the original theme that the child is based upon can be safely updated without worrying about breaking the original.

Here’s a great basic tutorial on Child Themes in WordPress

Another slightly more advanced tutorial on using a Child WordPress Theme

WordPress page title maximum length

My personal conclusion:
67 characters.

Page title maximum length for google

With WordPress you don’t get to use all of those characters by default and you must do some optimization to the engine to change this.

How to change WordPress page titles if you don’t have access to this article, you can request access from googlethem.

Blogging Tips for WordPress

These blog writing tips are for WordPress or any blog such as blogspot or blogger.

Write pertinent content regularly, if you want to ramble about different subjects, then tag them and/or categorize them differently so that people (or you) can view your entries chronologically and in a long page that are on a similar subject of interest.

To get listed in google and other search engines, you either need to be linked to from somewhere else on the internet, or you need to get proactive and submit your blog to google, submit your blog to yahoo.

If you have a page that you want removed, log in to WordPress, or your favorite blog engine, delete the post (blog entries are usually posts and not pages), then you still have to remove the post from google’s website cache.

Hyphens in URLs or URL Rewriting for WordPress SEO

Hyphens in URLs or “URL Rewriting” for WordPress SEO, Content Management Systems (CMS), Dynamically Generated Content and Shopping Cart Systems”:

If you have a dynamic website that creates pages from data then you are likely to have URLs that have stuff like http://www.mysite.com/product.php?product_id=8

This is not easy to remember, means nothing to a human or search engine, and does not help with google SEO or any SEO.

You should find out how to setup your backend, shopping cart engine, blog engine, or CMS to rewrite the URLs to search engine friendly versions like:
http://www.mysite.com/website-software/easy-website-maker

Howto URL rewrite in WordPress:Admin->Settings->Permalinks->Custom Settings->Enter text "/%postname%/"
Most WordPress installs I see do it this way instead:
Wordpress:Admin->Settings->Permalinks->Custom Settings->Check Radio button "Month and name"

Whalla! WordPress will now take care of the search engine friendly URL rewriting for you based upon your article’s title!

What really happens with URL rewriting on an Apache server (let’s hope this applies to you ;-), is that the .htaccess file gets rewritten by WordPress, but you can have direct control by looking and and if you’re brave, editing this file. You’ll need to know Regular Expressions (Regex) to even attempt this, a great tutorial on URL Rewriting is at addedbytes.com

Footnote: Are underscores in URLs ok to use? Well, they can only be in the path, which is after the domain name, not legal in a domain name, spaces are not either for that matter.

Matt Cutts from a speaking appearance at Word Camp 2007 said that underscores will be parsed like hyphens soon at google if not already (august 2007). He also dropped some info implying that google can parse dictionary words out of a domain name, but I wouldn’t count upon that, the engine has to work harder to pluck your keywords out of a oneworddomainname.com

Now for Matt’s quote from this website:
“Matt: Now the interesting thing is that we used to treat underscores as if they were like word A Underscore word B We would glom that together .And we would index that as A underscore B If you searched for the word A we wouldn’t have returned your post.
We are in the process of changing that. We might have already changed that.

So dashes and underscores are almost exactly the same. but in engine world dashes are nice because if there is no space at all the search engine has to segment it.”

WordPress Security Tips top ten

From: WordPress Security Tips and Hacks.

Ten security tips for WordPress.

WordPress Codex – Designing headers

Everything you wanted to know about designing Header Images in WordPress but were afraid to ask.

Even changing header images

Uploading or Posting Pictures in WordPress WPMU

To change the default image upload folder:
In the file: /wp-settings.php
define( "UPLOADS", "wp-content/blogs.dir/{$wpdb->blogid}/files/" );
When the problem remains that you have the uploaded files going into a /year/month subdirectory, there is a checkbox in the Admin->Settings  for not using the year date. However if you are using WordPress MU and you always want the uploads to not be deeply nested in a bewildering array of year/month folders, you can override this setting for all of your MU blogs by editing your /functions.php file to ignore the “uploads_use_yearmonth_folders” setting by modifying line 1855 (MU version 2.7)

from:  if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
to: if ( get_option( '' ) ) {

How to tell which upload directory your individual blog in WordPress MU is in:The /wp-includes/blogs.dir/ directory contains lots of numbered folders like 11, to determine which blog this folder belongs to go to your database and find the table for wp_blogs and this one will cross reference the blog names with the respective numbers.

About file uploads From a WordPress forum comment by a user sacredpath on:

When creating and uploading an image to wordpress.com here are some basics worth remembering:

(1) Be sure your image is one of these file types – jpg, jpeg, png, gif (Note that bmp’s cannot be uploaded due to size).

(2) Do not use anything in the file name except letters and numbers. Use no spaces, no dashes, no underscores, or any type of special character or punctuation, except for the dot between the file name and the extension. Also make sure that the file name has an extension.

(3) If you are using iPhoto, then use the “export” function under the file menu to export the image to your desktop before trying to upload it to WordPress.

(4) If you are not using the image in thumbnail size, make sure that the image is not too wide for the post area in your particular theme. You can find maximum image widths for the most popular themes here: http://faq.wordpress.com/2006/09/25/how-big-can-my-images-be/

(5) Optimize your images so that your blog pages will load faster. See http://faq.wordpress.com/2006/05/08/optimise-your-images/

(6) How to upload pictures in posts: http://faq.wordpress.com/2006/07/16/how-do-i-upload-pictures/

(7) How do I get text to go around a picture? http://faq.wordpress.com/2006/05/29/how-do-i-get-text-to-go-around-a-picture/

(8) How do I upload larger pictures? How to increase the file size limit on uploads with WordPress.

What are Trackbacks, Pings, Pingbacks and Permalinks?

They are all eloquently explained on an official WordPress information page about “Introduction to Blogging”, halfway down the page it gets more interesting to those who already know what a blog is and are more interested in how to optimize or market their blog.

How to add an image to your WordPress feed

This is directly from the page David – Adding the image tag to WordPress’s rss headers

The RSS specification allows you to have an <image> element in the header of your RSS feed.  A long time ago, if you used WordPress, you’d have to edit the wp-rss.php file and be very careful when you upgraded to new releases, or your change could be lost.

But if you use a modern version of WordPress, you should take advantage of the do_action(‘commentsrss2_head’) hooks* in the feed-rss… .php files.

Here’s what you’d do: Add the following code to your theme’s functions.php file:

function add_my_rss_image()
{
    echo '<image><title>', bloginfo_rss('name'), '</title>';
    echo '<url>', bloginfo_rss('url'), '/images/button.gif</url>';
    echo '<link>', bloginfo_rss('url'), '</link>';
    echo '<width>88</width><height>31</height>';
    echo '<description>Description of your blog.</description></image>';
}

add_action('rss2_head','add_my_rss_image');
add_action('rss_head','add_my_rss_image');
add_action('commentsrss2_head','add_my_rss_image');

Take care to actually put an image file in the path specified, and adjust the width and height accordingly.

Et, voila! Now your feeds have images, and they’re forwards compatible with future versions of WordPress. Oh, did I say future versions of WordPress? Excuse me, I have to:

svn sw http://svn.automattic.com/wordpress/tags/2.6/

Blam! Upgraded. Sweet.

* Also rss2_head and rss_head, just so I cover the appropriate Google terms.

WordPress Codex

The definitive guide to doing anything with WordPress, from the horse’s mouth:

http://codex.wordpress.org/Advanced_Topics

They have the WordPress Codex function list among other valuable things.

Adding google analytics tracking code to your WordPress installation the easy way

Insert your tracking code generated from google analytics into your footer.php for your specific theme that your blog uses, WARNING! if you switch themes you will need to go back and add that tracking code to the new theme!

\wp-content\themes\yourthemenamehere\footer.php and do a search for the </body> tag.

Directly above the </body> tag paste in the code given to you by Google analytics. It should like something like this:

The new google tracking code:
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-1292736-8″);
pageTracker._initData();
pageTracker._trackPageview();
</script>

Or the old google (urchin) tracking code:
<script src=”http://www.google-analytics.com/urchin.js” type=”text/javascript”>
</script>
<script type=”text/javascript”>
_uacct = “UA-1234567-8″;
urchinTracker();
</script>

After adding the code for your specific website upload it to your correct theme folder using ftp.

Stop SOPA