upload featured image in custom post type from frontend

You are using the wp_insert_attachment() function, which states the following in the Codex: This function is part of the low-level API used by WordPress for handling attachments. To perform the entire attachment upload and insertion process at once, you will want to use media_handle_upload() instead in most cases. So to automatically generate the image resizes … Read more

How do I create a way for users to assign categories to a post from the frontend of the website?

just remove this line update_term_cache($affected_terms); and it works perfectly <?php /* Plugin Name: WPSE Crowded Cats Plugin URI: http://wordpress.stackexchange.com/questions/43419/how-do-i-create-a-way-for-users-to-assign-categories-to-a-post-from-the-frontend Description: Allow visitors to change categories of posts. Ready to use with custom taxonomies and post types. Version: 0.1 Author: WPSE Author URI: http://wordpress.stackexchange.com/users/2110/maugly License: GPL2 */ add_action(‘plugins_loaded’,’wpse_init_crowd_cats_class’); function wpse_init_crowd_cats_class(){ new WPSECrowdCatsClass(); } class WPSECrowdCatsClass { … Read more

front end editing using iFrames, best approach?

Using a custom template and wp_update_post you should be able to build your own edit/add post pages in your sites frontend. There are also various plugins available that attempt to do similar things. iFrames can be done, but it will need some checks in functions.php to check for a get variable and add conditional stylesheets … Read more

Three level taxonomy dropdown frontend

After spending many hours using google I managed to make 3-level hierarchical taxonomy dropdown with ajax. Here is my code: searchform.php <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js” ></script> <script type=”text/javascript”> $(function(){ $(‘#apskritis’).change(function(){ var $apskritisSlug=$(‘#apskritis’).val(); // call ajax $(“#savivaldybe”).empty(); $(“#miestas_kaimas”).empty(); $.ajax({ url:”/wp-admin/admin-ajax.php”, type:’POST’, data:’action=get_savivaldybes&apskritis_slug=’ + $apskritisSlug, success:function(results) { //alert(results); $(“#savivaldybe”).removeAttr(“disabled”); $(“#savivaldybe”).append(results); } }); } ); $(‘#savivaldybe’).change(function(){ var $savivaldybeSlug=$(‘#savivaldybe’).val(); // … Read more

Using AJAX with Forms

Your add_action() calls for the AJAX handlers are too late. Add these hooks earlier, the best action is probably wp_loaded: add_action( ‘wp_loaded’, ‘register_ajax_handlers’ ); function register_ajax_handlers() { add_action( ‘wp_ajax_jp_ajax_request’, ‘jp_ajax_process’); add_action( ‘wp_ajax_nopriv_jp_ajax_request’, ‘jp_ajax_process’); } See also: Debug AJAX. This code should be placed in a plugin or in your theme’s functions.php.

Creating multiple enclosing shortcodes and fixing JS issues on click

Code:- function more_shortcode( $atts , $content = null ){ return ‘<div id=”more-outer-‘.$atts[‘id’].'”><a href=”#” id=”more-link-‘.$atts[‘id’].'”>More</a><div id=”more-inner”>’. $content .'</div></div>’; } add_shortcode( ‘more’, ‘more_shortcode’ ); Usage:- [more id=’1′]This is one.[/more] [more id=’2′]This is two.[/more] [more id=’3′]This is three.[/more] Output:- <div id=”more-outer-1″><a href=”#” id=”more-link-1″>More</a><div id=”more-inner”>This is one.</div></div> <div id=”more-outer-2″><a href=”#” id=”more-link-2″>More</a><div id=”more-inner”>This is two.</div></div> <div id=”more-outer-3″><a href=”#” id=”more-link-3″>More</a><div id=”more-inner”>This … Read more

RTL/LTR frontend switcher

Ok. I resolved it in this way. Let’s say that we have a CSS-file rtl.css, which contains rules for right-to-left content direction. Add menu items: Appearance->Menus->Select a menu to edit->Edit menus->Custom links. URL – ?language=rlt (or something like this), Link text – RTL (for example) URL – ?language=ltr, Link text – LTR Create a plugin: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)