Skip to content

Instantly share code, notes, and snippets.

@kisabelle
kisabelle / css-menu-icons.php
Created June 6, 2014 16:47
CSS Menu Icons / Wordpress Custom Menu Icons
function add_menu_icons_styles(){
?>
<style>
#adminmenu #menu-posts-mycustomposttype div.wp-menu-image:before {
content: "\f338";
}
</style>
<?php
@kisabelle
kisabelle / bootstrap-rows.php
Created May 27, 2014 16:39
Wordpress + Bootstrap 3: Every two posts in their own row together.
<?php
// $the_query = new WP_Query( 'showposts=4' );
$the_query = new WP_query(
array(
'posts_per_page' => 4,
'meta_key' => 'featured_facts',
'orderby' => 'meta_value_num date',
'order' => DESC
)
);
@kisabelle
kisabelle / wp-assign-parent-template.php
Created January 22, 2014 19:04
WordPress: Automatically Apply Parent Page Template to Child Pages by Matovu Richard
<?php
function switch_page_template() {
global $post;
// Checks if current post type is a page, rather than a post
if (is_page())
{
// Checks if page is parent, if yes, return
if ($post->post_parent == 0)
return true;
else if ($post->post_parent != $post->ID)
@kisabelle
kisabelle / wp-child-page-template.php
Created January 22, 2014 18:36
Wordpress Child Page Template
There is no specific template for child pages, but you can do this pretty easily with the get_template_part() function.
First create a file called "content-child.php".
Second create a file called "content.php".
Next, inside of page.php, place this:
<?php
if( $post->post_parent !== 0 ) {
@kisabelle
kisabelle / wp-custom-post-pagination.php
Created January 17, 2014 23:30
Pagination with Custom Post Types in WordPress
<?php
//setup new query
$query = new WP_query(
array(
'posts_per_page' => 10, // ??
'post_type' => 'custom-post-type', // custom post type
'paged' => get_query_var('paged'),
'meta_key' => 'wpcf-meta-key',
'orderby' => 'meta_value title',
@kisabelle
kisabelle / wp-insert-post-data.php
Last active January 3, 2016 15:29
Append post meta to the content (post_content) (uses 'wp_insert_post_data')
<?php
//----------------------------------------------
// Filter Post Data
//----------------------------------------------
/* The purpose of this filter is to take the
/* post meta from a custom field and save it
/* into post_content */
// Tack our filter onto the wp_insert_post_data action
@kisabelle
kisabelle / updated-wp-search-custom-fields.php
Last active April 19, 2017 20:10
Search Custom Fields: Include Custom Fields in Wordpress Search
// .dP"Y8 888888 db 88""Yb dP""b8 88 88
// `Ybo." 88__ dPYb 88__dP dP `" 88 88
// o.`Y8b 88"" dP__Yb 88"Yb Yb 888888
// 8bodP' 888888 dP""""Yb 88 Yb YboodP 88 88
// dP""b8 88 88 .dP"Y8 888888 dP"Yb 8b d8 888888 88 888888 88 8888b. .dP"Y8
// dP `" 88 88 `Ybo." 88 dP Yb 88b d88 88__ 88 88__ 88 8I Yb `Ybo."
// Yb Y8 8P o.`Y8b 88 Yb dP 88YbdP88 88"" 88 88"" 88 .o 8I dY o.`Y8b
// YboodP `YbodP' 8bodP' 88 YbodP 88 YY 88 88 88 888888 88ood8 8888Y" 8bodP'
@kisabelle
kisabelle / acf.php
Last active March 26, 2021 13:42
Advanced Custom Fields
/*----------------------------------------------*/
/* Image Field
/*----------------------------------------------*/
/* Return value: Attachment ID */
<?php if(get_field('logo')): ?>
<?php
$attachment_id = get_field('logo');
$size = "vendor-logo"; // (thumbnail, medium, large, full or custom size)
@kisabelle
kisabelle / clearfix.css
Created January 16, 2014 23:07
Micro clearfix by Nicolas Gallagher
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
@kisabelle
kisabelle / copyright-widget.php
Created December 30, 2013 20:23
A very simple custom Wordpress widget.