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

Shortcode Attribute

yeah, you are kind in the right path, just need to know that the ‘title’ is a variable that will get and past the value, so you have to call it exactly where you wrote “DO I NEED SOME TEXT HERE”, so it goes like this: function column_shortcode( $atts, $content = null ) { extract(shortcode_atts(array( … Read more

Loop output for custom plugin [solution found]

The Solution to my problem is to simply let my plugins output run through the do_shortcode()-Function of WordPress as pointed out by this article: Using Shortcodes Everywhere I updated my plugin so it uses shortcodes, too, so now my output looks like this: // Add this upon plugin initialization add_shortcode( ‘dosomethingawesome’, array( &$this, ‘output_callback’) ); … 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

page url in shortcode

Depending on how the page’s query and loop are constructed, when you access the post object from the sidebar or footer, you sometimes get the last post in the loop rather than the page itself. You can ensure you’re getting the original (page) object by running wp_reset_query() from inside your widget (before you access the … Read more

get_posts displaying wrong permalink for “continue reading” link

You need to reset the post data after your get_posts loop since your calling setup_postdata. It would be better to remove the setup_postdata all together. global $post; $recent_posts = get_posts( $yourargshere ); foreach($recent_posts as $post) : $return = ‘<h4 class=”recent-post-title c0″>’ . $post->post_title . ‘</h4>’; $return .= ‘<p class=”recent-content c0″>’ . apply_filters( ‘the_excerpt’, $post->post_excerpt ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)