• The code below generates content when I turn of nice url’s but when I try with apache re-write and nice permalinks it appears blank. I think this has to do with $_REQUEST[‘blog_type’]; – but I don’t know how to get the value. The url the user tries to access is: /blog_type/weather-blog/

    I have different kind of blogs and need to only show one at a time…

    Thanks!

    <?php
    
    	$blogtype			= $_REQUEST['blog_type'];
    
    	$father_category 	= get_term_by('slug', $blogtype, 'blog_type');
    
    	if($father_category->parent == 0) {
    
    		$father_category 	= get_term_by('id', $father_category->term_id, 'blog_type', ARRAY_A);
    
    		$tname 				= $father_category['name'];
    		$tdescription 		= $father_category['description'];
    
    	} else {
    
    		$father_category 	= get_term_by('id', $father_category->parent, 'blog_type', ARRAY_A);
    
    		$tname 				= $father_category['name'];
    		$tdescription 		= $father_category['description'];
    
    	}
    
    	$total_results = $wp_query->found_posts;
    
    ?>
    
    <?php if(is_single()) { ?>
    
    	<!-- SINGLE BLOG POST -->
    	<?php get_template_part('includes/blogs/single'); ?>
    
    <?php } else { ?>
    
    	<div class="col4">
    		<?php get_template_part('includes/blogs/sidebar'); ?>
    	</div>
    
    	<div class="col12 floatright leftsep">
    		<h2 class="wline"><?php echo $tname; ?></h2>
    		<p class="col9"><?php echo nl2br($tdescription); ?></p>
    	</div>
    
    	<div class="col9 floatleft leftsep"><?php if($total_results > 3 ) { wp_pagenavi(); } ?></div>
    
    	<div class="blogpost_children_wrapper col9 floatleft leftsep wline">
    
    		<?php
    		global $query_string;
    
    		$query_args = explode("&", $query_string);
    		$search_query = array();
    
    		foreach($query_args as $key => $string) {
    			$query_split = explode("=", $string);
    			$search_query[$query_split[0]] = $query_split[1];
    		} // foreach
    
    		$search = new WP_Query($search_query);
    		?>
    
    			<?php while ( $search->have_posts() ) : $search->the_post(); ?>
    				<div class="blogpost">
    
    					<div class="header">
    						<h3 class="title"><a href="<?php the_permalink(); ?>&blog_type=<?php echo $blogtype; ?>" title="Read more"><?php the_title(); ?></a></h3>
    						<h4 class="date"><span><?php the_time('m/d/Y'); ?></span> posted by <?php echo get_the_author(); ?></h4>
    					</div>				
    
    					<div class="content">
    						<?php the_content(); ?>
    					</div>
    
    					<div class="footer">
    
    						<?php  echo wpfblike(); ?>
    
    						<?php if(function_exists(getILikeThis)) getILikeThis('get'); ?>
    						<div class="readmore floatright"><a href="<?php the_permalink(); ?>&blog_type=<?php echo $blogtype; ?>" title="Read more">Read More ??</a></div>
    					</div>
    
    				</div>
    			<?php endwhile; ?>
    	</div>
    
    <?php } ?>
  • The topic ‘Permalinks: Get query vars from custom permalinks’ is closed to new replies.