All posts by Gary Garchar

8. Status Parameters

 

any, auto-draft, draft, exclude_from_search, future, inherit, pending, private, publish, trash

codex.wordpress.org/Class_Reference/WP_Query

<?php
$args = array( 
 'order' => 'asc',
 'orderby' => 'title',
 'post_type' => 'post',
 'post_status' => 'publish',
 'posts_per_page' => 1,
 );

get_header();

$theObject = new WP_Query( $args );
while ( $theObject->have_posts() ) : 
 $theObject->the_post();
 the_author();
 the_category();
 the_content();
 the_excerpt();
 the_ID();
 the_tags();
 the_time(); echo " - ";
 the_title(); 
 echo '<hr /><hr />';
endwhile;

get_sidebar();
get_footer(); 
?>

6) Rewrite

The argument rewrite defaults to true and will use $post_type as slug unless customizing the permalink structure slug as in this example.

Note: Should be translatable.

 

5) Has Archive

The argument has_archive enables post type archives. Will use $post_type as archive slug by default. Can also accept a string as its value.



1) Post Types

BUILT-IN POST TYPES

Label Post Type
Posts post
Pages page
Media attachment
Revisions revision
Navigation Menu Items nav_menu_item
Custom CSS custom_css
Changesets customize_changeset
oEmbed Responses oembed_cache

5.0 Resources

Child Theme Plugins

Guide to WordPress Child Theme Development

How To Make Your Own Child Theme

How to modify the Parent Theme behavior within the Child Theme

How to Modify WordPress Themes the Smart Way (four part series)

How to: Create a Child Theme based on Twenty Eleven

Leveraging Chrome Developer Tools for WordPress Development

Theme Development – Codex

Tutorial: Child Themes basics and creating Child Themes in WordPress

Why @import is no longer a best practice – An Alternative

WordPress Child Themes: The Whys and Hows

3.1 Using functions.php

Unlike the style.css file, the functions.php file of a child theme does not
override (cascade) its counterpart from the parent. Instead, it is loaded in
addition to the parent’s functions.php. Specifically, right before the parent’s file.

The fact that a child theme’s functions.php file
is loaded first means that you can make the user functions of your theme
pluggable, i.e., replaceable by a child theme by declaring them
conditionally. Example:

In that way, a child theme can replace a PHP function of the parent by
simply declaring it beforehand.

2.1.2 Create a Complicated Child Theme

/*
Theme Name: Twenty Sixteen – Child
Theme URI:
Description:
Author:
Author URI:
Template: twentysixteen
Version:
License:
License URI:
Tags:
Text Domain:
*/

Enqueue the parent and child theme stylesheets because using @import increases the amount of time it takes style sheets to load.

add a wp_enqueue_scripts action in a function.php file

functions.php

 

Setting ‘parent-style’ as a dependency will ensure that the child theme stylesheet loads after it.

Including the child theme version number ensures that you can bust cache also for the child theme. See a more detailed discussion on Stack Exchange:

versioning-import-of-parent-themes-style-css

The complete (recommended) example becomes:

where |parent-style| is the same |$handle| used in the parent theme when it registers its stylesheet.

For example, if the parent theme is twentyfifteen, by looking in its functions.php
for its |wp_enqueue_style()| call, you can see the tag it uses there is |’twentyfifteen-style’|. In your child code, replace the instance of |’parent-style’| with |’twentyfifteen-style’|, like so:

$parent_style = ‘twentyfifteen-style’;

Failure to use the proper tag will result in a CSS file needlessly being
loaded twice. This will usually not affect the site appearance, but it’s
inefficient and extends your page’s loading time.

*Note:* You may need to re-save your menu (Appearance > Menus, or
Appearance > Customize > Menus) and theme options (including background
and header images) after activating the child theme.

codex.wordpress.org/Child_Themes

2.0 How to Create a Child Theme

Upload into the themes folder, a directory containing the style.css file. The directory should be named for the parent with “-child” appended to it.

wp-content > themes > parent-child > style.css

At minimum, the style.css file should contain code looking at least something like this:

1.1 Why use a Child Theme?

At the very minimum, a WordPress Theme consists of at least two files, plus an optional 1200×900 image to suggest the theme’s design :

  • style.css
  • index.php
  • screenshot.png

A child theme can be even simpler because it inherits the functionality and styling of
a parent theme. It can be done with one file that imports the parent style.css.

  • style.css

But the current best practice is to use a functions.php that enqueues the parent style.css file:

  • style.css
  • function.php
  • screenshot.png

Child themes are the best way to make major modifications to an existing theme. *

  • ensure modifications are preserved
  • speed up development time
  • learn about WordPress theme development

* minor modifications to style can be done using the theme’s Customize feature.

9) For More Information – FYI

8) Selectors of TwentySixteen

virgin.zapmap.com

article { background: khaki;}
aside { background: lightblue;}
body { background: tan;}
button { background: red;}
footer { background: lightgreen;}
header { background: lightgreen;}
section { background: grey;}

.entry-content { background: magenta;}
.entry-footer { background: yellow;}
.screen-reader-text { background: white;}
.sidebar { background: lightblue;}
.site { background: lightgrey;}
.site-branding { background: ivory;}
.site-footer { background: coral;}
.site-header { background: coral;}
.site-main { background: cyan;}

5) Flex Samples

 

.container { display: flex; }
.container { display: inline-flex }
.container { flex-direction: row | row-reverse | column | column-reverse; }
.container{ flex-wrap: nowrap | wrap | wrap-reverse; }

flex-flow: <‘flex-direction’> || <‘flex-wrap’>

.container {
     justify-content: flex-start | flex-end | center | 
    space-between | space-around | space-evenly;
     }
.container { align-items: flex-start | flex-end | 
    center | baseline | stretch; }
.container {
    align-content: flex-start | flex-end | center | 
    space-between | space-around | stretch;
    }

.item { order: <integer>; }

.item { flex-grow: <number>; }
.item { flex-shrink: <number>; }
.item { flex-basis: <length> | auto; }
.item { flex: none | [ <‘flex-grow’> <‘flex-shrink’>? || <‘flex-basis’> ] }

.item { align-self: auto | flex-start | flex-end | center | baseline | stretch; }

7) My Container

pink
coral
khaki
light green
light blue
thistle
plum

1) CSS Rule Structure

Web page styling rules are defined inline, embedded, or in an external .CSS file

Declarations grouped within a block:

selector {
     property: value;
     property: value;
     }

Element selector:
ul { padding-left: 5em; }

Selectors grouped within a rule:
ol, ul { margin-left: 5em; }

Class selector:
.entry-content { background-color: #c0c; }

Combination of element and class:
span.warning { font-weight: bold; }

ID selector:
#blog_title { font-size: 17px; }

Element within a class:

 .entry-content ol {
     background-color: #cc0;
     padding-left: 5em;
     }

Group combination & comment:
ol, ul { margin: 16px 0; padding: 0 0 0 40px; } /* top, right, bottom, left */

Inline syle:
<div style=”font-weight:bold; color:red”>Content</div>

Mind Blowing Declaration:

.entry-footer > span:not(:last-child):after {
     content: "\002f";
     display: inline-block;
     opacity: 0.7;
     padding: 0 0.538461538em;
     }

 

3) wp_users

zapmap.com/wp-admin/profile.php

  1. mysql -u [username] -p -D [database_name]
  2. desc [table_name];
  3. UPDATE wp_users SET user_pass = MD5( ‘[new_password]’ ) WHERE user_login = ‘[username]’;
  4. UPDATE wp_users SET user_login = ‘[new_username]’ WHERE user_login = ‘[old_username]’;

mysql -u root -p -D wp480
desc wp_users;

UPDATE wp_users SET user_login = ‘Francisco’ WHERE user_login = ‘Frank’;

UPDATE wp_users SET user_pass = MD5( ‘def456’ ) WHERE user_login = ‘Francisco’;