Table of Contents

K2 Setup

Updated for:

falbum.php

In the \wordpress\wp-content\themes\k2 directory. Create a new file named falbum.php and copy the below code into it.

For Wordpress 2.5.1 and K2 v1 RC6 revision 692, create an FAlbum template using the following code:

<?php
/*
   Template Name: FAlbum Page template
*/
 
//Hack to set WP page id
$page_id = #; //Change this to match your sites WP page id of new Photos page
 
global $wp_query;
global $post;
if ($page_id != null) {
  $post->ID = $page_id;
  $wp_query->is_home = false;
  $wp_query->is_page = true;
  $wp_query->queried_object->ID = $page_id;
  $wp_query->queried_object_id = $page_id;
}
 
get_header(); ?>
 
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/jquery.js"></script> 
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/falbum.js"></script>
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/overlib.js"></script>
<?php if ($falbum->can_edit) { ?><script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/prototype.js"></script><?php } ?>
 
<?php /* Remove or comment out the below line after to finding the Photos page page_id */
// if ($page_id == null) { echo '<h2>page_id = '.$post->ID.'</h2>'; }
?>
 
<div class="content">
 
<div id="primary-wrapper">
	<div id="primary">
		<div id="notices"></div>
		<a name="startcontent" id="startcontent"></a>
 
		<div id="current-content" class="hfeed">
 
		</div>
 
			<div class="entry-content">
			<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
            <?php $falbum->show_photos(); ?>
            </div> <!-- #entry-content -->
		</div> <!-- #current-content -->
		<div id="dynamic-content">
		</div> <!-- #dynamic-content -->
	</div> <!-- #primary -->
</div> <!-- #primary-wrapper -->
 
	<?php get_sidebar(); ?>
 
</div> <!-- .content -->
 
<?php get_footer(); ?>

In FAlbum settings make sure to set the “Selected Style” preference to “_current_wordpress_theme”. The changes to the header file are not required.

For older versions (Falbum 0.6.6, Wordpress 2.0.4 and K2 0.9) falbum.php

<?php
/*
   Template Name: FAlbum Page template
*/
 
//Hack to set WP page id
$page_id = null; //Change this to match your sites WP page id of new Photos page
 
global $wp_query;
global $post;
if ($page_id != null) {
  $post->ID = $page_id;
  $wp_query->is_home = false;
  $wp_query->is_page = true;
  $wp_query->queried_object->ID = $page_id;
  $wp_query->queried_object_id = $page_id;
}
 
get_header();
?>
 
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/jquery.js"></script> 
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/falbum.js"></script>
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/overlib.js"></script>
<?php if ($falbum->can_edit) { ?><script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/prototype.js"></script><?php } ?>
 
<?php /* Remove or comment out the below line after to finding the Photos page page_id */
if ($page_id == null) { echo '<h2>page_id = '.$post->ID.'</h2>'; }
?>
 
<div class="content">
   <div id="primary">
      <div id="current-content">
         <div>
            <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
            <?php $falbum->show_photos(); ?>
         </div>
      </div>
      <div id="dynamic-content"></div>
   </div>
   <?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

header.php

In the \wordpress\wp-content\themes\k2 directory. Replace header.php with the following code:

header.php

<?php
	// Load localizatons
	load_theme_textdomain('k2_domain');
 
	// Load our scripts
	wp_enqueue_script('k2functions');
 
	if (get_option('k2rollingarchives') == 1) {
		wp_enqueue_script('k2rollingarchives');
	}
 
	if (get_option('k2livesearch') == 1) {
		wp_enqueue_script('k2livesearch');
	}
 
	if ((get_option('k2livecommenting') == 1) and ((is_page() or is_single()) and (!isset($_GET['jal_edit_comments'])) and ('open' == $post-> comment_status) or ('comment' == $post-> comment_type) )) {
		wp_enqueue_script('k2comments');
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
 
<head profile="http://gmpg.org/xfn/11">
 
<?php
require_once(ABSPATH.'/wp-content/plugins/falbum/falbum.php');
global $falbum;
?>
<?php global $falbum;?>
<?php if ($falbum->is_album_page()) { ?>
  <title><?php echo $falbum->get_page_title(); ?></title>
<?php } else { ?> 
  <title><?php wp_title(''); if (function_exists('is_tag') and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> Archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists('is_tag') and is_tag()) or (is_archive()) ) { ?> at <?php } ?><?php bloginfo('name'); ?></title>
<?php } ?>
	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
	<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
	<meta name="template" content="K2 <?php k2info('version'); ?>" />
 	<meta name="description" content="<?php bloginfo('description'); ?>" />
 
	<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />
	<?php /* Rolling Archives */ if (get_option('k2rollingarchives') == 1) { ?>
	<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('template_url'); ?>/css/rollingarchives.css.php" />
	<?php } ?>
	<?php /* Custom Style */ if (get_option('k2scheme') != '') { ?>
	<link rel="stylesheet" type="text/css" href="<?php k2info('style'); ?>" />
	<?php } ?>
 
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
 
	<?php if ( is_single() or is_page() ) { ?>
	<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
	<?php } ?>
 
	<?php wp_head(); ?>
 
	<script type="text/javascript">
	//<![CDATA[
		K2.columns = <?php echo get_option('k2columns') ?>;
 
		K2.layoutWidths = <?php /* Style Layout Widths */
			$styleinfo = get_option('k2styleinfo');
			if ( empty($styleinfo['layout_widths']) )
				echo '[580, 800, 970]';
			else
				output_javascript_array($styleinfo['layout_widths']);
		?>;
 
		if (K2.columns > 1) {
			jQuery(document).ready(dynamicColumns);
			jQuery(window).resize(dynamicColumns);
		}
 
		<?php /* Debugging */ if ( isset($_GET['k2debug']) ) { ?>
		K2.debug = true;
		<?php } ?>
 
		jQuery(document).ready(function(){
			<?php /* LiveSearch */ if (get_option('k2livesearch') == 1) { ?>
			K2.LiveSearch = new LiveSearch(
				"<?php if (get_option('k2rollingarchives') == 1) { output_javascript_url('rollingarchive.php'); } else { output_javascript_url('theloop.php'); } ?>",
				"<?php echo attribute_escape(__('Type and Wait to Search','k2_domain')); ?>"
			);
			<?php } ?>
 
			<?php /* Rolling Archives */ if (get_option('k2rollingarchives') == 1) { ?>
			K2.RollingArchives = new RollingArchives(
				"<?php output_javascript_url('theloop.php'); ?>",
				"<?php echo attribute_escape(__('Page %1$d of %2$d',k2_domain)); ?>"
			);
			<?php } ?>
		});
 
		<?php /* Hide Author Elements */ if (!is_user_logged_in() and (is_page() or is_single()) and ($comment_author = $_COOKIE['comment_author_'.COOKIEHASH]) and ('open' == $post-> comment_status) or ('comment' == $post-> comment_type) ) { ?>
			jQuery(document).ready(function(){ OnLoadUtils(); });
		<?php } ?>
 
		<?php if ((get_option('k2livecommenting') == 1) and ((is_page() or is_single()) and (!isset($_GET['jal_edit_comments'])) and ('open' == $post-> comment_status) or ('comment' == $post-> comment_type) )) { ?>
			K2.ajaxCommentsURL = "<?php output_javascript_url('comments-ajax.php'); ?>";
		<?php } ?>
 
	//]]>
	</script>
 
	<?php wp_get_archives('type=monthly&format=link'); ?>
</head>
 
<body class="<?php k2_body_class(); ?>" <?php k2_body_id(); ?>>
 
<a class="skiplink" href="#startcontent" accesskey="2"><?php _e('Skip to content','k2_domain'); ?></a>
 
<div id="page">
 
	<div id="header">
 
		<h1><a href="<?php echo get_settings('home'); ?>/" accesskey="1"><?php bloginfo('name'); ?></a></h1>
		<p class="description"><?php bloginfo('description'); ?></p>
 
		<ul class="menu">
			<?php if ('page' != get_option('show_on_front')) { ?>
			<li class="<?php if ( is_home() or is_archive() or is_single() or is_paged() or is_search() or (function_exists('is_tag') and is_tag()) ) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php echo get_settings('home'); ?>/" title="<?php echo get_option('k2blogornoblog'); ?>"><?php echo get_option('k2blogornoblog'); ?></a></li>
			<?php } ?>
			<?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
			<?php wp_register('<li class="admintab">','</li>'); ?>
		</ul>
 
	</div>
 
		<hr />

Please Fix Above Code

FIXME There are two instances closing the head tag (</head>). I don't know which is correct. I deleted the second and it worked on my site. Thanks. FIXED

WordPress page setup

Example

Old:

$page_id = null; //Change this to match your sites WP page id of new Photos page

New:

$page_id = 2; //Change this to match your sites WP page id of new Photos page

Then remove the following code in the falbum.php file:

<?php /* Remove or comment out the below line after to finding the Photos page page_id */
if ($page_id == null) { echo '<h2>page_id = '.$post->ID.'</h2>'; }
?>