Skip to content

Instantly share code, notes, and snippets.

View Jakobuz's full-sized avatar
🏠
Working from home

Jakob Jakobuz

🏠
Working from home
View GitHub Profile
@Jakobuz
Jakobuz / settings-api-class-demo.php
Created January 9, 2018 05:39 — forked from tareq1988/settings-api-class-demo.php
A simple theme options page created with WordPress Settings API PHP class https://github.com/tareq1988/wordpress-settings-api-class
<?php
require_once dirname( __FILE__ ) . '/class.settings-api.php';
/**
* Theme Admin panel for Tareq's Planet
*
* @author Tareq Hasan
*/
class Tareqs_Planet_Admin {
@Jakobuz
Jakobuz / functions.php
Created December 6, 2017 03:14 — forked from jnlsn/functions.php
WP Query Orderby Taxonomy Term Name
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query-&gt;query['orderby']) &amp;&amp; in_array($wp_query-&gt;query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb-&gt;term_relationships} AS rel2 ON {$wpdb-&gt;posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb-&gt;term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
LEFT OUTER JOIN {$wpdb-&gt;terms} USING (term_id)
@Jakobuz
Jakobuz / wp_get_archives() with cat_id
Last active April 21, 2022 05:02
Wordpress | Filter the function wp_get_archives() so a category_id can be added
/*
* Filter the wp_get_archives() so a cat_id can be added
* Example: wp_get_cat_archives('type=monthly&format=option&show_post_count=1', 46);
* in this case '46' = the category id
*/
add_filter('getarchives_where', 'custom_archives_where', 10, 2);
add_filter('getarchives_join', 'custom_archives_join', 10, 2);
function custom_archives_join($x, $r) {
@Jakobuz
Jakobuz / All terms in custom Taxonomy Wordpress
Last active December 6, 2017 00:29
Wordpress | Get all terms in custom Taxonomy
$taxonomies = array(
'custom_category'
);
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'exclude' => array(),
'exclude_tree' => array(),