insert thumbnail image from php script

You’ll want to take a look at wp_insert_attachment and wp_generate_attachment_metadata. You can’t insert a featured image/thumbnail using the_post_thumbnail – that function only gets the thumbnail for the current post. See: http://codex.wordpress.org/Function_Reference/wp_insert_attachment and http://codex.wordpress.org/Function_Reference/wp_generate_attachment_metadata

enumerating custom taxonomies?

get_tags is just a wrapper around the more general taxonomy function get_terms. So you’ll get the result you need with this: function execute_taxography() { $wpbtags = get_terms( ‘books’ ); $output.= ‘<div class=”grid”><div class=”taxography-grid”><ul>’; foreach($wpbtags as $tag) { $output.= ‘<li class=”item”><a href=”‘. get_term_link($tag->term_id, ‘books’ ) .'” style=”background-image: url(\’http://localhost/wordpress/wp-content/uploads/tags/’ . $tag->slug . ‘.png\’)”><span class=”count”>’. $tag->count .'</span><span class=”taxography-name”>’. … Read more

MySQL query in WordPress with AJAX

I would need to see your trigger function but it sounds like you just need to add event.preventdefault to the submit. This will block the page load while still executing AJAX. $(“form.searchCV_form”).submit(function(event){ event.preventDefault(); alert( “We’re not going anywhere now…” ); // j$.post… }); or $(“form.searchCV_form”).submit(function(e){ alert( “We’re not going anywhere now…” ); // j$.post… return … Read more

Why loop renders only last metabox from array? [closed]

Its because you are assigning your last array element to your class properties post_type,unicname,headline,fieldDisc Since the input is an array you are overriding the class properties again and again, only last array element is saved there(post_type,unicname,headline,fieldDisc). So what I would suggest is either store the whole array in one property or make each property an … Read more

Create 2-layered dropdown menus for custom taxonomy and custom post type

With a combination of jQuery / JavaScript and WP AJAX; you could look for an onchange event on the select box, send an ajax request to your admin-ajax.php with the year and then do a custom WP Query to return the html for the secondary drop down and append it to your dom. https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_%28action%29 http://api.jquery.com/jquery.ajax … Read more

the_post_thumbnail(); only works with fullsize images

You have to tell WP to generate this image sizes at first… Use function add_image_size and then “regenerate the thumbnails”: add_image_size( ‘custom-size’, 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode Note “custom-size” string which could be anything you want. https://developer.wordpress.org/reference/functions/add_image_size/ After that you can use the the_post_thumbnail function … Read more