Skip to content

Instantly share code, notes, and snippets.

@mateusneves
mateusneves / function.php
Created June 23, 2016 19:14
Detect scroll position
$(window).scroll(function (event) {
var scroll = $(window).scrollTop();
console.log( scroll );
if( scroll > 100 ){
// Run
}else{
// Run
}
});
@mateusneves
mateusneves / functions.php
Created June 14, 2016 02:43
WordPress load custom login style file
function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/css/custom-login.css" />';
}
add_action('login_head', 'my_custom_login');
@mateusneves
mateusneves / custom-login.css
Last active September 16, 2016 17:22
WordPress custom login style
/* Change background */
body.login {
background-image: url('home-bg.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
/* Change login logo */
.login h1 a {
@mateusneves
mateusneves / archive.php
Last active June 14, 2016 02:05
Get current category parent ID
$category = get_the_category();
$parent_cat = $category->category_parent;
@mateusneves
mateusneves / style.css
Created June 7, 2016 13:07
Basic media query for responsive websites
@media only screen and (min-width: 320px) {
}
@media only screen and (min-width: 480px) {
}
@media only screen and (min-width: 768px) {
}
@media only screen and (min-width: 1024px) {
@mateusneves
mateusneves / bp-custom.php
Created April 27, 2016 13:14
Buddupress remove rich text from profile text area field
// O arquivo bp-custom deve estar localizado na pasta plugins
function antipole_remove_rich_text( $field_id = null ) {
if ( ! $field_id ) {
$field_id = bp_get_the_profile_field_id( '3' );
}
$field = xprofile_get_field( $field_id );
if ( $field ) {
@mateusneves
mateusneves / functions.php
Last active April 18, 2016 14:27
Show WordPress bar only for administrators
add_action('after_setup_theme', 'qwp_remove_admin_bar');
function qwp_remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin() || !is_user_logged_in())
add_filter( 'show_admin_bar', '__return_false' );
}
@mateusneves
mateusneves / functions.php
Created April 12, 2016 17:29
Remove Private/Protected from Post Titles
//https://css-tricks.com/snippets/wordpress/remove-privateprotected-from-post-titles/
function the_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
'#Protected:#',
'#Private:#'
);
@mateusneves
mateusneves / template.php
Created April 6, 2016 18:44
Show Buddypress logged user avatar
<?php
echo bp_core_fetch_avatar( array(
'item_id' => bp_loggedin_user_id(),
'width' => 50,
'height' => 50,
'class' => 'avatar',
)
);
?>
@mateusneves
mateusneves / same-template.php
Last active April 5, 2016 14:13
Get Profile Field
// $user_id is a global variable
$about = xprofile_get_field_data( 'About', $user_id);