Saudee website freelance

Developers for my saudee website was having problems getting normal navigation to work. Had to look into the problem myself because it was very close to dateline.

Installed plugin WP Editor which has the advance editor(using mirrorcode) for the template editor.

Installed plugin Blackbox for debugging but was clashing with the site so I disabled it.

Found that the problem was bookblock. 

Although this was a really cool javascript library for the flip effect it was not very extensible in terms of navigation. It did not have a class to just jump to lets say page 10. what it does is it loads all the posts object and also all navigation as an empty span. These buttons are not numbered or has id in anyway. The script will automatically detect which button you press and then figure out which page that is. Very cool for a normal button based site, but if you wanted to say jump to a page by code it is a problem.

MY solution was to use the jump to function in bookblock in the header during document load to jump to page value saved in cookie initiated from the navigation from previous page. Bascially all navigation not from this page will jump to this page with value already saved in cookie. the below method using post could not work.

But we are accesing the page as categories. domain/categoryType (cant append ?variable=value).

so next had to use cookie method instead.

2 ways to set a cookie both must be done in functions.php because it can only be created before a page loads.

used the first method because it looks simpler.

/*-------------------------------------- COOKIE FUNCTION @SKY-------------------
Creates a cookie that last until end of tomorrow.
cookie can only be created here because cookie must be ceated before a page is loaded.
add_action('init', function() {
// yes, this is a PHP 5.3 closure, deal with it
if (!isset($_COOKIE['CurProd'])) {
setcookie('CurProd', '1', strtotime('+1 day'));
/*-------------------------------------- COOKIE FUNCTION @SKY   END-------------------*/


to extract value we could use php to extract using echo.

if you want to use jquery read here.

Next we need to be able to set cookie on click.

Great! works!! fixed nav
<li><a href=””

— header.php

/* saves product id into cookie */
function saveCurProd(val)
//alert($.cookie(‘wordpress_test_cookie’)+ val);
$.cookie(‘curProd’, val, { expires: 1 });

if($.cookie(‘curProd’)>0){currentProduct = $.cookie(‘curProd’);}else{currentProduct=1;}
$( ‘#bb-bookblock’ ).bookblock( ‘jump’, currentProduct);



we need to sort the number navigation by categories by name  rather than just by date now.

list categories
list all post in this category
load post

Double loop
query post
get categories

so we get this

//@SKY Show all posts order by categories then by date.
//for each category, show all posts
‘orderby’ => ‘name’,
‘order’ => ‘ASC’

foreach($categories as $category) {
‘posts_per_page’ => -1 ,
‘cat’ => $category->cat_ID,
‘post_status’ => ‘publish’,
‘orderby’ => ‘date’,
‘order’ => ‘ASC’
if(have_posts()): while ( have_posts() ) : the_post();


<?php $m++;endwhile; ?>
<?php endif;
} //Foreach categories

Next add google analytics
remove screen.css trying to disable mobile version on ipad

fix navigation
added css for each Li for correct padding.


Submit a Comment