Skip to content

Instantly share code, notes, and snippets.

@Sstobo
Sstobo / gist:9a7577ad12fe5fe40346752fe6a22510
Created November 9, 2017 17:53
[custom template page FOR ABOUT PAGE] #wp #setup
<?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 -->
@Sstobo
Sstobo / gist:9f434bb28252070ec5c1a9812987a508
Created November 9, 2017 17:40
[wordpress get_x] #setup #wp
<?php get_header(); ?>
<div>
<?php
// The loop might go here...
?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<!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>
@Sstobo
Sstobo / gist:21c7569734658260370ae8de2fbae06f
Last active November 8, 2017 19:50
[wordpress loop] #wp #setup #php
<?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; ?>
@Sstobo
Sstobo / gist:495bce997393ca0367b8241d8db09335
Created November 8, 2017 19:37
[wordpress theme .css] #wp #css #setup
/*
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
*/
@Sstobo
Sstobo / gist:7f69c255ee9fce951c3d294b80ab7935
Created November 8, 2017 19:37
[wordpress access] #wp #setup
To do that, go to the MAMP WebStart page and click on the Tools > phpMyAdmin in the menu.
@Sstobo
Sstobo / wpsetup.txt
Created November 8, 2017 17:58
[wordpress install] #wp #setup
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
@Sstobo
Sstobo / phpimpexp.txt
Created November 7, 2017 17:58
[PHP array implode explode] #php
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 );
@Sstobo
Sstobo / phploop.txt
Created November 7, 2017 17:44
[PHP loops] #php
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' ) :?>
@Sstobo
Sstobo / phptruthy.txt
Created November 7, 2017 17:38
[PHP truthy falsey] #php
$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;