This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Changing the excerpt length | |
* | |
* the default length is 55 words and the code below changes it to 25 words | |
*/ | |
function custom_excerpt_length( $length ) { | |
return 25; | |
} | |
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Contact Form 7 | |
* Speed enhancement | |
* | |
* The code below checks for the use of the CF7 shortcode and will remove scripts and styles when it isn't being used | |
*/ | |
function deviodigital_deregister_contact_form() { | |
global $post; | |
if ( ! has_shortcode( $post->post_content, 'contact-form-7' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Change the "mnml" text througout the code below to whatever you'd like to use | |
* | |
* Also, make sure the get_theme_mod instances are changed to your customizer option names | |
* | |
*/ | |
// Add custom logo to login page if it's uploaded through the customizer | |
if ( get_theme_mod( 'mnml_logo' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function devio_functionname() { | |
if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
echo '<div class="updated" id="message"><p>Put your notice here</p></div>'; | |
} | |
} | |
add_action( 'admin_notices', 'devio_functionname' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This code stops your shortcode from displaying | |
* at the top of your WordPress page or post | |
*/ | |
ob_start(); | |
// Do stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_rest_prepare_post( $data, $post, $request ) { | |
$_data = $data->data; | |
$thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
$thumbnail = wp_get_attachment_image_src( $thumbnail_id, 'full' ); | |
$_data['featured_image_thumbnail_url'] = $thumbnail[0]; | |
$data->data = $_data; | |
return $data; | |
} | |
add_filter( 'rest_prepare_post', 'my_rest_prepare_post', 10, 3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$.get( "wp-json/wp/v2/posts", function( data ) { | |
$.each( data, function( i, val ) { | |
$( "#app" ).append( | |
'<li>' + | |
'<h3>' + | |
val.title.rendered + | |
'</h3>' + | |
'<p>' + | |
val.excerpt.rendered + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>WP Dispensary Example API Usage</title> | |
</head> | |
<body> | |
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.2.min.js"></script> | |
<ul id="app"></ul> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* custom excerpt length for WordPress posts | |
* call the excerpt in your theme file with 'echo excerpt(25)' | |
* change the number to whatever amount of words you want to show | |
*/ | |
function excerpt($limit) { | |
$excerpt = explode(' ', get_the_excerpt(), $limit); | |
if (count($excerpt)>=$limit) { | |
array_pop($excerpt); |
OlderNewer