[wp-trac] [WordPress Trac] #14355: is_front_page returns false - if used before the loop starts
WordPress Trac
wp-trac at lists.automattic.com
Tue Jul 20 19:42:26 UTC 2010
#14355: is_front_page returns false - if used before the loop starts
-----------------------------+----------------------------------------------
Reporter: christian_gnoth | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0
Severity: normal | Keywords: reporter-feedback
-----------------------------+----------------------------------------------
Comment(by christian_gnoth):
{{{
<?php
$biq_theme_options = biq_get_theme_options();
get_header('xajax');
global $xajax;
//$xajax = new xajax();
$xajax->registerFunction('load_latest_post');
$xajax->processRequest();
echo
'<div id="main_content_container">' . "\n" .
' <div id="content_container">' . "\n";
if ( is_home() )
{
}
var_dump(is_front_page());
if ( is_front_page() )
{
// check for referer and show two latest posts excerpts
//biq_check_referer();
query_posts(array( 'posts_per_page' => '2', 'category_name' => 'Blog
Post' ));
echo ' <div id="latest_post_container">' . "\n";
echo ' <div id="latest_post">' . "\n";
if ( have_posts() )
{
while(have_posts())
{
the_post();
$biq_id = get_the_ID();
echo ' <div ';
post_class();
echo ' id="co-post-' . get_the_ID() . '">' . "\n";
$result = is_front_page();
var_dump($result);
echo 'index.php:' . is_front_page() . ':<br />' . "\n";
echo ' <h3><a href="' . get_permalink() . '" rel="bookmark"
onclick="xajax_load_latest_post(\'' . get_the_ID() . '\'); return false;"
title="Permalink: ' . the_title( '', '', false) . '">' . the_title( '',
'', false) . '</a></h3>' . "\n";
// echo ' <h3><a href="javascript:xajax_load_latest_post(' .
get_the_ID() . ')" rel="bookmark" onclick="return
!xajax_load_latest_post(' . get_the_ID() . ');" title="Permalink: ' .
the_title( '', '', false) . '">' . the_title( '', '', false) . '</a></h3>'
. "\n";
// echo ' <h3><a href="#" rel="bookmark"
onclick="xajax_load_latest_post(\'' . get_the_ID() . '\');"
title="Permalink: ' . the_title( '', '', false) . '">' . the_title( '',
'', false) . '</a></h3>' . "\n";
// echo ' <h3><a href="javascript:xajax_load_latest_post(\'' .
$biq_id . '\')" rel="bookmark" title="Permalink: ' . the_title( '', '',
false) . '">' . the_title( '', '', false) . '</a></h3>' . "\n";
the_excerpt();
echo ' </div>' . "\n";
}
}
wp_reset_query();
echo ' </div>' . "\n";
echo ' </div>' . "\n";
}
$biq_amazon_item_list_search = NULL;
$biq_amazon_items_per_page = NULL;
$biq_amazon_item_list_page = NULL;
// process submitted data
// SORT Order
if ( $_POST['biq_amazon_item_list_search'] )
{
$biq_amazon_item_list_search = $_POST['biq_amazon_item_list_search'];
}
// number of items to display
if ( $_POST['amazon_items_ppage'] )
{
$biq_amazon_items_per_page = intval($_POST['amazon_items_ppage']);
$_SESSION['amazon_items_ppage'] = $biq_amazon_items_per_page;
}
if ( !$biq_amazon_items_per_page )
{
if ( $_SESSION['amazon_items_ppage'] )
$biq_amazon_items_per_page = $_SESSION['amazon_items_ppage'];
else
$biq_amazon_items_per_page = 9;
}
// page number
if ( $_POST['biq_amazon_item_list_page'] )
{
$biq_amazon_item_list_page =
intval($_POST['biq_amazon_item_list_page']);
}
if ( !$biq_amazon_item_list_page OR
isset($_POST['biq_amazon_item_list_page_first']))
$biq_amazon_item_list_page = 1;
// call to get product items
$query = 'SELECT * FROM amazon_attributes;';
$biq_amazon_product_list = $wpdb->get_results($query);
if ( $biq_amazon_product_list )
{
$biq_amazon_product_list_count = count( $biq_amazon_product_list );
echo ' <div id="content">' . "\n";
echo ' <div id="amazon_item_list_header">' . "\n";
echo ' <div id="amazon_items_search">' . "\n";
echo ' <b>SORT BY</b> ' . "\n";
echo ' <form class="form_items_search" action="' .
$_SERVER['PHP_SELF'] . '" method="post">' . "\n";
echo ' <select name="biq_amazon_item_list_search" size="1">' .
"\n";
echo ' <option><a href="">LOW PRICE</a></option>' . "\n";
echo ' <option><a href="">HIGH PRICE</a></option>' . "\n";
echo ' <option><a href="">DISCOUNT</a></option>' . "\n";
echo ' </select>' . "\n";
echo ' </form>' . "\n";
echo ' </div>' . "\n";
echo ' <div id="amazon_items_count">' . "\n";
echo ' ' . $biq_amazon_items_per_page . ' of ' .
$biq_amazon_product_list_count . ' SHOES' . "\n";
echo ' </div>' . "\n";
echo ' <div id="amazon_items_ppage">' . "\n";
echo ' <form class="form_items_ppage" method="post"
action="">Items per Page <a href=""><input type="submit"
class="input_items_ppage" name="amazon_items_ppage" value="9" /></a> |
</form>' . "\n";
echo ' <form class="form_items_ppage" method="post" action=""><a
href=""><input type="submit" class="input_items_ppage"
name="amazon_items_ppage" value="18" /></a> | </form>' . "\n";
echo ' <form class="form_items_ppage" method="post" action=""><a
href=""><input type="submit" class="input_items_ppage"
name="amazon_items_ppage" value="27" /></a> | </form>' . "\n";
echo ' </div>' . "\n";
echo ' </div>' . "\n";
$biq_amazon_page_count = intval($biq_amazon_product_list_count /
$biq_amazon_items_per_page);
if ( ($biq_amazon_page_count * $biq_amazon_items_per_page) <
$biq_amazon_product_list_count )
$biq_amazon_page_count++;
if ( isset($_POST['biq_amazon_item_list_page_last']) )
$biq_amazon_item_list_page = $biq_amazon_page_count;
$biq_item_counter = $biq_amazon_items_per_page *
($biq_amazon_item_list_page - 1) + 1;
$biq_amazon_product_list_page_rest = $biq_amazon_product_list_count %
$biq_amazon_items_per_page;
$biq_amazon_page_row_count = $biq_amazon_items_per_page / 3;
for ( $index = 0; (($index < $biq_amazon_page_row_count)); $index++)
{
echo ' <div id="amazon_item_row">' . "\n";
for ( $i = 0; (($i < 3) AND ( ($biq_item_counter <=
$biq_amazon_product_list_count) )); $i++)
{
echo ' <div id="amazon_item_field">' . "\n";
echo ' <div id="amazon_item_img">' . "\n";
echo ' <a href="' .
$biq_amazon_product_list[$biq_item_counter]->detail_page_url . '" title="'
. $biq_amazon_product_list[$biq_item_counter]->title . '"
target="_blank">';
echo '<img src="' .
$biq_amazon_product_list[$biq_item_counter]->medium_image_url . '" alt="'
. htmlentities($biq_amazon_product_list[$biq_item_counter]->prod_desc) .
'" />';
echo '</a>' . "\n";
echo ' </div>' . "\n";
// echo ' <div class="item_seperator"></div>' . "\n";
echo ' <div id="amazon_item_description">' . "\n";
echo ' <a href="' .
$biq_amazon_product_list[$biq_item_counter]->detail_page_url . '" title="'
. $biq_amazon_product_list[$biq_item_counter]->title . '"
target="_blank">' . $biq_amazon_product_list[$biq_item_counter]->title .
'</a><br />' . "\n";
echo $biq_amazon_product_list[$biq_item_counter]->brand . '<br />' .
"\n";
if ( ($biq_amazon_product_list[$biq_item_counter]->pct_off != NULL)
AND ($biq_amazon_product_list[$biq_item_counter]->pct_off != 0))
{
echo $biq_amazon_product_list[$biq_item_counter]->formatted_price
. '<br />' . "\n";
echo $biq_amazon_product_list[$biq_item_counter]->display_price .
' (' . ($biq_amazon_product_list[$biq_item_counter]->pct_off * 100) . '%
off)' . "\n";
}
else
{
echo $biq_amazon_product_list[$biq_item_counter]->display_price .
'<br />' . "\n";
}
echo ' </div>' . "\n";
echo ' </div>' . "\n";
$biq_item_counter++;
}
if ( $index < ($biq_amazon_page_row_count - 1))
echo ' <div class="seperator"></div>' . "\n";
echo ' </div>' . "\n";
}
echo ' <div id="amazon_item_list_footer">' . "\n";
echo ' <div id="amazon_item_list_footer_link">' . "\n";
echo ' <a href="#top">Back To Top</a>' . "\n";
echo ' </div>' . "\n";
echo ' <div id="amazon_item_list_footer_nav">' . "\n";
echo ' <form class="form_item_list_page" method="post"
action=""><a href=""><input type="submit"
class="input_item_list_page_first" name="biq_amazon_item_list_page_first"
value="" /></a> </form>' . "\n";
if ( $biq_amazon_item_list_page > 10 )
$biq_list_page_start = $biq_amazon_item_list_page - 5;
else
$biq_list_page_start = 1;
for ( $i=$biq_list_page_start; (($i <= $biq_amazon_page_count) AND ($i
<= ($biq_list_page_start + 10))); $i++ )
{
if ( $i == $biq_amazon_item_list_page )
echo '<form class="form_item_list_page" method="post" action=""><a
href=""><input type="submit" class="input_item_list_page active"
name="biq_amazon_item_list_page" value="' . $i . '" /></a> | </form>' .
"\n";
else
echo '<form class="form_item_list_page" method="post" action=""><a
href=""><input type="submit" class="input_item_list_page nonactive"
name="biq_amazon_item_list_page" value="' . $i . '" /></a> | </form>' .
"\n";
}
echo ' <form class="form_item_list_page" method="post"
action=""><a href=""><input type="submit"
class="input_item_list_page_last" name="biq_amazon_item_list_page_last"
value="" /></a> </form>' . "\n";
echo ' </div>' . "\n";
echo ' </div>' . "\n";
echo ' </div>' . "\n";
}
else
{
echo ' <p>' . __('Sorry, no products available.', 'biq') . '</p>' .
"\n";
}
echo ' </div>' . "\n\n";
get_sidebar();
get_footer();
?>
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14355#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list