This file contains 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 //<~ dont add me in | |
add_filter( 'post_class', 'themeprefix_odd_even_classes' ); | |
function themeprefix_odd_even_classes( $classes ) { | |
global $wp_query; | |
if($wp_query->current_post % 2 == 0) {//http://stackoverflow.com/questions/7959247/php-test-if-number-is-odd-or-even | |
$classes[] = 'odd'; | |
} |
This file contains 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 | |
// WP_Query Arguments | |
$args = array( | |
'order' => 'DESC', | |
'posts_per_page' => 5 | |
); | |
// The Loop | |
$query = new WP_Query( $args ); |
This file contains 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 | |
class Single_Page_Walker extends Walker_Nav_Menu{ | |
function start_el(&$output, $item, $depth, $args) { | |
global $wp_query; | |
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; | |
$class_names = $value = ''; | |
$classes = empty( $item->classes ) ? array() : (array) $item->classes; | |
$classes[] = 'menu-item-' . $item->ID; |
This file contains 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 | |
/** | |
* Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory) | |
* | |
* Be sure to replace all instances of 'yourprefix_' with your project's prefix. | |
* http://nacin.com/2010/05/11/in-wordpress-prefix-everything/ | |
* | |
* @category YourThemeOrPlugin | |
* @package Demo_CMB2 | |
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) |
This file contains 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
# add to | |
functions.php | |
// This theme uses post thumbnails | |
add_theme_support( 'post-thumbnails' ); | |
set_post_thumbnail_size( 300, 300, true ); | |
add_image_size( 'thumbnail-small', 75, 9999 ); | |
add_image_size( 'thumbnail-medium', 500, 9999 ); | |
This file contains 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 | |
/** | |
* Initialize the custom Meta Boxes. | |
*/ | |
add_action( 'admin_init', 'custom_meta_boxes' ); | |
/** | |
* Meta Boxes demo code. | |
* | |
* You can find all the available option types in demo-theme-options.php. |
This file contains 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
<ul class="products"> | |
<?php | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => 12 | |
); | |
$loop = new WP_Query( $args ); | |
if ( $loop->have_posts() ) { | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
wc_get_template_part( 'content', 'product' ); |
This file contains 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
http://rubelmiah.com/show-top-selling-items-edd/ | |
HOW TO SHOW TOP SELLING ITEMS ON EDD | |
<?php $popular_items = new WP_Query (array( | |
'post_type' => 'download', | |
'orderby' => 'meta_value_num', | |
'meta_query' => array( | |
'relation' => 'AND', | |
array( | |
'key' => '_edd_download_sales', | |
'compare' => '>', |
This file contains 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
https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/ | |
By default search results do not include custom post type content into the search results. The code can be appended to functions.php to include CPT in search results : | |
// Show posts of 'post', 'page', 'acme_product' and 'movie' post types on home page | |
function search_filter( $query ) { | |
if ( !is_admin() && $query->is_main_query() ) { | |
if ( $query->is_search ) { | |
$query->set( 'post_type', array( 'post', 'page', 'acme_product', 'movie' ) ); | |
} | |
} |
This file contains 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 | |
trait Greetings | |
{ | |
public function sayHello() | |
{ | |
return 'Hello Bro'; | |
} | |
public function goodBye() |