We need to fill that while loop with content — or with content-outputting WordPress tags.<\/p>\n
If we change our loop, by adding the_title(), the_excerpt(), and we add HTML markup and the_ID(), to look like this:<\/p>\n
<\/span>if ( have_posts() ) {\n<\/span><\/span> while ( have_posts() ) {\n<\/span><\/span> the_post();\n<\/span><\/span> \/\/\n<\/span><\/span> \/\/ Post Content here\n<\/span><\/span> \/\/\n<\/span><\/span> } \/\/ end while\n<\/span><\/span>} \/\/ end if\n<\/span><\/span>?><\/span>\n<\/span><\/pre>\nWe’ll now get a list of posts on our home page, with no style applied:<\/p>\n\n
<\/p>\n
WordPress shows A blog page — an archive page for all the blog posts — by default.<\/p>\n
If we now visit single post URL — something like http:\/\/my-website.com\/2018\/11\/14\/sapiente-ad-facilis-quo-repellat-quos\/ — we’ll see something like this:<\/p>\n
<\/p>\n
Our loop<\/em>, albeit very crude, actually works.<\/p>\nStructuring Our Theme into Files and Applying Bootstrap Markup<\/h2>\n
We’ll now implement partials, like header.php and footer.php and various specialized templates, all using Twitter Bootstrap markup, so that we can style it more easily.<\/p>\n
Starting with index.php, we replace all the content before and after the loop with get_header() and get_footer() functions:<\/p>\n
<\/span> if ( have_posts() ) : while ( have_posts() ): the_post(); ?><\/span>\n<\/span>\n id=\"post-<\/span>\"<\/span>><\/span>\n<\/span> ><\/span><\/span><\/h2<\/span>><\/span>\n<\/span> class=\"post-excerpt\"<\/span>><\/span><\/span><\/div<\/span>><\/span>\n<\/span> <\/div<\/span>><\/span>\n<\/span>\n <\/span> endif;\n<\/span><\/span> ?><\/span>\n<\/span><\/pre>\nThis means we need to provide all that content in the partials we mentioned.<\/p>\n
In line with what we said — that we’ll use Twitter Bootstrap theme — our header.php file will look like this:<\/p>\n
<\/span>\/**\n<\/span><\/span> *\n<\/span><\/span> * @package Botega_Scratch_Theme\n<\/span><\/span><\/span> *\/\n<\/span><\/span>\n<\/span>get_header(); ?><\/span>\n<\/span>\n <\/span> if ( have_posts() ) : while ( have_posts() ): the_post(); ?><\/span>\n<\/span>\n id=\"post-<\/span>\"<\/span>><\/span>\n<\/span> ><\/span><\/span><\/h2<\/span>><\/span>\n<\/span> class=\"post-excerpt\"<\/span>><\/span><\/span><\/div<\/span>><\/span>\n<\/span> <\/div<\/span>><\/span>\n<\/span>\n <\/span> endif;\n<\/span><\/span> ?><\/span>\n<\/span>\n<\/span>\n<\/span><\/pre>\nOur footer.php file will look like this:<\/p>\n
\/*\n<\/span>Theme Name: Botega Simple Theme\n<\/span>Theme URI: https:\/\/botega.co.uk\n<\/span>Author: Tonino Jankov\n<\/span>Author URI: https:\/\/botega.co.uk\n<\/span>Description: Basic WordPress theme for Sitepoint theme building tutorial\n<\/span>Text Domain: bsimple\n<\/span>Version: 1.0.0\n<\/span>License: GNU General Public License v2 or later\n<\/span>*\/\n<\/span><\/pre>\nWe are using Bootstrap classes in our HTML tags, and wp_head() and wp_footer() fire wp_head and wp_footer action hooks.<\/p>\n
The next thing we’ll do is include the CSS and JavaScript from clean bootstrap template from startbootstrap.com, which comes with an MIT license, so we can freely use it. This way, our theme will come with predefined styles, responsiveness, and we’ll still be able to style it further.<\/p>\n
functions.php<\/h2>\n
functions.php is a file that comes with any serious WordPress theme. This is a file that acts as a poor man’s plugin archive. It allows us to include any custom functionality in our theme.<\/p>\n
We’ll firstly use this file to include Bootstrap and our bootstrap theme’s styles and scripts:<\/p>\n
<\/span>\/**\n<\/span><\/span> *\n<\/span><\/span> * @package Botega_Scratch_Theme\n<\/span><\/span><\/span> *\/\n<\/span><\/span>?><\/span>\n<\/span>\n<\/span>\n<\/span> <\/span><\/span>><\/span>\n<\/span>><\/span>\n<\/span> ><\/span><\/span><\/title<\/span>><\/span>\n<\/span> rel=\"stylesheet\"<\/span> href=\"<\/span>\"<\/span>><\/span>\n<\/span> <\/span>\n<\/span><\/head<\/span>><\/span>\n<\/span>
国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂
><\/span>\n<\/span>\n ><\/span>\n<\/span> ><\/span><\/span><\/h1<\/span>><\/span>\n<\/span> ><\/span><\/span><\/h3<\/span>><\/span>\n<\/span> <\/header<\/span>><\/span>\n<\/span>\n <\/span> if ( have_posts() ) :\n<\/span><\/span> \/* Start the Loop *\/\n<\/span><\/span> while ( have_posts() ) :\n<\/span><\/span> the_post();\n<\/span><\/span> endwhile;\n<\/span><\/span> endif;\n<\/span><\/span> ?><\/span>\n<\/span>\n<\/body<\/span>><\/span>\n<\/span><\/pre>\nThis is a WordPress-idiomatic way of including scripts and styles in a theme. It allows us to specify that the position of the scripts will be enqueued (header vs footer) and the priority of enqueuing. We can even specify the dependency of each particular resource on the other. This will ensure resources will be loaded in the right order.<\/p>\n
We’re using the wp_enqueue_scripts action hook here. We can learn more about it in the Codex. (We covered action hooks in the previous article.)<\/p>\n
Inside our custom bsimple_scripts() function — which we hook to wp_enqueue_scripts action hook — we use two WordPress functions to load our scripts and styles — wp_enqueue_script() and wp_enqueue_style(). Arguments for these functions — as specified in its linked reference pages — allow us to fully leverage flexibility that we mentioned.<\/p>\n
We can see that we’re loading styles from the Internet (Google fonts) and from our theme folder. Therefore, we create css, js and webfonts directories in our theme folder, and copy our Bootstrap theme’s CSS, JavaScript files, and FontAwesome icon-font files.<\/p>\n
We also copy our index.php file to archive.php, page.php and single.php files, which we’ll modify.<\/p>\n
Now our theme file structure will look something like this:<\/p>\n
<\/p>\n
Adjusting the Markup<\/h2>\n
If we now visit our home page, we’ll see the menu on the top — though it and the page are still a mess – because the following line in our header is still outputting the menu wrapped in div and its own ul tags, so it isn’t affected by our bootstrap styles:<\/p>\n
<\/span>if ( have_posts() ) {\n<\/span><\/span> while ( have_posts() ) {\n<\/span><\/span> the_post();\n<\/span><\/span>