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()…
Display Most popular Posts In WordPress
Blog Archives
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’ );
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…
Export the database table as CSV format using PHP
This code need some files those files are, 1.db.php 2.export.php 3.index.php as in the db.php file, make this. database name –> wallstreet table name–> export_table column names –> id,name,place and as you, here i just declare what i have given…
Drag and drop using jquery
Create .html file <link rel=”stylesheet” type=”text/css” href=”css/style.css”> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”></script> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js”></script> <script type=”text/javascript”> $(document).ready(function(){ // Example 1.1: A single sortable list $(‘#example-1-1 .sortable-list’).sortable(); // Example 1.2: Sortable and connectable lists $(‘#example-1-2 .sortable-list’).sortable({ connectWith: ‘#example-1-2 .sortable-list’ }); // Example…
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…
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 //…
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&p[title]=<?php echo $ftitle;?>&p[summary]=<?php echo $fdescription;?>&p[url]=<?php echo urlencode($fshare_url);?>& 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;”> </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;”> </a> For Linkedin share <a…
How to display blog posts (Fishpig module) with featured images on magento homepage?
When we integrate fishpig with magento we can have one folder “wordpress” in the template folder.(path:- appdesignfrontendbasedefaultwordpress). in that we can create our custom folder like “xyz”. in that we need to create one .phtml file called “xyz.phtml”. the followings…