Skip to content

Instantly share code, notes, and snippets.

@KTPH
KTPH / wp-categories-select-box.php
Last active Aug 29, 2015
Wordpress List Categories in Select Box
View wp-categories-select-box.php
<div id="categories">
<?php wp_dropdown_categories( 'show_option_none=Select category&Categories&orderby=name&show_count=1' ); ?>
<script type="text/javascript">
var dropdown = document.getElementById("cat");
function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo esc_url( home_url( '/' ) ); ?>?cat="+dropdown.options[dropdown.selectedIndex].value;
}
} dropdown.onchange = onCatChange;
</script>
@KTPH
KTPH / wordpress-post-count.php
Created Aug 29, 2015
Wordpress Show Total Number of Posts
View wordpress-post-count.php
// Show Totle Number of posts
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
echo $published_posts;
}
@KTPH
KTPH / wordpres-post-date-archives-lists.php
Last active Aug 29, 2015
Wordpress Post Date Archives as List or Select Box
View wordpres-post-date-archives-lists.php
// List date archives in ul
wp_get_archives( array( 'type' => 'yearly' ) );
// List date archives in select dropdown
?>
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr( __( 'Select Year' ) ); ?></option>
<?php wp_get_archives( array( 'type' => 'yearly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
</select>
@KTPH
KTPH / remove-create-widget-areas.php
Created Jun 5, 2015
Remove Default Widget Areas and Create Custom Widget Areas
View remove-create-widget-areas.php
/**
*
* Remove Default Widget Areas
*
*/
unregister_sidebar('sidebar-alt'); /* Secondary Sidebar */
unregister_sidebar('sidebar'); /* Primary Sidebar */
unregister_sidebar('header-right'); /* Header Right Sidebar */
/**
@KTPH
KTPH / acf-repeater-remove-front-end-dependency.php
Last active May 28, 2017
Remove Front-End Dependency for ACF Repeater Field Example (displays images with src, alt, width/height and also other sub fields)
View acf-repeater-remove-front-end-dependency.php
// Masonry Grid
$slides = get_post_meta( get_the_ID(), 'image_gallery_grid', true );
// Check if acf/custom field data exists
if( $slides ) { ?>
<ul class="grid effect-5" id="grid">
<?php
for( $i = 0; $i < $slides; $i++ ) { // Custom Count/Loop through rows
@KTPH
KTPH / acf-gallery-remove-front-end-dependency.php
Last active Oct 21, 2018
Remove Front-End Dependency for ACF Gallery Field Example (displays images with src, alt, width/height and caption)
View acf-gallery-remove-front-end-dependency.php
@KTPH
KTPH / img-iframe-wysiwyg-wodpress-acf-prevent.php
Created Jun 4, 2015
Prevent Wordpress from wrapping images and iframes in p tags (default WYSIWYG and Advanced Custom Fields Wordpress WYSIWYG Plugin)
View img-iframe-wysiwyg-wodpress-acf-prevent.php
/**
*
* Prevent Wordpress from wrapping images and iframes in p tags
* http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/
* ( <p> and <iframe> and ACF support - http://wordpress.stackexchange.com/questions/136840/how-to-remove-p-tags-around-img-and-iframe-tags-in-the-acf-wysiwyg-field
*/
// Default Wordpress WYSIWYG
function filter_ptags_on_images_iframes($content)
{
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
@KTPH
KTPH / foundation-grid-genesis-child-theme.php
Last active Aug 29, 2015
Adding Foundation Grid Classes to Wordpress Genesis Theme Framework (Child Theme)
View foundation-grid-genesis-child-theme.php
/**
*
* Add classes to genesis html structures for foundation grid
*
*/
add_filter('genesis_attr_content-sidebar-wrap', 'custom_class');
function custom_class( $attr, $class ) {
$site_layout = genesis_site_layout();
@KTPH
KTPH / Foundation5-Off-Canvas-Wordpress-Genesis.php
Last active May 15, 2017
Add Foundation Off-Canvas Navigation to Wordpress Genesis Child Theme
View Foundation5-Off-Canvas-Wordpress-Genesis.php
/**
*
* Off-Canvas Navigation required Open & Close Wraps
*
**/
// OPEN Off Canvas Wraps
add_action('genesis_before_header', 'custom_do_open_off_canvas_wraps', 9);
function custom_do_open_off_canvas_wraps() { ?>
@KTPH
KTPH / Foundation5-TopBar-Wordpress-Genesis.php
Last active Jan 9, 2016
Add Foundation Top-Bar Navigation to Wordpress Genesis Child Theme
View Foundation5-TopBar-Wordpress-Genesis.php
// A Fork of: http://garethcooper.com/2014/01/zurb-foundation-5-and-wordpress-menus/
/**
*
* Do Primary Top-Bar Navigation
*
**/
add_action('genesis_header', 'custom_do_top_bar_navigation', 11);
function custom_do_top_bar_navigation() { ?>