Bootstrap Templates Bundle

Friday, December 28, 2012

Adding A Floating “Back To Top” Button

Back to Top button or link is a link that sends your viewer to the top of page once clicked. This will help your readers navigate better, especially so if you have long pages. This link is usually located at the bottom of page or in the footer area.


To see example look on the right side of my page 
Here are the steps:
  1. Login to your Blogger account.
  2. Go to Dashboard > Design > Edit HTML.
  3. Back up your template.
  4. Insert the following code immediately before the </body> tag in your HTML. 
    <a style="position: fixed; bottom:5px;left:5px;" href="#" title="Back to Top"><img style="border: none;" src="YourButtonUrl"/></a>
    Replace YourButtonUrl with the link to your button or icon.
  5. If you prefer to use text instead of an image, use this code: 
    <a style="position: fixed; bottom:5px;left:5px;" href="#" title="Click to go to top">YourTextHere</a>
    Replace YourText with your own wording.
  6. You can change the location of the button / link by changing the values of this code:
    bottom:5px; left:5px;

How To Hyperlink Bookmark on the Same Page

This page shows the HTML code for making hyperlink bookmarks within the same page. This is achieved by using two different hyperlink codes. These hyperlink codes work together in pairs. One is the go-to target hyperlink and the other is the destination bookmark.

Hyperlink Bookmark Code

Insert the following HTML code into the part of the web document you want to bookmark:
Code
<a name="top"></a>
Now make a hyperlink that points to the bookmark:
Code
<a href="#top">Top of Page</a>

Output

Notes
In the above example, top is the name of the variable value. Name these anything you want.

If you want link to the other page just  change code by

<a href="http://www.hyperlinkcode.com/bookmark.php#top">Top of Page</a>

Thursday, December 27, 2012

How to Write a “Most Popular By Views” WordPress Plugin

Source: http://wp.tutsplus.com/tutorials/plugins/intermediate-wp-plugins-most-popular-by-views/

How to Display Popular Posts by Views in WordPress without a Plugin


paste this below code into functions.php file

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '1');
        return "1 জন পোষ্টটি দেখেছেন";
    }
    return $count.' জন পোষ্টটি দেখেছেন';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 1;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '1');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
Then add this where you want normally in post-sigle.php file 
<?php
          echo getPostViews(get_the_ID());
?>

and if you want to show the popular post list then add this where you want to show popular post list
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :  setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <li><?php setPostViews(get_the_ID()); echo getPostViews(get_the_ID());; ?></li>
<?php endforeach; ?>


Source: http://stackoverflow.com/questions/9472602/wordpress-popular-posts-without-using-plugins


Tuesday, December 25, 2012

PHP code for post list by category


<?php query_posts('cat=15&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  </li>
<?php endwhile; endif; ?>


add this code where you want to add post list by category

How to Display Total Number of Posts and Comments on Your Blog

how-to-display-time-ago-for-posts-and-comments/


Open functions.php file of your theme and paste following code and Save:
?
1
2
3
4
function time_ago( $type = 'post' ) {
    $d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
    return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');
}
Now place the following snippet in either single.php or comments.php (wherever you want to show it) within loop.
?
1
<?php echo time_ago(); ?>

Wokiee React eCommerce Template