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 | |
// get the post data, put it into $post variable | |
$post = perch_blog_custom(array( | |
'filter' => 'postSlug', | |
'match' => 'eq', | |
'value' => perch_get('s'), | |
'skip-template' => true, | |
'return-html' => true, | |
'template' => 'blog/post.html', | |
)); |
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
/* GROUP IMAGE ORIENTATION DETECTION | |
=================================================== */ | |
class PerchTemplateFilter_image_orientation_detection extends PerchTemplateFilter | |
{ | |
/* Notes... | |
You may want to do something different if the image is landscape e.g. span 2 columns in a CSS grid rather than 1 | |
- Assumes your template image has an ID of `image` | |
- e.g. `<div class="c-photo-grid__item c-photo-grid__item--<perch:content id="image" filter="image-orientation-detection" />">` | |
This would either output `c-photo-grid__item--landscape` or `c-photo-grid__item--portrait` | |
*/ |
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
<perch:if different="_block_type"> | |
This is a different block type | |
</perch:if> |
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 (perch_layout_has('blog-post')) { | |
perch_blog_post_meta(perch_get('s')); | |
perch_page_attributes(); | |
}else{ | |
echo '<title>' . perch_pages_title(true) . '</title>'; | |
perch_page_attributes(); | |
} | |
?> |
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
// We're grabbing each category and filtering the 'Properties' region using that category - if the property count is 0, we don't pass that category to the output. | |
// This method does produce a database query for each category, so I would run it with debug switched on to see if makes an impact for your setup or not. | |
<?php perch_categories(['set'=>'area','sort'=>'catTitle','sort-order'=>'ASC','each'=>function($item) { | |
if (PerchUtil::count(perch_content_custom('Properties', | |
['skip-template'=>true, 'category'=>$item['catPath']])) > 0) return $item; }] | |
); ?> | |
// You do have to make a slight change to the category template with this though - an example using the default category.html template: |
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
h1 { | |
background: #000000; | |
color: #FFFFFF; | |
font-size: 20px; | |
font-weight: bold; | |
padding: 5px; | |
position: relative; | |
} | |
h1:after { | |
border-color: #000000 transparent transparent; |
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
Perch.UserConfig.redactor = function(){ | |
var get = function(profile, config, field) { | |
return { buttons: ['bold', 'italic'] } | |
}; | |
var load = function(cb) { | |
cb(); | |
}; |
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
Perch.UserConfig.redactor = function(){ | |
var get = function(profile, config, field) { | |
if (config.plugins.indexOf('source') === -1) config.plugins.push('source'); | |
if (config.plugins.indexOf('fontcolor') === -1) config.plugins.push('fontcolor'); | |
if (config.plugins.indexOf('alignment') === -1) config.plugins.push('alignment'); | |
return config; | |
}; |
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
function after_post_content($content) { | |
if(!is_feed() && !is_home()) { | |
$content.= '<h4>Like this post?</h4>'; | |
$content.= '<p><a href="http://example.com/subscribe">Subscribe to our newsletter</a>!</p>'; | |
} | |
return $content; | |
} | |
add_filter ('the_content', 'after_post_content'); |
NewerOlder