Skip to content

Instantly share code, notes, and snippets.

View larodiel's full-sized avatar

Victor Larodiel larodiel

View GitHub Profile
@larodiel
larodiel / CSSComb.json
Created August 15, 2019 04:33
CSSComb Alphabetical order without prefix
{
"exclude": [
".git/**",
"node_modules/**",
"bower_components/**"
],
"sort-order": [[
"align-content",
"align-items",
"align-self",
@larodiel
larodiel / rm-wrap.php
Created January 13, 2018 18:34
Remove WP Contact 7 input wrap
add_filter('wpcf7_form_elements', function($content) {
$content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
return $content;
});
@larodiel
larodiel / column-id.php
Created December 12, 2017 15:12
Show the post ID on admin column
<?php
add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_content', 5, 2 );
function revealid_add_id_column( $columns ) {
$columns['revealid_id'] = 'ID';
return $columns;
}
@larodiel
larodiel / wp-images-default.php
Last active December 12, 2017 15:01
Wordpress image default change
function vl_default_image_size () {
return 'full';
}
add_filter( 'pre_option_image_default_size', 'vl_default_image_size' );
function vl_default_image_settings() {
update_option( 'image_default_align', 'center' );
update_option( 'image_default_link_type', 'none' );
update_option( 'image_default_size', 'full' );
}
@larodiel
larodiel / icegram.css
Created October 30, 2017 23:17
Icegram css reset
/** Popup **/
body .mfp-s-ready .ig_popup.ig_container {
border:1px solid transparent;
max-width: 740px;
background-color:#fff; /*Popup background color*/
}
body .mfp-s-ready .ig_popup.ig_container .ig_message {
padding: 0;
}
@larodiel
larodiel / custom-pagination.php
Created October 29, 2017 00:11
WP Custom Query Pagination
<?php
if(get_query_var('page')) {
$paged = get_query_var('page');
}
elseif(get_query_var('paged')) {
$paged = get_query_var('paged');
}
else {
$paged = 1;
}
# -----------------------------------------------------------------
# ver 1.1.0
#
# Change Log:
# 20160721 - First version
# 20171018 - error_log added
# -----------------------------------------------------------------
# ignore all files starting with . or ~
.*
@larodiel
larodiel / query.php
Created September 8, 2017 13:47
wordpress home query change
function home_query( $query ){
if( $query->is_home()
&& $query->is_main_query() ){
$query->set( 'posts_per_page', 5 );
}
}
add_action( 'pre_get_posts', 'home_query', 25 );
@larodiel
larodiel / json_ld_article.php
Last active October 11, 2018 15:15
Article Structured Data Wordpress
function json_ld_article() {
if(is_single()) {
global $post;
$user_name = get_bloginfo('name');
$article_title = get_the_title();
$excerpt = get_the_excerpt();
$post_author_id = (int)get_post_field( 'post_author', $post->ID );
if( get_the_author_meta('display_name', $post_author_id ) != "" ) {
$user_name = get_the_author_meta('display_name', $post_author_id );
function autogen_featured_img() {
global $post;
if (!has_post_thumbnail($post->ID)) {
$attached_image =
get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}