Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter biochip

    (@biochip)

    not yet… I’m working on local machine.

    Thread Starter biochip

    (@biochip)

    Ok, I think is resolved for me… I have the $categories_events variable to control some things in the template.

    global $EM_Category;
    $arrCategory = get_terms(EM_TAXONOMY_CATEGORY,array('parent'=>0,'hide_empty'=>0) );
    foreach($arrCategory as $arrterm) {
    	$child = get_term_children($arrterm->term_id,EM_TAXONOMY_CATEGORY);
    	foreach($child as $term_child_id) {
    		$term_child = get_term_by('id',$term_child_id,EM_TAXONOMY_CATEGORY);
    		if ( $term_child->name == $EM_Category->name ){
    			$categories_events = $arrterm->slug;					}
    }
    }//fi foreach

    For me is working another way without hacking the core: Duplicating, renaming and hacking the functions involved to functions.php from your template.

    Only need to insert “_2” to each function & the hack suggest by vtxyzzy in the “get_adjacent_post” function (our get_adjacent_post_2).

    function previous_post_link_2($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    	adjacent_post_link_2($format, $link, $in_same_cat, $excluded_categories, true);
    }
    function next_post_link_2($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    	adjacent_post_link_2($format, $link, $in_same_cat, $excluded_categories, false);
    }
    function adjacent_post_link_2($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
    	if ( $previous && is_attachment() )
    		$post = & get_post($GLOBALS['post']->post_parent);
    	else
    		$post = get_adjacent_post_2($in_same_cat, $excluded_categories, $previous);
    
    	if ( !$post )
    		return;
    
    	$title = $post->post_title;
    
    	if ( empty($post->post_title) )
    		$title = $previous ? __('Previous Post') : __('Next Post');
    
    	$title = apply_filters('the_title', $title, $post);
    	$date = mysql2date(get_option('date_format'), $post->post_date);
    	$rel = $previous ? 'prev' : 'next';
    
    	$string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">';
    	$link = str_replace('%title', $title, $link);
    	$link = str_replace('%date', $date, $link);
    	$link = $string . $link . '</a>';
    
    	$format = str_replace('%link', $link, $format);
    
    	$adjacent = $previous ? 'previous' : 'next';
    	echo apply_filters( "{$adjacent}_post_link", $format, $link );
    }
    function get_adjacent_post_2($in_same_cat = false, $excluded_categories = '', $previous = true) {
    	global $post, $wpdb;
    
    	if ( empty($post) || !is_single() || is_attachment() )
    		return null;
    
    	$current_post_date = $post->post_date;
    
    	$join = '';
    	$posts_in_ex_cats_sql = '';
    	if ( $in_same_cat || !empty($excluded_categories) ) {
    		$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
    
    //the hack
    if ( $in_same_cat ) {
       $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids');
       if ( !empty($excluded_categories) ) {
          $temp_excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
          $new_cat_array = array_diff($cat_array, $temp_excluded_categories);
       }
       $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $new_cat_array) . ")";
    }
    
    		$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
    		if ( !empty($excluded_categories) ) {
    			$excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
    			if ( !empty($cat_array) ) {
    				$excluded_categories = array_diff($excluded_categories, $cat_array);
    				$posts_in_ex_cats_sql = '';
    			}
    
    			if ( !empty($excluded_categories) ) {
    				$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
    			}
    		}
    	}
    
    	$adjacent = $previous ? 'previous' : 'next';
    	$op = $previous ? '<' : '>';
    	$order = $previous ? 'DESC' : 'ASC';
    
    	$join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories );
    	$where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );
    	$sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
    
    	$query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort";
    	$query_key = 'adjacent_post_' . md5($query);
    	$result = wp_cache_get($query_key, 'counts');
    	if ( false !== $result )
    		return $result;
    
    	$result = $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
    	if ( null === $result )
    		$result = '';
    
    	wp_cache_set($query_key, $result, 'counts');
    	return $result;
    }

    And the call in the template

    <div class="alignleft"><?php previous_post_link_2('%link', '<', TRUE,'3,10') ?></div>
    <div class="alignright"><?php next_post_link_2('%link', '>', TRUE,'3,10'); ?></div>
    Thread Starter biochip

    (@biochip)

    uops, it’s not working 4 me…
    but thank’s a lot!

    any new idea?

    Thread Starter biochip

    (@biochip)

    & for upload images from admin?

    The letters nc unites also cause the Internal Server Error, posting posts and comments.

    How can I activate mod_security, or what can I do to solve the problem?

    Thanak’s

Viewing 6 replies - 1 through 6 (of 6 total)