Month: February 2016

Create password protected directory using htaccess on server

Add security using password protected directory  on server as like admin site first ask to permission to go admin area. Add authentication on WordPress administration. Password protect our wordPress admin (wp-admin) directory. Bellow example for WordPress wp-admin password protected.

Step : 1

Login to your cpanel and go to “Password Protect Directories”.  After select directory OR add directory as your cpanel options. in my cpanel select directory in bellow screen short.

password-protected-1

Step : 2

Add protected directory name, username, password.

password-protected-2

Step : 3

Go to file manager and your selected directory create .htaccess file  with this script.


ErrorDocument 401 "Denied"
ErrorDocument 403 "Denied"

<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>

Advertisements

Display RSS Feed using WordPress

Using WordPress we can add RSS feed easily for default WordPress function. Using bellow snippet list of RSS feed.

/*********/
/* Display RSS Feed using WordPress
/*********/

include_once(ABSPATH.WPINC.'/rss.php'); // path to include script
$feed = fetch_rss('feed url'); // specify feed url
$items = array_slice($feed->items, 0, 9); // specify first and last item

foreach ($items as $item):
	?>
    <div class="blog-discription">
    	<div class="blog-meta">
        	<a class="blog-title" href="<?php echo $item['link']; ?>"><?php  echo $item['title'];?></a>
		</div>
        <div class="single-blog-content">
			<?php echo $item['description']; ?>
       	</div>
	</div>
    <?php
endforeach;

Get post by category id in custom post type with custom taxonomy

Snippet for create custom post type and it’s taxonomy.

$termsID = '191'; #e.i

	$dalwadi_ourteam_args = array(
		'post_type' => 'ourteam',
		'orderby' => 'post_date',               
		'order' => 'DESC',
		'post_status' => 'publish',		
		'tax_query' => array(
			array(
				'taxonomy' => 'member-category',
				'field' => 'term_id',
				'terms'    => $ourteam_category_check
			),
		),
	);
	
	$dalwadi_ourteam = new WP_Query($dalwadi_ourteam_args);
	
	while ($dalwadi_ourteam->have_posts()) : $dalwadi_ourteam->the_post();
		/*** My loop code ***/
	endwhile;