Skip to main content

Posts

WP similar or related posts widget without using any plugin

Hi guys, Recently I was working on some WP website and my client told me that he required a widget for displaying related/similar posts on the single post page. But as his website was already using many plugins, even for some pretty small tasks like this one, I decided not to use another WP plugin (plugins are not good for your WP websites, we will discuss about that on some other post.) I am not explaining the code as it is pretty simple if you are familiar with WP classes. But please let me know if you have any questions related to the PHP code posted below in the comments section or even much better, on Gist. You can add the following code directly in your child theme's functions.php file or you can create a separate file and include this at the bottom of functions.php file. <?php class similar_posts_widget extends WP_Widget {     function __construct()     {         parent::__construct('similar_posts_...
Recent posts

WordPress: Foundation 6 Top-Menu

Foundation Walker class FoundationMenu extends Walker_Nav_Menu {   function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output )   {     $element->has_children = !empty( $children_elements[$element->ID] );     $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : '';     $element->classes[] = ( $element->has_children ) ? 'has-dropdown' : '';     parent:: display_element( $element, $children_elements, $max_depth, $depth, $args, $output );   }   function start_el( &$output, $object, $depth = 0, $args = array ( ) , $current_object_id = 0 )   {     $item_html = '';     parent:: start_el( $item_html, $object, $depth, $args );     $output.= ( $depth == 0 ) ? '<li class = "divider"></li>' : '';     $classes = empty( $object->...

Python: calculating the area of circle

You can calculate the area of circle with and without using any variable. Both of these approaches are discussed below. Without using variable:- print (22.0 / 7) * (float(raw_input("Enter radius of the circle: ")) ** 2) With variable:- radius = float(raw_input("Enter radius of the circle: ")) print (22.0 / 7) * (radius ** 2)