Skip to content

Instantly share code, notes, and snippets.

@axxe16
axxe16 / function.php
Created January 7, 2020 09:04
Woocommerce snippet vari #woo #woocommerce #wp #customize
<?php
/*
* Remove "Add to Cart", il conteggio risultati e l'ordinamento
*/
add_action('wp', 'misha_remove_add_to_cart_product_categories' );
function ek_woo_rimuovo(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_before_shop_loop' , 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
@axxe16
axxe16 / cwgms
Created January 10, 2020 13:08
Pageview Conteggio visite #count #pageview #visite #wp
<?php
//per aggiornare le pagine viste
gt_set_post_view();
//per stampare il numero di visite
echo gt_get_post_view();
?>
@axxe16
axxe16 / piece-post.php
Created January 10, 2020 13:19
passa array a template_part #get_template_part #args #pass #wp
<?php $args = get_query_var('var_post'); ?>
<article class="post">
<h3><a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php echo the_excerpt(); ?>
<?php echo var_post['foo']; ?>
</article>
@axxe16
axxe16 / term.php
Created January 10, 2020 13:44
recupera term di una taxonomy nell'archivio #term #customtax #taxonomy #wp
<?php
// prima recupero l'id del termine poi recupero l'oggetto del termine corrente
$term = get_queried_object(); //recupero id term corrente
$tax_name = get_term_by( 'term_id', get_queried_object()->term_id, 'slugTax')->name;
@axxe16
axxe16 / DIVI
Created January 14, 2020 09:04
DIVI - varie #divi
Disabilitare Cerca: personalizza > header e navigaizone > elementi header
@axxe16
axxe16 / woocommerce.php
Created January 22, 2020 13:29
Woocommerce - aggiunta classi bootstrap a campi chekout #woocommerce #woo #wp #customize #filter
<?php
add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
function addBootstrapToCheckoutFields($fields) {
foreach ($fields as &$fieldset) {
foreach ($fieldset as &$field) {
// if you want to add the form-group class around the label and the input
$field['class'][] = 'form-group';
// add form-control to the actual input
$field['input_class'][] = 'form-control';
@axxe16
axxe16 / functions.php
Created January 28, 2020 11:09
Nascondere Wordfence in backend #wp #wordfence #backend #customize
<?php
//How to Hide Wordfence Security Admin Menus
function plt_hide_wordfence_menus() {
//Hide "Wordfence 0".
remove_menu_page('Wordfence');
//Hide "Wordfence 0 → Dashboard".
remove_submenu_page('Wordfence', 'Wordfence');
//Hide "Wordfence 0 → Firewall".
remove_submenu_page('Wordfence', 'WordfenceWAF');
//Hide "Wordfence 0 → Scan".
@axxe16
axxe16 / function.php
Created January 29, 2020 13:57
rendo ricercabile CPT #wp #search #customize
<?php
//aggiungo custom post type su cui effettuare la ricerca
function ek_add_post_type_to_search( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_search() ) {
$query->set(
'post_type',
@axxe16
axxe16 / template.php
Created January 29, 2020 14:10
limitare il cerca a un tipo di contenuto #wp #search #customize
<form class="searchform" role="search" method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input class="form-control search-autocomplete" type="text" value="<?php echo get_search_query(); ?>" placeholder="cerca" name="s" id="s">
<input type="hidden" name="post_type" value="prodotti" />
<button type="submit" id="searchsubmit" value="<?php esc_attr_x('Search', 'bst') ?>">Cerca</button>
</form>
@axxe16
axxe16 / js.js
Created January 30, 2020 11:10
animare le ancore #ancore #anchor #animation #animate #js
$(".scroll").click(function(event){
var offset = 40; //offset rispetto a posizione dell'ancora
//prevent the default action for the click event
event.preventDefault();
//get the full url - like mysitecom/index.htm#home
var full_url = this.href;
//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
var parts = full_url.split("#");