Skip to content

Instantly share code, notes, and snippets.

View fenda's full-sized avatar

Fernanda Sampaio fenda

View GitHub Profile
<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<div style="background-image: url(<?php echo $feat_image; ?>);">
// <h2 class="pagetitle">Search Results</h2>
// search.php
<h2 class="pagetitle">Search Result for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2>
<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>">
<div>
<label for="s">Search by:</label>
<input type="text" value="" name="s" id="s" />
in <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?>
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
@fenda
fenda / Click outside el to hide el
Created December 28, 2015 21:37
Hide element when clicking outside itself
$(document).click(function(e){
if ($(e.target).parents('.el').length === 0) {
$('.el').fadeOut();
}
});
@fenda
fenda / one_page.php
Last active August 5, 2016 16:24
One page Wordpress theme
<?php get_header(); ?>
<?php
query_posts('post_type=page');
while(have_posts() ) : the_post();
endwhile;
?>
<?php
$className = 'section1';
@fenda
fenda / ftimage_title.php
Created October 28, 2015 01:56
Add title to Featured Images (Wordpress)
//add_filter( 'media_send_to_editor', 'inserted_image_titles', 15, 2 );
function featured_image_titles($attr, $attachment = null){
$attr['title'] = get_post($attachment->ID)->post_title;
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'featured_image_titles', 10, 2);
@fenda
fenda / comma.js
Created October 25, 2015 15:09
add space after comma
$('.el').each(function() {
var string = $(this).html();
$(this).html(string.replace(/,/g , ', '));
});
@fenda
fenda / normalize.min.css
Created October 27, 2014 14:52
Normalize minified
/*! normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:hover,a:active{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.75em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}p,pre{margin:1em 0}pre,code,kbd,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word
@fenda
fenda / .htaccess (file extension)
Last active June 6, 2023 13:27
remove file extension from url
# The following will allow you to use URLs such as the following:
#
# example.com/link
# example.com/link/
#
# Which will actually serve files such as the following:
#
# example.com/link.html
# example.com/link.php
#
@fenda
fenda / Detect zoom and hide element
Created October 7, 2013 14:02
Hide elements when page is zoomed
var zoomOri = document.documentElement.clientWidth / window.innerWidth;
var zoomCurrent = zoomOri;
$(window).resize(function() {
var zoomNew = document.documentElement.clientWidth / window.innerWidth;
if (zoomOri != zoomNew && zoomNew != zoomCurrent) {
$('.yourclass').hide();
} else if (zoomOri == zoomNew && zoomNew != zoomCurrent) {
$('.yourclass').show();
}
zoomCurrent = zoomNew