Last active
August 29, 2015 14:15
-
-
Save epicallan/c3c3025248a9c33581b4 to your computer and use it in GitHub Desktop.
Creating modular wordpress page templates with classes
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 | |
/** | |
* themes class | |
* included on page templates by use of | |
* a template redirect hook | |
*/ | |
class ThemeClass | |
{ | |
protected $data; | |
public function __construct($init) | |
{ | |
$this->data = $init; | |
$this->type = $init["type"]; | |
$this->prefix = $init["prefix"]; | |
$this->taxonomy=$init["taxonomy"]; | |
$this->table_id=$init["table_id"]; | |
} | |
public function getData() | |
{ | |
$type = $this->type; | |
$prefix = $this->prefix; | |
$taxonomy=$this->taxonomy; | |
$table_id=$this->table_id; | |
$args = array('post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => -1, 'ignore_sticky_posts' => 1); | |
// The Query | |
$prefix = $prefix; | |
$query1 = new WP_Query($args); | |
// The Loop | |
while ($query1->have_posts()) { | |
//**code**/ | |
//loop logic | |
} | |
wp_reset_postdata(); | |
} | |
public function themeLogic(){ | |
/**code**/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment