Jak zmusić skrypt by przekazał zmienna $catID abym mógł ją odczytać w zaincludowanym load_data_artykuly.php
(Nie otagowuję jako kod ponieważ chce pokazać pogróbienia)
<? $urlServer= get_bloginfo('template_url');
echo $catID = get_query_var('cat');
echo"<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"></script>
<script type=\"text/javascript\">
$(document).ready(function(){
function loading_show(){
$('#loading2').html (\"<img src='$urlServer/images/loading.gif'/>\").fadeIn('fast');
}
function loading_hide(){
$('#loading2').fadeOut('fast');
}
function loadData(page){
loading_show();
$.ajax
({
type: \"GET\",
url: \"$urlServer/tools/load_data_artykuly.php\",
data: \"page=\"+page,
success: function(msg)
{
$(\"#container2\").ajaxComplete(function(event, request, settings)
{
loading_hide();
$(\"#container2\").html(msg);
});
}
});
}
loadData(1); // For first time page load default results
$('#container2 .pagination li.active').live('click',function(){
var page = $(this).attr('p');
loadData(page);
});
$('#go_btn').live('click',function(){
var page = parseInt($('.goto').val());
var no_of_pages = parseInt($('.total').attr('a'));
if(page != 0 && page <= no_of_pages){
loadData(page);
}else{
alert('Enter a PAGE between 1 and '+no_of_pages);
$('.goto').val(\"\").focus();
return false;
}
});
});
</script>"; ?>
</head>
<div id="loading2"></div>
<div align="center" style="font-size:24px;color:#cc0000;font-weight:bold"></div>
<div id="container2">
<div class="data"></div>
<div class="pagination"></div>
</div>
------------------------------------------------------------------------------
load_data_artykuly.php
<?php
include("../../../../wp-load.php");
TU CHCE ODCZYTAĆ TĄ ZMIENNĄ
if($_GET['page'])
{
$page = $_GET['page'];
$cur_page = $page;
$page -= 1;
$per_page = 2;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
$urlServer='http://'. $_SERVER['SERVER_NAME'];
$urlServerN= get_bloginfo('template_url');
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$loop = new WP_Query( array( 'post_type' => 'artykuly', 'posts_per_page' => $per_page, 'paged' => $cur_page,'cat'=> $catID ) ); ?> //TUTAJ JEST MI POTRZEBNA
<?php
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?
$custom = get_post_custom($post->ID);
?>
<div id="postmeta_div">
<p class="postmeta">
<?php the_time('F j, Y') ?> <?php /* _e('at'); */ ?> <?php /* the_time() */ ?> · autor <?php the_author() ?>
<?php edit_post_link(__('Edit'), ' · ', ''); ?>
</p>
</div> <div class="tyt"><a href="<? the_permalink();?>"><? the_title(); ?></a> </div>
<?php
echo '<div class="clr"></div>';
// echo "<span style=\"text-decoration:underline; font-style:italic; color:#444444; font-size:13px;\">"; the_title();echo "</span><div class=\"clr\">";
echo '<div class="clr"></div>';
echo '<span style=" font-size:13px;">';the_excerpt(); echo '</span><div class="clr">';
echo '<br><div class="clr"></div>';
?> <img border="0" src="<?php echo $urlServerN;?>/images/boxes/news/news_line_date.jpg"><BR><BR><?
//$screenshot_url = $custom["screenshot_url"][0];
//$website_url = $custom["website_url"][0];
?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<? // Reset Query
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
/* --------------------------------------------- */
/* $query_pag_num = "SELECT COUNT(*) AS count FROM lesson_inn"; //#####UZYSKAJ NUMERY STRON */
/*$result_pag_num = mysql_query($query_pag_num); /*
/*$row = mysql_fetch_array($result_pag_num); */
/*$count = $row['count']; */
echo $categoryID = $cat;
$ile_filmow2=0;
query_posts(array('post_type' => 'artykuly','showposts'=> -1, 'cat'=> $categoryID, 'orderby'=> none));
while (have_posts()) : the_post();
$ile_filmow2++;
endwhile; //echo "tyle filmow $ile_filmow2";
$count=$ile_filmow2;
$no_of_paginations = ceil($count / $per_page);
/* ---------------Calculating the starting and endign values for the loop----------------------------------- */
if ($cur_page >= 7) {
$start_loop = $cur_page - 3;
if ($no_of_paginations > $cur_page + 3)
$end_loop = $cur_page + 3;
else if ($cur_page <= $no_of_paginations && $cur_page > $no_of_paginations - 6) {
$start_loop = $no_of_paginations - 6;
$end_loop = $no_of_paginations;
} else {
$end_loop = $no_of_paginations;
}
} else {
$start_loop = 1;
if ($no_of_paginations > 7)
$end_loop = 7;
else
$end_loop = $no_of_paginations;
}
/* ----------------------------------------------------------------------------------------------------------- */
$msg .= "<div class='pagination'><ul>";
// FOR ENABLING THE FIRST BUTTON
if ($first_btn && $cur_page > 1) {
$msg .= "<li p='1' class='active'> <<</li>";
} else if ($first_btn) {
$msg .= "<li p='1' class='inactive'><<</li>";
}
// FOR ENABLING THE PREVIOUS BUTTON
if ($previous_btn && $cur_page > 1) {
$pre = $cur_page - 1;
$msg .= "<li p='$pre' class='active'><</li>";
} else if ($previous_btn) {
$msg .= "<li class='inactive'><</li>";
}
for ($i = $start_loop; $i <= $end_loop; $i++) {
if ($cur_page == $i)
$msg .= "<li p='$i' style='color:#fff;background-color:#006699;' class='active'>{$i}</li>";
else
$msg .= "<li p='$i' class='active'>{$i}</li>";
}
// TO ENABLE THE NEXT BUTTON
if ($next_btn && $cur_page < $no_of_paginations) {
$nex = $cur_page + 1;
$msg .= "<li p='$nex' class='active'>></li>";
} else if ($next_btn) {
$msg .= "<li class='inactive'>></li>";
}
// TO ENABLE THE END BUTTON
if ($last_btn && $cur_page < $no_of_paginations) {
$msg .= "<li p='$no_of_paginations' class='active'>>></li>";
} else if ($last_btn) {
$msg .= "<li p='$no_of_paginations' class='inactive'>>></li>";
}
//$goto = "<input type='text' class='goto' size='1' style='margin-top:-1px;margin-left:60px;'/><input type='button' id='go_btn' class='go_button' value='Go'/>";
$total_string = "<span class='total' a='$no_of_paginations'>Strona <b>" . $cur_page . "</b> z <b>$no_of_paginations</b></span>";
$msg = $msg . "</ul>" . $goto . $total_string . "</div>"; // Content for pagination
echo $msg;
} ?>