Why is WordPress so popular?

WordPress is a free and open source software used by millions of people around the world to create websites and blogs. The most popular features of WordPress include its ease of use and ability to be extended way beyond the simple blog software it starts out as.

WordPress Northern Ireland

I’ve been developing WordPress websites for 10 years and am always looking for the next exciting project from personal blog, community portal or business website. Why not get in touch to see if I can help you with yours.

Front-end themes and templates can be easily downloaded from the official WordPress site or from hundreds of other places around the web. The same goes with extensions and plugins, which are used to extend the functionality of your WordPress site. A wide range of people contribute time, knowledge and skill to keeping the core WordPress software updated and secure.

There’s also a huge number of designers, developers & bloggers who share their knowledge through blog posts, tutorials, reviews, videos and the creation of thousands of themes & plugins.

It is estimated that WordPress could power as much as 29% of the world wide web. It is used for everything from personal blogs to large corporate websites with an even wider range of uses. From news sites and magazines to full e-commerce and online booking systems.

Testing YouTube embedded video responsiveness in WordPress

It turns out YouTube video uploads have come a long way since I last tried them out. This is a test post with no discernibly interesting content. WordPress has, for quite a long time allowed embedding YouTube content simply by copy and pasting the URL into the WordPress post editor.

Checking-out how WordPress handles YouTube embeds, whether or not they are responsive and if not how I can make them work better.

Update

So it turned out that the standard embed method will add a fixed width video iframe into the page. To make this responsive a couple of additions were required.

First wrap YouTube embed iframes in a container. Add the following script to your theme functions.php script

add_filter('embed_oembed_html', 'wrap_embed_with_div', 10, 3);

function wrap_embed_with_div($html, $url, $attr) {
    return "<div class=\"responsive-container\">".$html."</div>";
}

Then add a little bit of CSS to your themes style.css or wherever your main CSS file is

.responsive-container { position: relative; padding-bottom: 50.25%; padding-top: 30px; height: 0; overflow: hidden; margin-bottom: 1em; }
.responsive-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%;}

And that did the job.


WordPress developer

in Belfast, Northern Ireland

I’ve been developing WordPress websites for 10 years and am always looking for the next exciting project from personal blog, community portal or business website. Why not get in touch to see if I can help you with yours.

Contact me today!

WordPress Code: Completely disable comments using functions.php

The code below will completely disable any commenting and trackback features in WordPress. This code won’t turn off any “This post has X comments” or front-end code that displays comments that may be in your theme. Instead it removes the ability for comments to be added/stored against posts.

It is in response to the usual issue whereby you think comments have been completely disabled only to get a notification that there is a new comments waiting moderation.

Simply copy and paste into your functions.php file in your template.

// First, this will disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
   $post_types = get_post_types();
   foreach ($post_types as $post_type) {
      if(post_type_supports($post_type, 'comments')) {
         remove_post_type_support($post_type, 'comments');
         remove_post_type_support($post_type, 'trackbacks');
      }
   }
}
add_action('admin_init', 'df_disable_comments_post_types_support');

// Then close any comments open comments on the front-end just in case
function df_disable_comments_status() {
   return false;
}
add_filter('comments_open', 'df_disable_comments_status', 20, 2);
add_filter('pings_open', 'df_disable_comments_status', 20, 2);

// Finally, hide any existing comments that are on the site. 
function df_disable_comments_hide_existing_comments($comments) {
   $comments = array();
   return $comments;
}
add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);

WordPress developer

in Belfast, Northern Ireland

I’ve been developing WordPress websites for 10 years and am always looking for the next exciting project from personal blog, community portal or business website. Why not get in touch to see if I can help you with yours.

Contact me today!

PHP: Use WordPress blog tags to find related posts

A simple script that can be used to pull related-type posts for a WordPress blog post. The related aspect is based on the fist tag assigned to the post. The script will return at most 5 other posts from the site that also include the first tag.

<?php

$tags = wp_get_post_tags($post->ID);

if ($tags) {
    
    $first_tag = $tags[0]->term_id;
    
    $select = array(
       'tag__in'          => array($tags[0]->term_id),
       'post__not_in'     => array($post->ID),
       'posts_per_page'   => 5,
       'caller_get_posts' => 1
    );
    
    $tag = get_tag($first_tag);
   
    $tag_query = new WP_Query($select);
   
    if( $tag_query->have_posts() ) {
        echo "<ul>";
        while ($tag_query->have_posts()) : $tag_query->the_post(); ?>
            <li>
                <a href="<?php the_permalink() ?>">
                   <?php the_title(); ?>
                </a>
            </li>

        <?php endwhile;
        echo "</ul>";
    }
    
    wp_reset_query();
}

?>

WordPress developer

in Belfast, Northern Ireland

I’ve been developing WordPress websites for 10 years and am always looking for the next exciting project from personal blog, community portal or business website. Why not get in touch to see if I can help you with yours.

Contact me today!

How to link to a PDF in WordPress

WordPress is designed to be simple and easy to use. Adding linking to a downloadable document is no different.

Open a post or page and put your cursor where you want to PDF link to appear in the content box.

Upload your PDF

Click on Add Media to the top left of the content box. A pop-up will appear.

on the “Upload Files” tab click Select Files and find the PDF or other document you wan to use.

It will be uploaded onto your WordPress site automatically and put into the media folder.

Insert the link 

Once the upload has finished your PDF will appear checked in the top left of the media folder in the “Media Library” tab of the pop-up. On the right hand side

  1. Edit the Title field to be the text you want to use for the link
  2. Make sure the “File Media” has been set to link to
  3. Click on “Insert into Post”

Your PDF will appear as a hyperlink in the content box where your cursor appeared.



WordPress developer

in Belfast, Northern Ireland

I’ve been developing WordPress websites for 10 years and am always looking for the next exciting project from personal blog, community portal or business website. Why not get in touch to see if I can help you with yours.

Contact me today!