Skip to content

Instantly share code, notes, and snippets.

@axxe16
axxe16 / rss.php
Created January 27, 2023 11:51
Manipolazione del #FEED #RSS di #WORDPRESS aggiunta di CPT e TASSONOMIE
//ORDINA IL FEED
function ek_reverseorder($query_string)
{
return query_posts( $query_string . '&order=DESC&orderby=date' );
}
add_action( 'rss2_head', 'ek_reverseorder' );
//AGGIUNGE uno o più CPT al feed RSS
add_action('pre_get_posts', 'exclude_category' );
function exclude_category( &$wp_query )
@axxe16
axxe16 / query.php
Last active September 21, 2022 07:33
wp query per post pubblicati oggi #wp #wpquery
<?php
//query che recupera tutti i ctp di titpo evento pubblicati oggi
$today = getdate();
$args = array(
'date_query' => array(
array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday'],
),
@axxe16
axxe16 / redirects
Created February 18, 2021 13:52
Redirect htaccess #htaccess #Redirect
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@axxe16
axxe16 / protezione
Last active November 5, 2020 13:15
Protezione con Password di cartella tramite htaccess #apache #password #folder
1) creo file .htaccess dove
- AuthUserFile indica path del server in cui c'è la password
- AuthGroupFile indica il path del server relativo alla cartella da proteggere
AuthUserFile /home/www/fbsr/prod/test/.htpassword
AuthGroupFile /home/www/fbsr/prod/test/
AuthName "Directory Protetta"
AuthType Basic
<Limit GET>
require valid-user
@axxe16
axxe16 / template.php
Last active November 5, 2020 13:37
Loop che cicla una custom taxonomy e tutti i post relativi #loop #wp #custom_taxonomy #custom_type
<?php
$cat_ricette = get_terms( 'categorie' );
foreach ( $cat_ricette as $cat_ricetta ) {
$query = new WP_Query( array(
'post_type' => 'ricette',
'posts_per_page' => '-1',
'tax_query' => array(
array(
'taxonomy' => 'categorie',
'field' => 'slug',
@axxe16
axxe16 / functions.php
Last active November 5, 2020 13:10
Rimuove supporto ai TAG nei post #remove #tag #article #post
<?php
// Remove tags support from posts
// *****
function myprefix_unregister_tags() {
unregister_taxonomy_for_object_type('post_tag', 'post');
}
add_action('init', 'myprefix_unregister_tags');
@axxe16
axxe16 / scripts.js
Created September 25, 2020 12:24
verifica se un elemento fixed su un area #js #fixed #sniff #ishover #jQuery #js #javascript
//restituisce true quando elemento fixed passa sopra ad element
//fixed si passa così $("#rightMenu")
//element si passa sempre così $('#s02')
function isHover(fixed, element) {
var isHover = false;
if ( element.length ) {
var fixed_position = fixed.offset().top;
var fixed_height = fixed.height();
@axxe16
axxe16 / function.php
Created September 11, 2020 14:50
Recuperare campi ACF su immagini e allegati con WPML attivo #wpml #acf #attachment #immagini
<?php
if( ICL_LANGUAGE_CODE == 'it' ) {
$link = get_field('link_ita', apply_filters( 'wpml_object_id', $image['ID'], 'attachment', TRUE, 'it' ));
} elseif( ICL_LANGUAGE_CODE == 'en' ) {
$link = get_field('link_en', apply_filters( 'wpml_object_id', $image['ID'], 'attachment', TRUE, 'en' ));
}
@axxe16
axxe16 / css.css
Created September 2, 2020 14:25
goTop - pulsante torna su #gotop #up #js #button
.goUp {
position: fixed;
right: 20px;
bottom: 20px;
font-size: 30px;
color: $blue;
padding: 0 9.3px;
z-index: 999;
background-color: rgba(0, 0, 0, .3);
-webkit-border-radius: 8px;
@axxe16
axxe16 / style.scss
Last active July 28, 2020 14:10
Permette di trasformare il modal in un layer a tutto schermo #modal #bootstrap #fullscreen #css #bootstrap4
.modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
max-width: none !important;
.modal-content {
height: auto;
min-height: 100%;