This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// snippet para exluir el post actual de la consulta o loop de WordPress | |
// author: Oscar Abad Folgueira. @oabadfol | |
// author-url: http://www.oscarabadfolgueira.com | |
$args = array ( | |
'post_type' => array( 'evento' ), | |
'posts_per_page' => '3', | |
'post__not_in' => array(get_the_ID()), // Excluir el post actual | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Argumentos de la consulta | |
$args = array( | |
'post_type' => 'post', | |
); | |
//Consulta basica de entradas | |
$query = new WP_Query( $args ); | |
if ( $query->have_posts() ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This script creates a WordPress post with code only once. | |
// author: Oscar Abad Folgueira. | |
// author-url: http://www.oscarabadfolgueira.com | |
// post-url: | |
function oaf_create_wordpress_post_with_code() { | |
// Set the post ID to -1. This sets to no action at moment | |
$post_id = -1; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Function that checks all the posts slugs | |
function oaf_post_exists_by_slug( $post_slug ) { | |
$args_posts = array( | |
'post_type' => 'posts', | |
'post_status' => 'any', | |
'name' => $post_slug, | |
'posts_per_page' => 1, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This is test snippet for learning purposes. | |
// Creates a WordPress Post with code. | |
$post_id = -1; | |
// Set the Author, Slug, title and content of the new post | |
$author_id = 1; | |
$slug = 'wordpress-post-created-with-code'; | |
$title = 'WordPress post created whith code'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // quitar esta línea | |
/* Snippet para añadir css personalizado al área de administracion de WordPress | |
* Segunda forma (la mejor, para mi). | |
*/ | |
// utilizamos 'admin_enqueue_script' para ejecutar la función | |
add_action( 'admin_enqueue_scripts', 'oaf_enqueue_custom_admin_styles' ); | |
// Función que registra el fichero css que hemos creado para tal efecto. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //esto podemos quitar | |
/* Snippet para añadir css personalizado al área de administracion de WordPress | |
* Primera forma (la no-mejor). | |
*/ | |
// Utilizadmos 'admin_head' para cargar el css | |
add_action('admin_head', 'oaf_admin_custom_css_1'); | |
// función que se ejecutará en 'admin_head' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Settings Tab Demo | |
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a | |
* Description: A plugin demonstrating how to add a WooCommerce settings tab. | |
* Author: Patrick Rauland | |
* Author URI: http://speakinginbytes.com/ | |
* Version: 1.0 | |
* | |
* This program is free software: you can redistribute it and/or modify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); | |
function woo_add_custom_general_fields() { | |
global $woocommerce, $post; | |
echo '<div class="options_group">'; | |
woocommerce_wp_checkbox( | |
array( | |
'id' => '_no_free_shipping_checkbox', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Only display minimum price for WooCommerce variable products | |
**/ | |
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); | |
function custom_variation_price( $price, $product ) { | |
$price = ''; | |
NewerOlder