Function to show random posts from a category

cleaned up syntax errors: <?php function titoloslide() { query_posts(array( ‘orderby’ => ‘rand’, ‘category_name’ => ‘testimonianze’, ‘posts_per_page’ => 1 )); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class=”testimonianzefurgonihome”><a href=”#” title=”Testimonianze noleggio furgoni KobalRent”><?php the_excerpt(); ?></a></div> <?php endwhile; endif; wp_reset_query(); } ?>

Custom Theme Want To Remove One Category From All Displays

The only solution I could imagine is removing, rewriting, replacing the meta box. // First remove the original one function wpse21483_remove_catbox() { remove_meta_box( ‘post_categories_meta_box’, ‘post’, ‘side’ ); } add_action( ‘admin_menu’, ‘wpse21483_remove_catbox’ ); // not sure about the hook function wpse21483_new_catbox() { // re-define – take a look at /wp-admin/include/metaboxes.php } // Hook the new one … Read more

Sort posts by newest child while keeping hierarchy intact

How do you retrieve and echo this structure in first place? I don’t think you can query by something like this (without some wicked SQL), so it would be probably easier to: Retrieve parent posts. Look up newest child (query, sort by date, limit to one). Reorder parent posts accordingly.

A way to detect which page a post is on

Alright, nevermind. I got this solved by doing this at the top of the single post template: $position_query = array( ‘post_type’ => ‘portfolio’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘numberposts’ => -1 ); $position_posts = get_posts($position_query); $count = 0; foreach ($position_posts as $position_post) { $count++; if ($position_post->ID == $current_id) { $position = $count; break; } … Read more

All my inserted images gets a link to the full image even if it is already full size image

The following code will empty the Link URL field when Full Size button is clicked. And fill the same field with the File URL value when other buttons are clicked. Tested with WordPress 3.4.2. Drop the code in your theme’s functions.php file or create a simple plugin for it. add_action( ‘admin_head-media-upload-popup’, ‘wpse_41539_add_remove_image_url’ ); function wpse_41539_add_remove_image_url() … Read more

Autoremove empty custom fields

I believe this was my solution to a previous question you had. I mentioned in that answer that the code didn’t deal with the eventuality of a key with multiple values and only some of which are empty. The reason why is how WordPress treats delete_post_meta… When using delete_post_meta, the first two arguments specify the … Read more