Skip to content

Instantly share code, notes, and snippets.

View raewrites's full-sized avatar

Raelene Morey raewrites

View GitHub Profile
@raewrites
raewrites / add-editor-style-function
Created January 13, 2015 03:53
Add Editor Style Function
<?php
function my_theme_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'after_setup_theme', 'my_theme_add_editor_styles' );
?>
@raewrites
raewrites / add-editor-style
Created January 13, 2015 03:53
Add Editor Style
<?php add_editor_style( $stylesheet ); ?>
@raewrites
raewrites / registering-custom-styles
Created January 13, 2015 03:39
Registering Custom Styles
// Callback function to filter the MCE settings
function my_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => '.translation',
'block' => 'blockquote',
'classes' => 'translation',
'wrapper' => true,
function enable_more_buttons($buttons) {
$buttons[] = 'fontselect';
$buttons[] = 'fontsizeselect';
$buttons[] = 'styleselect';
$buttons[] = 'backcolor';
$buttons[] = 'newdocument';
$buttons[] = 'cut';
$buttons[] = 'copy';
$buttons[] = 'charmap';
@raewrites
raewrites / my-function
Created January 16, 2015 05:54
My Function
<?php
function my_function() {
// contents of function go here
}
add_action( 'pre_get_posts', 'my_function');
?>
@raewrites
raewrites / get-posts
Created January 16, 2015 05:56
Get Post
<?php
function my_function() {
if ( is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'custom_post_type') );
return $query;
}
@raewrites
raewrites / amend-category-archives
Created January 16, 2015 05:58
Amend Category Archives
<?php
function my_function() {
if ( is_category() && $query->is_main_query() ) {
$query->set( 'post_type', 'custom_post_type' );
return $query;
}
@raewrites
raewrites / look-for-category
Created January 16, 2015 05:59
Look for Category
<?php
function my_function() {
if ( is_category( 'category-slug' ) && $query->is_main_query() ) {
$query->set( 'post_type', 'custom_post_type' );
return $query;
}
@raewrites
raewrites / display-alphabetical-order
Created January 16, 2015 05:59
Display Alphabetical Order
<?php
function my_function() {
if ( is_category() && $query->is_main_query() ) {
$query->set( 'orderby', 'title');
$query->set( 'order', 'ASC' );
return $query;
}
@raewrites
raewrites / using-wp-query
Created January 16, 2015 06:01
Using WP_Query
<?php
$args = array(
// arguments for your query
);
// the query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post() :
// contents of the Loop go here