WordPress


This draft deletes the entire topic.

expand all collapse all

Examples

  • 9

    WordPress is an open source Content Management System for websites written in PHP, with a focus on blogging. WP uses MYSQL as a datastore for user content and configuration. It has a rich biotope of plugins and themes thanks to the plugin infrastructure provided by the core application. API documentation can be found in the WP Codex.

    A basic WP template. Wordpress uses a 'loop' filtered by http query variables to make certain posts available to themes and plugins:

    <?php
    
    get_header();
    
    if( have_posts() ) :
       while( have_posts() ) :
          the_post   ();
          the_content();
       endwhile;
    endif;
    
    get_sidebar();
    get_footer();
    
  • 3

    The permalink settings/url rewrite rules detect what content you're trying to view. First, WP detects the type of the current page (Archive, Singular Page, Front Page, Blog Index, or Comment Popup).

    Then it looks along the Template Hierarchy to find the most specific version of that page type that can be applied. Defaults are broad and capable of overrides as needed for specific types of content. Here is an excellent visual reference for the template hierarchy.

    Once WP finds the matching view template in the hierarchy, it uses that file to process and render the page. A typical theme looks something like this:

        // Theme CSS
        style.css
    
        // Custom functionality for your theme
        functions.php
    
        // Partials to include in subsequent theme files
        header.php
        footer.php
        sidebar.php
        comments.php
    
        // "Archives", (listing views that contain multiple posts)
        archive.php
        author.php
        date.php
        taxonomy.php
        tag.php
        category.php
    
        // Individual content pages
        // Note that home and frontpage templates are not recommended
        // and they should be replaced by page templates
        singular.php
        single.php
        page.php
        front-page.php
        home.php
    
        // Misc. Utility Pages
        index.php (a catch-all if nothing else matches)
        search.php
        attachment.php
        image.php
        404.php
    

    Here is a basic single.php, a template to render an individual blog post. It loads header.php, sets up The Loop, displays the_title and the_content, then includes comments.php, sidebar.php, and footer.php. The Loop does the heavy lifting, setting up a Post object containing all the information for the currently-viewed content:

    <?php get_header(); ?>
    
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <h1><?php the_title(); ?></h1>
        <?php the_content(); ?>
        <?php comments_template( '', true ); ?>
    <?php endwhile; ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

    Here is a simple archive page, archive.php. It injects header.php, sets up The Loop, and includes sidebar.php, and footer.php. But in this case there are multiple posts in the loop, so instead an excerpt is shown with a link to the individual post. next_posts_link and previous_posts_link are also included so the archive can paginate results:

    <?php get_header(); ?>
    
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <a href="<?php the_permalink(); ?>"<?php the_title(); ?></a>
        <?php the_excerpt(); ?>
    <?php endwhile; ?>
    
    <?php
        next_posts_link( 'Older Entries', $the_query->max_num_pages );
        previous_posts_link( 'Newer Entries' );
    ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

    Out of the box, WordPress supports two types of content: Posts and Pages. Posts are typically used for non-hierarchical content like a rolling blog. Pages are used for static, standalone content like an About Us page, or a company's Services page with nested subpages underneath. Developers can define their own custom post types as well as custom fields through additions such as Advanced Custom Fields.

Please consider making a request to improve this example.

Remarks

enter image description here WordPress is an open source Content Management System (CMS) which is used to build and manage websites. WordPress is the most popular CMS on the internet by a country mile, powering about half of all CMS websites at time of writing and about a quarter of all websites on the internet.

WordPress started life as a platform for blogging but has evolved over the years to be suitable for most types of websites. The interface can be used without coding knowledge making it popular for beginners and developers who want to empower their clients to manage their own website.

Another large factor in the popularity of WordPress is it's flexibility, mostly due to the core's plugin and theming systems. The plugin system makes it easy to extend the core functionality without modifying the core code. In a similar manner, the theming system makes it easy to change the website's layout and aesthetics. There are now thousands of free and premium WordPress plugins and themes available. Many of these are located at the wordpress.org plugin repository and theme repository respectively.

WordPress is developed by it's own community, but is strongly associated with the company Automattic, which employs many of WordPress' core developers.

Code

WordPress is built upon the PHP server scripting language and the MySQL querying language. WordPress uses MySQL as a datastore for user content and configuration. The PHP wrangles the content data into a HTML webpage with all the necessary assets.

wordpress.com vs wordpress.org

You can use WordPress by signing up for Automattic's wordpress.com service and hosting your website on their servers, or you can download the WordPress software from wordpress.org and host your website on a server under your control. The first option is easy but you cannot edit any site code. You can only make changes through the WordPress interface. The second option requires more work but gives you flexibility to do whatever you like with your website code. If you are a StackOverflow user, you probably will be going with the second option.

Open Source

WordPress is open source software meaning it is free to use and anyone can view the source code and contribute to it. Potential contributors can get started by reading the Contribution page of the WordPress codex..

Bugs can be reported by submitting a bug on the WordPress ticket tracker.

Documentation

WordPress is officially documented in the WordPress Codex at WordPress.org. Developers working with WordPress will be particularly interested in the Developer Codex section and Developer Reference section of wordpress.org.

Versions

VersionRelease Date
1.02004-01-03
1.22004-05-22
1.52005-02-17
2.02005-12-26
2.12007-01-22
2.22007-05-16
2.32007-09-24
2.52008-03-29
2.62008-07-15
2.72008-12-10
2.82009-06-10
2.92009-12-18
3.02010-06-17
3.12011-02-23
3.22011-07-04
3.32011-12-12
3.42012-06-13
3.52012-12-11
3.62013-08-01
3.72013-10-24
3.82013-12-12
3.92014-04-16
4.02014-09-04
4.12014-12-17
4.22015-04-23
4.32015-08-18
4.42015-12-08
4.52016-04-12
4.62016-08-16
4.72016-12-06
Still have a question about Getting started with WordPress? Ask Question

Topic Outline