Skip to content

Instantly share code, notes, and snippets.

View Matteo182's full-sized avatar

Matteo Ragusa Matteo182

View GitHub Profile
@Matteo182
Matteo182 / user_profile.php
Created April 3, 2020 17:36
Front_end profile page in WordPress
<?php
/**
* The template for displaying user profile in front_end
*
* This is the template that displays user profile in fron_end.
*
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
@Matteo182
Matteo182 / csv_to_json.php
Created March 30, 2020 11:17
converte csv to json
<?php
/**
* Template Name: from csv to create json
*
* Template for converte csv to json.
*
* @package understrap
*/
if ( ! defined( 'ABSPATH' ) ) {
@Matteo182
Matteo182 / set_ posts_per_page.php
Created February 13, 2020 09:06
Set the number of posts on the page for all site queries in WordPress
// Set the number of posts on the page for all site queries
function tdm_filter_pre_get_posts( $query ) {
$query->set( 'posts_per_page',9 ); // 9 post per page
return $query;
}
add_filter( 'pre_get_posts', 'tdm_filter_pre_get_posts' );
@Matteo182
Matteo182 / wordpress-breadcrumbs.php
Created January 20, 2020 12:28
show breadcrumbs in wordpress theme custom
// Breadcrumbs
function get_breadcrumbs() {
// Settings
$separator = '&gt;';
$breadcrums_id = 'breadcrumbs';
$breadcrums_class = 'breadcrumbs';
$home_title = 'Homepage';
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
@Matteo182
Matteo182 / .htaccess
Created December 5, 2019 15:36
REDIRECT PER LA CARTELLA /web di BEDROCK
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# REDIRECT PER LA CARTELLA /web di BEDROCK # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Add directives
RewriteEngine on
# Change root directory to “web” folder
RewriteCond %{THE_REQUEST} ^GET\ /web/
RewriteRule ^web/(.*) /$1 [L,R=301]
RewriteRule !^web/ web%{REQUEST_URI} [L]
@Matteo182
Matteo182 / cascade-select-comuni.html
Last active July 3, 2024 08:48
Select cascade Province italiane e comuni jquery
<-- Esempio parte in HTML -->
<div style="margin-top:3rem;" class="row">
<label for="billing_address">(È richiesto indirizzo completo)*</label>
<!-- select delle province -->
<div class="col-md-4 ">
<div class="form-group">
<select class="select form-control user-success" placeholder="Provincia" required="required" id="address_state">
@Matteo182
Matteo182 / active-menu-bar.js
Created September 12, 2019 10:40
Add class Active in navbar menu
$(function(){
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,'') + "$"); // create regexp to match current url pathname and remove trailing slash if present as it could collide with the link in navigation in case trailing slash wasn't present there
// now grab every link from the navigation
$('#box-menu a').each(function(){
// and test its normalized href against the url pathname regexp
if(urlRegExp.test(this.href.replace(/\/$/,''))){
$(this).addClass('active');
}
@Matteo182
Matteo182 / add_class_menu.php
Last active August 27, 2019 14:13
Add class activ in wp_menu
/* Aggiungo classe activ nel menu di navigazione di WP */
add_filter('nav_menu_css_class' , 'tdm_special_nav_class' , 10 , 2);
function tdm_special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@Matteo182
Matteo182 / book-filter.php
Created August 1, 2019 09:03
Plugin per WordPress per creare filtri per prodotti di Woocommerce con custom field, genera uno short code.
<?php
/*
Plugin Name: Book Filter
Description: Crea uno short code per applicare i filtri alla pagina Biblioteca
Version: 1.0
*/
/* Includo js in wordpress */
function enqueue_scripts(){
@Matteo182
Matteo182 / social_widget.php
Created July 12, 2019 09:39
Social share button widget for Wordpress
<?php
/************************** */
// social media sharing button
/************************** */
//creao una widget area
function tdm_social_post_widgets_init() {
register_sidebar( array(
'name' => __( 'Social in post', 'tdm_social' ),