Display Most popular Posts In WordPress

Blog Archives

Display Most popular Posts In WordPress

Add code in your theme where ever you want the popular 5 posts to be displayed. <ul> <?php $pc = new WP_Query(‘orderby=comment_count&posts_per_page=5’); while ($pc->have_posts()) : $pc->the_post(); ?> <li><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a> <p>Posted by <strong><?php the_author()

Posted in Blog, Wordpress Tagged with: , , ,

How to add js and css in wordpress?

/** * Proper way to enqueue scripts and styles */ function theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ );

Posted in Blog, Wordpress Tagged with: , ,

Create Custom Post Type with Texamony(Categories) in WordPress

Custom Post types are very handy tool in wordpress. To create a custom Post Type is pretty easy. Goto functions.php file of your theme folder and copy the below code. You will get the new section for adding posts. These

Posted in Blog, Wordpress Tagged with: ,

Powerful WordPress Tips And Tricks

Posted in Blog, Wordpress Tagged with: ,

How to get latest article(post) in wordpress.

Get latest 5 post <?php $myposts = get_posts(”); foreach($myposts as $post) : setup_postdata($post); ?> Get featured image of article  <?php the_post_thumbnail(‘medium’); ?> Get post title and its link. <h3><a href=”<?php the_permalink() ?>” title=”<?php the_title_attribute(); ?>”> <?php the_title(); ?></a></h3> Get limit

Posted in Blog, Wordpress Tagged with: , ,

How to upload image in wordpress

  if(isset($_POST[‘submit’])&&$_POST[‘submit’]==’SUBMIT’){ //This is the directory where images will be saved $target = WP_CONTENT_DIR.”/upload/”; you have to create folder name upload in root directory(path: wp-content/upload/..) $target = $target . basename($_FILES[‘photo’][‘name’]); //This gets all the other information from the form //

Posted in Blog, PHP, Wordpress Tagged with: , , ,

How to share custom data on social network site !!!

For Facebook share <a id=”ref_fb” href=”http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $ftitle;?>&amp;p[summary]=<?php echo $fdescription;?>&amp;p[url]=<?php echo urlencode($fshare_url);?>&amp; p[images][0]=<?php echo $fimage_url;?>” onclick=”javascript:window.open(this.href, ”, ‘menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600’); return false;”>&nbsp;</a> For Twitter share <a id=”ref_tw” href=”http://twitter.com/home?status=<?php echo $ttitle; ?>+<?php echo urlencode($tshare_url);?>” onclick=”javascript:window.open(this.href, ”, ‘menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600’);return false;”>&nbsp;</a>   For Linkedin share <a

Posted in Blog, Wordpress Tagged with: , , , , ,

WordPress Custom Post Type Code Generator

Default Post Types There are five post types that are readily available to users or internally used by the WordPress installation by default : Post (Post Type: ‘post’) Page (Post Type: ‘page’) Attachment (Post Type: ‘attachment’) Revision (Post Type: ‘revision’)

Posted in Blog, Wordpress Tagged with: , ,

How To Get Category Name ,Author Name And Date In WordPress

Get Category : You can get category name by perticular post <?php $categories = get_the_category(); $separator = ‘ ‘; $output = ”; if($categories){ foreach($categories as $category) { $output .= ‘<a href=”‘.get_category_link( $category->term_id ).” . esc_attr( sprintf( __( “” ), $category->name

Posted in Blog, Wordpress Tagged with: , ,

Difference Between excerpt() And Content() function

excerpt The WordPress Excerpt is an optional summary or description of a post in short, a post summary. Html tags doesn’t work eg.<ul>,<li>,<Span>. you can Use of this function in index.php in your theme to post summary. <?php the_excerpt(); ?> content Use

Posted in Blog, Wordpress Tagged with: , ,