Skip to content

Instantly share code, notes, and snippets.

View marcosnakamine's full-sized avatar

Marcos Nakamine marcosnakamine

View GitHub Profile
@marcosnakamine
marcosnakamine / functions.php
Created March 28, 2017 18:37
WordPress - Add menu support
<?php
add_action( 'init', 'register_new_menu' );
function register_new_menu() {
register_nav_menus();
}
@marcosnakamine
marcosnakamine / functions.php
Created March 25, 2017 21:03
WordPress - Remove social share buttons from excerpts in Jetpack plugin
<?php
add_action( 'init', 'remove_excerpt_share' );
function remove_excerpt_share() {
if ( has_filter( 'the_excerpt', 'sharing_display' ) ) {
remove_filter( 'the_excerpt', 'sharing_display', 19 );
}
}
@marcosnakamine
marcosnakamine / index.php
Created March 22, 2017 20:44
WooCommerce - Google Merchant xml feed generator
<?php header( 'Content-type: text/xml' ) ?>
<?php echo '<?xml version="1.0"?>' ?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title><?php echo bloginfo( 'name' ) ?></title>
<link><?php echo home_url() ?></link>
<description><?php echo bloginfo( 'description' ) ?></description>
<?php
$query = new WP_Query( array(
@marcosnakamine
marcosnakamine / example_feed_xml_rss.xml
Created March 22, 2017 20:20
Google Merchant - Feed example in xml
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Example - Online Store</title>
<link>http://www.example.com</link>
<description>
This is a sample feed containing the required and recommended attributes for a variety of different products
</description>
<!--
First example shows what attributes are required and recommended for items that are not in the apparel category
@marcosnakamine
marcosnakamine / taxonomy-with-ids.pt-BR.txt
Last active March 30, 2017 21:15
Google Merchant - List of taxonomies for Brazilian products
# Google_Product_Taxonomy_Version: 2015-02-19
772 - Adultos
780 - Adultos > Armas
2214 - Adultos > Armas > Acessórios e cuidados para armas
503026 - Adultos > Armas > Acessórios e cuidados para armas > Acessórios e equipamentos de recarga
499857 - Adultos > Armas > Acessórios e cuidados para armas > Acessórios e equipamentos de recarga > Prensas para recarga de munição
505762 - Adultos > Armas > Acessórios e cuidados para armas > Caixas e suportes de munição
1822 - Adultos > Armas > Acessórios e cuidados para armas > Canhões elétricos
1783 - Adultos > Armas > Acessórios e cuidados para armas > Coldres para armas
499853 - Adultos > Armas > Acessórios e cuidados para armas > Correias para armas
@marcosnakamine
marcosnakamine / index.php
Created March 21, 2017 20:24
WordPress - Show login form in custom page
<?php
wp_login_form( array(
'redirect' => home_url(),
'label_username' => 'User',
'label_password' => 'Password',
'id_username' => 'user_login',
) );
@marcosnakamine
marcosnakamine / functions.php
Created March 21, 2017 20:00
WordPress - Add new user with custom role
<?php
add_action( 'wp_loaded', 'add_role_client' );
function add_role_client() {
add_role( 'client', 'Client', array(
'read' => true
) );
}
@marcosnakamine
marcosnakamine / index.php
Last active July 5, 2017 21:20
WordPress - Get current taxonomy
<?
var_dump( get_queried_object() );
/*OR*/
$terms = get_the_terms( get_the_ID(), 'taxonomy');
/*
@marcosnakamine
marcosnakamine / functions.php
Created March 15, 2017 14:19 — forked from claudiosanches/functions.php
WooCommerce - Redirect to checkout after add product to the cart
<?php
/**
* Add to cart redirect to checkout.
*
* @param string $url
* @return string
*/
function my_wc_add_to_cart_redirect_to_checkout( $url ) {
return wc_get_checkout_url();
@marcosnakamine
marcosnakamine / index.php
Created March 15, 2017 14:09 — forked from claudiosanches/page-template.php
WordPress - List all posts gruped by category.
<?php
foreach ( get_categories( array( 'orderby' => 'name', 'order' => 'ASC' ) ) as $category ) {
$posts = get_posts( array(
'showposts' => -1,
'category__in' => array( $category->term_id ),
'ignore_sticky_posts' => 1
) );
if ( $posts ) {
echo '<h4>' . __( 'Categoria:' ) . ' <a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a></h4>';
foreach ( $posts as $post ) {