WP Insert Post function – Insert Post Thumbnail

you need to first create the post and get the id: $postit = array( ‘post_title’ => $itemtitle, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_type’ => ‘items’, ‘post_author’ => $user_ID, ‘tags_input’ => $the_post_id ); $the_post_idit = wp_insert_post( $postit); Once you have the post id you can use update_post_meta( $the_post_idit,’_thumbnail_id’,$itemimage); just make sure that $itemimage holds the … Read more

Convert imploded plain text into links

<?php $categories = get_field(‘categories’); $elements = array(); foreach($categories as $category) { //do something $elements[] = ‘<a href=”‘ . $url . ‘” title=”‘ . $title . ‘”>’ . $name .'</a>’; } echo implode(‘,’, $elements); ?> at the //do something here you should find what the URL should be for your category/tag something like get_tag_link() might be … Read more

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(); } ?>

WordPress custom image size on custom field image

when you get image form post_meta, you get the path to the image, then you get do something like : <img src=”https://wordpress.stackexchange.com/questions/21718/<?php echo get_post_meta(ID,”customr field name’,true); ?>” width=200 height=200 />

Getting the dropdown menu to redirect to different pages?

ok so i figured it out… i changed the select to <select onChange=”this.form.submit()” name=”page_id”{$id} class=”$class”> so that name passed in the url gets changed to ?page_id which i want since that is the format i am using (default wordpress format), and then i called my page_by_title function (btw i had to change the name of … Read more

Overide a function that is inside a plugin

If there are hooks in the function, this is possible, if not, there may be pluggable functions, where you can replace their function with your own custom function. I have not seen pluggables in plugins frequently, but with most of the more popular plugins, you do see actions and filters. You may be able to … Read more