Skip to content

Instantly share code, notes, and snippets.

View OscarAbadFolgueira's full-sized avatar

Oscar Abad Folgueira OscarAbadFolgueira

View GitHub Profile
@OscarAbadFolgueira
OscarAbadFolgueira / wp_query_excluir_post_actual.php
Last active May 21, 2019 12:17
WP_Query: Excluir el post actual
<?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
);
@OscarAbadFolgueira
OscarAbadFolgueira / wp-consulta-basica-01.php
Created September 7, 2018 16:36
Consulta básica y sencilla para mostrar los posts en una página de WordPress
<?php
//Argumentos de la consulta
$args = array(
'post_type' => 'post',
);
//Consulta basica de entradas
$query = new WP_Query( $args );
if ( $query->have_posts() ){
@OscarAbadFolgueira
OscarAbadFolgueira / oaf-create-post-with-code-final.php
Created November 28, 2017 06:24
Snippet that creates a WordPress post with code
<?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;
@OscarAbadFolgueira
OscarAbadFolgueira / oaf-check-posts-slugs-funcion.php
Created November 27, 2017 20:31
Function that checks all the WordPress Posts Slugs
<?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,
);
@OscarAbadFolgueira
OscarAbadFolgueira / oaf-create-post-with-code-1.php
Last active November 27, 2017 20:08
Crear un post de WordPress con código
<?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';
@OscarAbadFolgueira
OscarAbadFolgueira / wp_admin_custom_css-bueno.php
Created November 22, 2017 10:40
Añadir css al área de administración de WordPress - bueno
<?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.
@OscarAbadFolgueira
OscarAbadFolgueira / wp_admin_custom_css.php
Created November 22, 2017 10:31
Añadir css al área de administración de WordPress - 1
<?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'
<?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
@OscarAbadFolgueira
OscarAbadFolgueira / functions.php
Created September 25, 2017 17:55 — forked from amitramani/functions.php
[WooCommerce] How to add Custom Fields to Products
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',
/**
* 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 = '';