title: strange parse error when including a loop template within another template

text: I have a loop template called `loop-event-details.php` where I have code to display each event. My main page template is called `events-page.php`. I use the following code to include the loop template:               get_template_part( 'loop', 'event-details' );      I have also trying this code:               include(TEMPLATEPATH . '/loop-event-details.php');      However, when viewing a page it always complains about parsing error:               Parse error: syntax error, unexpected T_ENDWHILE in /<my_templatepath>/loop-event-details.php on line 1      The `loop` isn't on line 1, but line 15. The code in the `loop` file is correct, because when I copy and paste all the code from the `loop` file into the `page` file it all works. As soon as I try to include it with either contract (`get_template_part()` or `include()`) it doesn't work and always complains about line 1. Any tips and help would be hugely appreciated. Thanks, Dasha WP 3.1.0 PHP Version 5.2.6-1+lenny9


title: is_single() works in plugin, not in theme?

text: I'm attempting to move some code from a plugin over to my theme's functions.php file, but when I attempt to wrap it in the is_single() wrapper inside of functions.php, it never fires. What am I missing?               if (is_single()) {     echo "hello world";      }      I can't get the echo to fire from any inside post page. This has to be something insanely simple I'm overlooking.


title: Use page template for custom $_GET content

text:
I have a list of products, and I want to be able to click a link and get to a page with more information about the product, which I can do using `$_GET` like so:               $s .= '
id.'>Details
';      And then in `test.php` I have:               if (isset($_GET['info'])) {         echo 'string';     }      With that, I obviously just get a blank page with `string` written on it, but I was wondering if it would be possible to use a page temnplate on this page, so I would get `string` written in the area of the page template (like where I would get the output If I had a post loop on a regular page) ?


title: When coding a Wordpress theme, where does the theme (i.e. the presentation) end and the plugin (i.e. the functionality) begin?

text: The best guideline I have seen for what should be in a theme is to put "functionality" in a plugin. I am looking at adding more "premium features" like jQuery image sliders. This requires a back-end user interface for selecting featured content to slide. Is this presentation? How about shortcodes? A shortcode is a simple hook that enables you to call a PHP function by adding something such as [shortcode] to a post or page. I see this in themes all the time. Is it presentation? I am unable to sort it out!


title: Use meta boxes inside an archive page template for Woocommerce

text: I'm creating my own Wordpress theme, and I'm trying to make it compatible with Woocommerce. I understand pretty much everything about theming woocommerce, including copying the template files and changing them, also I'm confortable with some of the Woocommerce hooks as well. Now Woocommerce uses an archive-product.php file to show shop items, and it is also currently using the a page named 'Shop' for that. The problem is that I'm not able to use the custom meta box data in my archive-product.php file when I save them in the 'Shop' page. So I just want to know if there is anyway of using meta box data in an archive template, such as the archive-product.php template of Woocommerce. Any suggestions? **Edit:** So I was able to solve my problem completely by using the following code in the file that I'm including:               if( is_shop() ) {       $post_id = get_option( 'woocommerce_shop_page_id' );;     } else {       $post_id = $post->ID;     }          $meta_key = get_post_meta($post_id, 'meta_key', true);


title: Exceprt not displaying

text: I am using a custom template homepage in which I want to display some excerpt from a category but it's not displaying as I code for just `the_excerpt`. I have a confusion too, they say the `the_excerpt` should be used within loop. What is the main reason of loop? Because I am just surrounding my `the_excerpt` call with the loop, is it correct?               <div class="summary">     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>       <?php the_excerpt(); ?>       <?php endwhile; else: ?>     <?php endif; ?>     </div><!--summary-->


title: Event booking form for wordpress

text: Cannot find plugin which will allow me to do this: I want to accept event bookings on my website like on the screenshot. Below text fields event list will be presented and green will show events with available seats, red will show sold out. I want to set event list and free/sold out status in admin panel manually. All my events are 3-days each so manual period selection using jquery calendar is not for me. I want just event list. Also I want this plugin to let me track all the bookings in admin panel.


title: Get Next/Previous (Sibling) Top Level Parent Page Id - Wordpress

text: Question: Is there any possibility to get next/previous page id in wp_nav_menu in wordpress. Example: I have navigation menu like this               Menu_Item_1  (ID = 5)       >SubMenu_Item_1-1       >SubMenu_Item_1-2          Menu_Item_2 (ID = 11)       >SubMenu_Item_2-1       >SubMenu_Item_2-2      If I am on the Menu_Item_1 or any of its child pages, the id of the next top level menu item ( Menu_Item_2 in this case) must be stored in a variable and so on.


title: HTML-to-WordPress: Dropdown Navigation Menu

text:
so I've been searching around in the hope somebody also had this issue.. But I can't find any. I've currently created a Wordpress template out of a hardcoded HTML template for somebody. Now here's the problem... He already had coded the dropdown function in CSS so it was my job to port it over to Wordpress but it doesn't seem to work out very well. This is how it should look like (Note that there are three rows because there are three categories within the menu itself): ![This is how it should like](http://i.stack.imgur.com/4aPwU.jpg) This is the HTML from the hardcoded template;
         Evenementen

                         Evenementen

                         Braderie

                         Jaarmarkten

                         Bedrijfsfeesten

                         Sportfeesten

                         Cateringbus

                         Filmlocatiebus

                         Kinderfeesten

                         Schoolfeesten

                         Familiedagen

      What I myself have so far is in the header.php at the moment:                    <a href="<?php bloginfo('url'); ?>">Home
          <?php wp_nav_menu('title_li=&depth=2'); ?>      Functions.php :               add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );     function add_menu_parent_class( $items ) {          $parents = array();     foreach ( $items as $item ) {         if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {             $parents[] = $item->menu_item_parent;         }     }          foreach ( $items as $item ) {         if ( in_array( $item->ID, $parents ) ) {             $item->classes[] = 'submenu';          }     }          return $items;}       EDIT: I've tried everything to look at the codex of wp_nav_menu, but I can't seem to make anything out of it. Someone told me that I'm not using it correctly, the thing is: Where am I not using it correctly? Is it in functions.php or header.php? I just need to port it over as it seems the most safest thing to do. I've never done such a dropdown menu before which is why I'm asking for a push in the right way.


title: Toggle a metabox based on a selection

text:
Is there a way to toggle a custom metabox based on a custom drop down selection for a custom post type? What I mean is I would like my custom post "proposal" to display different metaboxes based on a selection. For example, I select Print from a drop down and it will display all my custom fields that are assigned to Print. When I select Website I would like to display different fields that are assigned to Website. When each field is selected I would like the previous selected field to hide. Each selection will display a few fields. To display my custom post type                $args = array(           'labels'              =>  array(           'name'                => __( 'Proposal Overview'),           'singular_name'       => __( 'Proposal'),           'add_new'             => __( 'Add New Proposal'),           'add_new_item'        => __( 'Add New Proposal'),           'edit_item'           => __( 'Edit Proposal'),           'new_item'            => __( 'New Proposal'),           'all_items'           => __( 'All Proposal'),           'view_item'           => __( 'View Proposal'),           'search_items'        => __( 'Search Proposal'),           'not_found'           => __( 'No Proposal found'),           'not_found_in_trash'  => __( 'No Proposal found in Trash'),           'hierarchical'        => true,           'parent_item_colon'   => '',           'all_items'           => __('Proposal')                ),           'supports'                => array( 'title','revisions','comments','author','editor' ),                     'show_in_menu'          => 'edit.php?post_type=client_portal',                     'public'                => true,             );                   register_post_type( 'Proposal', $args );          Metaboxes to display for print (still working on more metaboxes)                 add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );       function cmb_sample_metaboxes( array $meta_boxes ) {       $prefix = '_cmb_';           $meta_boxes['squid_metabox_venders'] = array(         'id'         => 'squid_metabox_venders',         'title'      => __( 'Vendor Information', 'cmb' ),         'pages'      => array( 'vendors', ), // Post type         'context'    => 'normal',         'priority'   => 'high',         'show_names' => true, // Show field names on the left         // 'cmb_styles' => true, // Enqueue the CMB stylesheet on the frontend         'fields'     => array(             array(                 'name' => __( '
Project Size
', 'cmb' ),                 'desc' => __( 'Folded and flat', 'cmb' ),                 'id'   => $prefix . 'squid_title',                 'type' => 'title',             ),             array(                 'name' => 'Flat',                 'desc' => 'optional',                 'id' => $prefix . 'vendorflat',                 'type' => 'text_small'             ),             array(                 'name' => 'Folded',                 'desc' => 'optional',                 'id' => $prefix . 'vendorfolded',                 'type' => 'text_small'             ),             array(                 'name'    => __( 'Fold Type', 'cmb' ),                 'desc'    => __( '', 'cmb' ),                 'id'      => $prefix . 'test_select',                 'type'    => 'select',                 'options' => array(                     'none' => __( 'None', 'cmb' ),                     'flat' => __( 'Flat Fold', 'cmb' ),                     'halfFold'   => __( 'Half Fold', 'cmb' ),                     'zFold'     => __( 'Z Fold', 'cmb' ),                     'triFold'     => __( 'Tri Fold', 'cmb' ),                     'gateFold'     => __( 'Gate Fold', 'cmb' ),                 ),             ),             array(                 'name' => __( '
Project Pages/Paper
', 'cmb' ),                 'desc' => __( '', 'cmb' ),                 'id'   => $prefix . 'squid_title',                 'type' => 'title',             ),             array(                 'name' => 'Pages',                 'desc' => '',                 'id' => $prefix . 'vendorPages',                 'type' => 'text_small'             ),             array(                 'name' => 'Paper',                 'desc' => '',                 'id' => $prefix . 'vendorPaper',                 'type' => 'text_small'             ),             array(                 'name' => 'Color',                 'desc' => '',                 'id' => $prefix . 'vendorColor',                 'type' => 'text_small'             ),             array(                 'name' => 'Special Inks',                 'desc' => '',                 'id' => $prefix . 'vendorInks',                 'type' => 'text_small'             ),             array(                 'name' => 'Coating',                 'desc' => '',                 'id' => $prefix . 'vendorCoating',                 'type' => 'text_small'             ),             array(                 'name' => 'Turnaround',                 'desc' => '',                 'id' => $prefix . 'vendorTurnaround',                 'type' => 'text'             ),             array(                 'name' => __( '
Invoice Specs
', 'cmb' ),                 'desc' => __( 'Phone Number, email, and web address', 'cmb' ),                 'id'   => $prefix . 'squid_title',                 'type' => 'title',             ),         ),     );


title: base directories / URL

text: Is there a way to handle base directories for taxonomies that result in a 404. For example my URLs are: http://skipology.com/category/...   http://skipology.com/app/... but the taxonomies / base directories above result in 404. Can they be redirected to a taxonomy index page (which I may need to create) for example without impacting the child directory (post) or is there a better option. If so how? I suspect the answer lies in redirects but I'm not confident.


title: Changing the post date without causing 404 error

text: We have permalink structure based on date (like 'www.mysite/2012/05/27/postname').   Some times there are some posts that we need to be shown the first, so we change they date.   The problem is, that by this way, after changing the date the URL is chenged also, so the old link causes 404 error.   Is there any solution for this problem?


title: Correct Syntax for uploading files to custom directory in Wordpress

text: I have current PHP code that works when attaching files on a form. The files have to go to a certain directory. I know that while attaching in Wordpress I need to use a different syntax. However, I've been reading for days literally on how I can do this. Again, my code here works on a standalone PHP page but not in Wordpress. I'm not that worried about security either since my page is on an intranet site behind a firewall and cannot be reached otherwise. I see some tutorials and code for uploading to a custom directory in the WP uploads folder, but I need to upload to a directory in the root of the web server. Here's my code currently from the standalone PHP page.               $folderPath = "/jobtracking/files/standard/{$projID}";     mkdir($folderPath);          $filename = basename($_FILES["Attach_Files"]["name"]);     $filetype = $_FILES["Attach_Files"]["type"];     $datei = "/jobtracking/files/standard/{$projID}/{$filename}";     $target_path = $folderPath . "/" . $filename;         if(move_uploaded_file($_FILES["Attach_Files"]["tmp_name"], $target_path)) {         mysql_query("INSERT INTO files(files.name, files.project, files.added, files.datei, files.type, files.folder) VALUES('{$filename}', '{$projID}', UNIX_TIMESTAMP(now()), '{$datei}', '{$filetype}', 0)");         }     chmod("{$target_path}", 0777);      I've seen the codex on wp_handle_upload but not sure if that applies to my need. I feel like that's what I need to use but having a hard time finding anything that fits what I'm trying to do. I don't need the form attachment to go into Wordpress at all. I saw this article which seemed promising but it is still uploading to putting files inside the WP directory and not outside. Also tried to use this article as reference. My question is how can I have a single file attachment form field in a custom Wordpress Page Template to follow my current PHP and upload to a custom directory outside of WP? Thanks in advance for any suggestions! **Update 12.13.13 I tried using site_url to establish the correct folder path but still no luck. Here's the code I tried so far.               $folderPath = site_url('/jobtracking/files/standard/{$projID}');     mkdir($folderPath);     $filename = basename($_FILES["Attach_Files"]["name"]);     $filetype = $_FILES["Attach_Files"]["type"];     $datei = site_url('/jobtracking/files/standard/{$projID}/{$filename}');     $target_path = $folderPath . "/" . $filename;         if(move_uploaded_file($_FILES["Attach_Files"]["tmp_name"], $target_path)) {         mysql_query("INSERT INTO files(files.name, files.project, files.added, files.datei, files.type, files.folder) VALUES('{$filename}', '{$projID}', UNIX_TIMESTAMP(now()), '{$datei}', '{$filetype}', 0)");         }     chmod("{$target_path}", 0777);      **Update: 01.31.14 It seems that I'm not even getting a directory created on form submission. The folders are all set to 0777 for now just to make sure I have all the read/write privileges I need for my test. I also read about using wp_mkdir_p(); instead of mkdir(); when using Wordpress. I don't know if I can use a variable for the string in the wp_mkdir_p();. As soon as I can get the directory to create and the file to move in, I feel like I'm halfway there. **Update: 02.03.14               $folderPath = ABSPATH . '/jobtracking/files/standard/{$projID}';          wp_mkdir_p($folderPath, 0777, true);          $filename = basename($_FILES['Attach_Files']['name']);     $filetype = $_FILES['Attach_Files']['type'];     $datei = ABSPATH . 'files/standard/{$projID}/{$filename}';     $target_path = $folderPath . "/" . $filename;         if(move_uploaded_file($_FILES['Attach_Files']['tmp_name'], $target_path)) {         mysql_query("INSERT INTO files (files.name, files.project, files.user, files.added, files.datei, files.type, files.folder) VALUES('{$filename}', '{$projID}', 0, UNIX_TIMESTAMP(now()), '{$datei}', '{$filetype}', 0)");         }     chmod("{$target_path}", 0777);      **Update 02.04.14 - - This creates the directory and puts the file in it. However, information still not entering the database. Maybe I'm not using the if(); correctly?               $folderPath = "/jobtracking/files/standard/{$projID}";          mkdir(ABSPATH.$folderPath, 0777, true);          $filename = basename($_FILES['Attach_Files']['name']);     $filetype = $_FILES['Attach_Files']['type'];     $datei = 'files/standard/{$projID}/{$filename}';     $target_path = ABSPATH.$folderPath . "/" . $filename;         if(move_uploaded_file($_FILES['Attach_Files']['tmp_name'], $target_path)) {         mysql_query("INSERT INTO files (files.name, files.project, files.user, files.added, files.datei, files.type, files.folder) VALUES('{$filename}', '{$projID}', 0, UNIX_TIMESTAMP(now()), '{$datei}', '{$filetype}', 0)");         }     chmod("{$target_path}", 0777);      **Update 02.04.14 - IT WORKS!!! Here's my code:               $folderPath = "/jobtracking/files/standard/{$projID}";          mkdir(ABSPATH.$folderPath, 0777, true);          $filename = basename($_FILES['Attach_Files']['name']);     $filetype = $_FILES['Attach_Files']['type'];     $datei = "files/standard/{$projID}/{$filename}";     $target_path = ABSPATH.$folderPath . "/" . $filename;         if(move_uploaded_file($_FILES['Attach_Files']['tmp_name'], $target_path)) {         mysql_query("INSERT INTO files (files.name, files.project, files.user, files.added, files.datei, files.type, files.folder, files.visible) VALUES('{$filename}', '{$projID}', 5, UNIX_TIMESTAMP(now()), '{$datei}', '{$filetype}', 0, ' ')");         }     chmod("{$target_path}", 0777);


title: Edit "thank you for creating with Wordpress" in version 3.3.1

text: Is there a way to edit the text "thank you for creating with Wordpress" in version 3.3.1 at the bottom of the CMS? If so what file do I need to edit?


title: How can I reorder admin bar items?

text: I have a plugin that adds custom admin bar items, but I'd like them to appear all the way to the left. I know I can add and remove menu items with `$wp_admin_bar->add_menu()` etc, but how can I reorder them? Edit: It looks like the admin bar menu item orders are defined in wp- includes/class-wp-admin-bar.php, but I can't figure out how to change this order from within my plugin function.                           add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );                 add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );                 add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );                 add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );


title: Custom user taxonomies fail when i register multiple taxonomies

text:
I have a site with people from different areas of expertise, and I want to be able to group them with custom taxonomies. I've taken Justin Tadlocks tutorial-code and it works fine when I have one taxonomy registered, but when i register another one they start to behave strangely. For now I have the taxonomies "Profession" and "Office". I have five different professions and 20+ offices. If i select one profession and save, then another two might be checked of even though I haven't checked them. Here's my code. Could it be a problem when the terms are being saved? Should it be one function to rule them all or should they have separate functions like now? **EDIT:** _400 lines of code is a bit much, sorry._ What it does is that it registers two taxonomies and then "bind" them to the user-pages instead of latching on to "Posts" which it does by default, and then multiplied by two. Each taxonomy gets its own function for everything. I don't know if it is the task of saving the fields that is the source of my problems, but everything works just fine until i save a users profile. Here's the function that saves the checkboxes.               function my_save_user_profession_terms( $user_id ) {          $tax = get_taxonomy( 'profession' );          /* Make sure the current user can edit the user and assign terms before proceeding. */     if ( !current_user_can( 'edit_user', $user_id ) && current_user_can( $tax->cap->assign_terms ) )         return false;          $term = $_POST['profession'] ;          /* Sets the terms (we're just using a single term) for the user. */     wp_set_object_terms( $user_id, $term, 'profession', false);          clean_object_term_cache( $user_id, 'profession' );     }          add_action( 'personal_options_update', 'my_save_user_office_terms' );     add_action( 'edit_user_profile_update', 'my_save_user_office_terms' );      And here's how I output my terms as checkboxes in the admin:               /* If there are any profession terms, loop through them and display checkboxes. */             if ( !empty( $terms ) ) {                      foreach ( $terms as $term ) { ?>                     <input type="checkbox" name="profession[]" id="profession-<?php echo esc_attr( $term->slug ); ?>" value="<?php echo esc_attr( $term->slug ); ?>" <?php checked( true, is_object_in_term( $user->ID, 'profession', $term ) ); ?> /> <label for="profession-<?php echo esc_attr( $term->slug ); ?>"><?php echo $term->name; ?>
                 <?php }             }      **Edit 2, added answer.**


title: Add new post with predefined / preset date

text: ## The current situation The plugin I'm currently working on is an additional post list view: A calendar, as you can see in the following screenshot. ![Admin Calendar View](http://i.stack.imgur.com/Nczzv.png) Admin calendar view with MP6 and handheld screen width. ## The goal Now each day shows the amount of posts only. > What I want to add is **a link to add a new post**. But this link should > _not only_ take you to the `~/wp-admin/post-new.php?post_type=abc` screen, > but as well add **a predefined post date** \- the one from the day where you > clicked on. ## The possible solutions and problems So far there're several options:   1. Hook into the publish meta box and try to modify the date somehow.    2. Remove the meta box, make a clone of it and just replace the date to accept data from a query variable (@Rarst idea).   3. Add a draft with a custom post status and predefined date upon click on "new"-link, redirect to the draft. Clean up drafts with a wp cron job (@userabuser idea). ## The problems   1. Hooking into the meta box means adding a callback to the `preview_post_link`-filter. Then I'd attach another callback to intercept the `gmt_offset`-option with a `'pre_option_gmt_offset'`-filter just to change the calculation done inside `touch_time()` to return the current date. Problem is that the calculation is `time() + ( $offset * HOURS_IN_SECONDS );` and the only value one could change is `$offset`.   2. Replacing the meta box would mean keeping track of every trac ticket and core change and therefore wouldn't be much future proof.   3. A lot of effort to add drafts, clean them up, etc. Then there's the problem that using custom post status still is a field full of mine traps. Any idea appreciated. Code that proofs the concept even more. I'll announce a bounty as soon as there're some usable drafts as answers.


title: Form validation on user profile edit

text: I have added a custom field to user profiles in bbPress however I am unsure how to do form validation other than javascript. I would like to do some PHP validation however the few things I have tried didn't work. If you fail to enter an email it will say "ERROR: Please enter an e-mail address." after you have submitted the form. I want something like that. I have tried:               $myErrors = new WP_Error();     $myErrors->add('id_error', __('Test error.',""));          bbp_add_error( 'bbp_steamid_invalid', __( 'ERROR: The ID you entered is invalid.', 'bbpress' ) );      I am not at all familiar with error handling in both WordPress and bbPress however I feel it is a must. Any help would be must appreciated.


title: Custom Post Types: pretty search URLs and has_archive

text:
This is a question based on the comments from the answer here. I'm using the following code to create a couple of different search boxes for my website:               <form action="<?php echo home_url( '/glossary/' ); ?>" method="get">
SEARCHGLOSSARY
         <input type="text" name="s" value="" />         <input type="submit" value="GO" class="glossary_submit" />     </form>          <form id="profilesearch" action="<?php echo home_url( '/species/' ); ?>" method="get">         <input type="text" size="50" class="default-value" value="SEARCH" name="s" />         <input type="submit" value="GO" class="profilesearch_submit" />                  <input type="checkbox" name="showthumbnails" id="showthumbnails" class="checkbox" <?php if ($_POST["showthumbnails"] == "on") { echo 'checked="checked" '; } ?>/>HIDE THUMBNAILS     </form>      My `glossary` CPT has the following creation `$args`:               $args = array(       'labels' => $labels,       'public' => true,       'publicly_queryable' => true,       'exclude_from_search' => true,           'show_ui' => true,       'show_in_menu' => true,       'query_var' => true,       'capability_type' => 'post',       'has_archive' => false,       'hierarchical' => true,       'menu_position' => 40,       'menu_icon' => $this->plugin_url . 'images/glossary.png',       'supports' => array('title','editor','thumbnail','page-attributes')     );      And my `species` CPT has these:               $args = array(       'labels' => $labels,       'public' => true,       'publicly_queryable' => true,       'show_ui' => true,       'show_in_menu' => true,       'query_var' => true,       'has_archive' => true,       'capability_type' => 'post',       'has_archive' => true,       'hierarchical' => false,       'menu_position' => 5,       'menu_icon' => $this->plugin_url . 'images/fish20.png',       'supports' => array('author','thumbnail','excerpt','comments','revisions')     );      Currently, when I submit a search from the glossary form, the URL changes to: `/glossary/?s=term`. When I submit a search from the species form, the URL changes to: `/search/term`. The glossary URL does what it's meant to do - searches for `glossary` CPT types only. The species URL however simply searches for everything. **If I change`has_archive` to `false`, the searches work as per the above `glossary`. If I change it to `true`, the searches work as per the above `species`.** What I want both to do is this: change URL to `/search/cpt-slug/term`, i.e. `/search/species/bettas` and search for only posts with that CPT. Have I done something wrong with my `$args`?


title: Generate multiple tag query URLs

text: As we know WordPress supports multiple tag queries (',' and '+'). The only problem with this `add_query_arg()` doesn't handle these methods if a query param is already exists in the URL. From the following url `www.domain.com?post_type=ptype&param=value1 add_query_arg('param', 'value2')` will generate `www.domain.com?post_type=ptype&param=value2` insead of `www.domain.com?post_type=ptype&param=value1,value2` or `value1+value2` I would only use comma separated (OR) method. Could you please help me to write a function which adds additional param value next to an exsisting one? regular expressions perhaps?


title: Generate a user list per site to communicate upgrade plans

text: My team has inherited a large WordPress Networks install. Updates need to be run and we need to communicate this to our editors and administrators. My system admin has asked me for a list of URLs and email address matched to those URLs. We plan to contact them site-by-site to manage a system wide upgrade. What would be an efficient way to go about this? I can get a list of emails from the `wp_users` table. Is there a tool that does this already (and properly)? **Most importantly: How can I group these users to their individual WP sites in the Networks install?** In other words, how might I get a report like this from within the WP-Admin? My client would like to use a plug-in if possible to produce this report inside of the admin interface.               site one     - smellyPete     - bilboBaggins989      site two     - sallysue997     - billyBob      etc, etc


title: Copy/clone/associate Custom field to Custom Taxonomy

text: I'm looking for a solution to "clone or copy or associate" custom fields data to custom taxonomies. example: Custom field "location" should copy data of that posts custom field to Custom Taxonomy "location" There is a plugin which Converts custom fields to custom taxonomies on demand, http://wordpress.org/extend/plugins/custom-field-taxonomies/ but I would need it's function in cron... automatically on daily basis.... Any solution counts, to adopt this plugin work in cron or a simple code to accomplish this function ThankS!


title: How can I change a plugin's URL?

text: I'm trying to use the OTW Portfolio Light plugin and what it does is adds it's own bit in the URL before the post type and I can't find where to change it. Going to a profile page brings up the proper URL:   `site.com/portfolio-name` But going to a portfolio item includes what I guess is the custom post name. So you get:   `site.com/otw-portfolio/portfolio-item` I can't get the otw-portfolio out of, or changed, in the URL. Support, as with most plugins it seems is near nonexistent so I'm looking around for help.


title: Help Understanding Taxonomy

text: OK, I need some help understanding taxonomies. I know what they are, I know how to make them, but I just don't what they're actually good for. So let's say I have a custom post type for video game reviews, and I want to separate the reviews by game console. XBox 360, PS3, and WII. So, from what I understand this would be a good use for taxonomies. I can make a taxonomy called "Video Games" and use the hierarchy feature for the "sub-categories" XBox 360, PS3, and WII. OK, so I get that, but what's the difference between making the taxonomy and just using categories and sub-categories? What are the advantages of taxonomies? I just don't see the difference. Can somebody explain this to me?


title: front end post with multiple upload images?

text: I am using front end post with upload image, my code               if (!function_exists('wp_generate_attachment_metadata')){                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');             }              if ($_FILES) {                 foreach ($_FILES as $file => $array) {                     if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                         return "upload error : " . $_FILES[$file]['error'];                     }                     $attach_id = media_handle_upload( $file, $new_post );                 }                }             if ($attach_id > 0){                 //and if you want to set that image as Post  then use:                 update_post_meta($new_post,'_thumbnail_id',$attach_id);             }      and it's work good with uploading one image like this                <input type="file" id="image" name="image">      but when I change my html to                <input type="file" id="image" name="image[]" multiple="multiple" >      it stop uploading Can any one help me please????


title: Associate Posts with individual user - hide from other members

text: Does WordPress have any functions which will help me create a system to have data ( eg custom posts ) associated with a particular user and (by default) not visible to any other user. I have had a look around and I haven't seen anything really like this so I am starting to suspect that it's outside of WordPress's domain but I thought I'd just ask here to make sure I wasn't missing anything obvious. I haven't fully checked out all the capabilities of the membership plugins because I believe they focus of allowing all ( or tiered ) content to logged in members ... so I may be wrong in this. What I need is something like a membership scenario where members can only see their own content, and not anyone else's. Is it possible to do something like this with WordPress, ideally with the core functions or better still a plugin. I am thinking that the user table is not designed for this type of activity. I found this article, and I know it's pretty old, but from this I sort of derive that adding twitter usernames and the like are about as far as we can go.


title: Print profile details as PDF or from modal window

text: I have been able to use the Advance Custom Fields plugin to create more fields I need for every new user to our site. What we need though, is that once someone has registered, they still need to be able to print off their details, sign it and bring it back to the property agency. What I need is to be able to add a print button next to the Update User button which would then pull all the details of that person, lay it out nicely and export it as a PDF for that person to sign and bring back. Here is what I would consider:   * Create new plugin   * Look into get_userdata() function to pull details.   * Figure out how to hook into User page and add button   * Add event to button that passes User ID to function.   * Launch Modal window with content extracted.   * Add button to modal window to print content. Might not even need the PDF option? Many thanks


title: Category slug in in loop always the same?

text:
My post category structure is 3-level deep:   * Products     * Milk products       * Milk       * Chocolate       * Cheese I want to show all posts from "Milk products" and add appropriate category slug as class, for example - a post with name "Cacao Chocolate" is inside Chocolate category and I want it to have "Chocolate" slug. With the following code all my posts added to category "Milk products" have the slug "Milk" - doesn't matter if they are also in category Milk, chocolate or cheese.               <?php          query_posts('category__in=39');     while ( have_posts() ) : the_post();         echo '
slug .'" data-filter="'. $category->slug .'">'. get_the_content() .'
';          endwhile;          // Reset Query     wp_reset_query();     ?>      Any idea how to get the the last category slug of the post?


title: add action only on post publish - not update

text: I have action which adds meta field with value on post publish. Problem is that when I update post meta field is reset to default value. I already tried 'new_to_publish' instead of 'publish_post' but it doesn't work.               add_action('publish_post', 'add_custom_field_automatically');     function add_custom_field_automatically($post_ID) {       global $wpdb;            if(!wp_is_post_revision($post_ID)) {         update_post_meta($post_ID, 'votes_count', '0');          }     }      Still can't make it work               add_action( 'transition_post_status', 'wpse120996_post_status_publish', 10, 3 );     function wpse120996_post_status_publish( $new_status, $old_status, $post_ID ) {          if ( $new_status == 'publish' && $old_status == 'pending' ) {               global $wpdb;            if(!wp_is_post_revision($post_ID)) {         update_post_meta($post_ID, 'votes_count', '0');         }     }}      As I can understand it - every time status changes from pending to publish do whatever is inside if. But it doesn't work. In my site I have post rating system with meta field 'votes_count' where are stored votes. When I query votes_count from highest to lowest it doesn't show posts with no votes, so I need to populate it with default value 0 to include them into query. Everything works fine but when i update votes are reset to 0... Posts are published by users with pending status which I check and publish.


title: Use php array outside his function

text: any ideas why my function print_r $arr with lot of elements, but only retain cat and dog when it comes to print_r $stack? I need to have $arr used outside the function,               function pre_selected_results() {         $args = array(...)         $the_query = new WP_Query($args);              $arr = array("Dog","Cat");              while ($the_query->have_posts()) :              $the_query->the_post();             $args = array(...)             $results = wp_get_post_terms(get_the_ID(),'type',$args);               foreach ($results as $result){                 $arr[] = $result;                }          endwhile;         print_r ($arr);         return $arr;     };//End of pre_get_results function     $stack = pre_selected_results();     print_r ($stack);      Thanks a lot! EDIT : my $args in case that helps: for the quey :               $args['tax_query'] = array(     'relation' => 'OR',      array(         'taxonomy' => 'category',         'terms' => $_GET['category'],         'field' => 'slug',     ),     array(         'taxonomy' => 'genres',         'terms' => $_GET['genre'],         'field' => 'slug',     ),     array(         'taxonomy' => 'types',         'terms' => $_GET['type'],         'field' => 'slug',     ),      ); and for the wp_get_post_term:               $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs');      thanks again


title: wp_localize_script & wp_enqueue_script not working in front end

text: Here is my code snippet :               wp_enqueue_script( 'ajax-script', get_stylesheet_directory_uri().'/js/myajax.js', array('jquery'), 1.0 );     wp_localize_script( 'ajax-script', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );      My problem is when ever i use that ajax_object it won't work. Also myajax.js file won't load to the site. But works fine in Admin panel. Why that enqueue script & localize script not working in front end ?


title: How to find out if an wp-admin action edited a file?

text: I want to create a small plugin to automatically purge the APC opcode cache after specific actions in the Wordpress admin interface. This is necessary if e.g. apc.stat is set to 0, as a change to a file then doesn't reset its cache value in the opcode cache and so calls will use the old, cached, out-of-date file. Total debug nightmare if you forget to clear the cache manually. **Is there an easy way to find out if an action edited/changed a file?** I could manually check if is_admin and POST and file is e.g. theme-editor.php, but this seems like a not very nice hack that is bound to miss some things.


title: How is WooCommerce cart.php template supposed to be used?

text: I have a fresh install of Wordpress 3.5 and WooCommerce 1.6.6 (WC from now on) and use the default Twenty Twelve theme. I added a Product to WC and when viewing that product and using the Debug Bar Template Trace plug-in I can see that the template `woocommerce/templates/single-product.php` is used. However, if I view the Cart page, which was automatically generated by WooCommerce, it uses the `twentytwelve/page.php` template and not the `woocommerce/templates/cart/cart.php` template, which I found surprising. I'm a little confused from this outcome. Isn't the `cart.php` template supposed to be used for the Cart page? If not, what is that template for, and under which circumstances does it get used by WC?


title: Gravity prerender taxonomy

text: I'm trying to prepopulate a category field or post drop down in gravity forms. Here is what I have:               <?php          add_filter("gform_pre_render", "gform_prepopluate_populate_books");          //Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.     add_filter("gform_admin_pre_render", "gform_prepopluate_populate_books");          function gform_prepopluate_populate_books($form){         $posttype = 'books';         $taxtype = 'genres';         $formid = 5;         $fieldid = 14);              //only populating drop down for form id 5         if($form["id"] != $formid)            return $form;              //Reading posts for "Business" category;         //$posts = query_posts(array('post_type' => array('post', 'movies')));        // $posts = query_posts( array( 'post_type' => $querytype ) );                   $taxonomies=get_taxonomies(array('name' => $taxtype ), 'names');         // if ( have_posts() ) : while ( have_posts() ) : the_post();              //Creating drop down item array.         $items = array();              //Adding initial blank value.         $items[] = array("text" => "", "value" => "");              //Adding post titles to the items array         if ( $taxonomies ) {             foreach($taxonomies  as $taxonomy) {                 $items[] = array("value" => $taxonomy->slug, "text" => $taxonomy->name);             }         }              //Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.         foreach($form["fields"] as &$field)             if($field["id"] == $fieldid ) {                             $field["choices"] = $items;         }          }      Doesn't seem to be working to populate my taxonomy values into my dropdown. Any thoughts?


title: Filter taxonomy terms using multiple id in the edit-tags.php

text: I want to use the edit-tags.php search function with multiple term id's. For example, if i type into the searchbox something like this: #1245&6832, it should display these two terms in the results table(WP_Terms_List_Table). I tried to use the pre_get_posts action to get access to the query that is running for the search, but this is just showing me an "empty" query:               add_action('pre_get_posts', 'filter_terms_by_ids' );          function filter_terms_by_ids( $wp_query ) {         global $pagenow;              if($pagenow == 'edit-tags.php' && $_GET['s']):             print_r($wp_query->query_vars);         endif;          }      My idea is to check the $_GET['s'] and if # is the first character, i can modify the query to only include these terms in the search:               if ('#' == substr($_GET['s'],0,1))


title: WP_ENQUEUE not working with Foundation 5 (resolved)

text: **EDIT** : PLEASE SEE MY ANSWER BELOW FOR ASSISTANCE :) feel free to use the code! I've recently started integrating Foundation 5.2.3 into Wordpress 3.9, and I am having issues with getting jquery to initialize via wp_enqueue. The styles load just fine, though. A working example of what I am trying to achieve can be found here (styles & scripts in header.php and footer.php) functions.php               // Enqueue scripts     require_once('library/enqueue-scripts.php');      Now in my enqueue-scripts.php               <?php          // wp_enqueue foundation_styles     function foundation_styles() {            // wp_enqueue style, as you do not need to register style links.        wp_enqueue_style( 'reset', get_template_directory_uri() . '/style.css' );       wp_enqueue_style( 'foundation', get_template_directory_uri() . '/css/foundation.css' );       wp_enqueue_style( 'icons', get_template_directory_uri() . '/font-files/font-icons/foundation-icons.css' );       wp_enqueue_style( 'nprogress', get_template_directory_uri() . '/css/nprogress/nprogress.css' );       wp_enqueue_style( 'override', get_template_directory_uri() . '/css/project.override.css' );          }          // wp_enqueue foundation_scripts     function foundation_scripts() {            // wp_enqueue jqeury        wp_enqueue_script('jquery');            // wp_enqueue scripts        wp_enqueue_script( 'modernizer', get_template_directory_uri() . '/js/modernizr-2.5.3.js',null,null, false );       wp_enqueue_script( 'scrollreveal', get_template_directory_uri() . '/js/foundation/foundation.scrollReveal.js',null,null, false );       wp_enqueue_script( 'jquery110', get_template_directory_uri() . '/js/vendor/jquery-1.10.js',null,null, true );       wp_enqueue_script( 'nprogress', get_template_directory_uri() . '/js/foundation/foundation.nprogress.js',null,null, true );       wp_enqueue_script( 'foundationmin', get_template_directory_uri() . '/js/foundation/foundation.min.js',null,null, true );       wp_enqueue_script( 'foundationscripts', get_template_directory_uri() . '/js/foundation/foundation.scripts.js',null,null, true );          }          add_action( 'wp_enqueue_scripts', 'foundation_styles' );     add_action( 'wp_enqueue_scripts', 'foundation_scripts' );          ?>      I have my custom script file /js/foundation/foundation.scripts.js initializing foundation via:               jQuery(document).foundation(($);      In my header.php I have my title functions, basic meta, and the `wp_head`. Im really lost as to why my jquery isn't loading. Side note: the jquery 1.10 is used ONLY to help nprogress.js work.


title: Login With Ajax and Register Plus Redux conflict: a verification email?

text: Is there a way to force Login With Ajax to obey the Register Plus Redux email verification setting? I've enabled the email verification and emails as usernames in Register Plus Redux. I'm using Login With Ajax for the front-end ajax registration / login handling. With this combination, a regular username is created and the user is able to use that. However, the temporary (waiting to be verified) username is never created and the new user thus never receives the confirmation email. The temporary username is created (and the verification email is sent) if the user uses the WP's own registration form. I am using WP 3.6.1, Register Plus Redux 3.9.10 and Login With Ajax 3.1.2.


title: Advanced Taxonomy query, with 3 post types

text: I'm been trying to figure out how to do this for a few hours now and Have final given in to asking for help. I've got 3 custom post types that I need to query for a term called home which is inside a taxonomy on each one. hope I've been clear with what I want to achieve, here is the code I'm using at the moment.                           <?php               $args = array(             'post_type' => array( 'testimonial', 'casestudy', 'post'),             'posts_per_page' => 1,             'tax_query' => array (             'relation' => 'OR',             array(             'taxonomy' => 'testimonial_category',             'terms' => 'home'             'field' => 'slug'             ),             array(             'taxonomy' => 'casestudy_category',             'terms' => 'home'             'field' => 'slug'             ),             array(             'taxonomy' => 'category',             'terms' => 'home'             'field' => 'slug'             ),             )     );                  $query = new WP_Query( $args );             $postcount = 0;                 ?>                <?php if ($query->have_posts()) : ?>                <?php while ($query->have_posts()) : $query->the_post(); ?>                <?php $postcount++; ?>


title: Is it possible to personalize the Media Library?

text: When we create a new post and click on Featured Image, I realize that WP creates a folder structure "year/month/image.jpg". I'd like to change that behavior to "category_of_the_post/image.jpg" (or maybe "category_of_the_post/year/month/image.jpg"). The reason is that **I want to create a different album of each "category_of_the_post" folder**. I tried different plugins, but **I didn't find any plugin which allow to upload the images at the same time we create the new post** (like when we upload the feature image). Maybe there is some other way to do the same stuff, but I'm beginning with this beautiful CMS so I cannot see the different possibilities from the top.


title: Enable infinite scroll on single.php

text: I have a problem similar to the author of this thread: Possible to paginate on single.php? I am trying to enable infinite scrolling on single.php. So far I successfully load an additional 1 post when I reach the bottom of the page, but I'd really like to load more. I've diagnosed the problem several ways:   1. Perhaps the original query returns only the two posts, and that's why no more appear. In this case, how do I expand the original query to include more posts? I figure it has something to do with using pre_get_posts, but I haven't succeeded yet.   2. Perhaps, after outputting the original single post (I want the original single post to be first), I can overwrite the original query. I tried get_posts, new WP_Query, query_posts... but again I don't understand these well enough (I did read the Codex). And although I sometimes succeeded in displaying more than two posts, those posts were included in the original HTML, and so the infinite scroll functionality was skipped. Can anyone point me in the right direction? Has anyone succeeded in doing this? Other posts I read had people respond confused as to why someone would want multiple posts on single.php. I want an infinite scroll functionality on single.php because my visitors land on a single post often enough. That being the case, I'd like to optimize this page by encouraging them to read more by having more posts once they reach the bottom of the page. Catch my drift? It might all be a failure but the team wants to try it. Thanks for reading. -Miguel


title: Alternative for is_taxonomy() to workaround theme's default sidebar

text: My Wordpress theme is using some code in the "sidebar.php" file that tells it that some pages should always use the default sidebar. This was fine until I found that each and every custom taxonomy (example: "taxonomy-mountains.php") page is defaulting to this default sidebar. I thought about catching this with `is_taxonomy()`, but that's deprecated and won't work. Any better programmers out there with an idea of how I could fix this now. Something like `if(is_taxonomy('mountains')){}` would've worked fine. Below code is an excerpt, if you think something is missing let me know.               //Default sidebar     $selected_sidebar_replacement = 'Sidebar Widgets';          //If is page or single     if(is_singular()){     global $wp_query;     $post = $wp_query->get_queried_object();     $selected_sidebar_replacement = get_post_meta($post->ID, 'sbg_selected_sidebar_replacement', true);          //If default selected     if($selected_sidebar_replacement == '0' || $selected_sidebar_replacement == ''){     $selected_sidebar_replacement = 'Sidebar Widgets';                         }          // Reset the global $the_post     wp_reset_query();                          }


title: How can I display a specific user's first published post?

text: I'm looking for a way to display a user's first published post using their unique ID. I have a function that calls a list of specific users using their IDs, and would like to display the date the user first published a post. This is the code I put in, however, the cells return blank with no PHP errors in the log.               $useremail = $ticket['email'];     $user = get_user_by( 'email', $useremail );     $IDuser = $user->ID;           $args = array(         'posts_per_page' => 1,         'post_status' => 'publish',         'author' => $IDuser,         'orderby' => 'ID',         'order' => 'ASC',     );     $first_post = new WP_Query($args);     if ($first_post->have_posts()) {         $first_post->the_post();              echo the_time('M j, Y');              wp_reset_postdata();     }


title: Exclude category from query

text: ## PROBLEM Hey everyone I have the wp loop to display posts, but I need to exclude category 81. I tried: **query_posts('cat=-81'); ?>** before the loop but the pagenavi is broken and it doesn't work properly. ## CODE                   <?php  if(have_posts()): ?>                          <ol class="list posts">                          <?php                         $end = array(3,6,9,12,15,18,21,24,27,30,33,36,39,42,45);                         $i = 0;                         while (have_posts()) : the_post();                         $i++;                         global $post;                     ?>      ## HEADER I have this in the begining of the page - maybe it has something to do with it?:               <?php get_header();          global $wp_query;     $curauth = $wp_query->get_queried_object();     ?>


title: What is considered a default query for the request filter?

text: As stated in one of the answers in this question and in the codex entry for the `request` filter, said filter gets called only in a default query, such as the main query used for a loop. My question is, what else is or isn't considered a default query? Would creating a new `WP_Query` object be considered such?


title: How to change post thumbnail title and alt attributes to post title?

text: Can we change the title and alt attributes of the_post_thumbnails and set them to post title instead ? like creating a function for it and adding a filter ? I tried searching but I can't seem to find what I want. and thanks in advance.


title: WordPress Gallery Permalink Structure Displaying Incorrectly

text: When an image is added to a gallery, the resulting attachment URL is generally displayed in a structure like this: **example.com/post-slug/attachment-slug/** However, take a look at my gallery: http://themeforward.com/demo2/?p=2195 and view an image. What could be preventing this slug from appearing correctly? The images have been attached to the post properly.


title: custom post type category page

text: I can't seem to get archive page or category page to work correctly. I am following http://codex.wordpress.org/Template_Hierarchy#Category_display and it still defaults to archive.php ( i think, according to chart ) even though I have named it category-business.php here is my code:               /******************     //  Business     ******************/          function my_custom_post_business() {       $labels = array(             'name'               => _x( 'business', 'post type general name' ),             'singular_name'      => _x( 'business', 'post type singular name' ),             'add_new'            => _x( 'Add New', 'book' ),             'add_new_item'       => __( 'Add New business' ),             'edit_item'          => __( 'Edit business' ),             'new_item'           => __( 'New business' ),             'all_items'          => __( 'All business' ),             'view_item'          => __( 'View business' ),             'search_items'       => __( 'Search business' ),             'not_found'          => __( 'No business found' ),             'not_found_in_trash' => __( 'No business found in the Trash' ),              'parent_item_colon'  => '',             'menu_name'          => 'business'         );         $args = array(             'labels'        => $labels,             'description'   => 'Holds our business and business specific data',             'public'        => true,             'hierarchical'      => true,             'show_ui'           => true,             'show_in_nav_menus' => true,             'menu_position' => 5,             'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),             'has_archive'   => true,                  //'taxonomies' => array('category'),         );         register_post_type( 'business', $args );          }     add_action( 'init', 'my_custom_post_business' );                    /** add categories for custom post type */     add_action( 'init', 'build_taxonomies', 0 );     function build_taxonomies() {         register_taxonomy( 'mycategories', 'business', array( 'hierarchical' => true, 'label' => 'Business Categories', 'query_var' => true, 'rewrite' => true ) );     }


title: Allow users to upload file through plugin

text:
I am writing a plugin where I want to allow users to upload a .zip file. When they hit submit, I want WordPress to unzip the files and place the files into a specified folder. I've noticed functions such as unzip_file(); and wp_handle_upload(); , but I can't seem to get any files uploading and storing correctly. I have created an html form with an input field and submit button, and after hitting submit it looks like the file is uploading (you can see % going up) at 100%, the page refreshes but the file doesn't get stored anywhere.               <form id="custom_plugin_form" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
                     Select Custom Font Pack :
                     <input type="file" id="custom_plugin_form_upload_field" name="custom_plugin_form_upload_field">
                             note: file must be a .zip downloaded from icomoon
                                     <?php                         $other_attributes = array('onclick' => 'custom_plugin_upload_files()');                         echo submit_button( 'Upload', 'primary', '', true, $other_attributes );                     ?>
             </form>      First how do I store the files into a specific folder? (not the default media upload file, maybe into my plugin root?) After I get that, how do I run unzip_file() on the file just uploaded? Thanks


title: Trip Advisor and WordPress

text: I would like to have TripAdvisor reviews of a client's restaurant shown on the site, what's the best way to do that? If possible he would like the possibility to check the review first before it is posted to the site.


title: Change the filename format of saved featured images

text: Does anyone know how I could change the way wordpress saves the featured image's additional image sizes? Right now I have the main image saving like so:               test_builder_banner_2.jpg      and for each additional image size it saves like so:               test_builder_banner-610x260.jpg      All I want to do is get rid of the "-" between the name of the file and the file size, and replace it with an underscore. Is there a filter I can use or something of that sort?


title: Wp Query with multiple custom tag(taxonomy) by get the terms

text: I need to do a wp query that will get any post in custom post type that has one custom taxonomy (not hierarchical, like a post tag) or more. My current code work for one tag, but I've try for multiple and I can't do... I've try a lot of possibilites, query by taxonomy ID etc, no one works for me. Can you help me ? Thank's ! There is my actual code, work for one tag :               <?php foreach (get_the_terms( $post->ID, 'tag_blogcom' ) as $term ) {}?>          <?php     $query = new WP_Query(array(     'post_type' => 'blogcom',     'tag_blogcom' => $term->slug,     'showposts' => 10     ));     ?>


title: "Securing" images in WordPress

text: I'm generally against the practice of making images difficult to download on websites. However, we have a number of photographic contributors who grant us exclusive free access to their images. Not long back I had an instance of a website using a lot of our information including photographs. What steps can I take to secure our images? I appreciate that it will never be bullet-proof, but I'd like to make it at least mildly difficult. The likes of a watermark would probably be ideal, but I know very little about the subject. **EDIT** : It has just occurred to me, having watched a Watermarking plugin demonstration video, that I need my users to be able to view the image perfectly, but for it to be downloaded with a watermark (i.e. if they right click > save as). Obviously this makes things much more complicated and I realise that the images will be susceptible to screenshotting and `wget`, but at least I'll make it somewhat difficult for some would-be image thieves. Do any such plugins exist, or are there any built-in WordPress functions which might help me out? Thanks in advance,


title: Why doesn't wpmu_new_user work from a plugin when it does from theme?

text: So here's a simple test function that should send an email (just want to get it working first before I work on other functionality) when a new user is created on the multisite installation. The email should be sent when a user signs up from wp-signup.php and clicks the activation link from their email.               function test_wpmu_new_user( $user_id ) {         wp_mail( 'me@myemail.com', 'The subject', 'The body' );     }     add_action( 'wpmu_new_user', 'test_wpmu_new_user' );      It **works** from a theme's functions.php, but **not** from a simple plugin with nothing else in it. It also works when I hardcode it into ms-functions.php where another function, `newuser_notify_siteadmin` lives, which also fires on `wpmu_new_user`. Obviously I don't want to hardcode it. And lastly, it **does** work from the same plugin file, but only when the new user is created by the super admin in the WP admin. I need it to work for a self registering user however. Trac states: > This function runs when a user self-registers as well as when a Super Admin > creates a new user. Hook to 'wpmu_new_user' for events that should affect > all new users, but only on Multisite (otherwise use 'user_register'). Is it a priority issue? Do I need to load it on a specific hook?


title: How to get WordPress Time Zone setting?

text: Can someone tell me how to get the time zone that is set in the WordPress Admin? For example, if the blog is set to Eastern time, I need this exact string to print out: > US/Eastern This is for a function that lives in functions.php in my theme.


title: Are all ID's used unique?

text: I'm using JSON api plugin to pull data from wordpress into an app I am making. I need a unique identifier to make sure I don't have any duplicates WHILE also using the identifier as a way to sort from newest post to oldest post. As of right now I'm confused because I pull the 10 most recent posts. I then take the ID and I attempt to reach example.com/?id=1774 but I don't get the correct post. I get a different one. I'm starting to run out of ideas?


title: wp enqueue script using scripts from cdn with a safety callback

text: I want to include several scripts and styles from a remote CDN... in this case bootstrap and similer files but i want to provide a safety net in the form of a callback in the case the CDN is down for some reason... I would add some code but i really dont know how to approace this at all... **Here is an example of a regular wp_enqueue_script i currently use:**               wp_enqueue_script( 'bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js', array('jquery'), 3.3, true);


title: turn off WooCommerce for a site in a multi site environment

text: I've just installed P3 (Plugin Performance Profiler) and it shows that WooCommerce & WooCommerce Subscriptions are active on every one of my subdomain multi sites. How do I turn plugins off on on a site by site basis?


title: Posts showing [...] in it

text: I have seen a bug on my website. It appeared just few days back and was not present before so I am suspecting a plugin updgrade to be the reason for it. The problem is that when I open a post for reading, it shows me `[...]` after about 300 characters(just guessing the characters). This is the same truncation that is done on the page which shows the list of all articles on my website. How can I remove it? Please help me out. Thanks


title: Strict Standards Error bootstrap navwalker

text:
I am having trouble understanding this error and I've not come across it before, please could someone help?               Strict Standards: Declaration of wp_bootstrap_navwalker::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in .../wp-content/themes/flat-portfolio/wp_bootstrap_navwalker.php on line 143      The wp_bootstrap_navwalker.php code is as follows:               <?php          /**      * Class Name: wp_bootstrap_navwalker      * GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker      * Description: A custom WordPress nav walker class to implement the Twitter Bootstrap 2.3.2 navigation style in a custom theme using the WordPress built in menu manager.      * Version: 1.4.3      * Author: Edward McIntyre - @twittem      * License: GPL-2.0+      * License URI: http://www.gnu.org/licenses/gpl-2.0.txt      */          class wp_bootstrap_navwalker extends Walker_Nav_Menu {              /**          * @see Walker::start_lvl()          * @since 3.0.0          *          * @param string $output Passed by reference. Used to append additional content.          * @param int $depth Depth of page. Used for padding.          */         function start_lvl( &$output, $depth ) {             $indent = str_repeat( "\t", $depth );             $output    .= "\n$indent
\n";                 }              /**          * @see Walker::start_el()          * @since 3.0.0          *          * @param string $output Passed by reference. Used to append additional content.          * @param object $item Menu item data object.          * @param int $depth Depth of menu item. Used for padding.          * @param int $current_page Menu item ID.          * @param object $args          */              function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {             global $wp_query;             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  /**              * Dividers & Headers              * ==================              * Determine whether the item is a Divider, Header, or regular menu item.              * To prevent errors we use the strcasecmp() function to so a comparison              * that is not case sensitive. The strcasecmp() function returns a 0 if               * the strings are equal.              */             if (strcasecmp($item->title, 'divider') == 0) {                 // Item is a Divider                 $output .= $indent . '
';             } else if (strcasecmp($item->title, 'divider-vertical') == 0) {                 // Item is a Vertical Divider                 $output .= $indent . '
';             } else if (strcasecmp($item->title, 'nav-header') == 0) {                 // Item is a Header                 $output .= $indent . '
' . esc_attr( $item->attr_title );             } else {                      $class_names = $value = '';                 $classes = empty( $item->classes ) ? array() : (array) $item->classes;                 $classes[] = ($item->current) ? 'active' : '';                 $classes[] = 'menu-item-' . $item->ID;                 $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );                      if ($args->has_children && $depth > 0) {                     $class_names .= ' dropdown-submenu';                 } else if($args->has_children && $depth === 0) {                     $class_names .= ' dropdown';                 }                      $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';                      $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );                 $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';                      $output .= $indent . '
';                      $attributes = ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';                 $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';                 $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';                 $attributes .= ($args->has_children)        ? ' data-toggle="dropdown" data-target="#" class="dropdown-toggle"' : '';                      $item_output = $args->before;                      /**                  * Glyphicons                  * ===========                  * Since the the menu item is NOT a Divider or Header we check the see                  * if there is a value in the attr_title property. If the attr_title                  * property is NOT null we apply it as the class name for the glyphicon.                  */                 if(! empty( $item->attr_title )){                     $item_output .= 'attr_title ) . '"> ';                 } else {                     $item_output .= '';                 }                      $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;                 $item_output .= ($args->has_children && $depth == 0) ? ' ' : '';                 $item_output .= $args->after;                      $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );             }         }              /**          * Traverse elements to create list from elements.          *          * Display one element if the element doesn't have any children otherwise,          * display the element and its children. Will only traverse up to the max          * depth and no ignore elements under that depth.           *          * This method shouldn't be called directly, use the walk() method instead.          *          * @see Walker::start_el()          * @since 2.5.0          *          * @param object $element Data object          * @param array $children_elements List of elements to continue traversing.          * @param int $max_depth Max depth to traverse.          * @param int $depth Depth of current element.          * @param array $args          * @param string $output Passed by reference. Used to append additional content.          * @return null Null on failure with no changes to parameters.          */              function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {             if ( !$element ) {                 return;             }                  $id_field = $this->db_fields['id'];                  //display this element             if ( is_object( $args[0] ) ) {                $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );             }                  parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);         }     }          ?>      I'm calling the walker by putting the following code in my header.php               <?php          wp_nav_menu( array(             'menu'       => 'top_menu',             'depth'      => 2,             'container'  => false,             'menu_class' => 'nav',             'fallback_cb' => 'wp_page_menu',             //Process nav menu using our custom nav walker             'walker' => new wp_bootstrap_navwalker())         );     ?>      and registering the function in functions.php:               // Register Custom Navigation Walker     require_once('wp_bootstrap_navwalker.php');


title: Strict Standards: Declaration of ... should be compatible with

text:
I try this answer, and i changed the               function start_el(&$output, $item, $depth = 0, $args = array() ) {      but it did not work. The problem is, I have this theme, link here. and I'm getting this error: Strict Standards: Declaration of description_walker::start_el() should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in C:\xampp\htdocs\wordpress\wp- content\themes\bismuth\functions.php on line 278 about the part of functions.php               function register_menus() {     register_nav_menus( array( 'top-menu' => 'Top primary menu')                         );      } add_action('init', 'register_menus'); class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                      $class_names = $value = '';                 $classes = empty( $item->classes ) ? array() : (array) $item->classes;                 $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );            $class_names = ' class="'. esc_attr( $class_names ) . '"';                 $output .= $indent . '
ID . '"' . $value . $class_names .'>';                 $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';            $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';            $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';            if($item->object == 'page')            {                 $varpost = get_post($item->object_id);                 $attributes .= ' href="' . get_site_url() . '#' . $varpost->post_name . '"';            }            else                 $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';             $item_output = $args->before;             $item_output .= '';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID );             $item_output .= $args->link_after;             $item_output .= '';             $item_output .= $args->after;                  $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );             }      } Someone please know how to solve this? Thanks a lot!


title: Custom nav walker error

text:
I'm using wordpress 3.9 locally to develop a new theme for my website, however I am getting these errors when trying to use a custom nav walker function:               Strict Standards: Declaration of ik_walker::start_lvl() should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in C:\xampp\htdocs\myproject\wp-content\themes\matt\functions.php on line 111          Strict Standards: Declaration of ik_walker::end_lvl() should be compatible with Walker_Nav_Menu::end_lvl(&$output, $depth = 0, $args = Array) in C:\xampp\htdocs\myproject\wp-content\themes\matt\functions.php on line 111          Strict Standards: Declaration of ik_walker::start_el() should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in C:\xampp\htdocs\myproject\wp-content\themes\matt\functions.php on line 111      My nav walker:               class ik_walker extends Walker_Nav_Menu {              function start_lvl(&$output, $depth) {             $GLOBALS['ik_walker_counter'] = 0;             $output .= ''.                 '
';         }              function end_lvl(&$output, $depth) {             $output .= '
'.                 '<button id="menu" class="menu-button" type="button" role="button" aria-label="Menu Toggle">'.                 ''.                 '</button>'.                 '
';         }              function start_el(&$output, $item, $depth, $args) {             global $wp_query;             global $ik_walker_counter;             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';             $class_names = $value = '';             $classes = empty( $item->classes ) ? array() : (array) $item->classes;             $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';             $output .= $indent . '
ID . '"' . $value . $class_names .'>';             $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target )  ? ' target="' . esc_attr( $item->target     ) .'"' : '';             $attributes .= ! empty( $item->xfn )        ? ' rel="'  . esc_attr( $item->xfn      ) .'"' : '';             $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';             $attributes .= ' class="c'.(++$ik_walker_counter).'"';             $item_output = $args->before;             $item_output .= '';             $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             if(strlen($item->description)>2){ $item_output .= '
' . $item->description . ''; }             $item_output .= '';             $item_output .= 'my_individual_class.'">';             $item_output .= $args->after;             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }          }      Calling the nav walker:               <?php     wp_nav_menu( array(         'menu' => 'primary-menu'         ,'container' => 'nav'         ,'container_class' => 'subpages'         ,'depth' => 0         ,'walker' => new ik_walker()      ));     ?>      Help would really be appreciated


title: exclude pages in custom menu

text:
I am creating a custom theme for wordpress, which will have a settings page. i am adding the option to exclude pages from the navigation, which will simply work on the page id separated by a "," here is the code i have so far:
     <?php         $exmenuitems = get_option('exmenuitems');         $recentPosts = new WP_Query();         $recentPosts->query (array (         'post__not_in' => array($exmenuitems),         'post_type' => 'page',         'showposts' => $menuitems     ));      while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>     <?php $slug = basename(get_permalink());?>
<a href="#<?php echo $slug; ?>"><?php the_title();?>
     <?php endwhile; ?>
      this works fine excluding just 1 page id. but when i try and exclude more than 1 id it doesn't work, only the first id in the text input will get excluded and the other remain visible. any help would be greatly appreciated. Dan


title: If custom taxonomy else conditional

text:
I have a menu that I only want to show on certain pages using the following code:               <?php if ( is_front_page() || is_archive() || is_404() ) {          }     else     {          if ( function_exists('has_parent') ) {              $id = get_the_ID();         $menu_to_use = get_post_meta($id, 'themestore-meta-menu-name', 1);         echo '';         echo '

';         wp_nav_menu( array('menu' => $menu_to_use, 'menu_class' => 'nav container group', 'container' => '' ));           echo '';     }     }          ?>      I have a custom taxonomy and post type that I DON'T want the menu to show up on for single post pages. I've tried the following and none seem to work:               if ( is_front_page() || is_archive() || is_404() || is_singular('tips') )     if ( is_front_page() || is_archive() || is_404() || is_tax('tips') )     if ( is_front_page() || is_archive() || is_404() || taxonomy_exists('tips') )     if ( is_front_page() || is_archive() || is_404() || 'tips' == get_post_type() )     if ( is_front_page() || is_archive() || is_404() || is_category('tips') )      And I've tried both custom functions from this answer: If is custom post type It would seem that one of those should work but none of them hide the menu. What am I missing?


title: Buddypress Adding a Nav item and Calling Custom Fields

text: function my_bp_nav_adder()      {      bp_core_new_nav_item(      array(          'name' => __('information', 'buddypress'),          'slug' => 'info',          'position' => 15,          'show_for_displayed_user' => true,          'screen_function' => 'all_conversations_link',          'default_subnav_slug' => 'testing',          'item_css_id' => 'all-conversations'      ));      }      // Load a page template for your custom item. You'll need to have an item-one-   template.php and item-two-template.php in your theme root.     function all_conversations_link () {          }          add_action( 'bp_setup_nav', 'my_bp_nav_adder' );       I am trying to display some value of custom fields in the tab that I have just created called information. I have created custom profile fields called location. using this code I am fetching the value               <?php          //code inside the directory loop          $location= xprofile_get_field_data( "Contact Person" ,bp_get_member_user_id());//fetch  the text for location     echo " $location ";          ?>      However I get this to be a broken page.I do get the output but it is displayed at the top of the page.How to correctly format these values to fit in line and diplay like the profile


title: How to concatenate two separate colums into one?

text: In phpmyadmin I have two separate columns for latitude and longitude. e.g. lat: '38.897683' lng:'-77.03649'. These coordinates are generated for my location custom posts. How can I automatically merge them into a new (third) column so that I have the values in one string: '38.897683,-77.03649'. I would like to apply this to both the preexisting and new posts that are created. Thaks


title: Wordpress query var pretty url prefix

text: I want to add custom query parameter to define language in wordpress, but i want it to be in permalink structure before all other vars, for example:                 site.com/en/page       site.com/en/post      and for default language:                 site.com/page       site.com/post      Is this possible?


title: Getting stripos error when trying to add menu classes

text: I'm using a custom theme that is doing something that blocks Custom Menu Classes (the optional ones that you can input from inside the Menu Panel) to print to HTML.   1. I found in the code where they are adding classes to the `li` tag. So I tried to add this line of code: `$li->addClass($classes);` Would that be the correct code to use to pull the class field from the menu panel? If so.. I did that and I got this error: `Warning: stripos() [function.stripos]: needle is not a string or an integer in file-path/file.php on line 397` Here's that block of code: (I noted just above the line the warning referenceS)               protected static function attrClass($action, DOMNode $node, $class) {              $classes = $node->getAttribute('class');     /* error found in line below */         $found   = stripos($classes, $class) !== false && in_array(strtolower($class), explode(' ', strtolower($classes)));              if ($action == 'has') {             return $found;         }              if ($action == 'toggle') {             $action = $found ? 'remove' : 'add';         }              if ($action == 'add' && !$found) {             $node->setAttribute('class', trim(preg_replace('/\s{2,}/i', ' ', $classes.' '.$class)));         }               if ($action == 'remove' && $found) {                  $classes = trim(preg_replace('/\s{2,}/i', ' ', preg_replace('/(^|\s)'.preg_quote($class, '/').'(?:\s|$)/i', ' ', $classes)));                  if ($classes !== '') {                 $node->setAttribute('class', $classes);             } else {                 $node->removeAttribute('class');             }         }              return $node;     }      I'm not sure what's going wrong and what I need to do next in order to get the menu custom class function working. Note: Still learning wordpress/php so if I'm missing any needed any information I'm sorry and I'll post it if you ask. Trying to be as thorough as possible! -edit- Here's the block of code where i tried adding `$li->addClass($classes);` (I noted just before it again)               class WarpMenuDefault extends WarpMenu {          /*         Function: process              Returns:             Object     */       public function process($module, $element) {         self::_process($module, $element->first('ul:first'));         return $element;     }          /*         Function: _process              Returns:             Void     */     protected static function _process($module, $element, $level = 0) {              if ($level == 0) {             $element->attr('class', 'menu '.$module->menu_style);         } else {             $element->addClass('level'.($level + 1));         }              foreach ($element->children('li') as $li) {                  // is active ?             if ($active = $li->attr('data-menu-active')) {                 $active = $active == 2 ? ' active current' : ' active';             }                  // is parent ?             $ul = $li->children('ul');             $parent = $ul->length ? ' parent' : null;                  // set class in li             $li->attr('class', sprintf('level%d item%s'.$parent.$active, $level + 1, $li->attr('data-id'),$class));     /* Here's the line I added*/            $li->addClass($classes);                        // set class in a/span             foreach ($li->children('a,span') as $child) {                      // get title                 $title = $child->first('span:first');                      // set subtile                 $subtitle = $title ? explode('||', $title->text()) : array();                      if (count($subtitle) == 2) {                     $li->addClass('hassubtitle');                     $title->html(sprintf('%s%s', trim($subtitle[0]), trim($subtitle[1])));                 }                      // set image                 if ($image = $li->attr('data-menu-image')) {                     $title->prepend(sprintf(' ', $image));                 }                      $child->addClass(sprintf('level%d'.$parent.$active, $level + 1));             }                  // process submenu             if ($ul->length) {                 self::_process($module, $ul->item(0), $level + 1);             }         }          }      }


title: Change a sidebar name?

text: I'm using a child theme created from a twenty-twelve theme, the theme packs a number of sidebars one which is called "Main Sidebar". Is it possible to change it's name to something else?


title: Trigger shortcode after submit button pressed

text: I need to **execute a shortcode after the user will press the submit button**. I am using Contact form 7 and have inserted the form by a shortcode in the Post edit section. It's basically a form collecting data and after submit, I will redirect the user to PayPal in a new window. The shortcode for the PayPal button works already on it's own. I have tried this function but the form seems to get stuck, I get the loading icon forever, the message is delivered but most important, it's not executing my shortcode. Not even a simple `echo "test";`.               add_action ('wpcf7_mail_sent', 'after_mail_sent');     function after_mail_sent () {       echo do_shortcode ('[book]');     }      Any ideas please?


title: How to properly test a method that is called by an action hook

text: The constructor in my class adds an action to the 'init' action hook:               class My_Custom_Post_Type {              function __construct( $type ) {             $this->type = $type;             add_action( 'init', array( $this, 'register_my_type' );         }              function register_my_type() {             register_post_type( $this->type);         }      }          I was trying to test this in a unit test and finally realized that there was no reason for the 'init' action hook to fire. Is there any way to test that the register_my_type method is being called and that a new post type is being registered? Edit: The main source of my confusion came from not understanding the relationship between phpunit, the WordPress test suite, my class code, and my test code. What I now understand is that with the WordPress developer tools installed in the way the is suggested by this tutorial or through WP-CLI, a call to `phpunit` loads a bootstrap file which then hooks the plugin into the `muplugins_loaded` action hook. The bootstrap file then loads the WordPress test environment. After WordPress has finished loading the `init` hook is run. Plugin code that makes use of `init` should work as expected. Tests are mostly just normal code that is making use of available functions or classes. What is different about them is that they are written as methods of a class that extends `WP_UnitTestCase` which extends `PHPUnit_Framework_TestCase`. Being wrapped in this class gives the tests access to assertions and object factories, and runs `setUp` and `tearDown` methods so that each test is independent of the others.


title: CPU Resource Management For Bulk Attachment Insert Share Host

text: I've created a page on a shared host which loops through a series of posts and then attaches images to each of the posts. The images are already on the server and are copied into the WP-Content folder. It 'works' but after about the 3rd iteration of the loop, the web page gives a timeout error and if I look at the server's CPU utilisation it is 100%. So the question(s) are: 1) Is there some sort of generalised 'garbage collection' I should be using after each iteration of the loop to prevent the CPU/memory build-up? 2) Failing that, is there a tool I can use to profile what is going on, with a shared hosting account? Here is the code for the main loop. The guts is in a separate function 'save_post()' which calls wp_insert_post and then wp_generate_attachment_metadata. I figured I'd start with asking about some -general- memory/resource management before going into the weeds with that. I assume this would be many times more efficient if I could use bulk SQL statements rather than individual SQL requests for each insert/attachment but it seems like there is too much complexity in what happens when WP creates thumbnails and assigns postmeta for me to want to tackle that for a one-off project. ` $args = array('post_type' => 'ims_gallery', 'post_status' => 'draft', 'posts_per_page' => 10); $pwp_query = new WP_Query($args);                                   while( $pwp_query->have_posts() ) : $pwp_query->the_post();                                      $post = get_post();                                                         // var_dump($post);                                 $gallery = $post;                                 $galid = $gallery->ID;                                 $galmeta = get_post_custom( $galid );                                 $galpath = '/' . trim( $galmeta['_ims_folder_path'][0], '.,/' );                                      $titlename = preg_replace('/\s+/', '', get_the_title() );                                 $sourcefolder =  '/home/myserver2/public_html/source/CurrentImages/' . $titlename;                                      echo('Processing: ' . $sourcefolder);                                 $destfolder =  '/home/myserver2/public_html/myserver.net/wp-content/_imsgalleries/gallery-' . $galid;                                                                $_resized_destfolder = $destfolder . '/_resized';                                 $flist = '';                                 $files1 = scandir($sourcefolder);                                                                if($files1) {                                         $flist = implode(',', $files1);                                         echo($galpath);                                         // @mkdir( $destfolder, 0751, true );                                         @mkdir( $destfolder, 0751, true );                                                                                @mkdir( $_resized_destfolder, 0751, true );                                                                                @shell_exec('cp -a ' . $sourcefolder . '/* ' . $destfolder);                                                                                // code to generate attachments is here.                                         save_post( $galid, $post );                                      }                                 else                                 echo('No files for: ' . $sourcefolder);                              endwhile; ?>      `


title: edit search.php to include subdomain posts

text: Is there a way for us to edit the search.php to include the subdomains with its search results? The only "condition" the code has is... ...and I have really nothing more to go by. =/ And oh, I kinda want to avoid installing plug-ins, so please don't tell me to download and install the Multisite Global Search plugin. Many thanks~


title: Grabbing the first image attached to a post and use it with the admin columns

text: I'm currently using @kovshenin's tutorial here on adding a thumbnail (a featured image) to my post type admin columns. Would it perhaps be possible ( and how :) ) to retrieve the first image attached to a post first, if no featured image available? (and perhaps return a local hosted image if also no featured image available) This is the code I currently have:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;       switch ( $column ) {         case 'thumbnail':           echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );           break;       }     }      **Edit:** As mentioned in the next comments, it took some time to figure things out :). In the end, and with the suggestions of @ifdion I came up with the next result:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;            $args = array(         'numberposts' => 1,         'post_mime_type' => 'image',         'post_parent' => $post->ID,         'post_type' => 'attachment',       );       $attachments = get_children( $args );            if ( has_post_thumbnail() ) {         echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );            } elseif ( $attachments ) {         foreach ( $attachments as $attachment ) {           $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'edit-screen-thumbnail' );           echo '';         }            } else {         echo '';       }     }      **Another edit** Not entirely sure if this grabs the **last** image attached to a post, but anyways, this code will get it:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;            $args = array(         'numberposts' => 1,         'post_mime_type' => 'image',         'post_parent' => $post->ID,         'post_type' => 'attachment',         'post_status' => null,       );       $attachments = get_posts( $args );            if ( has_post_thumbnail() ) {         echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );            } elseif ( $attachments ) {         foreach ( $attachments as $attachment ) {           echo wp_get_attachment_image( $attachment->ID, 'edit-screen-thumbnail' );         }            } else {         echo '';       }     }


title: Static directories in a WordPress multisite network

text: I’m planning ahead for a class website, where students will have the choice to either build their pages from scratch, or to use a WordPress multisite install as a CMS. I would like their work to sport URLs such as : http:// myschool.edu/2011/project1 ➤ WP blog   http:// myschool.edu/2011/project2 ➤ serves files directly uploaded by the students   http:// myschool.edu/2011/project3 ➤ WP blog And to have it work for future years too (2012, etc.). My gut feeling is that this would be possible to achieve with some Redirect rules in the Apache configuration. Even if I have to manually write them. Can someone with more experience with the WP Network feature and ModRewrite confirm this is possible? Or suggest an altogether better alternative? Thanks!


title: Link to a .po file in a child theme

text: i'm working in a twenty ten child theme, i want to change the               load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );          $locale = get_locale();     $locale_file = TEMPLATEPATH . "/languages/$locale.php";     if ( is_readable( $locale_file ) )       require_once( $locale_file );      locate in the twentyten functions by the one in my child theme :               load_theme_textdomain( 'BETA', STYLESHEETPATH . '/languages' );     $locale = get_locale();     $locale_file = STYLESHEETPATH . "/languages/$locale.php";     if ( is_readable( $locale_file ) )       require_once( $locale_file );       With this change in the stylesheetpath the twenty ten function is still taking over my own function How can i fix that ?