Skip to content

Instantly share code, notes, and snippets.

@ville6000
ville6000 / tpl.php
Last active August 29, 2015 14:16
Get page link from title in WordPress
<a href="<?php echo get_permalink( get_page_by_title( 'Contact' ) ); ?>">
<?php _e( 'Contact', 'your_text_domain' ); ?>
</a>
@ville6000
ville6000 / functions.php
Last active October 22, 2015 08:19
Exclude pages from WordPress search
<?php
/**
* Exclude footer pages from search
*
* @param $query
*
* @return array
*/
function your_theme_exclude_pages_from_search( $query ) {
if ( $query->is_search ) {
@ville6000
ville6000 / next_permutation.rb
Last active October 1, 2015 15:08
Given a number, find the next higher number that uses the same set of digits. For instance, given the number 38276, the next higher number that uses the digits 2 3 6 7 8 is 38627.
def next_permutation(value)
values = value.to_s(10).split(//).sort
newValue = value + 1
while false == newValue.to_s(10).split(//).sort.eql?(values)
newValue = newValue + 1
end
return newValue
end