Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active August 7, 2018 13:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpataki/d2a4aa5bedec00b5e8b3 to your computer and use it in GitHub Desktop.
Save danielpataki/d2a4aa5bedec00b5e8b3 to your computer and use it in GitHub Desktop.
WordPress Coding For Beginners
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<article id="post-344" class="post-344 post type-post status-publish format-standard has-post-thumbnail sticky hentry category-photos tag-example tag-tag">
/*
Theme Name: Twenty Fourteen Child
Theme URI: http://mytheme.com
Description: My Child Theme
Author: Daniel Pataki
Author URI: http://danielpataki.com
Template: twentyfourteen
Version: 1.0.0
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: my-child-theme
*/
/* =Theme customization starts here
-------------------------------------------------------------- */
add_filter( 'the_content', 'my_content_filter' );
function my_content_filter( $content ) {
$content .= ' (checked by Daniel Pataki)';
}
<?php if( $coming_soon->have_posts() ) ?>
<ul>
<?php while( $coming_soon->have_posts() ) : $coming_soon->the_post() ?>
<li <?php post_class() ?>>
<a href='<?php the_permalink() ?>'><?php the_title() ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif ?>
<?php if( have_posts() ) ?>
<?php while( have_posts() ) : the_post() ?>
<div <?php post_class() ?>>
<h2><?php the_title() ?></h2>
<div class='content'>
<?php the_content() ?>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
Oh no, there are no posts here
<?php endif ?>
add_action( 'wp_enqueue_scripts', 'my_parent_styles' );
function my_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
<?php if( date( 'G' ) > 18 ) : ?>
<h2>Good Night!</h2>
<?php else : ?>
<h2>Good Day </h2>
<?php endif ?>
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );
endif;
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'future',
'category_name' => 'app_reviews',
'posts_per_page' => 3
);
$coming_soon = new WP_Query( $args );
?>
<h1 class="entry-title">THe title of my article</h1>
the_title( '<h1 class="entry-title">', '</h1>' );
add_action( 'wp_footer', 'my_tracking_code' );
function my_tracking_code() {
?>
// Paste Google Analytics code here
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment