title: Restrict other Admins from using Editor in Admin Panel

text: I am running a WordPress website. I want to assign other users roles like Admin, Editor, etc. I want them to be able to install plugins, themes, delete them, etc. The only thing I don't want them to do is access the "Editor" page. I don't want them to edit any core files directly , even if it is as small task as adding a CSS style. If they want to add anything, they will have to send those changes to me & I will upload those changes via FTP. So how can I restrict other Admin, Editor, etc. completely from accessing the "Editor" while restricting access to it myself? If restricting access will cause a global lockout and will also lock me out if I try to restrict them, I am willing to go for this option too, if the former is not possible. Can I achieve the above without using any plugin? If not, is there any plugin that will do the job for me? I have access to WordPress core files, FTP, etc. I can make any modifications needed. So a solution in this regard is highly appreciated.


title: Deregister default wp-admin css on login screen only?

text: I have a question about deregistering 'wp-admin' styles specifically on the login screen. If I just globally run:               <?php wp_deregister_style( 'wp-admin' ); ?>      my login screen will have no styles. If I run a function like:               function remove_default_styles() {         wp_deregister_style( 'wp-admin' );     }     add_action( 'admin_enqueue_scripts', 'remove_default_styles' );      this removes the styles successfully in the admin area, but not on the login page. However, if I run the same function with a login action, like so:               add_action( 'login_enqueue_scripts', 'remove_default_styles' );      it has no effect. Does anyone know how to deregister the default styles just on the login screen? Thanks


title: How to retreive terms associated with a custom post type?

text: Let's say I have a custom post type (e.g. `product`) and a custom taxonomy (e.g. `prod_cat`).   What I need to do is to get all my custom taxonomy terms associated with an object of my custom post type.   Here is how I do it inside the loop.               $terms = wp_get_object_terms(get_the_ID(),'prod_cat', array('fields'=>'slugs'));      But it's not working. It returns an empty array.


title: Adding page links to content that automatically convert to pretty permalinks?

text: Is it possible to insert links in Wordpress's wysiwyg editor that will convert to pretty permalinks when enabled? i.e. the links would be this without pretty permalinks: /?p=13 But with permalinks on, it would become this: /mypagename/ I'm thinking I'd have to use a shortcode to do that right? Something that would use the ID and wp_list_pages() for pages at least... just thinking about a way to get links in content to work when permalinks are on and off. Thanks osu


title: How do I add a class to every menu item automatically in a nav menu?

text:
At the moment I'm adding a button element around the menu anchors using this markup:               $defaults = array(         'theme_location'  => '',         'menu'            => 'main-nav',         'container'       => 'ul',         'container_class'    => 'nav navbar-nav',         'before'          => '<button class="btn btn-warning">',         'after'           => '</button>',         'menu_class'      => '',         'menu_id'         => 'menu',         'echo'            => true,         'fallback_cb'     => 'wp_page_menu',         'link_before'     => '',         'link_after'      => '',         'items_wrap'      => '
%3$s
',         'depth'           => 0,         'walker'          => ''     );     wp_nav_menu( $defaults );      How would I add the `btn btn-warning` classes to the menu links automatically? Here is an example of my site


title: why my menu is not appearing on the admin panel

text:
i am new to wordpress so you can except a lot insane coding below. What i want is to give one option in the adminpanel of wordpress to my client under the Pages->MergeImage. when the client will click on MergeImage option appearing under the Pages Widget i want to display him my custom form . To achieve all the above i followed the codex and ended up creating a plugin. below is the code for my plugin.               add_action('admin_menu', 'my_plugin_menu');          function my_plugin_menu() {         add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options');     }          function my_plugin_options() {         if (!current_user_can('manage_options'))  {             wp_die( __('You do not have sufficient permissions to access this page.') );         }         echo '
';         echo '
Here is where the form would go if I actually had options.
';         echo '
';     }      There is nothing else in this single index.php file inside the ImageMerger folder. When i activate the plugin i receive no errors but also dont see any menu. The below code is copy paste from the codex. So there shouldn't be any thing wrong with the code i think it must be some thing to add more into it which i am missing and i didn't find any good tutorial on wordpress to achieve this task. Please tell me what else is required ?


title: sort posts by alphabetic plugin suggestion

text: I am looking for plugin to sort posts by alphabetic orders.               Sort: A-Z Z-A Newest Oldest      and option to view per page like in stake exchange websites               Per Page: 20 40 60 All      if not exists, can i do this in **query post** (How ?) Please suggest me ! Thanks


title: Extend a class plugin

text: I can't get the user variable from the main class loading a "child class" example:               //PLUGIN FILE     class father{              var $user;              function __construct() {             add_action('plugins_loaded', array(&$this, 'loaded'));         }              function plugins_loaded(){             global $wp_get_current_user;             $this->user = wp_get_current_user();         }     }          $plugin = new parent();      That was the plugin file.               //EXTEND CLASS     class child extends father{              function __construct(){             parent::__construct();         }              function user_id(){             echo $this->user->ID;         }     }      That was the extend class.               //CONFIG FILE (DISPLAYED IN ADMIN PANEL)     $child = new child();     $user_id = $child->user->id;     $child->user_id();      And that was the config page. I can't get the user id in the extended class, but yes in the father class. Why and how i can solve it?


title: Javascript not working in admin

text: It seems that none of the javascript is working when I log into the admin section of my site. I cannot do anything that requires javascript or AJAX : Nextgen thumbnails, Widget organisation, even the admin menu doesn't work. The javascript in the front end of the site works as it should. I looked in firebug for the scripts and found this (obviously loaded in the footer):               <script src="http://kainielsen.web44.net/wp-admin/load-scripts.php?c=1&load=jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,hoverIntent,common,jquery-color,wp-ajax-response,wp-lists,jquery-ui-resizable,quicktags,jquery-query,admin-comments,postbox,dashboard,thickbox,plugin-install,media-upload&ver=e0f647a6df61adcc7200ce17a647db7f" type="text/javascript">      In some way wordpress seems to be trying to load all the scripts at once. Could it be this that is causing the malfunction? Is this normal Wordpress behaviour? Or could it have come about because I was using W 3 Total Cache ? The ultimate question is that if loading everything at once is the cause, How do I undo it?


title: Adsense: You have rejected ad requests, which will result in lost revenue

text: Got an alert on my adsense account which says > You have rejected ad requests, which will result in lost revenue. The > following ad units have made ad requests with incorrect site information. > This occurs when the URL of the server from which the ad unit has been > served differs from the URL of the actual page where the ad will be > displayed. Learn how to fix these errors. So the solution is that I'll have to use "google_page_url = "http://myurl.com/fullpath";" I'm using wordpress, what should be the URL for google_page_url? For example my website is www.technostall.com. Should I put www.technostall.com there or should I give the path of each post? That is not good because I'm using a sidebar widget for sidebar ad unit. I can't change google_page_url for each page. What should I do? This error is appearing only on my sidebar/navigation ad units. Is using google_page_url = document.location; fine?


title: How WP decide to show or not to show in admin panel the pop-up window with hint? Need a fix

text: To all newcommers the WP3.5 show the floating hint about new abilities of 3.5 version placed on top left coner of screen saying: **We 've combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what's new. {close}** after close-click the hint disapeared for good. And this was my case. but after use of Search&Replace plugin on my mysql database i got this banner again, and this time it is not clicable and still atached to top left corner unless i change screen for other wordpress activity i.e. apearance or something other than initial dashboard. I wonder where i do look for fix in database? I joined a screenshot of this banner (ru_RU) ![WP3.5 non-removable hint](http://u.askdev.ru/50e/f00b/e4df3b/medium.gif)


title: Query last updated posts (posts updated in the last 24 hours)

text: I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of posts that had been updated in the last day (24 hours from the time the query is done) Is this possible ? Is there any way to perform that query ? Thanks in advance


title: Make division in post_query?

text: I am new to both PHP and WP so I am struggling with one thing: I want to fetch all my post and then order it according to my meta-value "_mycounter" divided with the date in seconds from 1970 or what ever it was. I know `'orderby' => 'meta_value_num / date'` is not right but how can I solve this? Is there anyway to add division/multiplication calculation in the way I am asking for?               $query = array(       'orderby' => 'meta_value_num / date',        'meta_key' => '_mycounter',       'order' => 'DESC'     );     query_posts($query);


title: Display custom field value on woocommerce product page

text: I know similar questions have been asked dozens of times but I'm just not understanding how to display custom fields. I'm using woocommerce and want to display a custom field value on product pages. I add the custom field "current_promotions" and a value to a product, and have tried adding this to the content-product.php template, but I'm getting nowhere:               <?php $postid = get_the_ID(); ?>          <?php get_post_meta($post_id, $key, $single); ?>


title: CPT posts listed by category with custom rewrite URL, please help!

text: Here is what I'm trying to do: I have 10 total dessert recipes (in shared dessert category) that are divided by 2 custom post types. I want to create 3 different views of these posts with the custom URL structure described below:   1. Recipes 1-3 (CPT "a") with URL: "home/%posttype%/%category%/"   2. Recipes 4-10 (CPT "b") with URL: "home/%posttype%/%category%/"   3. Recipes 1-10 (all CPTs) with URL: "home/%category%/" I have searched far and wide for an answer that completes both the URL and content aspects of my goal, but everything I've tried only addresses one or the other. For example: For the content, I've used `get_posts()` parameters to view specific category and post type, but since the template is assigned to a "page" the wordpress generated URL does not include the custom post type and the result is: home/%pagename%/ For the URL, I've tried to use the init action to modify rewrite rules as suggested in this forum here and although this creates a URL structure exactly as I want it, the content output for the URL does not match what would be expected. The result is that all three URLs have all 10 recipes (essentially the general category archive page): "home/%posttype%/%category%/" is the same as "home/%category%/" and I can't figure out why. I've also added a filter to `pre_get_posts` to include my CPTs in the main query so that they show up at all. Not sure if there is a better way to do this in case it is interfering with the URL rewrite, although considering I took the code from the WP codex here under "Custom Post Types in the Main Query" I think the problem/solution is somewhere I don't seem to be looking. I can't imagine that what I want is supposed to be that complicated. Can anyone see what I'm missing? Thanks!!


title: get_posts() not working in functions.php

text: If I use the following function in any theme template, it works as expected. However when trying to use it within an AJAX function in my functions.php, it returns empty.               $args = array (             'numberposts' => 10,             'post_type' => array('topic','reply'),             'author' => 454         );     $user_posts = get_posts($args);      Any ideas? Here is the full function:               function he_delete_user(){              $args = array (             'numberposts' => 10,             'post_type' => array('topic','reply'),             'author' => 454         );         $user_posts = get_posts($args);              if (empty($user_posts)){             $response_array['status'] = 'false';                 echo json_encode($response_array);         }         else{             // delete all the user posts             foreach ($user_posts as $user_post) {                 wp_delete_post($user_post->ID, true);             }             $response_array['status'] = 'success';                 echo json_encode($response_array);         }     }     add_action('wp_ajax_he_delete_user','he_delete_user');


title: Limit a user to have access to only specified pages?

text: I have several users that I would like to put in user groups. The reason for this is each user group will have access to a specific set of pages or a specific custom post type. I would like to be able to limit each of the user groups to only have access (both by privilege and visibility) to the specific pages and post types that I choose. I'd like to have a section of checkboxes in each of the pages/posts that has each user group/role listed. If the user group isn't checked, they won't be able to see or edit anything else in the admin. These changes only apply to the admin. I want everyone to have access on the front end. Here's the code I have so far. I'm creating two different roles and assigning to them only specific capabilities. The intent here is for each of the roles to only be able to see/edit pages to which they are given explicit access. In other words, I'd like the admin to be completely empty for them with the exception of the pages they are allowed to edit. I don't even want them to be able to see the other pages in the admin. The code below adds the roles and assigns each of them the capabilities correctly, but they can both see all of the pages, and neither of them can edit any of the pages. I have custom meta associated with the pages they should be able to edit (i.e. 'allow_access'), and the meta returns an array of user ids that are allowed to edit the page. The meta works correctly and returns the array correctly, but the users are still not able to edit the page.               add_action('init', 'taylors_add_roles');     function taylors_add_roles() {         if(!$GLOBALS['wp_roles']->life_stages_children) {             add_role(                 'life_stages_children',                 __( 'Life Stages - Children' ),                 array(                     'read'         => true,                     'edit_posts'   => false,                     'delete_posts' => false,                 )             );         }         if(!$GLOBALS['wp_roles']->life_stages_students) {             add_role(                 'life_stages_students',                 __( 'Life Stages - Students' ),                 array(                     'read'         => true,                     'edit_posts'   => false,                     'delete_posts' => false,                 )             );         }     }          add_action('init', 'taylors_add_cap');     function taylors_add_cap() {         $custom_cap['life_stages_children'][] = 'edit_life_stages_children_pages';         $custom_cap['life_stages_children'][] = 'delete_life_stages_children_pages';         $custom_cap['life_stages_children'][] = 'delete_others_life_stages_children_pages';         $custom_cap['life_stages_children'][] = 'read_life_stages_children_pages';         $custom_cap['life_stages_children'][] = 'read_private_life_stages_children_pages';         $custom_cap['life_stages_children'][] = 'edit_others_life_stages_children_pages';         $custom_cap['life_stages_students'][] = 'edit_life_stages_students_pages';         $custom_cap['life_stages_students'][] = 'delete_life_stages_students_pages';         $custom_cap['life_stages_students'][] = 'delete_others_life_stages_students_pages';         $custom_cap['life_stages_students'][] = 'read_life_stages_students_pages';         $custom_cap['life_stages_students'][] = 'read_private_life_stages_students_pages';         $custom_cap['life_stages_students'][] = 'edit_others_life_stages_students_pages';              foreach ($custom_cap as $role => $caps){             foreach ($caps as $cap){                 if(!$GLOBALS['wp_roles']->role_objects[$role]->has_cap($cap)) {                     $GLOBALS['wp_roles']->role_objects[$role]->add_cap($cap);                 }             }         }          }          add_filter( 'map_meta_cap', 'taylors_map_meta_cap', 10, 4 );     function taylors_map_meta_cap( $caps, $cap, $user_id, $args ) {              /* If editing, deleting, or reading a page, get the post and post type object. */         if ( 'edit_pages' == $cap || 'delete_pages' == $cap || 'read_pages' == $cap ) {             $post = get_post( $args[0] );             $post_access = get_post_meta($post->ID, 'allow_access', true); //an array containing the users allowed to access this post.             $post_type = get_post_type_object( $post->post_type );                  /* Set an empty array for the caps. */             $caps = array();         }              /* If editing a page, assign the required capability. */         if ( 'edit_pages' == $cap && $post->post_type == 'page' && in_array(get_current_user_id(), $post_access) ) {             if ( $user_id == $post->post_author )                 $caps[] = $post_type->cap->edit_life_stages_children_pages;             else                 $caps[] = $post_type->cap->edit_others_life_stages_children_pages;         }              /* If deleting a page, assign the required capability. */         elseif ( 'delete_pages' == $cap && $post->post_type == 'page' && in_array(get_current_user_id(), $post_access) ) {             if ( $user_id == $post->post_author )                 $caps[] = $post_type->cap->delete_life_stages_children_pages;             else                 $caps[] = $post_type->cap->delete_others_life_stages_children_pages;         }              /* If reading a private page, assign the required capability. */         elseif ( 'read' == $cap && $post->post_type == 'page' && in_array(get_current_user_id(), $post_access) ) {                  if ( 'private' != $post->post_status )                 $caps[] = 'read';             elseif ( $user_id == $post->post_author )                 $caps[] = 'read';             else                 $caps[] = $post_type->cap->read_private_life_stages_children_pages;         }              /* Return the capabilities required by the user. */         return $caps;     }


title: Custom taxonomy page returns 404

text: Ive created a custom post type and a custom taxonomy. I can create new posts and assign those taxonomies, but it returns a 404 when I go to mydomain.com/mycustomtaxonomy/termslug Here is my code:               $labels = array(             'name' => _x('Videos', 'post type general name'),             'singular_name' => _x('Video', 'post type singular name'),             'add_new' => _x('Nuevo', 'portfolio item'),             'add_new_item' => __('Nuevo video'),             'edit_item' => __('Editar video'),             'new_item' => __('Nuevo video'),             'view_item' => __('Ver videos'),             'search_items' => __('Buscar videos'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'rewrite' => array("slug" => "video"),             'hierarchical' => true,             'menu_position' => 5,             'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')           );               register_post_type( 'videos' , $args );         flush_rewrite_rules();              // Register custom taxonomy              register_taxonomy("familia_videos", array("videos"), array("hierarchical" => true, "label" => "Categorias de Videos", "singular_label" => "Categoria de videos", 'rewrite' => true  ));      And my permalink structure: /%postname%/ Ive created: taxonomy-familia_videos.php Ive refreshed the permalinks structure, but I always get a 404. Any help ? Thanks


title: Help Tabs with: add_help_tab() callback - How does the argument work?

text: I just tried to add a simple help tab, from within a class (example to test below). I wanted to use a helper/callback fn to prepare the content for different help tabs. According to core, the function takes some args: > WP 3.3 /wp-admin/includes/screen.php LINE 722                    // If it exists, fire tab callback.          if ( ! empty( $tab['callback'] ) )             call_user_func_array( $tab['callback'], array( $this, $tab ) );      For some reason I get the complete `WP_Screen` object in the callback, instead of just the tab. See PasteBin here. Here's the example. For your convenience, as a plugin, so testing is easier (on post screens).               <?php     /**      * Plugin Name: Help Tab Test Case      * Plugin URI:  http://unserkaiser.com      * Description: Add Help Tab test case      */     class example_help     {         public $tabs = array(              'EXAMPLE' => array(                  'title'   => 'TEST ME!'                 ,'content' => 'FOO'              )         );             static public function init()         {             $class = __CLASS__ ;             new $class;         }              public function __construct()         {             add_action( "load-{$GLOBALS['pagenow']}", array( $this, 'add_tabs' ), 20 );         }              public function add_tabs()         {             foreach ( $this->tabs as $id => $data )             {                 get_current_screen()->add_help_tab( array(                      'id'       => $id                     ,'title'    => __( $data['title'], 'some_textdomain' )                     ,'content'  => $data['content']                     ,'callback' => array( $this, 'prepare' )                 ) );             }         }              /* HELPER */         public function prepare( $tab )         {     error_reporting( E_ALL );     // FAILS: return blank     // _dump( $tab['tabs'] );     // No error output on screen     var_dump( $tab );          // I can dump it using my own function,      // that adds the data to a global and then calls & prints it on shutdown     // See pastebin for content     // _dump( $tab );             return printf(                   '<p>%s</p>'                 ,__( 'test', 'dmb_textdomain' )             );         }     }     add_action( 'load-post.php', array( 'example_help', 'init' ) );     add_action( 'load-post-new.php', array( 'example_help', 'init' ) );      ### Edit: If I just output `print $tab` in the callback, I get `Array` as output string _above_ the actual content (`WP_Screen` is an object). I tried dumping all parts of the array without any result (white screen, no error).


title: Include print style sheet

text: How do I properly link a print style sheet? All my styles have been enqueued through functions file. The codex suggested I put the link in the header but this didn't work, is there a core print stylesheet? I tried to create a link in the header but I see any of these styles? I do see the print.css file in the header when I look at the source. /css/print.css" type="text/css" media="print" />


title: How to add template to theme in WP

text: I've _very_ new to WP and I'm trying to setup a new page which displays only a specific category through the WP admin section. I've downloaded the ACE plugin and I've managed to filter out posts with a specific category from the main page. Now I want to create a separate page which displays only this category, but I can't work out how to add a new template to the theme through the online editor, in order to show these posts. I'm using the Clean Home theme. Can someone help me work out how to do this? do I need to ssh in to the server to create a file, or is there some way of doing this through the admin console?


title: Malware on site

text: Hi when I try to enter my site I get redirected to another site. IT appears the htaccess file has been changed. When I scan the site with Sucuri I get this error Known javascript malware. Details: http://sucuri.net/malware/malware-entry-mwhta7 Location: http://ca- no.ru/example/status.php How do I fix this permanently? I already had this problem last week and reset the htaccess file, however it happened again.


title: Newly created category does not show category

text: I'm creating New Posts in WordPress when i try to add New category and click on Add Category its does not show created category so default category used as category Its create create category but not showing in category list in new post page. I don't know whats the problem.


title: How do I aproach this?(for sale, for lease, sold->move something from a category to another)

text: First of all, I really apologize for the title of this question. I'm currently working on a real estate wordpress theme for that will feature ads from the town that I live in. I basically want to have 3 categories: for sale, for lease and sold and to be able to move let's say a post(house add) from one category to another category. Each category should have a page where each house that's currently on that category is shown as an excerpt(like the blog index page) The thing is I don't know how to aproach this? (I'm a beginner developer). Should I store the house ads in pages or posts. Should I have special page templates? Could someone give me a set of steps that I need to follow in order to achieve this? (looking for some plain English advice, not code). Thanks!


title: Ascending sort order for monthly & category view, i.e. ?m=201204, ?cat=4

text: I have my posts ordered ascending (from oldest to newest) because I use Wordpress as a website to accompany a book published based on the original blog. To do this I put the following code just before The Loop in index.php of my custom version of the Connections theme:               <?php         $wp_query->set('orderby', 'post_date');         $wp_query->set('order', 'ASC');         $wp_query->get_posts();     ?>      This works fine for the main index and for when the posts are displayed by page, i.e.:   `index.php?paged=1` However, when the posts are retrieved by month or by category, the sort order defaults to DESC, i.e.: http://www.justanothersoldier.com/?cat=4 http://www.justanothersoldier.com/?m=200312 I just want everything to always be ASC. Are there monthly and category templates I need to edit? Thanks.


title: Aggregate multisite RSS and restrict certain content

text: As the title says, I've got a multi-site setup with 18 sites and would like to combine the RSS feeds from all sites into the root site's feed. The other feeds can still exists, that's not a problem. Additionally, I'd like a way in the admin (on page/post edit, perhaps), to exclude certain posts from the feeds. In addition to a custom plugin containing all the specialty widgets and core function overrides, we're using a heavily customized theme as well. I'm using this code in my functions.php to pull all content types into RSS:               function custom_post_feeds($qv){         if (isset($qv['feed']))             $qv['post_type'] = get_post_types();         return $qv;     }     add_filter('request', 'custom_post_feeds');      Any ideas?


title: title not being printed within html tag

text: I am wrapping html tags around `the_title();` like               if(has_post_thumbnail()) {        the_post_thumbnail('home-thumbs');        echo "".the_title()."";      }      But the `the_title` is printing above `<span>`, not like what i want. am i missing something? or doing something wrong?


title: Load jQuery inside Page Template

text: This is rather basic, and maybe it's a duplicate question, so let me know where exactly is answered in that case. I need to add a very simple jQuery script inside my Page Template. I'm using Openstrap theme and I can see that jQuery is loaded on every page, so I thought I could insert my script normally but doesn't work. After reading some posts, I've seen that I have to use `wp_enqueued_script` function, however I just need to load the script on the Page Template only, not every page. * * * **edit** It worked! I changed it to is_singular($post_type) for my needs, and it works as expected. However, the jQuery script isn't doing anything. Inside functions.php,               /* loader iframes */     function loader_iframe() {     if ( is_singular('farmacia') ) {             wp_enqueue_script( 'loader-iframe', get_template_directory_uri() . '/js/loader-iframe.js', array( 'jquery' ));         }     }          add_action( 'wp_enqueue_scripts', 'loader_iframe' );      Inside js/loader-iframe.js,               $(function() {         $('.loader-iframe').on('load', function(){             $('.loader-iframe').find('img').hide();         });     });


title: Loading Images from Javascript on the Front End

text: I'm getting some 404 errors on image paths in this plugin I'm building. I'm trying to build a plugin that has some Javascript and images (like a close icon and a progress bar) that I want to load on the frontend. I found the proper technique to enqueue jQuery, and then the proper technique to register and enqueue my jQuery script I made. The only trouble is that the jQuery needs to load an image like a close icon and a progress bar. I am told that I can't rely on relative paths in various blog situations, and also put the image in the same directory as the script. Everything fails to load those images -- I get 404s because WordPress gets the paths wrong. Sure, I can specify something like...               jQuery('#test').css('background','transparent url(wp-content/plugins/myplugin/closer.png) 0 0 no-repeat');      ...but the wp-content/plugins/myplugin/closer.png path is unreliable in some ways that people setup their blogs. What's the technique to get my front-end jQuery component to load these images without 404 errors and without hard-coding a path? I mean, does WordPress automatically inject some kind of path global constant in jQuery that I can pick up and use?


title: How to make slider show 4 recent news and news start from begining not from 4th

text:
I am kinda new to wordpress and I wanted to know how to make my wordpress site to show recent 4 news in this slider and again all news below:                   class s_naujienos extends WP_Widget {              function s_naujienos() {             $widget_ops = array('classname' => 's_naujienos', 'description' => 'Naujienų slideris');             $this->WP_Widget('s_naujienos', 'Naujienų slideris', $widget_ops);         }              function form($instance) {             $instance = wp_parse_args((array) $instance, array('title' => ''));             $title = $instance['title'];             ?>
<label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
<?php                 }                      function update($new_instance, $old_instance) {                     $instance = $old_instance;                     $instance['title'] = $new_instance['title'];                     return $instance;                 }                      function widget($args, $instance) {                     extract($args, EXTR_SKIP);                     echo $before_widget;                     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);                     if (!empty($title)) {                         echo $before_title . $title . $after_title;                     }                     if (have_posts()) {                         //$count_posts = wp_count_posts();                         //$published_posts = $count_posts->publish;                         $naujienu_sk = 4;                         ?>                                                   <link rel="stylesheet" href="./css/foundation.css" type="text/css" media="screen"/>
                     <img onclick='newsslider.left()' class='snauj_left' src='<?php echo get_template_directory_uri(); ?>/img/nauj_left.png'/>                     <img onclick='newsslider.right()' class='snauj_right' src='<?php echo get_template_directory_uri(); ?>/img/nauj_right.png'/>                                 <div style='width: <?php echo $naujienu_sk * 500; ?>px; height: 282px;'>                         <?php                         $counter = 0;                         $argum = array('numberposts' => $naujienu_sk);                         $recent_posts = wp_get_recent_posts($argum);                         foreach ($recent_posts as $recent) {                             the_post();                             $counter++;                             ?>                             <div id='snauj<?php echo $counter; ?>' style='width: 500px; height: 282px; display: inline-block; position: relative; color: #fff; float: left; background: #000;'>
<?php the_title(); ?>
                                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                                     <?php     //add_image_size('my_image_media', 600, 338);     //add_image_size( 'category-thumb', 300, 9999 );     //set_post_thumbnail_size( 500, 282 );                                          the_post_thumbnail('large', array('class' => 'wp-caption')); // Declare pixel size you need inside the array the_post_thumbnail('newsslider-size');                                       ?>
                             <?php                         }                         ?>

<?php             }          //echo get_bloginfo("template_url");                   echo $after_widget;         }          }          add_action('widgets_init', create_function('', 'return register_widget("s_naujienos");'));


title: Separate Editing from Publishing for pages

text: My site is made of "pages". Those page are static, but my team is going to modificated those pages frequently. I would like to have several authors and one editor. The authors edit content, but cannot publish it. The edito can edit content, but mainly validate and publish changes. I was not able to do that. One more thing, it would be great to separate my pages in section, so that each author can edit pages in his assigned section. I could not find a way to do it in WP. I use WP 3.9.2 Tx !!!


title: How to paginate a list of tags

text:
I have a page that displays a list of all tags of my blog. Iuse this code which works fine:               <?php     $poststocount=get_tags($args);     echo '
Alphabetic Index of All '
';     ?>          <?php     $taxonomy = 'post_tag';     $tax_terms = get_terms($taxonomy);     ?>
     <?php     foreach ($tax_terms as $tax_term) {     echo '
' . 'name ) . '" ' . '>' . $tax_term->name.'
';     }     ?>
      Question: how can I paginate this lidt (say 40 per page). What would the code to accompish that, preferably with an option to "see all tags". Thanks.


title: foreach loop pagination for taxonomy blog category

text:
I have a wordpress website running in which I have a blogs page where I display all the blogcategories using the following code               <?php                      $taxonomy = 'blogcategory';                 $tax_terms = get_terms($taxonomy);     ?>                  <?php                 foreach ($tax_terms as $tax_term) {                     $cat_image = z_taxonomy_image_url($tax_term->term_id);                          echo '
';                     if (!empty($cat_image)): ?>                     <a href="<?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?>">                         <img style="float: left; margin-right: 10px;" src="<?php echo z_taxonomy_image_url($tax_term->term_id); ?>" />                                         <?php endif;                        echo '
name ) . '" ' . '>' . $tax_term->name.'

'.$tax_term->description.'

';                 }          ?>      This is working properly. It lists all the blogcategory. My problem is I am not able to do a pagination, so that I have not more than 10 blog categories listed on the single page. Hope I made it clear. I am new to wordpress. Any help would be highly appreciated.


title: WP_list_table unhideable columns

text: So I have managed to setup a custom WP_list_table in my theme as per the tutorial here. I really love the fact that you can make the columns hide-able, and I have manage to implement that. What I would like to know is how to make individual columns so that it is impossible to hide them.


title: Page to show custom posts and one category

text: I want to show all my custom posts and category `ID=15` in a page. I managed to call my custom posts as follows:               $type = 'my_custom_posts';         $args=array(           'post_type' => $type,           'post_status' => 'publish',           'posts_per_page' => 5);      How do I get to call, besides `my_custom_posts`, category `ID=15`, which is only for normal posts?


title: Get taxonomy on publish

text: I'm not seeing exactly what I'm looking for, so forgive the potential repetitive question. On publish_post, I'd like to check the current post's taxonomies and do something with them. However, the publish_x hook seems to happen before the taxonomies have been set. Does anyone have a solution to grab this information?


title: Add code to header based on category for specific posts?

text: ![enter image description here](http://i.stack.imgur.com/UhErM.png) Hello all! I'm trying to add as you'll see in the image attached a small huffington post icon and accompanying text to some posts on my blog. I'd like to set up a category "Huffington Post" and when this category was checked for a new post, it would add the "As Published on.." text and Huff Post icon to the post. I don't want this code on every post just the posts that are denoted by this category. Any help is much appreciated! Cheers!!!


title: disable email notification for specific page

text: I would like to make the page with id = 2 that do not get notification mail that the message was written because I have on this page of me made to automatically approve comments. so i dont need notification mail


title: strip_tag not working in header.php

text: Used code I found on css tricks to remove the li tags from wp_nav_menu.               $menu_parameters = array(     'container'       => false,     'echo'            => false,     'items_wrap'      => '%3$s',     'depth'           => 0,     );          <?php echo strip_tags(wp_nav_menu( $menu_parameters ), '<a>' ); ?>      I placed $menu_parameters in functions.php and called it in my index file and everything was working great until I separated my index files into their appropriate php files. After I moved the strip_tag function into the header.php and then called it using get_header, the nav now falls back to the wp default. Any ideas?


title: Sanitising post content for use in an email

text: I'm sending the content of a custom post type in a plaintext email (it's to send competition entries to a panel of judges), so I need to make sure that `$post->post_content` is correctly sanitised first. Is there a filter I can use for this, or if not, what sanitisation do I need to do? Update: I've just found `wp_strip_all_tags` in `wp-includes/formatting.php`, is this what I need?


title: Wordpress admin not working with domain name

text: I had wordpress site on LAMP server without domain name mapping. I am able to access site with IP `http://192.237.169.17` without any issue. `http://192.237.169.17` pointing to sub-domain folder on server But now after mapping domain name I am able to access front end but admin showing blank page with domain name, but with IP both working. Checked view source it's showing some iframe with reference to IP. I have also tried to update all links in database with domain name but still same issue. Also, tried with dedug true but showing no error message, in error log as well. domain name is deals.anilabsinc.com working with both ip and domain name deals.anilabsinc.com/wp-admin not working but working with IP `http://192.237.169.17/wp-admin` I think, I am new to wordpress so am not able to figure out this issue. still looking for it. Please help me to solve this issue. Let me know if any other detail is required.


title: Get a submitted value from front end post form for single template

text: I'm using Wordpress Form Manager to allow users to post from the front end and I need to place values for the post in different spots in a single post template. The code they offered doesn't return anything in or outside the loop. For instance I need to put the url of the file upload into a script to play a song. The tutorial says use this function but it doesnt return anything. Anyone have any experience with it?               <?php fm_summary_get_item_value('song-mp3'); ?>      Update: Still stressing over this. I tried something I found in a thread that somebody said allowed them to turn a value into a custom field but it doesn't seem to work the way I have it.                function my_custom_field($postID) {     $my_custom_field_value_var = fm_summary_get_item_value('song-mp3');     $my_get_lastID = wp_get_recent_posts('1');     $my_thePostID = $my_get_lastID['0']['ID'];     add_post_meta($my_thePostID, 'song_mp3', $my_custom_field_value_var, true);     }     add_action('fm_form_submission', 'my_custom_field');


title: Switching themes without losing widgets?

text: The other day, I switched from 2010 default them to Semiologic, then back. When back to the 2010, all my appearance/widgets had gone back to the default. Does this often happen? What is the best practice? Should I always do a database backup before trying new themes, then restore if I don't like it? Or is there something simple I might have missed?


title: Filter content by custom field and category

text:
Im trying to filter an Wordpress request with 2 parameters.   1. by a custom field (REGION) there are 6 regions    2. by categorie, there are n-categories with 1 value per post. As result i would like to have all posts with by example region 1 and categorie 5(if region 1 AND categorie 5 is true for this post). It workes not optimal.... but the main problem I have is: I would like to get an html <select> with any categories in region 1. it should look like this:               region1,       5       3       8      but it looks like:               region1,       5       5       5       3       8       3       8       8      Here are the problemarea of my code:               $selectsql = "                  SELECT                  wterms.*                      FROM $wpdb->posts wposts                         INNER JOIN $wpdb->term_relationships AS tr ON (wposts.ID = tr.object_id)                         INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)                         INNER JOIN $wpdb->terms wterms ON (tt.term_id = wterms.term_id)                         INNER JOIN $wpdb->postmeta wpostmeta ON (wposts.ID = wpostmeta.post_id)                      WHERE wposts.post_status = 'publish'                     AND tt.taxonomy = 'th5'                     AND wpostmeta.meta_key= '_sprachgruppen'                 GROUP BY tt.taxonomy                  ";                       $select_output = $wpdb->get_results($selectsql,OBJECT);      And here are the complete code, I am using by now. I hope, someone can understand my problem an can help me.               <?php       global $wpdb;      global $post;            if(isset($_POST[gruppe])){      $sprachgruppe = $_POST['gruppe'];      }           if(isset($_POST[gruppe]) && isset($_POST[sprache])){      $sprache = $_POST['sprache'];      }           ?>      <form action="<?php //$_SERVER['PHP_SELF']; ?>" method="post" class="liedsuche" accept-charset="utf-8">     Liedsuche:          <select name="gruppe" id="sprGr">             <option value="0" <?php if($_POST[gruppe]==0){echo"selected=\"selected\"";} ?>  >Alle Sprachgruppen</option>             <option value="1"  <?php if($_POST[gruppe]==1){echo"selected=\"selected\"";} ?>  >I LATEIN UND ROMANISCHE SPRACHEN</option>             <option value="2"  <?php if($_POST[gruppe]==2){echo"selected=\"selected\"";} ?>  >II GERMANISCHE SPRACHEN</option>             <option value="3"  <?php if($_POST[gruppe]==3){echo"selected=\"selected\"";} ?>  >III  BALTISCHE SPRACHEN</option>             <option value="4"  <?php if($_POST[gruppe]==4){echo"selected=\"selected\"";} ?>  >IV SLAWISCHE SPRACHEN</option>             <option value="5"  <?php if($_POST[gruppe]==5){echo"selected=\"selected\"";} ?>  >V KELTISCHE SPRACHEN</option>             <option value="6"  <?php if($_POST[gruppe]==6){echo"selected=\"selected\"";} ?>  >VI VEREINZELTE INDOGERMANISCHE SPRACHEN</     option>              </select>                              <select name="sprache">             <option value="0">Alle Sprachen</option>                  <?php             $selectsql = "                  SELECT                  wterms.*                      FROM $wpdb->posts wposts                         INNER JOIN $wpdb->term_relationships AS tr ON (wposts.ID = tr.object_id)                         INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)                         INNER JOIN $wpdb->terms wterms ON (tt.term_id = wterms.term_id)                         INNER JOIN $wpdb->postmeta wpostmeta ON (wposts.ID = wpostmeta.post_id)                      WHERE wposts.post_status = 'publish'                     AND tt.taxonomy = 'th5'                     AND wpostmeta.meta_key= '_sprachgruppen'                 GROUP BY tt.taxonomy                  ";             $select_output = $wpdb->get_results($selectsql,OBJECT);           if ($select_output){          foreach ($select_output as $post){             setup_postdata($post);           if(isset($_POST[gruppe])){             $option .= '<option value="'.$post->term_id.'"';             $option .= ' >';             $option .= $post->name;             $option .= '</option>';      }           echo $option;              }                }else{              echo "leider leer";           }                   ?>         </select>         <input type="submit" name="auswahl" value="Auswahl">

      </form>                     <?php      if ($_POST[sprache]!=='0') {  // if language is selected           $querystr = "          SELECT            wposts.*,         wterms.*              FROM $wpdb->posts wposts                 LEFT JOIN $wpdb->term_relationships AS tr ON (wposts.ID = tr.object_id)                 LEFT JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)                 LEFT JOIN $wpdb->terms wterms ON (tt.term_id = wterms.term_id)                 LEFT JOIN $wpdb->postmeta wpostmeta ON (wposts.ID = wpostmeta.post_id)              WHERE wposts.post_status = 'publish'             AND tt.taxonomy IN ('th4', 'th5')             AND tt.term_id IN ($sprache)             AND wpostmeta.meta_key= '_sprachgruppen'             AND wpostmeta.meta_value= $sprachgruppe         GROUP BY wposts.ID          ";                  }else if($_POST[sprache]=='0'){      $querystr = "          SELECT            wposts.*,         wterms.*              FROM $wpdb->posts wposts                 LEFT JOIN $wpdb->term_relationships AS tr ON (wposts.ID = tr.object_id)                 LEFT JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)                 LEFT JOIN $wpdb->terms wterms ON (tt.term_id = wterms.term_id)                 LEFT JOIN $wpdb->postmeta wpostmeta ON (wposts.ID = wpostmeta.post_id)              WHERE wposts.post_status = 'publish'             AND tt.taxonomy IN ('th4', 'th5')             AND wpostmeta.meta_key= '_sprachgruppen'             AND wpostmeta.meta_value= $sprachgruppe              GROUP BY wposts.ID          ";             }                  $postids = $wpdb->get_results($querystr,OBJECT);           if ($postids){               $tab= "
";         foreach ($postids as $post){             setup_postdata($post);                  // ermittelt das aktuellste attachment(PDF) der Seite             $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND      post_type='attachment' ORDER BY post_date DESC LIMIT 1");                       $tab .= "
";             $tab .= "";             $tab .= $post->post_title;             $tab .= "	";             $tab .= "PDF Download $sprachgruppe";             $tab .= "	";             $tab .= "
\n";              }              $tab .= "
";           echo $tab;                }else{              echo "leider leer";           }                      ?>


title: How can I use a sliced image As banner?

text: I am giving a try to something i have never done before. I am trying to slice a psd file and want to use it as a banner. But the problem is, as you may already know that, wordpress only allow one image as banner, so how can I use sliced psd as banner? If coding is needed, can you give me some hints, so that I can make a try over it.


title: How to make the post summary taller?

text: right now our posts on the landing page are only showing 2 lines of the content. How can I get the posts to show 5 lines of the content each?


title: Why is "/page/2/" not working?

text: Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work?               <?php     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query();     $wp_query->query('post_type=videos&showposts=1'.'&paged='.$paged);          while ($wp_query->have_posts()) : $wp_query->the_post();       //display stuff     endwhile;                     php  wp_pagenavi();      ?>


title: php include returns 1 as output with other outputs

text: I have this code               $return = include(TEMPLATEPATH . '/apex.php' );          $html .= $return;      I using the above code to get a php for from a plugin from theme dir. but it returns 1 with the other wanted outputs. how to solve this I have seen the other question on stackoverflow but those hasn't work thanks in advance


title: wordpress taxonomy in regular posts

text: I have a custom post type and taxonomy so the user can post in a specific areas in the theme. User (admin) can add categories easily. But the categories that has been added through my taxonomy don't show up in wordpress regular posts category option. I do not have any problem with displaying those posts on theme. My problem is to showing those custom categories in regular post's category option. Is there a way to make ; a custom category created by taxonomy to be shown in **wordpress regular post's category section**?


title: Replace do_action() with a normal submit form in comments.php

text: In my comments.php I have this code:                <input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />      <?php comment_id_fields(); ?>      <?php do_action('comment_form', $post->ID); ?>      Is there a way to replace this code whit a simple submit form? and not use: do_action() ?


title: Redirect user to a custom url after submitting the comment

text: After someone submits a comment this line of codes redirects him to the post (i believe). Can I modify the code in order to redirect him to a custom URL? do_action('comment_form', $post->ID) Ty for the answer, UPDATE: my comments.php               <form>        .......       <input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />       <input type="hidden" name="my_redirect_to" value="http://www.google.com"; />       <?php comment_id_fields(); ?>       <?php do_action('comment_form', $post->ID); ?>       </form>      my functions.php               add_action('comment_post_redirect', 'redirect_to_thank_page'); // Redirect to thank you post after comment        function redirect_to_thank_page() {            if ( isset( $_POST['my_redirect_to'] ) )             return $_POST['my_redirect_to'];         }      The code does not work, it's not redirecting to google.com for example. Any ideas why? Ty


title: Display custom field if it exists and has a specific value

text: I am trying to display the post title if the custom field exists and has a value of apple...               <?php if ( isset ( get_post_meta($post->ID, 'mycustomvalue', true ) ) ) && if ( get_post_meta($post->ID, 'mycustomvalue', true ) == 'apple' ) : ?>          <?php the_title(); ?>      I am getting a white screen, anyone spot where I am going wrong?


title: How to set a default meta value for custom field

text: I have setup a custom meta_key for attachments. Since it is a radio button with Yes/No options, and the default value is always Yes, I need that this default value is saved into the db when the attachment is created. Right now the problem is that when I upload an image, the Edit Media page shows me that the value for this meta_key is "Yes", but it is actually not saved in the database until I click "Save All Changes" or "Update Media". Since these attachments can be added both by manually uploading files and automatically by importing an RSS feed, I need the default value to be created at the moment the attachment is created in the db. UPDATE: To explain the issue in more detail, this is the code I am using in the template to find the attachments. I don't know if I can modify this to also query the attachments when the _show_attach is null?               $attached_photos = get_children(array(             'post_parent'    => get_the_ID(),             'post_type'      => 'attachment',             'numberposts'    => -1, // show all             'post_status'    => null,             'post_mime_type' => 'image',             'order' => 'ASC',             'orderby' => 'menu_order',             'meta_key' => '_show_attach',             'meta_value' => 'false',             'meta_compare' => '!='         ));


title: use query_posts to return a post OR a page by ID

text: I'm building a custom homepage for a client where they want to have a few changeable boxes to link to specific pages, or posts, within the site. I've added custom fields to the homepage so that they need only enter the page/post ID, and then it will display the proper post or page. And I'd like it to be flexible enough that they can do a post or page. Right now, my code for the box is               <?php query_posts('p='.$topright); ?>     <?php while (have_posts()) : the_post(); ?>          {title and featured image}     <?php endwhile; ?>      where $topright is a variable already defined. (I've tested the variable with an echo and it is returning the proper ID number.) Unfortunately, WordPress seems to require that I use p=ID if it is a post, and page_id=ID if it is a page. So, if I designate the ID for a post, it is working fine, but not if I desingate the ID for a page. Is there an alternative syntax I could use? Or, it there a conditional of some kind that might look a the ID and recognize if it is a post or a page so I could run the query with an IF ELSE?


title: Generate page title tag from the content of H1

text: Is there any way of generating the title tag of a page from the content of an H1 tag on my wordpress page? I've got some dynamically generated content pulled in via an external XML feed and and at the moment, as the page isn't physically generated via the wordpress admin system and is just using a template, the page title is just staying the same regardless of the content. However, I was just wondering whether it would be possible in php, to grab the content of an H1 on a page and generate the title tag from that? Any tips / advice would be greatly appreciated :) Thanks


title: Target admin page body via CSS class

text: Within admin pages can one target specific pages based on their body class, as in the front end? For example I created a custom post type and would like to target its add and edit pages for some CSS tweaks. How do I go about that?


title: Why Editor reformats my code

text: I'm using TinyMCE Advanced and SyntaxHighliter plugins on my WordPress install. Why does the editor change my inserted code, from:               [php]     <?php     /**     echo('code');     /**/     [/php]      to:               [php]     <!--?php <br ?-->/**     echo('code');     /**/     [/php]


title: custom permlink .htaccess file 404 Not Found error

text: i read alot of atricles taking about this but i could fix my problem yet .. i want to make the permlink custom > /%category%/%postname% and i searched for the .htaccess in the wordpress files and i couldn't find it so i created one and added this code               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /sitename/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /sitename/index.php [L]     </IfModule>     # END WordPress      in the RewriteBase this name is the name of the folder of wordpress in my hosting , when i open my site the permlink changed as i want but when i open the page it gives me an error 404 Not Found error by the way i tried to choose the twentytwelve but its not working also , i added the .haccess file in the file mythemes in mytemplate is that the right place ??


title: Use mysql_query instead of $wpdb query

text: I have a custom table inside my wordpress database called test. What if i query this table using mysql_query() instead of using for example $wpdb->get_results() Will this affect my performance? Ty very much:)


title: check current_theme_supports in admin_menu hook

text: I'm adding a menu and sub-menus via the `admin_menu` hook in my functions.php. One of the sub-menus I want to add is `menus`. I want to make sure that the theme supports menus before I do that, so I tried using the `current_theme_supports` function, but it returns false, apparently because `$_wp_theme_features` is still null at this stage. What should I do? Do you think I really need this check, if I'm anyway in my functions.php? And if I do - should I use a later hook to create my menus? Or any other solution?


title: How to embed page content in a blog post

text: I've built an HTML table that is posted on a page in my site, and I'd like to use that same content inside a blog post (something of an announcement of the table's publication). The table is likely to get updated from time to time, so I'd like to have a single source for maintenance purposes. Is there a way I can do a one-off embedding of the table's source into the blog post, so that it is always updated when the page is updated? This isn't expected to happen often, so I don't want to put a lot of elbow grease into making this work. Thanks in advance! EDIT SO I made a really short shortcode solution using http://wordpress.org/extend/plugins/shortcode-exec-php/               extract(shortcode_atts(array('arg' => 'default'), $atts));     $id = 2328;     $post = get_post( $id );     return apply_filters('the_content', $post->post_content );      Thanks to everyone who helped. I don't have rep to upvote answers, but i will when I get more points.


title: Change behavior depending on content length

text: I have a large amount of posts and some only have one sentence. This means for some posts all the content can be read in an archive without needing to go to the posts single page. For these posts I want to disable the_permalink in the post's title. Is there a way I can detect if the excerpt length limit was reached? Then I can use something like               <a href="<?=($if_has_more_link ? the_permalink() : '#' )?>" ><? the_title(); ?>


title: How to use the settings API to set multidimensional arrays

text: I'm writing a course information plugin. Most course info is related to to a post (a custom post type of 'course'), so I have put the majority of info in the postmeta table. But some info isn't related to any of the posts - venue information for example. I'm using the options table to store that info. I've added a set of options pages, and am using the settings API to edit basic information. The problem is that some of the info is dynamic and more complicated: I have a venue page where I need to support adding new venues, and editing them. Each venue has a title, 3 address lines and a postcode. An example of the array of venues is:               array(         1 => array(                     'venue_title' = 'Edge Hill University, Ormskirk',                     'address_1'   = '20 Edge Lane',                     'address_2'   = 'Ormskirk',                     'address_3'   = 'Lancashire',                     'postcode'    = 'L12 6EA'              ),         2 => array(                     'venue_title' = 'Edge Hill University, Aintree',                     'address_1'   = '12 Aintree Close',                     'address_2'   = 'Aintree',                     'address_3'   = 'Liverpool',                     'postcode'    = 'L48 6PQ'              ),         3 => array ( ...etc other venues)          );      So to make any changes I use text fields. These get handled by the settings api. The name attribute and content are set dynamically from a $_GET variable.               <input type="text" name="venues[<?php echo $venue_id; ?>][venue_title]" value="<?php echo $venues[$venue_id]['venue_title']; ?>" />      which would output as               <input type="text" name="venues[2][venue_title]" value="<?php echo $venues[2]['venue_title']; ?>" />      I only have one set of these fields registered with the settings api, which is where i think the problem is, as when I change one, it removes all the other ones and just inserts the new one. So in my mind the code above should update just the $venues[2][venue_title], but it overwrites all venues. I think because there is only one set of fields registered it will only update as if there is one set of fields. Does anyone know a simple way to make this work? Thanks


title: Using Page/Post Slug In Link / URL

text: Hope this is easy! Need to figure out (if possible) how to input my page's SLUG into a web url as a placeholder. For example: http://www.samplewebsite.com/search.ashx?t=current I need to replace "current" with my page's SLUG making it dependent on the current page's SLUG For Slugs.... test1, test2, test3, test4, test5 Output... http://www.samplewebsite.com/search.ashx?t=test1 - for each test1 "slug" Is this possible?


title: is theme network enabled?

text: So I have been looking for something that allows me to get an array of themes that are network enabled (set in the Network Admin > Themes) There is the field called "allowedthemes" in the wp_options table however, this function is slightly different. It only contains themes that are enabled for that given networked blog as oppose to a global enable... if that makes sense? So it's scope is limited to one blog ID instead of all blogs (this info is set in the Network Admin > Sites > (clicking edit button of desired blog) > Themes). Anyways, if anyone has any solutions it would be much appreciated :) Thanks!


title: Add a field to just ONE page

text: I discovered the 'More Fields' plugin which allows an editor to control which fields appear on which types of items in WordPress. Problem is, I would like to control which pages appear on just ONE page. Example of this: - About page has WYSIWYG editor & Image - Contact page has multiple text fields From the looks of it, you have to create new page types, but each of them show up in a separate section in the sidebar. I would like everything to appear under my pages tab. Any help would be great.


title: Editing Help Section

text: I was trying to find the contextual help section for all the admin pages so I could add some additional text. The main pages I need to hit are the "Pages" page and the "Widgets" page but I'm not sure where to find the files for these. Anybody know file names where I can find the contextual help?


title: Recent activity query WordPress

text: Does anyone know how I can get a list of posts based on their recent activity? Activity such as a new comment, an edit, a new post, et cetera. Some Q&A wordpress themes seem to be using this but I have no clue on how to generate such a query myself... Please, it's very important.


title: Get password when user registers and save it sha1 into database

text: im working on a website where the users can connect with iphone to some functions of it by using a sha1 encrypted password. In other words the plain password of wordpress encrypted in sha1. In the past i did the silly thing of editing the core files of wordpress to get the password when the user register and save that password in sha1 on the wp_users table. Of course my client updated wordpress and all the functions were lost. Yeah im stupid, im not sure what i was thinking that day. There is any way to hook to the register function to get the password , encrypt it in sha1 format and storeit in the database from the functions.php file of my theme? Any ideas?


title: How to save Uploaded image in custom option panel?

text:
I'm trying to add a custom option panel to a new template following a tutorial found on NetTuts. I saved all the code for the option panel inside a file called optionpanel.php (LoL) and everything is working but now I would like to add an Upload/Image button so I'll be able to change images inside a slideshow straight from Wordpress Media Library instead of connecting via FTP each time. So here is the problem, how to achieve this? This is what I've got up to now, I can see the Media Upload box and I can upload the image and the image is stored inside the media library but when I click on save in my option panel and try to echo the function it gives me nothing and after saving the form where there was the link to the image became empty once again! I know that my English is ugly anyway please be polite and, if, you can, try to explain it to me like if you are talking to your 3 years old son! I googled a lot (maybe too much!!!) and I've read: http://www.sitepoint.com/wordpress-options-panel/ http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in- your-plugin-or-theme/ http://www.theenglishguy.co.uk/2010/01/24/multiple-media-uploads-in-wordpress- functions-php/ http://stackoverflow.com/questions/2388697/wordpress-2-9-theme-options-admin- page-with-image-upload http://www.wptavern.com/forum/themes-templates/1346-creating-upload-function- options-page.html#post13306 http://sicdigital.com/2010/07/create-custom-post-type-for-image-upload- wordpress3/ http://www.tanzilo.com/2009/01/15/wordpress-adding-a-custom-option-box-and- developing-file-upload-plugin/ http://wordpress.org/support/topic/file-upload-with-custom-post-type?replies=8 https://github.com/JeffreyWay/WordPress-Theme-Options-Page/blob/master/admin- menu.php http://stuntsnippets.com/wordpress-custom-theme-options/ http://www.sitepoint.com/wordpress-options-panel/ And much more!!!! So here is my code:               <?php          $themename = "Centenario Pascoliano";     $shortname = "cp";          $categories = get_categories('hide_empty=1&orderby=name');     $wp_cats = array();     foreach ($categories as $category_list ) {            $wp_cats[$category_list->cat_ID] = $category_list->cat_name;     }     array_unshift($wp_cats, "Choose a category");           $options = array (          array( "name" => $themename." Opzioni",         "type" => "title"),               array( "name" => "Generale",         "type" => "section"),     array( "type" => "open"),          array( "name" => "Colour Scheme",         "desc" => "Select the colour scheme for the theme",         "id" => $shortname."_color_scheme",         "type" => "select",         "options" => array("blue", "red", "green"),         "std" => "blue"),          array( "name" => "URL Locandina",         "desc" => "Inserisci il link alla locandina",         "id" => $shortname."_locandinah",         "type" => "text",         "std" => "/wp-content/themes/centenario/images/locandinacentenario.png"),          array( "name" => "Product Image Upload",           "desc" => "Upload product image",           "id" => $shortname."_upload_one",           "type" => "upload",           "std" => ""),                 array( "type" => "close"),     array( "name" => "Homepage",         "type" => "section"),     array( "type" => "open"),          array( "name" => "Homepage header image",         "desc" => "Enter the link to an image used for the homepage header.",         "id" => $shortname."_header_img",         "type" => "text",         "std" => ""),          array( "name" => "Prima categoria da mostrare",         "desc" => "Scegli la prima categoria da mostrare in HomePage",         "id" => $shortname."_feat_cat",         "type" => "select",         "options" => $wp_cats,         "std" => "Scegli la prima categoria"),          array( "name" => "Seconda categoria da mostrare",         "desc" => "Scegli la seconda categoria da mostrare in HomePage",         "id" => $shortname."_feat_cat2",         "type" => "select",         "options" => $wp_cats,         "std" => "Scegli la seconda categoria"),          array( "type" => "close"),     array( "name" => "Footer",         "type" => "section"),     array( "type" => "open"),          array( "name" => "Footer copyright text",         "desc" => "Enter text used in the right side of the footer. It can be HTML",         "id" => $shortname."_footer_text",         "type" => "text",         "std" => ""),          array( "name" => "Google Analytics Code",         "desc" => "You can paste your Google Analytics or other tracking code in this box.             This will be automatically added to the footer.",         "id" => $shortname."_ga_code",         "type" => "textarea",         "std" => ""),             array( "name" => "Custom Favicon",         "desc" => "A favicon is a 16x16 pixel icon that represents your site; paste the URL     to a .ico image that you want to use as the image",         "id" => $shortname."_favicon",         "type" => "text",         "std" => get_bloginfo('url') ."/favicon.ico"),            array( "name" => "Feedburner URL",         "desc" => "Feedburner is a Google service that takes care of your RSS feed. Paste     your Feedburner URL here to let readers see it in your website",         "id" => $shortname."_feedburner",         "type" => "text",         "std" => get_bloginfo('rss2_url')),               array( "type" => "close")          );               function mytheme_add_admin() {          global $themename, $shortname, $options;          if ( $_GET['page'] == basename(__FILE__) ) {          if ( 'save' == $_REQUEST['action'] ) {              foreach ($options as $value) {         update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }          foreach ($options as $value) {            if( $value['type'] == 'upload' )          {              $upload = wp_handle_upload( $_FILES[ $value['id'] ] );              if( isset( $upload['url'] ) )              {                  update_option( $value['id'], $upload['url'] );              }          }                  elseif( isset( $_REQUEST[ $value['id'] ] ) )              {                  update_option( $value['id'], $_REQUEST[ $value['id'] ]  );              }              }          header("Location: admin.php?page=optionpanel.php&saved=true");     die;          }          else if( 'reset' == $_REQUEST['action'] ) {          foreach ($options as $value) {         delete_option( $value['id'] ); }          header("Location: admin.php?page=optionpanel.php&reset=true");     die;          }     }          add_menu_page($themename, $themename, 'administrator', basename(__FILE__),     'mytheme_admin');     }          function mytheme_add_init() {          $file_dir=get_bloginfo('template_directory');     wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0",     "all");     wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");          }     function mytheme_admin() {          global $themename, $shortname, $options;     $i=0;          if ( $_REQUEST['saved'] ) echo '

        '.$themename.' settings saved.

';     if ( $_REQUEST['reset'] ) echo '

    '.$themename.' settings reset.

';          ?>

<?php echo $themename; ?> Settings

     <form method="post" enctype="multipart/form-data" >       <?php foreach ($options as $value) {     switch ( $value['type'] ) {          case "open":     ?>          <?php break;          case "close":     ?>

               <?php break;          case "title":     ?>
To easily use the <?php echo $themename;?> theme, you can use the menu below.
               <?php break;          case 'text':     ?>
         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?>         <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?    php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo     stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />      <?php echo $value['desc']; ?>

     <?php     break;          case 'textarea':     ?>
         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?>         <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>"     cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo     stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>      <?php echo $value['desc']; ?>

          <?php     break;          case 'select':     ?>
         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?>          <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">     <?php foreach ($value['options'] as $option) { ?>             <option <?php if (get_settings( $value['id'] ) == $option) { echo     'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>     </select>              <?php echo $value['desc']; ?>

     <?php     break;          case "checkbox":     ?>
         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?>          <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked =     "";} ?>     <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id'];     ?>" value="true" <?php echo $checked; ?> />                   <?php echo $value['desc']; ?>

     <?php break;      case "section":          $i++;          ?>

<img src="<?php bloginfo('template_directory')?    >/functions/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?>
        <input name="save<?php echo $i; ?>" type="submit" value="Save changes"     />

               <?php break;     case "upload";?>

     Upload Image	          <input id="upload_image" type="text" size="36" name="upload_image" value="" />     <input id="upload_image_button" type="button" value="Upload Image" />
Enter an URL or upload an image for the banner.

          <?php break;     }     }     ?>          <input type="hidden" name="action" value="save" />     </form>     <form method="post">
     <input name="reset" type="submit" value="Reset" />     <input type="hidden" name="action" value="reset" />
     </form>
Icons: WooFunction

                <?php     }         ?>         <?php         function my_admin_scripts() {     wp_enqueue_script('media-upload');     wp_enqueue_script('thickbox');     wp_register_script('my-upload', get_bloginfo('template_url') .     '/functions/maisdesignscript.js', array('jquery','media-upload','thickbox'));     wp_enqueue_script('my-upload');     }     function my_admin_styles() {     wp_enqueue_style('thickbox');     }     if (isset($_GET['page']) && $_GET['page'] == 'optionpanel.php') {     add_action('admin_print_scripts', 'my_admin_scripts');     add_action('admin_print_styles', 'my_admin_styles');}     add_action('admin_init', 'mytheme_add_init');     add_action('admin_menu', 'mytheme_add_admin');     ?>


title: Custom Register Link on Backend Form

text: I want a similar solution like this one for my login form on the backend of my WordPress installation: Forgot Password URL Filter What I want to do instead of returning a custom forgot password url, I want to return a custom register link (all of this is on the login form at `/wp- login.php`). Basically I'm trying to white label WordPress completely, and I've got front end forms for creating and editing posts, registering, logging in, profile editing, and post management all in the front end. However, when someone attempts to login and that attempt is failed, they're redirected to `/wp-login.php`. Ideally I could throw an error on my site and have it redirect to my front-end login page (is there a filter for that?), but worse case-scenario, I've rebranded my backend form so wordpress doesn't look like an issue (aside from the url being `http://www.site.com/wp-login.php`, but that's not a huge deal) What I want to know is if there's a filter so I can return a custom register link on the backend, and if possible even a custom login link back there too. I've learned that there is a lostpassword_url filter, but as far as I know there isn't a register_url filter that I can use to change that. Any help? **UPDATE** http://core.trac.wordpress.org/browser/tags/3.2.1/wp-login.php#L418 This is what I want to hook into with a filter to change.


title: Dynamically Load Styles and Scripts from Theme Functions.php

text: I am attempting to dynamically load stylesheets and scripts based on the template name. So if I have a template named `page-signup.php` then it will load the corresponding stylesheet `page-signup.css` and `page-signup.js` if they exist for that page from a specific directory in my theme folder. Here is what I have so far in functions.php of my theme. It does not currently load any styles or scripts when the css and js files are present in the proper directory:               /**      * Auto loads scripts and styles based on the page name if they exist.      */     function mytheme_bootstrap_page_resources() {         if( is_page_template() ) {             $page_template = basename( get_page_template(), '.php' );             $css_file_path = get_template_directory() . "/css/pages/$page_template.css";             $js_file_path = get_template_directory() . "/js/pages/$page_template.js";             $css_file_uri = get_template_directory_uri() . "/css/pages/$page_template.css";             $js_file_uri = get_template_directory_uri() . "/js/pages/$page_template.js";                  if(file_exists($css_file_path)){                 wp_enqueue_style($page_template, $css_file_uri);             }                  if(file_exists($js_file_path)){                 wp_enqueue_script($page_template, $js_file_uri);             }         }     }     add_action('wp_enqueue_scripts', 'mytheme_bootstrap_page_resources');


title: Query function not executed between <div> element

text:
I'm wondering why the following code is not executed between the element it's put in. I know sort of how to fix, but I'm not sure if that's the best solution. My code: **First function**               function myfunction1($args = array()) {              var_dump($args);              $output = null;              $output .= '
';         $output .= myfunction2( $args );         $output .= '
';              return $output;               }      **And the second function (myfunction2)**               function myfunction2($args) {                  $options = $args;          /* get post types */         $default_post_types = explode(' ',$options['post_type']);             if ($default_post_types[0] == 'any') {                $default_post_types = 'any';            }              /* default args */         $args = array(                 'post_type'         => $default_post_types         );              $query = new WP_Query( $args );                        if ($query->have_posts()) :                       require_once dpf_path . 'frontstyle/dpf-front.php';              else :                   require_once dpf_path . 'frontstyle/dpf-cantfind.php';              endif;          }      In the dpf-front.php file are some html elements. The posts that are called in function1 are not between the `<div id="mydivelement"></div>` element. How to do this properly? Thanks! When I echo the div element it works somehow. Why is that?


title: Can I list a custom post type within another custom post type in the admin area?

text: I'm hoping someone can steer me in the right direction. I have a custom post type called 'locations'. I have another custom post type called 'testimonials'. What I'd really like to do is be able to associate a 'testimonial' with a 'location'. So I was trying to figure out if I could some how list those locations within the testimonial post page in the admin area. Almost like a meta box. I haven't been able to find anything like this anywhere. Any and all help is appreciated!


title: 404 errors in log showing urls with 'GET', plus and numerical code

text: My wordpress logs show 404 errors to URLs having the following pattern:               http://example.com/path/++GET+http:/example/+0,48595,73506+-      Web searches do not return answers because of the _plus_ and _minus_ symbols. Note that the second _http_ is followed by a single slash. Accessing my site with a corrected URL (where I use a double slash after the second http) returns a 404. My logs show fifty errors each day from different IP addresses, where each IP address tries the same file three times. I am curious to know what type of exploit this may be. It seems to have something to do with the GET request method. Ideas?


title: How to prevent wordpress from autoformatting my posts once and for all?

text: I am using ifttt to sync my wordpress blog with my blogger site, and there is a problem of auto-formatting on wordpress's side. It likes inserting `<br>` everywhere when exporting posts. For example, a list on wordpress looks like this: ![enter image description here](http://i.stack.imgur.com/g4Ae2.jpg) After syncing, the list looks like this on blogger: ![enter image description here](http://i.stack.imgur.com/3O8OP.jpg) Leaving the syncing scenario aside, Wordpress does this to its own posts, too. I had to disable the `wpautop` function in `wp-include/formatting.php` to prevent it from inserting those annoying `<br>` tags. But I don't know which function to disable in the current case. **If possible I would like to disable all forms of autoformatting once and for all, because I always use html for markup and there is no need for WP to reformat for me at all.**


title: List posts from Custom Post type with hierarchy?

text:
I have a custom post type that is set to have hierarchy. I'm trying to create a list of posts in that post type that display's that hierarchy using nested unordered lists. I have this post structure: Post -child post -- child of child post -- child of child post And I want to be able to create a list of posts (which i guess are behaving more like pages since they have hierarchy), that reflects this structure using unordered lists, like so:

Post

child post

child of child post

chld of child post

      What's the best way to do this (if there is one) so that I don't have to go back into the code whenever I add new parent pages?


title: WordPress Theme is not Responsive to Updates

text: I have a WordPress theme that's installed and has been running fine for a while. I recently needed to update the theme itself, and I did so using the built-in theme editor. Upon reloading the site, the theme changes are not presented in the markup. Removing the index.php file from the theme or changing it's name results in a blank page as expected, but removing all contents of the theme's index.php does not have a similar effect. In fact, the WordPress installation continues as if I had not made index.php blank. I have no caching plugins installed, Varnish is not present, memcached is not in use at all, and neither is APC. I attempted upgrading all the plugins and WordPress itself. The raw-html plugin I have installed failed to update with a fatal error about an include on line 16, but that include was not present. The update worked fine when I renamed the plugin filename though (from raw_html.php to raw_html1.php).


title: get_avatar won't show uploaded avatar, only default gravatar

text: I'm using the Simple Local Avatars plugin so my bbPress forumgoers can upload their own avatars. Now, when a user logs in, I want his/her avatar to display next to the relevant links (i.e. logout, edit profile, etc.). I tried the call below but it only keeps showing the default mystery man gravatar. `<?php echo get_avatar( $current_user->user_login, 48 ); ?>` Is there something I overlooked? How can I get the user's uploaded avatar to show up?


title: Show the most recent post for an author on the author page

text:
I have 6 authors in my blog page. I have profile for each of the authors. I want to show the posts of the authors dynamically under their own profile. I tried the following but it showed all posts. with this code it is showing the posts in all profiles not specific profiles. What changes should i make?               $current_author = get_query_var('author');     $author_posts=  get_posts( 'author='.$current_author->id.'&posts_per_page=1&order=DESC&orderby=post_date' );     if($author_posts){       echo '
';       foreach ($author_posts as $author_post)  {         echo '
ID).'">'.$author_post- >post_title.'
';       }       echo '
';     }      I use the following function to show the Image and description about the author               function ajaxified_function()      {      $post = get_post($_POST['post_id']);     $feat_image = get_the_post_thumbnail($post->ID);     $desc_values = get_post_custom_values("description",$post->ID);         if( is_array( $desc_values ) )         {             foreach($desc_values as $key => $value );         }     echo '
'.$feat_image.'
'.$post->post_.'
'.$post->post_title.'

'.$value.'

'.$post->post_content.'

'.$author.'
';     die();     }      Following js is which I use to show the above in a lightbox when clicking on a link                jQuery(document).ready(function (){      jQuery('#options_to_connect a').on('click',function(event){              event.preventDefault();     var post_id = jQuery(this).parent().attr('class');      jQuery.ajax({       type: "POST",                       url:  'http:www.myblog.com/wp-admin/admin-ajax.php',          data: 'action=ajaxified_function&post_id='+post_id,            success: function (msg) {                                                    jQuery('#cboxLoadedContent').html(msg);        },        error: function () {                         alert('Error');                       }         });                  });            });


title: How to make the excerpt_more filter apply to the actual post excerpt?

text:
In the get_blog_excerpt() function below, the excerpt_more filter works perfectly when the post excerpt is not present, however, when the post has an excerpt, I'm not getting the "Read More" link. I understand that the_excerpt first checks to see if a post excerpt is present, which is fine, but I want the read more link applied to it too. What do I need to change in order to make the excerpt_more apply in all cases?               function get_blog_excerpt(){         add_filter('excerpt_length', 'ce4_excerpt_length');         add_filter('excerpt_more', 'ce4_excerpt_more');         return the_excerpt();     }          function ce4_excerpt_length($length) {         return 150;     }          function ce4_excerpt_more($more) {         global $post;         return '...ID) . '">Read More';     }               function get_blog_links(){         global $post;         setup_postdata($post);         $myposts = get_posts($args);echo '
';          echo '
';          foreach($myposts as $idx=>$post){ ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>         <?php          echo get_blog_excerpt();         echo '

';?>
         <?php } echo '

';     }      The code above is inside functions.php The code below is inside archive.php               <?php      if(is_category()){         if (get_query_var('cat') == get_category_by_slug('blog')->term_id){             get_blog_links();         }         else          {         get_category_links();         }     } ?>


title: Function to show random posts from a category

text:
Hi to all I'm trying to create a function that can ECHO the excerpt of a random post from a choosen category. What I did up to now is:               <?php function $titoloslide() = {     query_posts(array('orderby' => 'rand', 'category_name' => 'testimonianze', 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_post();     "
"the_excerpt();"
"      endwhile;     endif;     wp_reset_query();};?>      Obviously... it doesn't work! Is there anyone who can help me? Thank you very much! Why i need all of this inside a function? Because I need to use it as title tag of some images and stuff like this so I can't write all my code inside title="" and I tought that a function could do the trick. I'm trying to use NivoSlider so I need to put this code as a title tag to an image to be shown. example: " title=" /> This function takes a random post from category testimonianze and shows his excerpt (I think it's easy to understan this :P The code works if I use it like this:               <?php query_posts(array('orderby' => 'rand', 'category_name' => 'testimonianze', 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_excerpt(); ?>
      <?php endwhile; ?>      <?php endif;?>      <?php wp_reset_query(); ?>      But no way to have a working version in any other way even after code corrections. Any idea or suggestions? (Maybe some prays will work too :P )


title: Eliminate duplicates in a foreach loop

text: I've created a filter for my search results that allows people to filter user searches based on their `State` from their profile. The problem I am having is that there are duplicate states showing in the drop-down list for users that have the same state. Here is the current code trying to eliminate that problem.               <div class="state">         <input type="hidden" name="search_type" value="members">         <select id="stateDrop" name="state">             <option value="name">State</option>             <?php                 $prevState = "";                  foreach($users as $user) {                     $state = get_cimyFieldValue($user->ID, 'STATE'); // Grabing their state from their profile page                          if($prevState != $state) {                         $prevState = $state;                         echo '<option value="'.$state.'">'.$state.'</option>';                     }                 }             ?>         </select>     </div>      This works great when 2 states are right after each other, but when I have something like the below, it will not eliminate the duplicates...               Not working       -California       -Washington       -California          Working       -California       -California       -Washington      What can I do differently to get the results I need and possibly sort it alphabetically? Thanks,


title: Check if username exist with AJAX

text: I've created a custom registration form for a WordPress MultiSite installation. It allows registrations of new blogs and users. I want to check with ajax if a given username is available. This is what I have so far:               add_action( 'wp_footer', 'pb_ajax_add_js' );          function pb_ajax_add_js() {          // add script to the footer     wp_enqueue_script( 'pb_ajax',         plugin_dir_url( __FILE__ ).'js/script.js',         array('jquery'), BOJ_ARM_VERSION, true     );          //Get protocol of the current page.     $protocol = isset( $_SERVER["HTTPS"]) ? 'https://' : 'http://';          // Display the admin-ajax.php using the same protocol as the current page.     $params = array(       'ajaxurl' => admin_url( 'admin-ajax.php', $protocol )     );     wp_localize_script( 'pb_ajax', 'pb_ajax', $params );     }      Server side request handling:               // Ajax request handling.     add_action('wp_ajax_nopriv_boj_arm_ajax', 'pb_check_username');     add_action('wp_ajax_boj_arm_ajax', 'pb_check_username');          function pb_check_username() {     $username = $_REQUEST['usr'];     echo $username;          die();     }      And jQuery script(note: in this version, validation is after click link)               (function($) {         $('.check-username').click(function(){             var link = this;             $(link).html('sprawdzanie...');             // href="' . get_permalink() . "#more-{$post->ID}"             var usr = $("#site-addres-input").attr('value');                  var data = {                 action: 'boj_arm_ajax',                 usr: usr             };                  $.get(boj_arm.ajaxurl, data, function(data){                 $(link).after(data).remove();             });             return false;         });     })(jQuery);      Script isn't complete. It Must check if the username exists, and return true or false. Can You help me Please?


title: Correct attachment size

text:
I am trying using Really Simple slideshow with Wordpress and I am having issue while trying to retrive the correct image size for the slideshow. I am able to retrieve the first image without problem using the following code:               <?php if ( $attachments ) {         $first_image = array_slice($attachments, 0, 1);         $first_thumb = wp_get_attachment_url( $first_image[0]->ID, 'blog-thumb', false );         ?>         <img src="<?= $first_thumb; ?>" alt="" title="" />      However, I am using the following code to retrieve the rest of the images:               <?php foreach ($attachments as $attachment) { ?>
<a href="<?= wp_get_attachment_url( $attachment->ID, 'blog-thumb', false ); ?>">
     <?php } ?>      and I am able to retrieve the images, but the original version of the images, not the "blog-thumb" dimensions. I am not sure what I'm doing wrong here... Here's how I am retrieving attachments:                       <?php if ( $post->post_type == 'post' && $post->post_status == 'publish' ) {                     $attachments = get_posts( array(                         'post_type' => 'attachment',                         'posts_per_page' => -1,                         'post_parent' => $post->ID,                         'exclude'     => get_post_thumbnail_id(),                         'orderby'           => 'menu_order',                         'order'           => 'ASC'                            ) );             ?>      I am also adding the whole code, so you guys can check the whole picture of what's going on:                       <?php if ( $post->post_type == 'post' && $post->post_status == 'publish' ) {                     $attachments = get_posts( array(                         'post_type' => 'attachment',                         'posts_per_page' => -1,                         'post_parent' => $post->ID,                         'exclude'     => get_post_thumbnail_id(),                         'orderby'           => 'menu_order',                         'order'           => 'ASC'                            ) );             ?>                    <?php if ( $attachments ) {                  $first_image = array_slice($attachments, 0, 1);                 $first_thumb = wp_get_attachment_image_src( $first_image[0]->ID, 'blog-thumb', false );                    ?>                      <div id="post-<?php the_ID(); ?>" <?php post_class() ?>>
                      <div id="slideshow<?php the_ID(); ?>" class="rs-slideshow">
                         <img src="<?php echo '' . $first_thumb[0] . ''; ?>" alt="" title="" />

                     <?php foreach ($attachments as $attachment) { ?>
<a href="<?= wp_get_attachment_image( $attachment->ID, 'blog-thumb'); ?>">
                          <?php } ?>

                                                        <?php } ?>             <?php } ?>
       As mentioned, I am having difficulties while trying to retrieve the correct image size inside the list, the code to retrieve the first image works like a charm. Thanks for your help!


title: How to add text to comment form #content textarea?

text: I have a plugin that does validation on user submitted comments. When validation fails, I want to redirect them back to the comment form, and have their comment still appear in the comment box, so they don't have to type it again. How can I add custom content to the comment form #content textarea?


title: "update_post_meta" not working in "wp_insert_post_data" hook

text: I have created the following hook in my functions.php               add_filter('wp_insert_post_data', 'ad_change_title');     function ad_change_title($data)     {         if($data['post_type'] != 'ad_listing')             return $data;         if(!is_admin())             return $data;              global $post;            update_post_meta((int)$post->ID, 'cp_entitle_englishel', (string)$_POST['qtrans_title_en']);              return $data;     }      but the "update_post_meta" part. I have checked the post_id, cp_entitle_englishel, qtrans_title_en values, and they are valid. Any suggestions?