Example #1
0
 function gabfire_categoryad($path)
 {
     if ((is_single() or is_category()) and file_exists(get_template_directory() . '/ads/' . $path . '/' . current_catID() . '.php')) {
         get_template_part('/ads/' . $path . '/' . gabfire_current_catID());
     } else {
         get_template_part('/ads/' . $path);
     }
 }
Example #2
0
function box_art_300($qty = 4, $theorder = 'date', $showthumb = 1, $thecat = 0, $offset = 0, $theboxtitle = '0', $ast = 0, $astc = 0)
{
    $box_art_cat = 0 ? current_catID() : $thecat;
    $aststr = '';
    if ($ast > 0) {
        $aststr = '?ast=' . $ast;
        if ($astc > 0) {
            $aststr = $aststr . '&astc=' . $astc;
        }
    }
    //insert cache query
    $box_qt = 'art300_' . $qty . '_' . $theorder . '_' . $showthumb . "_" . $thecat . "_" . $offset . "_" . $theboxtitle . "_" . $ast . "_" . $astc;
    $box_q = preg_replace("/[^A-Za-z0-9_ ]/", '', $box_qt);
    $local_box_cache = get_transient($box_q);
    if (false === $local_box_cache) {
        // start code to cache
        ob_start();
        ?>
								<span class="catname">
									<?php 
        if (strlen($theboxtitle) == '0') {
            ?>
										<a href="<?php 
            echo get_category_link($box_art_cat);
            ?>
"><?php 
            echo get_cat_name($box_art_cat);
            ?>
</a>
									<?php 
        } else {
            echo '<a href="' . get_category_link($box_art_cat);
            echo $aststr . '">' . $theboxtitle . '</a>';
        }
        ?>
								</span> 
								
								<?php 
        $count = 1;
        $args = array('post__not_in' => $do_not_duplicate, 'offset' => $offset, 'posts_per_page' => $qty, 'orderby' => $theorder, 'cat' => $thecat);
        $query = new WP_Query($args);
        while ($query->have_posts()) {
            $query->the_post();
            ?>
								
									<div class="featuredpost<?php 
            // if($count == $qty) { echo ' lastpost'; }
            ?>
">
											<?php 
            if (in_category(array(10650, 10651, 10652, 144, 11112))) {
                if (in_category(144)) {
                    echo '<span style="color:red; font-weight:bold;"><em>Digital Issue Article</em></span>';
                }
                if (in_category(10650)) {
                    echo '<span style="color:#039; font-weight:bold;"><em>News</em></span>';
                }
                if (in_category(10651)) {
                    echo '<span style="color:#039; font-weight:bold;"><em>Opinion</em></span>';
                }
                if (in_category(10652)) {
                    echo '<span style="color:#039; font-weight:bold;"><em>How-to</em></span>';
                }
                if (in_category(11112)) {
                    echo '<span style="color:#039; font-weight:bold;"><em>Resource</em></span>';
                }
            }
            ?>
                                            <h2 class="posttitle">
												<a href="<?php 
            the_permalink();
            echo $aststr;
            ?>
" rel="bookmark" title="<?php 
            printf(esc_attr__('Permalink to %s', 'advanced'), the_title_attribute('echo=0'));
            ?>
" ><?php 
            the_title();
            ?>
</a>
											</h2>							
									<?php 
            if ($showthumb == 1) {
                $smallsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
                $largesrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
                ?>

						<img data-interchange="[<?php 
                echo $largesrc[0];
                ?>
, (default)], [<?php 
                echo $smallsrc[0];
                ?>
, (large)]" alt="<?php 
                the_title();
                ?>
">

									<?php 
            }
            ?>
		
											<p><?php 
            echo the_excerpt();
            ?>
&hellip;</p>
											
											

			<?php 
            if ($count == $qty) {
                ?>
  			<div class="morenews"><strong><?php 
                if (strlen($theboxtitle) == '0') {
                    ?>
				<a href="<?php 
                    echo get_category_link($box_art_cat);
                    if ($astused > 1) {
                        echo '?ast=' . $astused;
                        if ($astc > 0) {
                            echo '&astc=' . $astc;
                        }
                    }
                    ?>
">View all <?php 
                    echo get_cat_name($box_art_cat);
                    ?>
</a>
			<?php 
                } else {
                    ?>
 
            <a href="<?php 
                    echo get_category_link($box_art_cat);
                    if ($astused > 1) {
                        echo '?ast=' . $astused;
                        if ($astc > 0) {
                            echo '&astc=' . $astc;
                        }
                    }
                    ?>
">View all <?php 
                    echo $theboxtitle;
                    ?>
</a>
			<?php 
                }
                ?>
</strong></div>
		  <?php 
            }
            ?>
	
										
									</div><!-- .featuredpost -->
								<?php 
            $count++;
        }
        wp_reset_query();
        ?>

<?php 
        echo '<div class="clear"></div>';
        $local_box_cache = ob_get_clean();
        echo $local_box_cache;
        // end the code to cache
        //end cache query
        if (current_user_can('edit_post')) {
            //you cannot cache it
        } else {
            set_transient($box_q, $local_box_cache, 60 * 15);
        }
    } else {
        echo $local_box_cache;
    }
}