Facebook Twitter

How to Create WordPress Shortcodes. 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 . 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 Bien, ya sabemos qué es un Shortcode y dónde se archiva, ahora toca ponerse a practicar para realizar nuestro ejemplo en donde queremos crear una caja en donde destacar información relevante. Nuestro contenido. 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.

WordPress shortcode: Automatically insert image by file name

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.

Extend WordPress With Custom Fields - Smashing Magazine

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. A couple of years ago, WordPress was a blogging platform — a good one, but a blogging platform nonetheless. 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. 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 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 Now you can display the value of any of these things just by knowing the name: Possibly Related Posts. How to change WordPress editor font. Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías. * Copyright 2010 Matt Wiebe. * This code is licensed under the GPL v2.0 * * If you do something cool with it, let me know!

Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías

* 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.