Skip to content

Instantly share code, notes, and snippets.

@zogot
zogot / functions-hooks-adverts.php
Last active December 26, 2015 05:19
Easily add posts into certain positions on WP_Query. Adverts example.
<?php
add_action( 'pre_get_posts', 'kwpn_advert_positions_pre_get_posts', 20 );
function kwpn_advert_positions_pre_get_posts( WP_Query $query ) {
// Only continue if the query chose to have adverts
if ( ! is_array( $query->get( 'kwpn_insert_adverts' ) ) )
return;
// Get the chosen advert positions
@zogot
zogot / jquery.pronamic-media.js
Last active December 23, 2015 23:39
Pronamic WordPress Media jQuery Plugin
pronamicMedia = function(elem, options) {
this.elem = elem;
this.$elem = jQuery(elem);
this.options = options;
};
pronamicMedia.prototype = {
_frame:undefined
@zogot
zogot / index.php
Created May 13, 2013 06:55
Limit WordPress content by words.
<?php // where 15 is the word limit ?>
<?php echo apply_filters( 'the_content', wp_trim_words( get_the_content(), 15, '&hellip;' ) ); ?>
@zogot
zogot / gist:5500940
Last active December 16, 2015 21:39 — forked from Clorith/gist:5500932
<?php
function breadcrumbs() {
?>
<?php if ( ! is_home() ) : ?>
<?php global $post; ?>
<a href="<?php bloginfo( 'wpurl' ); ?>">Home</a> &raquo;
<?php
@zogot
zogot / functions.php
Last active April 14, 2020 06:05
WordPress Meta Boxes above the Editor. Including a sortable content area.
<?php
/**
* Prints all metaboxes with the above context
* above the editor
*/
function themeplugin_prefix_meta_box_above() {
global $post;
echo '<div id="postbox-container-3" class="postbox-container">';
do_meta_boxes( get_current_screen(), 'above', $post );
echo '</div>';
<?php
// call this method inside the method that shows the metabox contents
function prefix_upload_inputs() {
global $post;
wp_enqueue_media();
$scripts = "
<script type='text/javascript'>
jQuery(document).ready(function($){