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

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

Hiding a php element from mobile browsers

This is more of a php question than a WP question, but there’s a great function here that does what you’re looking for. function is_mobile() { // Get the user agent $user_agent = $_SERVER[‘HTTP_USER_AGENT’]; // Create an array of known mobile user agents // This list is from the 21 October 2010 WURFL File. // … Read more

Woocommerce Custom CSV export

Ain’t this just a matter of opening the exported CSV with all products on their own row and doing a global search/replace of “carriage returns” for “commas“? This way you get the format in your example… Example: Item Name_01, Item Quantity_01, Item Variation_01, Item Amount_01, Item Total Price_01, Item Name_02, Item Quantity_02, Item Variation_02, Item … Read more

Wrong links in WordPress?

Go to Settings, then General Settings, then enter the correct url for your WordPress Address (URL). Perhaps you need to change your Site Address too. Source: The WordPress Codex: http://codex.wordpress.org/Settings_General_Screen If this isn’t the case, but the category links are bad, edit the category slug. Go to Posts, then Categories, select article and edit the … Read more