WordPress Goodies

A few tidbits for WordPress I picked up this week working on Psychic Coupons and a couple other sites.

===============================================

This is an oldie but goody, helps a lot: http://codex.wordpress.org/Template_Hierarchy
and the PNG: http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

===============================================

Here’s one from equalmark and banago at http://wordpress.org/support/topic/query-if-on-front-page-home-index :
If you’re on the front page, conditional statements:

<?php if(is_front_page() ) { ?> //do stuff <?php } ?>
— or --
<?php if(is_home() ) { //do stuff } else { //do stuff } ?>

Mvied notes: I’d just like to point out that the is_home() function is true if you’re on the main blog page, and the is_front_page() function can be the same page unless you have a static front page set, then it will only be true on that page.

============================================

Passing variables in the URL, by stvwlf from http://wordpress.org/support/topic/passing-variables-using-the-permalink-structure :

Step 1:
Create and save PHP file in plugins directory:
<?php
/* Plugin Name: Parameter
Plugin URI: http://webopius.com/
Description: A plugin to allow parameters to be passed in the URL and recognized by WordPress
Author: Adam Boyse
Version: 1.0
Author URI: http://www.webopius.com/
*/
add_filter('query_vars', 'parameter_queryvars' );

function parameter_queryvars( $qvars )
{
$qvars[] = ' myvar';
return $qvars;
}
?>
Step 2:
Pass var in URL href:
if (isset($wp_query->query_vars['myvar']))
{
print $wp_query->query_vars['myvar'];
}

=============================================

Find and show related posts by tag: http://wordpress.org/support/topic/variables-through-get_posts-query_posts

=============================================

elseloop offers a simple way to implement a “Post template based on category”: http://wordpress.org/support/topic/post-template-based-on-category-or-tag

=============================================

I just want to pass my thanks to the many talented people who take the time to share their expertise on the WordPress community forum. They are adding value to the world, so, KUDOS to all you geniuses!

Posted under WebDev, WordPress

This post was written by Content Curator on April 10, 2012

Tags: , , , , , , , , , , , , , , , , ,

How To Make a Shiny Rounded Button in Adobe Illustrator

Using Adobe Illustrator CS4 (this procedure may also apply to CS3 and earlier versions, please let me know if it does) you can make a neat little object that looks like it is curved, rounded, and shiny, with a light shine highlight and edge darkening effect to get the full depth.

  1. Start with an image layer, containing the image that will be the skin of the object (which is in our case a round convex button).
  2. Put a new layer under it.
  3. On the new layer create a circle (Ellipse (L) tool and hold Shift to force circular, hold Alt to anchor center point of ellipse while manipulating the size) that encompasses the part of the image that whall be visible on the final “button” to be created.
  4. Create a radial gradient in the circle. Make it lighter in the center.
  5. Create a new layer between the image layer and the circle layer.
  6. Create another circle on this layer, a bit smaller than the last one, and shifted down a bit so it almost touches on the lower boundary of the circles.
  7. On the same layer create an ellipse that is larger than the circle, but leaves a crescent at the top of the button, for the shine.
  8. Using the layers box, and holding Shift, select both these layers. Then click Pathfinder > Subtract From Shape. This trims out all but the crescent.  (If it does the opposite, Undo (Ctrl-Z) back and reverse the order stacking order of the circle and ellipse on this layer, and try this step again.)
  9. Create a new layer between the image layer and the original circle layer.
  10. On this layer create a rectangle that covers the entire crescent.
  11. In the rectangle, create a white-down-to-black gradient (at -90 deg.) using the standard black and white color pair.
  12. Using the layers box again, select both the rectangle and crescent layers.
  13. On the Transparency panel dropdown (located in the right-corner of the panel) menu selet Make Opacity Mask.
  14. Select the original circle and copy it.
  15. Select the image layer, and paste the circle using Ctrl-F.
  16. Select the pasted circle. Remove the fill and stroke from it.
  17. Select the entire image layer (which selects all sublayers too) and do Ctrl-7 to create a clipping mask. Now your button looks round.
  18. Create a new layer above the image layer, but under the shine layer.
  19. Paste the circle again into this new layer.
  20. Convert the fill to a B&W gradient.
  21. On the gradient, move the center nugget toward the black as far as it will go. This creates a domed shadow effect.
  22. In the Transparency panel, select Mode of Multiply, then select Opacity of 20%.

Viola! Now you have a round  button that looks roundy and shiny.  Rotate the crescent layer to change the direction of light in the shine.

Great Adobe Illustrator tutorial I got this metod… thank you Veerle!

Posted under Graphic, Uncategorized, WebDev

Stats on Browsers, Operating Systems, used in browsers

I found some nice information on which browsers are being used, which resolutions and operating systems are running them, what desktop resolutions they have, etc. Very nice. See how fast Vista is losing usership…

Info courtesy W3Schools

Posted under Browsers, Network, Operating System, WebDev

This post was written by Content Curator on February 2, 2010

Tags: , , , , , , , , , , ,

WordPress Template Start

Start the PHP file with this:

<?php
/*
Template Name: Snarfer
*/
?>

Posted under WebDev, WordPress

This post was written by Content Curator on December 8, 2009

Tags: , , , , , , , , , ,

How To Make puTTY Automatically Load a Session

The most awesome emulator of all time, puTTY.exe, just got even easier to use. Along with loggiong automatically into a SSH session add the Windows shortcut that loads a saved session and launches it, now you have one click shell access to your Linux host from your Windows PC.

Here’s how:

  1. Download puTTY.exe
  2. Save it to the folder  C:\puTTY\
  3. Open a Windows Explorer window in C:\puTTY\
  4. Run puTTY.exe once, and create a “saved session”, making note of what you name it. My example below uses the name my neatly named Saved Session
  5. Right-click-drag puTTY.exe and drop it next to itself, this creates a shortcut to the .exe file.
  6. Right-click the shortcut you just created, on the popup menu click Properties.
  7. In the Target box, add -load “your-saved-session-name” after C:\putty\putty.exe
  8. The final content in the target box should look like:
    C:\putty\putty.exe -load "my neatly named Saved Session"
  9. Save the shortcut. Viola! Move or copy this shortcut anywhere you like (e.g. your Desktop, your QuickLaunch toolbar, your custom explorer toolbar, etc.) and you have 1-click access to a command prompt on your Linux / Unix host.

Enjoy!

Posted under Apple, Freeware, Linux, Microsoft, Network, Software, WebDev, ZyXel

This post was written by Content Curator on December 5, 2009

Tags: , , , , , , , , ,

How to Add Thumbnails in WordPress

When a website user makes a search with WordPress,  the search results typically are shown using the search.php template file. If one chooses to do so, these results can incluse an automatically “grabbed” image thumbnail generated by the images contained in the image. Posts with no images can show a default generic image instead. And this can all be done using the Get-The-Image plugin and perhaps a bit of code tweaking.

<div style="clear: both; margin-bottom: 20px;">
<div style="float: left; width: 150px; height: 150px; margin: 0 10px 10px 0;"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php if ( function_exists( 'get_the_image' ) ) { get_the_image('width=150&height=150&image_scan=true&default_image=http://yoursite.com/default.jpg' ); } ?></a></div>
<div>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?><br />
<p>Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
</div>

Insert this snippet, written by mercime ar wordpress.org into your loop, typically right after the beginning while-have-posts loop.

Posted under WebDev, WordPress

This post was written by Content Curator on November 16, 2009

Tags: , , , , , , , , , , , , , , , , , ,

How to Import Customer Records Into OTRS from CSV

Thanks to Mike Dent’s efforts and OTRS, we now know how a CSV file can be imported into the MySQL database directly. Here is the sample code:

mysql> load data infile '/tmp/otrs_test.txt' into table customer_user
fields terminated by '\t' lines terminated by '\r' (first_name,
last_name, address, postcode, phone1, email, customer_id, valid_id,
create_time, create_by, change_time, change_by, login);

Make sure to import all the required fields (that is, the ones that the database requires, see the table schema for details, >show table x;)

Posted under Freeware, MySQL, WebDev

This post was written by Content Curator on November 16, 2009

Tags: , , , , , , , , , , , , , , , , , , ,

Alternate Time Servers for Automatic Clock Set

In modern Microsoft Windows operating systems and all Unix / Linux systems the system clock time can be set automatically. The computer will connect to a special server on the Internet called a Network Time Protocol server, and get the current universal time, and then adjust it according to the local time zone on the computer. It keeps the computer clock very accurate and corrects drift before it can become much of a problem.

We recommend using a reliable server: pool.ntp.org

A wonderful group of generous folks provide this extremely reliable cluster of computers for us all to use, free of charge. Thank you NTP Pool Project and all the participants!

Posted under Freeware, Linux, WebDev

How to Delete Records in PHP using MySQL

The code in the HTML/PHP markup would look something like:

<?php mysql_query("DELETE FROM yourtable WHERE yourfield='yourvalue' ")
or die(mysql_error()); ?>

This code deletes any record from the table named “yourtable” when that record’s field named “yourfield” is identically equal to “yourvalue”. The names of these objects will, of course, be replaced by the unique names that your set up uses.

Source: tizag.com – excellent tutorials on all kinds of coding, programming, and other technical stuff.

Posted under Freeware, MySQL, WebDev

This post was written by Content Curator on November 16, 2009

Tags: , , , , , , , , , , , , , ,

How to fix “is not accessible. You might not have permission to use this network resource. Access is denied.” Network error with accessing XP windows shares

Trying to access a Windows XP host computer over a LAN (local area network) and get into it’s shared folders.

This little turd of an error can be really irritating. It happens when trying to access a shared folder, or any shares, on a remote, but LAN networked, Windows XP computer. After running the Network Setup Wizard on the host computer, and enabling file and printer sharing, it just won’t go away. In Windows XP Professional, you can go into the explorer view settings, and disable Simple File Sharing, which didn’t fix it either.

The fix ended up being a simple registry edit, suggested by Microsoft: http://support.microsoft.com/kb/913628

Here is the process:

To resolve this issue, set the value of the restrictanonymous registry entry to 0. To do this, follow these steps:

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then double-click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. On the right side, double-click restrictanonymous.
  4. Make sure that the value in the Value data box is set to 0, and then click OK.
  5. Close Registry Editor.
  6. Restart the computer.

This worked like a charm more than once for me.

Posted under Microsoft, Network, WordPress