Create wpsc category loop

Starts loop to show all or selected categories.

1) Show default category

 PHP |  copy code |? 
1
<?php wpsc_start_category_query(array('category_group'=>get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>

2) Show all categories

 PHP |  copy code |? 
1
wpsc_start_category_query(array('category_group'=>1,'show_thumbnails'=>get_option('show_category_thumbnails')));

Do some stuff here with the category data.

End the loop.

 PHP |  copy code |? 
1
<?php wpsc_end_category_query(); ?>

Posted in WP Ecommerce | Leave a comment

Show Category Image in Template

Must be within wpsc category loop

 PHP |  copy code |? 
1
<?php wpsc_print_category_image(get_option('category_image_width'), get_option('category_image_height'));
2
                    ?>

Posted in WP Ecommerce | Leave a comment

Additional Image Sizes

In THEME/functions.php

 PHP |  copy code |? 
1
if (function_exists('add_image_size')) {
2
  add_image_size('category-thumb', 280, 9999); //280px wide unlimited height
3
  add_image_size('item_detail', 400, 500, true); // cropped
4
}

To use new image sizes

 PHP |  copy code |? 
1
<?php
2
if (has_post_thumbnail()) {
3
  the_post_thumbnail('category-thumb');
4
} //uses image size defined as 'category-thumb'

Posted in Code, Theming, Tips and Tricks, Wordpress 3 | Leave a comment

Views Featured Image Size

Specify featured image size using WP Views field:

 HTML |  copy code |? 
1
[wpv-post-featured-image size="full"]

Can define new image sizes in functions.php and use them for specific instances

Posted in Views, Wordpress 3 | Leave a comment

Featured Image Size

To show featured image in theme:

 PHP |  copy code |? 
1
<?php the_post_thumbnail(); ?>

To specify size from media settings:

 PHP |  copy code |? 
1
<?php the_post_thumbnail('thumbnail');  // thumbnail size ?>
2
<?php the_post_thumbnail('medium');  // medium size ?>
3
<?php the_post_thumbnail('large');  // large size ?>
4
<?php the_post_thumbnail('full');   // Full resolution (original size uploaded) ?>

Specify max size: (may not work in WP 3+)

 PHP |  copy code |? 
1
<?php the_post_thumbnail(array( 400,400 ); ?>

Add class:

 HTML |  copy code |? 
1
<?php the_post_thumbnail(array( 200,200 ), array( 'class' => 'alignleft' )); ?>

Posted in Theming, Tips and Tricks, Wordpress 3 | Leave a comment

Parse PHP within HTML file

To make the server parse php within an html file, add this to the .htaccess file

 HTML |  copy code |? 
1
AddType application/x-httpd-php .php .htm .html

or

 HTML |  copy code |? 
1
AddType application/x-httpd-php5 .html

Check with your host for correct format.

Posted in PHP, Servers | Leave a comment

No Posts Found Text Shortcode

Shows text within shortcode tags when no rows are returned by the view

 HTML |  copy code |? 
1
[wpv-no-posts-found]<strong>No posts found</strong>[/wpv-no-posts-found]

Posted in Views | Leave a comment

Views using URL parameters for filters with spaces in the name

When using URL parameters to specify a filter use the Taxonomy name and use %20 in place of spaces.

 HTML |  copy code |? 
1
/12/latest-reviews/?wine=Sauvignon%20Blanc&vintage=2010

Posted in Views | Leave a comment

Display list of links

To show a list of links from the admin links section in a template:

 PHP |  copy code |? 
1
<?php wp_list_bookmarks( $args ); ?> 

Where $args can include the following:

 PHP |  copy code |? 
01
<?php $args = array(
02
    'orderby'          => 'name',
03
    'order'            => 'ASC',
04
    'limit'            => -1,
05
    'category'         => ,
06
    'exclude_category' => ,
07
    'category_name'    => ,
08
    'hide_invisible'   => 1,
09
    'show_updated'     => 0,
10
    'echo'             => 1,
11
    'categorize'       => 1,
12
    'title_li'         => __('Bookmarks'),
13
    'title_before'     => '<h2>',
14
    'title_after'      => '</h2>',
15
    'category_orderby' => 'name',
16
    'category_order'   => 'ASC',
17
    'class'            => 'linkcat',
18
    'category_before'  => '<li id=%id class=%class>',
19
    'show_description' => '1', 
20
    'category_after'   => '</li>' ); ?> 
21
 
22

Posted in Code, Theming, Tips and Tricks, Wordpress 3 | Leave a comment

Include Custom Template File

To include a file in the themes folder in another theme file:

 PHP |  copy code |? 
1
<?php get_template_part('special'); ?>

will include the file special.php in the current file.

Parameters are $slug and $name

 PHP |  copy code |? 
1
<?php get_template_part($slug $name); ?>

 PHP |  copy code |? 
1
<?php get_template_part('navbar' 'special'); ?>

will load navbar-special.php

ie:

slug = navbar (required)

and name = special (optional)

Posted in Theming, Tips and Tricks, Wordpress 3 | Leave a comment