This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Full-width | |
*/ | |
get_header(); ?> | |
<div id="primary" class="content-area"> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php get_template_part( 'content', 'page' ); ?> | |
<?php endwhile; // End of the loop. ?> | |
</div><!-- #primary --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php get_header(); ?> | |
<div> | |
<?php | |
// The loop might go here... | |
?> | |
</div> | |
<?php get_sidebar(); ?> | |
<?php get_footer(); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html <?php language_attributes(); ?>> | |
<head> | |
<meta charset="<?php bloginfo( 'charset' ); ?>"> | |
</head> | |
<body> | |
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1> | |
<p class="description"><?php bloginfo( 'description' ); ?></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<h2><?php the_title(); ?></h2> | |
<?php the_content(); ?> | |
<?php endwhile; ?> | |
<?php the_posts_navigation(); ?> | |
<?php else : ?> | |
<h2>Nothing found!</h2> | |
<?php endif; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: RED Starter Theme | |
Theme URI: http://underscores.me/ | |
Author: RED Academy | |
Author URI: http://www.redacademy.com/ | |
Description: A WordPress start theme for RED Academy students. | |
Version: 1.0.0 | |
License: GNU General Public License v2 or later | |
License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To do that, go to the MAMP WebStart page and click on the Tools > phpMyAdmin in the menu. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We can also install WP locally using MAMP: | |
Download WordPress | |
Unzip your download and move it to your htdocs folder (rename the unzipped folder if you like) | |
Go to phpMyAdmin (via MAMP) and create a new database | |
Rename wp-config-sample.php to wp-config.php and fill in your database name and MAMP credentials | |
Go to http://localhost:8888/YOUR-FOLDER/wp-admin/install.php and complete your install | |
name folder and name database same thing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To convert array items into a comma-separated string, use the implode() function: | |
$skills = array( 'html', 'css', 'js', 'php' ); | |
$comma_separated = implode(',', $array); | |
echo $comma_separated; // output: html,css,js,php | |
You can also convert a string to an array using the explode() function: | |
$skills = 'html css js php'; | |
$skills_array = explode( ' ', $skills ); | |
print_r( $skills_array ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You may often see loops written in a slightly different way from what we've seen so far: | |
if ( $color == 'blue' ) { | |
echo '<p>The color is blue.</p>'; | |
} elseif ( $color == 'red' ) { | |
echo '<p>The color is red.</p>'; | |
} else { | |
echo '<p>The color is not blue or red.</p>'; | |
} | |
<?php if ( $color == 'blue' ) :?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$my_var = false; | |
if ( isset( $my_var ) ) { | |
echo "It's set!"; | |
} else { | |
echo "It's not set."; | |
} | |
The empty() function checks if the variable is an empty string, 0, NULL, or false. | |
$my_var = false; |