Skip to content

Instantly share code, notes, and snippets.

View Jonnyauk's full-sized avatar
🎯
Focusing

Jonny Allbut Jonnyauk

🎯
Focusing
View GitHub Profile
@Jonnyauk
Jonnyauk / gist:16aefac2db04485b2da9
Created February 7, 2015 00:00
pre_get_posts example
<?php
function mywfx_archive_order_by_title($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ( is_post_type_archive( ‘kitty’ ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
return $query;
}
}
@Jonnyauk
Jonnyauk / unbrand-wonderflux.php
Last active December 20, 2015 07:09
Wonderflux has lots of filters for you to manipulate the output. Here's how to change the footer and comment credit - NOTE: You are free to do this, there is no requirement to give Wonderflux credit (although it would be appreciated - at-least tell your WordPress buddies!)
<?php
// Just a simple text string that appears near the footer as a HTML comment (view source)
function my_wfx_filter_code_credit() {
return 'Designed and coded by Wonderflux. Powered by WordPress and the Wonderflux theme framework.';
}
add_filter( 'wflux_comment_code_credit', 'my_wfx_filter_code_credit' );
// Replace the footer credit with your own text
function my_wfx_filter_footer_credit() {
return '<p class="meta">All content &copy;' . date('Y') . ' My Company | Website design &amp; coding by <a href="http://www.wondeflux.com" class="footer-credit-logo" title="Website design and coding by Wonderflux">Wonderflux</a></p>';
@Jonnyauk
Jonnyauk / wp-post-publish-first.php
Created June 25, 2012 14:35
Detect if WordPress post is published for the first time
<?php
/*
* On first publish set a special date in advance in custom field
*/
add_action('transition_post_status','tanc_first_schedule_publish_set',10,3);
function tanc_first_schedule_publish_set($new, $old, $post) {
// REFERENCE
// $new = new post status ('publish')
// $old = old post status ('draft')
@Jonnyauk
Jonnyauk / wp-jonnya-cpt-right-now.php
Created May 12, 2012 15:56
WordPress custom post type 'Right Now' panel integration
<?php
// Add all your custom post type counts to 'Right Now' dashboard widget
function tanc_admin_post_types_rightnow(){
$post_types = get_post_types(array('_builtin' => false), 'objects');
if (count($post_types) > 0)
foreach ($post_types as $pt => $args) {
$url = 'edit.php?post_type=' . $pt;
echo '<tr><td class="b"><a href="' . $url . '">' . wp_count_posts($pt)->publish . '</a></td><td class="t"><a href="' . $url . '">' . $args->labels->name . '</a></td></tr>';
}