background preloader

Wordpress

Facebook Twitter

How to Create WordPress Shortcodes | Nettuts+ Guía para entender los Shortcodes en Wordpress « ONtips.es – Aprende y comparte en Español. Ene Detalles del tutorial: * CMS: WordPress * Dificultad: media. * Tiempo estimado: 15-20 minutos. Imaginad que queréis crear una caja destacada donde destacar una información muy importante y queréis darle un aspecto diferente al resto del contenido.

Para este ejemplo, te tocaría ponerte en modo HTML a escribir código HTML y CSS para realizar esta funcionalidad. Además cuando quieras volver a destacar otro texto, tendrías que volver a repetir todo este proceso. Pensemos un poco, Bien, esto es posible gracias a los . Resumiendo, los Shortcodes es un conjunto de funciones creadas con un objetivo y que van a ser reutilizadas en nuestra web. Los shortcodes se crean dentro del archivo de nuestra plantilla, en el caso de que nuestra plantilla no tenga este archivo los crearemos para tal efecto. Si nos creamos nuestro propio archivo functions.php, recuerda añadirle el código de entrada y salida del lenguage PHP function caja_destacado( $atts , $content = null) if ( $content == null) return '' ; How to use WordPress shortcode outside in your theme files.

WordPress shortcode: Automatically insert image by file name. Shortcodes are always a good solution when you need to achieve a specific task. In this recipe, let’s see how we can insert an image in a post, simply by using a shortcode and the filename. The first thing to do is to paste this code on your functions.php file: function image_shortcode($atts, $content = null) { extract( shortcode_atts( array( 'name' => '', 'align' => 'right', 'ext' => 'png', 'path' => '/wp-content/uploads/', 'url' => '' ), $atts ) ); $file=ABSPATH.

"$path$name. $ext"; if (file_exists($file)) { $size=getimagesize($file); if ($size! Once done, you can use the image shortcode in your posts. [image name=cat] Will insert (with all proper attributes) cat.png from the /wp-content/uploads/ directory. Thanks to Rarst for his valuable contribution to WpRecipes! Extend WordPress With Custom Fields - Smashing Magazine. Advertisement WordPress’ popularity has grown exponentially as of late. This rise in popularity is due in part to WordPress’ custom fields. Custom fields allow you to add little bits of data to posts.

They have changed the way people look at WordPress. How exactly did these bits of data transform WordPress? The Custom Field Syntax In order to do more complicated things, you’ll need to understand the syntax. A real-world example: let’s say you run a blog about cameras. Displaying the field on the page is simple, too. <? (You might want to wrap this in a paragraph, ordered list or the like. Custom fields can be conditional, too. <? That’s the general syntax, and now the only limit is your imagination!

Spicing Up Post Titles Post titles are usually fairly boring. Using a conditional statement and custom fields, adding any HTML to your posts’ titles is now possible. You can add any HTML you like to your posts’ titles. <? An easy yet effective way to improve your website. <? <? <? <? <? (al) It's done. Global Custom Fields, Take Two. Just as I hoped, someone wrote in with a far nicer solution to my Global Custom Fields solution than I originally had. Big thanks to David Hollander for this. Options Table Turns out we can post values to options.php and literally save them right to the options table in the database. We can add a new settings panel right to our Admin area for doing this, and all it takes is a few lines of code.

Amazing. Just put this in your themes functions.php file: New Option in Settings Here is a screenshot showing the new "Global Custom Fields" option displayed in the WordPress menu: Click it, and you'll be taken to this form: This form is of course fully functional! Altering If you are familiar at all with HTML forms, you should have no trouble updating this to add and remove new areas. <p><strong>New Unique Value:</strong><br /><input type="text" name="newuniquevalue" size="45" value="<?

Then in the hidden input near the bottom of the form, add the new name to the list of values to submit: Usage. How to change WordPress editor font. Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías | emenia.es. * Copyright 2010 Matt Wiebe. * This code is licensed under the GPL v2.0 * * If you do something cool with it, let me know!

* Version 1.3 * === Changelog === * - Initial release * - Added feed support in URL rewrites * - Removed redundant post_class code. * - Removed redundant single post_type template code * - Introduced directory support for template files * - Use the newer, more robust labels array to set defaults * - Add possible support for adding post_type to nav_menus. . * SD_Register_Post_Type class * @author Matt Wiebe * @link * @param string $post_type The post type to register * @param array $args The arguments to pass into @link register_post_type()

. * @param string $custom_plural The plural name to be used in rewriting ( ). If ( ! Class SD_Register_Post_Type { private $post_type; private $post_slug; private $args; private $post_type_object; 'show_ui' => true,