Shortcode Variations?

function btn($atts, $content = null) { extract(shortcode_atts(array(‘link’ => ‘#’, ‘color’ => ‘teal’ , ‘size’ => ‘large’), $atts)); return ‘<a class=”btn ‘.$size.'” href=”‘.$link.'” style=”background:’.$color.’;”><span>’ . do_shortcode($content) . ‘</span></a>’; } With that function you get by default color teal and size large. I suppose that for size you are using classess and for color just background. If … Read more

Adding a filter to my posts

The excerpt must be used by the Theme. I don’t think it is. Use ‘the_content’ filter to append to the post. Excerpts are usually used in feeds and only by certain themes. add_filter(‘the_content’, function($content){ if(!is_archive()) return $content; global $post; // This is the current output post ob_start(); // Echo stuff to append to post here! … Read more

WordPress Comment functions

I do hope I understand what you’re asking, as you’re not giving much information. From what I specifically to customize the output of your comments. Well, there partially is. The wp_list_comments accepts a callback argument among several others. This callback allows you to run a custom function; in your case, a custom function to manipulate … Read more

Changing functions.php and .htaccess files

functions.php file is where you can do wonders with your theme without touching the core WordPress files. Most of the time the backup functions.php trick would work for you unless you aren’t changing anything in the database with any of your action or filter hooks. You could check this link too -> http://codex.wordpress.org/Theme_Development#Functions_File Regarding the … Read more

Echo custom field value in shortcode function

Try this code, I’ve removed query_posts and used get_posts instead because I’m not sure if query_posts will work in a shortcode and using get_posts is safer. function featured() { $posts = get_posts(array(‘post_type’ => ‘property’, ‘posts_per_page’ => 2)); if(isset($posts) && !empty($posts)) { foreach($posts as $post) { echo “<div class=\”singlefeatured group\”>”; //I wasn’t sure what you wanted … Read more

Add title & subtitle to shortcodes

function spoiler( $atts, $content = NULL ) { extract( shortcode_atts( array( ‘title’ => ‘default title’, ‘subtitle’ => ‘default subtitle’, ), $atts ) ); return ‘<div class=”moreinfo”><h3 class=”click drop subtitle”>’ .’Title:’.$title.’Subtitle:’.$subtitle. ‘</h3><div class=”morecontent”><p>’ .$content. ‘</p></div><!–/.morecontent–></div><!–/.moreinfo–>’; } add_shortcode( ‘spoiler’, ‘spoiler’ ); //[spoiler title=”title” subtitle=”subtitle”]content[/spoiler] Docs: add_shortcode, extract That should allow you to display the title and subtitle … Read more

How to Insert A List of Posts in A Category Written by the Author into the Author Archive

Not the most efficient way but it works, put this in your theme’s functions.php function author_post_breakdown($author_id){ //get all post of this author $n = get_posts(array( ‘author’ => $author_id, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’ ) ); $cats= array(); //loop over all post of this author and get the categories for each post foreach((array)$n as $id){ … Read more

Gallery Shortcode Function Help

The function you’ve supplied actually doesn’t look that bad. It’s almost the same way I’d handle the problem, however if you only ever want to modify the include part and always get the attachment_ids associated with the post, here is what I would do. I would actually create a new shortcode which in turn calls … Read more