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 | |
$archivetitle = post_type_archive_title('', false); // No prefix and false to display | |
$thepage = get_page_by_title( $archivetitle ); // Get page object using the archive title | |
$content = $thepage->post_content; // Get raw page content | |
if ( !empty( $content ) ) { | |
$content = apply_filters('the_content', $content); // Apply filters to add formating | |
echo $content; | |
if ( current_user_can( 'edit_pages' ) ) { | |
// Let us also add an edit link for ease during development | |
$pageid = $thepage->ID; // Get the page ID for the edit link |
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
<style> | |
a.edit {display:inline-block; text-transform:uppercase; color:#FFF; background-color:#000; padding:1em 2em; border-radius:0.1em; margin:2em; clear:both} | |
</style> | |
<?php | |
if ( current_user_can('manage_options') ) { | |
$editlink = get_edit_post_link(); | |
echo '<a href="' . $editlink . '" class="edit">Edit</a>'; | |
} | |
?> |
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 | |
$tagline = get_bloginfo ( 'description' ); | |
$post_object = get_post(); | |
$excerpt = $post_object->post_excerpt; // Get the raw excerpt, warts (tags) and all. | |
$content = $post_object->post_content; // Get the raw content. | |
$char_limit = 150; // Set the character length to 150, best practice for SEO. | |
echo '<meta name="description" content="'; | |
if ( !empty( $excerpt ) ) { // If there is an excerpt lets use it to generate a meta description | |
$excerpt_stripped = strip_tags( $excerpt ); // Remove any tags using the PHP function strip_tags. | |
$excerpt_length = strlen( $excerpt_stripped ); // Now lets count the characters |
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 | |
$build_year = '2018'; // Amend this accordingly using the YYYY format | |
$year = date('Y'); // Get A full numeric representation of the current year, 4 digits | |
$blogname = get_bloginfo( 'name' ); // Get the Site Title as specified in Settings / General | |
echo '<p class="copyright">©'; | |
if ( $build_year == $year ) { | |
echo $year; | |
} else { | |
echo $build_year . ' - ' . $year; | |
} |
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 | |
add_action( 'after_setup_theme', 'add_image_sizes' ); | |
function add_image_sizes() { | |
add_image_size( 'tiny', 80, 60, true ); // 80 pixels wide by 60 pixels tall, hard crop mode | |
add_image_size( 'super', 1600, 1200, true ); | |
} | |
// Use them like this | |
if ( has_post_thumbnail() ) { | |
the_post_thumbnail( 'super' ); |
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 | |
// If there is a CF7 form with the same name as the current page let us display it. | |
$current_page_title = get_the_title(); | |
$cf7form = get_page_by_title( $current_page_title, OBJECT, 'wpcf7_contact_form' ); | |
if ( $cf7form ) { | |
$formid = $cf7form->ID; | |
$formtitle = $cf7form->post_title; | |
echo( do_shortcode('[contact-form-7 id="' . $formid . '" title="' . $formtitle . '"]') ); | |
} | |
?> |
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 contact form 7 retreat select | |
add_action( 'wpcf7_init', 'custom_retreat_select' ); | |
function custom_retreat_select() { | |
wpcf7_add_form_tag( 'retreat_select', 'custom_retreat_handler', array( 'name-attr' => true ) ); | |
} | |
function custom_retreat_handler( $tag ) { | |
$atts = array(); |
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 | |
$args = array( | |
'post_type' => 'posts', | |
'posts_per_page' => 99, | |
'orderby' => 'parent', | |
'order' => 'ASC' | |
); | |
$posts = get_posts( $args ); | |
foreach ( $posts as $post ) { | |
$childargs = array( |
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
// Add crop options for medium and large images to dashboard > settings > media. | |
function crop_settings_api_init() { | |
// Add the section to media settings | |
add_settings_section( | |
'crop_settings_section', | |
'Crop images', | |
'crop_settings_callback_function', | |
'media' | |
); | |
// Add the fields to the new section |
OlderNewer