CodeHQ

Archive for January, 2016

|

Time ago date format | PHP

Wednesday, January 20th, 2016

To set your time up as ’12 days ago’ instead of dd/mm/yyyy format.

Using ‘php time ago

<?php $timeAgo = new TimeAgo();
echo $timeAgo->inWords(get_the_time('jS F Y')); ?> ago

Tags: , , ,
Posted in PHP | No Comments »

Sidebar.php WordPress template for dynamic sidebars | PHP

Tuesday, January 19th, 2016

This code can be added in to sidebar.php or any other theme file.

<?php if ( is_active_sidebar( 'sidebar_name' ) ) : 
    dynamic_sidebar( 'sidebar_name' );
endif; ?>

Tags: , , ,
Posted in PHP, WordPress | No Comments »

Pulsing heart | CSS

Monday, January 11th, 2016

.heart {
    position: relative;
    width: 34px;
    overflow: inherit;
    -webkit-animation: animateHeart 2.5s infinite;
    animation: animateHeart 2.5s infinite;
}
.heart:before,
.heart:after {
   position: absolute;
   content: '';
   top: 0;
   left: 17px;
   width: 17px;
   height: 27px;
   background: #3C948B;
   border-radius: 50px 50px 0 0;
   -webkit-transform: rotate(-45deg) translateZ(0);
   transform: rotate(-45deg) translateZ(0);
   -webkit-transform-origin: 0 100%;
   transform-origin: 0 100%;
}
.heart:after {
   left: 0;
   -webkit-transform: rotate(45deg) translateZ(0);
   transform: rotate(45deg) translateZ(0);
   -webkit-transform-origin: 100% 100%;
   transform-origin :100% 100%;
}

@-webkit-keyframes animateHeart {
  0%  { -webkit-transform: scale(1); }
  5%  { -webkit-transform: scale(1.2); }
  10% { -webkit-transform: scale(1.1); }
  15% { -webkit-transform: scale(1.3); }
  50% { -webkit-transform: scale(1); }
  100% { -webkit-transform: scale(1); }
}
@keyframes animateHeart {
  0%  { transform: scale(1); }
  5%  { transform: scale(1.2); }
  10% { transform: scale(1.1); }
  15% { transform: scale(1.3); }
  50% { transform: scale(1); }
  100% { transform: scale(1); }
}

Tags: , , ,
Posted in CSS | No Comments »

Show current year with PHP (copyright)

Wednesday, January 6th, 2016

Add this code to your website to show the current year e.g. 2016. Can be used to always show the current year in the date format in a copyright statement.

<?php echo date("Y") ?>

Tags: , , , ,
Posted in PHP | No Comments »