Website Tutorial

Learn how to design a website, write your website copy, design your website graphics and more with this step-by-step tutorial.

Website Tutorial

WordPress displays articles in a specified category

<?php $posts = get_posts( “category=4&numberposts=10″ ); ?> <?php if( $posts ) : ?> <ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <li> <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul>...
Website Tutorial

WordPress display related articles

WordPress display related articles <?php $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $tags[0]->term_id; $args=array( ‘tag__in’ => array($first_tag), ‘post__not_in’ => array($post->ID), ‘showposts’=>10, ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href=”<?php the_permalink()...
Website Tutorial

WordPress display the latest comment

WordPress display the latest comment <?php global $wpdb; $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type...
Website Tutorial

wordpress display random articles

<?php $rand_posts = get_posts(‘numberposts=10&orderby=rand’); foreach( $rand_posts as $post ) : ?> <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php endforeach; ?>
Website Tutorial

WordPress-Change the blog name and description

In header.php, the following two lines of code are used to display the blog name and description: ~~~ <h1 id=”logo” class=”grid_4″>BBBBF</h1> <h2 class=”grid_12 caption clearfix”>Our <span>blog</span>, keeping you up-to-date on our latest news.</h2> ~~~ The above is static code, now...
Website Tutorial

WordPress theme-Change the stylesheet style.css path

WordPress theme-Change the stylesheet style.css path Before this, the homepage you saw was messy because the css style had not been loaded. Now let’s add the style together. You can find this code in header.php: `<link rel=”stylesheet” href=”./style.css” type=”text/css” media=”screen”...
Website Tutorial

WordPress theme-create header.php

WordPress theme-create header.php Next, create a new PHP file header.php in the theme directory wp-content\themes\bbbbf we created last time. We extract the header code in index.php and copy and paste it into header.php. The following code is all the code...
Website Tutorial

WordPress template main file composition

Theme file composition Before you start making a WordPress theme, you must first understand what files the WordPress theme is made of, and you must know how the WordPress program is connected to the theme file. The following are all...