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

Radom post image/link based on custom taxonomy

<?php query_posts( ‘cat=36&post_type=athletes&showposts=1&orderby=rand’); ?> changed to : <?php $args = array( ‘numberposts’ => 36,’category’ => ‘1’,’post_type’ => ‘athletes’, ‘orderby’ => ‘rand’); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); ?> <h2><a href=”https://wordpress.stackexchange.com/questions/56381/<?php the_permalink(); ?>”><?php the_title(); ?></a></h2> <?php endforeach; ?>

Strange widget behavior

I am not seeing you registering the widget in this code. For inside of a theme: register_widget(‘WP_Widget_Mood’); For inside of a plugin: add_action( ‘widgets_init’, create_function(”, ‘return register_widget(“WP_Widget_Mood”);’) );

PHP Widget and do_shortcode

The problem was the double quotes which are needed in normal shortcode usage in posts and pages for some reason when using do_shortcode the double quotes in the attributes where breaking the function. Working code below <div> <?php $lat = get_field(‘woo_maps_lat’); $long = get_field(‘woo_maps_long’); echo do_shortcode(‘[forecast location=’ . $lat .’,’.$long. ‘]’); ?> </div>