title: Pods CMS - loading a pod twice in a page

text:
I am having difficultly loading a Pod twice. Say I load a Pod which is related to another Pod - let's call it the child pod. Later in the page, if I try to load the child pod, I will get empty result. Example               $pods = new Pod('customization_category');             $pods->findRecords(array('select' => "t.id, t.name", 'where' => "t.id=$id"));             $pods->fetchRecord();             $entity = new customization_category_entity;             $entity->id = $pods->get_field('id');             $entity->name = $pods->get_field('name');             $entity->options = array();                  // process options             $customization_option_model = new customization_option_model();             $options = $pods->get_field('options');                       foreach ($options as $v)             {                 $entity->options[] = $customization_option_model->create_from_array($v);             }                  return $entity;           customization_category has a PICK field to the customization_option pod. After I call this code to load the customization_option pod (using `$pods->get_field`), I will get an empty array if I am do call this code next:               function get_single($id)         {             echo "$id = $id
";             $pod = new Pod('customization_option', $id);             return $this->create_from_array($pod->fetchRecord());                }              function create_from_array($array)         {                    $entity = new customization_option_entity();             $entity->id = $array['id'];             $entity->name = $array['name'];             $entity->selection_image = $array['selection_image'];             $entity->layer_image = $array['layer_image'];             $entity->price = $array['price'];             echo '
entity='.print_r($entity, true).'
';                  return $entity;         }      The code above will load when I load in customization_strategy pod, but later on when I call it again (via the `get_single` function), it will not work. Google search yields nothing. Any idea?


title: How to check if the Menubar contains no items?

text: I'm using the Menubar plugin to place a menu at the top of my website. However, I need to find a way to check if the menu contains items or not. My menu is called 'menubar'. Currently, I'm loading the menu like so:               do_action('wp_menubar', "menubar");      It loads fine, but I need to check if there are items in it or not so I can adjust and display other things instead. Any ideas? Or is this question too vague?


title: Adding a "More Galleries" Page to the End of an Image.php Gallery

text: On many magazine sites, when you click through a gallery (which is done in WP with the image.php template) the last click brings you to a "More Galleries" page. I would like to achieve something similar and would hope to do so by making a template for the "more galleries" page. The problem is I don't know how to make my next/previous links present a prev link on the last image which redirects to the "more galleries" page instead of another image. **I figure the best way to do this would be to add a statement to the previous link which sends the user to a predefined link (the more galleries page) when the previous link no longer links to an image... but I'm a little lost on how that would be done.** I'm also looking for other posssible workarounds for this if anybody has a better idea. My current code:               <?php             $parent = $post->post_parent;             $attachments = array_values(get_children(array('post_parent' => $post->post_parent, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'ID') ) );             foreach ( $attachments as $k => $attachment )             if ( $attachment->ID == $post->ID )               break;             $next = $k+1;             $prev = $k-1;             $next_link = "";             $prev_link = "";             if ( isset($attachments[$next]) )             {               $next_exists = 1;               $next_link = "ID ) . "'>←";               $img_link = "ID ) . "'>";             }                  if ( isset($attachments[$prev]) )             {               $prev_exists = 1;               $prev_link = "ID ) . "'>→";               if  (!$next_exists)               {                 $img_link = "ID ) . "'>";               }             }             if (!$next_exists and !$prev_exists)             {               $img_link = "ID ) . "'>";             }             $img_url = wp_get_attachment_url( $attachments[$k]->ID );             if (sizeof($matches) > 1)             {               $fn = "/home/phasenet/public_html" . $matches[1];               $exif_data = read_exif_data($fn);             }           ?>      How I currently call the links:               <?php echo $prev_link ?>     <?php echo $next_link ?>


title: Sanitize User Entered CSS

text: Does anyone have any idea how to sanitize CSS entered via user input? I am concerned about cross-site scripting via CSS. I am using wp_filter_kses to clean up user entered HTML, but I need a like solution for user entered styles. So far I am using the following ugly and incomplete function but I'd like something more complete.               function sanitizeCSS ( $css ) {         $css = str_replace( '/-moz-binding/', '', $css );         $css = str_replace( '/expression/', '', $css );         $css = str_replace( '/javascript/', '', $css );         $css = str_replace( '/vbscript/', '', $css );         return $css;      }


title: Make (custom) post type accessible only by custom query

text: I am trying to make a web application based on wordpress. This application needs some text data to process and then display to users. For that I use a custom post type. So far so good. Problem is, I do not want the data (some posts) to be accessible by normal way, but only by my custom queries which process them. I do not want users to have any chance of seeing that data. Is there any way to disable post form being read by default loop and allow only my own queries?


title: Keep main articles and author blogs seprerate, News / Magazine like site

text: I am working on a project that requires a CNN like article structure, where there are main articles (published in a magazine 'volume/issue') and authors' blogs separate. The idea is to have official articles (gone through a rigorous editorial process) while allowing each individual author to make shorter, less significant blog posts. Both the main articles and the blog posts need to be associated with the author who wrote it. EDIT: So imagine a menu that looked something like the following...   * Home   * Categories (for the main articles)      * Cat one     * Cat two     * Cat n+1   * Archives (for the main articles)      * Volume n        * Issue n       * Issue n+1     * Volume n+1        * ...   * Blogs      * Author one     * Author two     * Author n+1   * About I've been working with Wordpress for a few years now, and I would love to adapt it to this model. **Does anyone have any suggestions? Would the solution be in custom taxonomies? Custom post types?** Summary of Requirements:   * Individual Author Blogs   * Main Published Articles


title: Add "sub-nav" class to a sub menu parent item

text:
i have a problem. I have an CSS Dropdown Menu. The HTML Code of the is this:

Home

Archiv

Kontakt

Submenue 1

Submenue 2

Submenue 3

Impressum

      WordPress makes them into the following:

             Archiv

Submenue 1

      How can i tell WordPress that the link on "menu-item-615" should have the a-class "sub-nav" ?


title: Convert HTML to HTML 5?

text: I have a website which is in XHTML (wordpress coded). I need to convert it into HTML 5. I just started learning about HTML 5 tags like section, nav, footer etc. While finding deep into it, I came across a site which actually converts the XHTML code into HTML 5. Now I am confused, any how I have to learn HTML 5, but for the time sake is it a good decision to use that site? The converted HTML 5 code contains all the new tags, but is that actual pure method to do that? Will this converted code will be approved by W3C as HTML 5? Here is the site: http://mynthon.net/tools/xhtml-to-html5/


title: How to check during "pre_get_posts" if WP performing default query for specific custom template?

text: I want to modify default query for custom RSS template loaded by plugin that i'am writing right now. What is the best way to check - in function hooked to "pre_get_posts" - if default query for my specific custom teplate is about to be performed, so i can modify it? **Answer:** It was much easier than i thought. When using approach suggested in Controlling and customising RSS feeds in WordPress where you can see something like this in rewrites `index.php?feed=custom_feed` you simply check query vars, so your actions looks like that:                   add_action('pre_get_posts', 'gs_gscrf_pre_get_posts');         function gs_gscrf_pre_get_posts($query) {             if (!is_admin() && $query->is_main_query() && $query->query_vars['feed'] == 'custom_feed') {             // do stuff             }         }      Check Rarst explanation, if you want to know why i have to use `query_vars`and cannot check for template.


title: Change a url / link if a user is logged in?

text:
I'm working on some themes for a multisite and would like to modify the code below. It relates to a special div that will display an image or logo that users upload. Normally the logo links to the home page of the blog, but could it be modified so that if the user is logged in it will link to "/themes.php?page=wptuts- settings" instead which is the logo upload screen? Thanks

     <?php $wptuts_options = get_option('theme_wptuts_options'); ?>                <?php if ( $wptuts_options['logo'] != '' ): ?>                   <a href="<?php echo get_option('home'); ?>/">
                       <img src="<?php echo $wptuts_options['logo']; ?>" />
               <?php  endif; ?>


title: Paginate pages with dynamic query

text:
I have a wordpress page that has a series of listings and a searchbox at the top. The search allows the user to filter posts by creating a custom WP_Query object based on what they selected. I am wondering if there is a way I can have this be paginated so that there aren't hundreds of results displaying on the page. Basically I have an if statement to check if the form is submitted which then populates the selected fields into an array and passes it to the meta_query               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         if(isset($_POST['submit'])){         $the_query = new WP_Query(array(               'post_type' => 'business',               'post_status' => 'publish',                'taxonomy' => 'business-type',               'business-type' => 'attraction',               'posts_per_page' => 15,               'orderby' => 'title',               'order' => 'ASC',               'meta_query' => $arrays,               'paged' => $paged             ));         }else{         $the_query = new WP_Query(array(             'post_type' => 'business',             'post_status' => 'publish',              'taxonomy' => 'business-type',             'business-type' => 'attraction',             'posts_per_page' => 15,             'orderby' => 'title',             'order' => 'ASC',             'paged' => $paged            ));      The I loop through the query using `while ( $the_query->have_posts() ) : $the_query->the_post();` and after endwhile; I have my pagination               if($the_query->max_num_pages>1){?>
         <?php           if ($paged > 1) { ?>             <a href="<?php echo '?paged=' . ($paged -1); //prev link ?>"><           <?php }           for($i=1;$i<=$the_query->max_num_pages;$i++){             if($paged==$i){?>               <?php echo $i; ?>             <?php }else{?>               <a href="<?php echo '?paged=' . $i; ?>" class="inactive"><?php echo $i;?>             <?php           }         }         if($paged < $the_query->max_num_pages){?>             <a href="<?php echo '?paged=' . ($paged + 1); //next link ?>">>         <?php } ?>


title: save post running twice and creating two database entries - how do I disable this?

text: I am developing a job tracking database for my utility engineering company and am having an issue when running a save hook. I have a task_types db table that tasks are created off of and using a custom meta box on the "cover_page" (post edit screen) of the job I allow these tasks to be created for each job from user input. It is processing my validation code twice therefor creating 2 database entries and two identical tasks from its task type, which is not correct. Can anyone assist me with this problem. See the code snippets below.                   // Validate Data    for Custom Meta Boxes     function rfd_argument_function() {         global $post;         global $rfd_meta_box_options;               foreach($rfd_meta_box_options as $rfd_meta_box_option){                 $meta_box_options[] = $rfd_meta_box_option['meta_box_form_fields'];         }               foreach($meta_box_options as $options){              foreach ($options as $option){                  if($option['name']){                         $arguments = array(                         'post_id' => $post->ID,                         'name' => $option['name'],                         );                   }                 do_action('save_hook', $arguments);             }            }     }     add_action( 'save_post', 'rfd_argument_function');          // Save data for Custom Meta Boxes     function rfd_save_meta_box_values( $args ) {     $post_id = $args['post_id'];     $name = $args['name'];     $old_data = get_post_meta($post_id, $name);     $new_data = $_POST[$name];          // Autosave, do nothing      if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {       return;      }      // Check permissions      if ( 'page' === $_POST['post_type'] ) {       if ( !current_user_can( 'edit_page', $post_id ) ) {             return;       }      }else {       if ( !current_user_can( 'edit_post', $post_id ) ) {             return;       }      }     if( $_POST['job-update-action']==='freeze'){ // Freeze associated items updated below in save_rfd_job_update_action.             return;     }     // AJAX? Not used here     if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {             return;     }     // Return if it's a post revision     if ( false !== wp_is_post_revision( $post_id ) ){             return;     }          // if new is same as old     if($new_data === $old_data[0] ){           return;     }else{         // add_post_meta($post_id, 'save-count', 0, true); // add "save-count" if none exists         // $save_count = get_post_meta($post_id, 'save-count', true); // grab save count          // if( $save_count == 0){             // $save_count++;              // update_post_meta( $post_id, 'save-count', $save_count );             if($_POST['task-to-assign'] !== 'Select a Task Type to Assign'){                 global $wpdb;                 $table_name = $wpdb->prefix . 'task_types';                 $task_type = $wpdb->get_results("SELECT * FROM $table_name WHERE task_name = '" . $_POST['task-to-assign'] . "'", OBJECT);                 $table_name = $wpdb->prefix . 'tasks'; // Change table                 // check for duplicate task                 $task = $wpdb->get_results("SELECT * FROM $table_name WHERE task_name = '" . $_POST['task-to-assign'] . "' AND job_id = '" . $post_id . "'", OBJECT);                      // rfd_debugger( $task[0],1);                 // if( $task[0]->job_id === false){                     $rows_affected = $wpdb->insert( $table_name, array( 'task_type_id' => $task_type[0]->id,                                                                      'task_name' => $task_type[0]->task_name,                                                                     'description' => $task_type[0]->description,                                                                     'job_id' => $post_id,                                                                                'assigned' => $_POST['person-to-assign'],                                                                                'assigned_datetime' => current_time('mysql'),                                                                                )                                              );                 // }             }              // }else{             // delete_post_meta($post_id, 'save-count', 0);         // }         update_post_meta($post_id, $name, $new_data); // Add New Data            update_post_meta($post_id, 'task-to-assign', 'Select a Task Type to Assign'); // Reset Field         update_post_meta($post_id, 'person-to-assign', 'Select A Person'); // Reset Field        }          }            add_action( 'save_hook', 'rfd_save_meta_box_values');


title: Wrap the_title_attribute in a H2 within a Conditional Tag?

text: I have the following that works fine..               elseif( get_post_type($post->ID) == 'press' ){the_title_attribute();}      However, i need the aforementioned title to be wrapped with a h2 tag. Tried this but it just puts the h2 after the title...               elseif( get_post_type($post->ID) == 'press' ){echo'<h2>'. the_title_attribute() .'</h2>';}      Any ideas? Many thanks for any help :)


title: JQuery Accordion Menu Widget Expand All on Mobile?

text: Can anyone tell me how to/if it would be possible to set up this plugin so that when it's being viewed on the desktop, it works as usual (hover to expand) but when being viewed on mobile, the menu expands everything?


title: Sort wp_nav_menu() by menu order

text: I have made a custom menu handler for the back end, sorting the via a drag drop based on CMS Page Order. The problem now is that it seems that it's not possible to sort wp_nav_menu in any other way than the default one, can that be really be true?


title: Convert post name into post ID

text: I am trying to create a function for my functions.php file that will allow me to convert a post name into a post id. I have had a look around online and managed to find this link http://www.devdevote.com/cms/wordpress- hacks/get_id_by_post_name which gives the following example..               function get_id_by_post_name($post_name)     {         global $wpdb;         $id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$post_name."'");         return $id;     }          <?php echo get_id_by_post_name('my-post-name'); ?>      After replacing **my-post-name** in the example I am not getting any results, can anyone suggest what is wrong? I was also looking into the get_by_postname function in case this was a better way of doing things.


title: Adding more pages to author pages

text: At the moment I have the following code for changing the author_base slug.               /** ADD REWRITE RULES **/     function change_author_permalinks() {        global $wp_rewrite;             $wp_rewrite->author_base = 'profile';        $wp_rewrite->flush_rules();     }     add_action('init','change_author_permalinks');      How can I add, for example, a extra "edit" page on to this, i.e., /profile/my- user-name/edit ???


title: Where do i create my own function in wp-admin

text: i want to create my own function in wp-admin same like do in wp- content->functions.php, but i don't know where is the function file in wp- admin folder. anybody know where is the function file in wp-admin folder?


title: Replacement search plugin that reads widgets or catalogs entire page?

text: I remember seeing a search plugin that creates a database log of your pages it use for search. Does anyone know of the plugin? And would this be a good way to make the Widget Text searchable? If not is there a plugin to add widget text to the search?


title: Will Wordpress use the newer schedule if it is updated using the filter 'cron_schedules'?

text: I learned that you can add new cron schedules by using the cron_schedules filter. If I change a interval of a schedule that I added earlier, will a job that uses this schedule be scheduled using this new interval the next time, or will it still use the previous interval?


title: How to prevent plugins from sniffing/stealing other plugins' options?

text: Many plugins require configuration with sensitive data such as API keys, passwords, etc. When implementing these plugins, this sensitive data is stored using functions such as `update_option()` and `get_option()`. It would be trivial to write a trojan plugin that provides a useful function but also performs a variety of `get_option()` calls on known-sensitive options. Even if this isn't possible, a manual SQL query can reveal this sensitive data. Is there any way to avoid this inherently insecure model?


title: Twenty Eleven Theme Adjusts for iPhones. How to stop this feature?

text: I would like to prevent Twenty Eleven from changing to mobile version when seen on an iPhone. Any way of doing this?


title: Using mr-image-resizer and Advanced Custom Fields

text: I'm using Advanced Custom Fields for displaying images in my Wordpress theme, but need to implement the TimThumb alternative mr-image-resizer. Here's my 'standard' code:               <?php if(get_field('call_to_action_boxes')): while(has_sub_field('call_to_action_boxes')): ?>     <?php if (get_sub_field('call_to_action_image')) : ?>     <img class="feature_img" src="<?php the_sub_field('call_to_action_image'); ?>">     <?php endif; ?>     <?php endwhile;  else: ?>      Does any know how I would change this to use the mr-image-resizer PHP script?


title: Display different custom post type each week

text: I have a project where I need to display an alternating food menu each week.   * i.e. menu1 on week1, menu2 on week2 then back to week1 etc.   * I've created custom post types for each menu (menu1 & menu2). Ideally, if the user wanted to see what the food menu was going to be next week, they would click on a calendar day a week from today & the food menu would display week2's food menu. I could deal with changing the food menu per week by having different custom pages to pull the different custom post types, but this does not solve the above requirement of what was on next week.


title: Pluging with content for a specific page or post

text: I'm new to writing WordPress plugins, and I'm running into a snag. A lot of what I've seen is about using actions or filters to manipulate or add content at specific global areas (all posts, on post, etc). What I'm looking for is how to create content for a specific page. I haven't seen any tutorials that cover this. Take, for instance, Contact Form 7 - you copy a specific string into a page body, and it triggers the content. Are they just replacing the content using a filter? I want to make sure there isn't an easier way to tackle this.


title: Using Javascript to Set Redirect Page in Contact Form 7

text: I have a Contact Form 7 form that needs to redirect to specific pages depending on how the user arrived at the form. I'm storing the URL they need to be redirected to using localStorage and I'm trying to figure out how to tell contact form 7 this stored URL to use for redirection when the user clicks "Submit". i.e. the basic redirection method within CF7's "Additional Settings" is: `on_sent_ok: "location.replace('http://www.YOURSITE.com');"` and I'm trying to set the URL using javascript: `var newUrl = localStorage.getItem('storedurl');}` `on_sent_ok: "location.replace( newUrl );"}` Doesn't have to call localStorage from within CF7, it could just call in a variable that's been set globally. But I can't get either to work. Thanks!


title: A way to detect which page a post is on

text: I'm wondering if there is a good way to tell which archive page a post came from. I essentially just need the post's position in the total order, then divide it by the 'posts_per_page' option. The hangup I'm having is getting that position or offset of where the post sits. EDIT: All while being on the SINGLE POST template. There, no matter what, the usual $wp_query global and 'page'/'paged' query vars are always 0 - so those won't get me anywhere.


title: Removing customise fields during plugin uninstallation

text: I created a plugin that insert a field on the customise theme options. Since I use               add_action( 'customize_register', 'myregister' );      to create the customise, should I use                remove_action( 'customize_register', 'myregister' );      when the plugin is deactivated or uninstalled?


title: Trigger save as draft when uploaded image

text: I have a custom post type with two custom meta boxes. The first meta box is a gallery that allows me to upload some images. The second meta box is a drop-down with some options. I selected an option from second meta box. Then, inside the first meta box, I have a button to open WP Media Uploader. After I have uploaded some images and clicked the 'Insert selected Images'. My browser will auto refresh because of the gallery(It needs to show thumbnail of those images). My problem is when the browser is refreshed, my second custom meta box data will be gone. I need to trigger the save_as_draft function for the WP Media Uploader when I click the 'Insert Selected Images'. Any ideas?


title: Hook in to add new post link wp admin?

text: How can i customize the **Add new post** link or how can i add my custom parameter in add new post link like **http://www.test.localhost/wp-admin/post- new.php** looks like **http://www.test/wp-admin/post-new.php?lang=fr** I have customized the links in menu by               global $menu, $submenu;     $submenu['edit.php'][10][2]='post-new.php?lang='.ICL_LANGUAGE_CODE;      But what i want to hook all the links`(post-new.php?lang='')` where ever it appears in the admin panel


title: Add new column to sites page

text: I'm trying to get info into my network sites page in a column. Below works great to grab the network site ID for each site. How can I make it display the option_value for the item (blog_expire) in the option_name column within my blogname_options table?               class Add_Blog_ID {     public static function init() {         $class = __CLASS__ ;         if ( empty( $GLOBALS[ $class ] ) )             $GLOBALS[ $class ] = new $class;     }     public function __construct() {         add_filter( 'wpmu_blogs_columns', array( $this, 'get_id' ) );         add_action( 'manage_sites_custom_column', array( $this, 'add_columns' ), 10, 2 );         add_action( 'manage_blogs_custom_column', array( $this, 'add_columns' ), 10, 2 );         add_action( 'admin_footer', array( $this, 'add_style' ) );     }     public function add_columns( $column_name, $blog_id ) {         if ( 'blog_id' === $column_name )             echo $blog_id;         return $column_name;     }     // Add in a column header     public function get_id( $columns ) {         $columns['blog_id'] = __('ID');         return $columns;     }     public function add_style() {         echo '<style>#blog_id { width:7%; }</style>';     }     }     add_action( 'init', array( 'Add_Blog_ID', 'init' ) );


title: Query Posts Creates 404 Error

text: When I'm on archives pages I am using the code below to query posts. In my theme options to_count_home calls the number of posts. WordPress isn't generating the correct number of pages based on posts_per_page. Instead it is generating pages based on the number of posts per page I have selected in my default WordPress settings. For example, if I have 10 posts per page in the settings then set posts_per_page in the code as 5, when I go to the second page (which should have 5 posts on it) I get a 404 error. Here is the code I'm using:               <?php     $per_page = get_option('to_count_home');     query_posts("posts_per_page={$per_page}");     if (have_posts())     ?>


title: Disable Filter and Allow Embed/iFrame on Blogger Import

text: I'm trying to import blogger posts into a wordpress site but all embedded audio/video content is getting filtered out. I've commented out the following in kses.php:               // Post filtering     #add_filter('content_save_pre', 'wp_filter_post_kses');     #add_filter('excerpt_save_pre', 'wp_filter_post_kses');     #add_filter('content_filtered_save_pre', 'wp_filter_post_kses');      But still the content is not getting imported. I've also tried inserting "embed" and "iframe" into the $allowedposttags array, but still not getting the embedded content.


title: colorpicker WP 3.5 path to stylesheet when called from a child theme

text: What is the path to the 3.5 colorpicker stylesheet?               wp_enqueue_style( 'wp-color-picker' );      I am trying to enqueue the color picker from a child theme but it does not load. I have added an admin metabox that shows when editing pages and posts and one of the options in the metabox is a color choice. I have the colorpicker script loading but the button does not bring up the picker because I am not loading the stylesheet. When I firebug the colorpicker and switch from display: none it shows. It looks like this is the stylesheet that loads: load-style.php. However, I took the css from this file and pasted it into my child theme style but the color picker does not work. UPDATE: It looks like the style is loading but nothing happens when the click on the color picker. The default color loads in the picker, etc. I think the javascript is not working. When you click on the picker the 'wp- picker-open' class is not added to the `<input>` tag.               jQuery(document).ready(function($){        $('.color-picker').wpColorPicker();     });               function wp_enqueue_color_picker() {         wp_enqueue_style( 'wp-color-picker' );         wp_enqueue_script( 'wp-color-picker-script', get_bloginfo('stylesheet_directory').'/include/javascript/custom-scripts.js', array( 'wp-color-picker' ), false, true );     }     add_action( 'admin_enqueue_scripts', 'wp_enqueue_color_picker' );               <input type="text" value="#cc9999" class="color-picker" data-default-color="#009999" />


title: Date range filter for manage posts list on edit.php

text: I need to add some custom submenu links to the Posts menu in WordPress admin so content managers can click on a link and get a list of posts from today, yesterday or this month. The default date filter in the WordPress back end filters posts by month only. When you select that filter it produces a URL like `http:// ..... /wp- admin/edit.php?s&post_status=all&post_type=post&action=-1&m=201301&cat=0&post_format=0&paged=1&mode=list` where m is the current month, so 201301 = January 2013. Is it possible to pass edit.php a date in some other format, i.e. a date range? If not, can anyone suggest the best way to generate a list of posts from the last month on the manage posts page?


title: Dynamic price product

text: I started a wordpress project for a client which has an e-commerce part. So I decided to try Woocommerce. Nevertheless I'm not yet familiar with this "big" plugin. The client has several specific needs and I'm not able to say if the plugin would cover those needs. This is an airsoft website. The users will be able to reserve a match. One of client's needs is: Depending your stuff, the price changes (49$ for non-equiped and 10$ for those who have their stuff). If Woocommerce can do it, I would like to know how to implement those features ? I mean a "product" will be a "match", but then how to customize it like I would like. Any help would be apreciated, regards,


title: JQuery multiple toggle values

text: I'm trying to hide/show metaboxes dependant on the page template chosen. This has been working fine until I have come to show a metabox on more than one chosen page template. The below code displays the Rich Content Editor for default pages, but not page-child.php pages. I'm guessing I have written the code incorrectly:               (function($){         $(function() {             $('#page_template').change(function() {                 $('#postdivrich').toggle($(this).val() == 'page-child.php') ;                 $('#postdivrich').toggle($(this).val() == 'default') ;             }).change() ;         }) ;     })(jQuery) ;


title: Fix Custom Taxonomy Display two times on each call

text:
 <?php $terms = wp_get_post_terms($post->ID, 'sublocation');         if ($terms) {            foreach ($terms as $term) {            $out[] = 'slug .'" href="' .get_term_link( $term->slug, 'sublocation') .'">' .$term->name .'';            }         echo join( ', ', $out );         } ?>

TYPE OF MUSIC: <?php $terms = get_the_terms($post->ID, 'music');            if ($terms) { foreach ($terms as $term) {           $out[] = 'slug .'" href="' .get_term_link( $term->slug, 'music') .'">' .$term->name .'';           } echo join( ', ', $out );            }?>

TYPE OF PUB: <?php $terms = wp_get_post_terms($post->ID, 'pub');           if ( !empty( $terms ) ) {            foreach ($terms as $term) {              $out[] = 'slug .'" href="' .get_term_link( $term->slug, 'pub') .'">' .$term->name .'';            }             echo join( ' ', $out );            } ?>
      After calling this i am getting like this ![enter image description here](http://i.stack.imgur.com/5ea2v.png) See above image the categories are showing same on each type. Please how can i fix this


title: Display Current Post's Position in Custom Taxonomy

text: I'm using custom post types and taxonomies to organize posts into different series where the order of the posts is important (travel narratives). My plan for the `single-{custom-post-type}.php` was to display each post's position within the series:   * Post 3/7 in TAXONOMY TERM I'm currently using the following standard WP_Query to find the total number of posts in each taxonomy:               $query = new WP_Query(array(         'TAXONOMY' => 'TAXONOMY TERM',          'posts_per_page' => -1,          'post_status' => 'publish'     ));     echo $query->post_count;      However, I have been unable to figure out how to find the current post's position within the series. `Post ?? / echo $query->post_count` I was considering using WP_Query's date parameters (before), but because it only accepts DD, MM, YYYY it wouldn't really work if there were more than one post published in a day. I may be going about this the wrong way, so I am definitely open to other interpretations of how to solve this problem. Thanks in advance!


title: URL-parameters and RewriteRule gives 404

text: In Wordpress I have a template (lets call it template.php) that has content on the following page:               example.com/template      This page should be able to handle URL-parameters like. I got this to work.               example.com/template?country=thailand&city=bangkok      **But I really want the URL to be pretty like this**               example.com/template/country-is-thailand-and-city-is-bangkok      I have the following in my .htaccess-file:               RewriteRule ^template/country-is-([^/]+)-and-city-is-([^/]+)?$ /template?country=$1&city=$2 [L]      But this just gives a 404-page, and I think that Wordpress thinks this is a blog post (which is it not). I got this to work in flat files outside Wordpress - but I know there are loads of URL-rules in Wordpress and somehow things clash. Can anybody help me achieve this? Thank you.


title: Any way for get_next_post() to use the actual post order instead of publish order?

text: I'm currently using get_next_post() and get_previous_post() to get their ID so that I can permalink my next/previous buttons for a custom post type. I'm also using a wordpress plugin called "Anything Order" to be able to reorder them however I want. Problem is, no matter the order I give them, get_next_post() and get_previous_post() will ALWAYS fetch the adjacent posts depending on their PUBLISHED date. It completely ignores the actual order of the posts. Any idea how to fix that ?


title: Assigning input to variable

text:
I am trying to create a plugin that will generate users. I am pretty new to Wordpress and my PHP is ehhhh. I got some helpful help earlier but have made a few turns since... The plugin will generate a user when submit it clicked, the issue is it ignores anything put into the input field and doesn't require it to work. Even if I set $num_users to a number it still only generates one...Perhaps an issue with my for loop? I know it has to be something small I am over looking.                function sl_add_options_page() {         // Add new page under the "Settings tab         add_options_page(             __( 'User Options' ),             __( 'User Options' ),             'manage_options',             'user_options_page',             'sl_render_options_page'         );     }          add_action( 'admin_menu', 'sl_add_options_page' );          function sl_render_options_page() {         ?>

<?php _e( 'Content & User Generator Options' ); ?>
             <form action="options.php" method="post">                 <?php settings_fields( 'num_users' ); ?>                 <?php do_settings_sections( 'user_options_page' ); ?>
                     <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Submit' ); ?>">
             </form>
         <?php     }          function sl_add_setting() {         // Register a binary value called "pimple_disable"         register_setting(             'num_users',             'num_users',             'absint'         );              // Add the settings section to hold the interface         add_settings_section(             'user_main_settings',             __( 'User Controls' ),             'sl_render_main_settings_section',             'user_options_page'         );              // Add the settings field to define the interface         add_settings_field(             'user_main_settings_field',             __( 'How Many users' ),             'sl_render_users_input',             'user_options_page',             'user_main_settings'         );     }          add_action( 'admin_init', 'sl_add_setting' );          function randomName() {         $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";         $name = array();          $alphaLength = strlen($alphabet) - 1;          for ($i = 0; $i < 8; $i++) {             $n = rand(0, $alphaLength);             $name[] = $alphabet[$n];         }         return implode($name);      }               function randomEmail() {         $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";         $email = array();          $alphaLength = strlen($alphabet) - 1;          for ($i = 0; $i < 8; $i++) {             $n = rand(0, $alphaLength);             $email[] = $alphabet[$n];         }         return implode($email);     }          function sl_wp_create_user() {         if( isset( $_POST['submit'] ) ) {             //$num_users = 100;             $num_users = $_POST['num_users'];             for( $j = 0; $j <= $num_users; $j++ ) {              $username = randomName();             $email = randomEmail() . '@gmail.com';             $password = wp_generate_password( 12, false );                      $user_login = esc_sql( $username );                 $user_email = esc_sql( $email    );                 $user_pass = esc_sql( $password );                      $userdata = compact('user_login', 'user_email', 'user_pass');                 return wp_insert_user($userdata);             }          }     }          add_action( 'admin_init', 'sl_wp_create_user' );          function sl_render_main_settings_section() {         echo '
Main settings for the Content and User Generator plugin.
';     }          function sl_render_users_input() {         echo '<input id="num_users" name="num_users[]" type="text" value=""/>';     }


title: SERVER ERROR (wp-admin urls won't load, site will)

text: **Server error** The website encountered an error while retrieving http://mydomain.org/wp- admin/. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. _HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request._ I just restored my site from backup using BackUp Buddy and `importbuddy.php` file. The site works, all the pages are there, but... the wp-admin doesn't load. I'm confused as to what would cause this. **UPDATE:** It seems that any url with wp-admin in it is giving me the same error.


title: Duplicating Complete Wordpress Install for Development and then Redeployment?

text: What is the best way to duplicate an entire Wordpress site, including database, themes, plugins and all associated settings to another URL for development purposes, and then redeploying it back to the main site? The site in question is a large Wordpress install — Wordpress 3.5 to be specific — with thousands of posts and a large audience. I have seen various plugins which purport to do this, but what is the best way to duplicate for development and then, in a month or two, redeploy back? I am committed to keeping the development database up to date manually with the existing database once the split occurs – I don't envision using the same database on two installs or whatever. Thanks.


title: Sanitizing a custom query's clauses

text: I'm trying to build a custom query much like the one found in WordPress' native `get_posts()` inside `wp-includes/query.php`, meaning something along these lines:               global $wpdb     SELECT *     FROM $wpdb->my_custom_table custom     WHERE 1=1     $conditions     $orderby      I want to be able to `apply_filters` to the variables `$conditions` and `$orderby`, again much like WP's own functionality, so a plugin might add their own `AND custom.column = 'foo'` and such via filters. But there seems to be a glaring vulnerability to that approach: what if a filter that comes from a plugin inserts malicious code into that query? I know about the `$wpdb->prepare` function, but as far I understand that sanitizes only the arguments that are passed to the query, and not the clauses themselves. It makes sense, because queries that should benefit from `prepare` are the ones with arguments passed dynamically via user input. Anyway, here are my doubts: is my concern trivial, meaning that I can't be 100% safe when there will always be plugins with direct access to the code and the database at runtime? Is there even such a thing as a malicious plugin (well, I'm sure there is, but should I code with them in mind)? But if I should indeed be concerned, is there a way to sanitize the whole query and not just the arguments so I can achieve what I want (i.e. how does WordPress achieve it)? Or should I just try a different approach, even though it would mean sacrificing flexibility?


title: echo product-name in a link

text: I am trying to make a link that links to the wordpress url with the product name after. (http://siteurl.com/productname) Here is what I have, I don't know what I am doing wrong.               <?php     apply_filters( 'woocommerce_order_table_product_title', ''View Video'', $item );     ?>      Thanks!


title: How to create a Re-Usable content snippet that I can Pass a Value to?

text: Here's the scenario... For a local site I have different city specific pages. The first paragraph of those pages will be unique and related to the specific city. But the content after that will be the same with exception of the city names... So what I want to do is create a content snippet that holds the content that is the same for every city BUT ALSO I will need to be able to pass that content snippet a value (the city names). For example, if my content snippet would hold this text: "CITYNAME is a beatiful city", then CITYNAME should be replaced by the value that I passed to the content snippet, e.g. Dallas. What are the different ways to achieve this with wordpress? Plugins or custom code.


title: Hide comment form completely (preferably without using CSS)

text:
I need to conditionally not show the comment form. I've added a filter to `comment_form_defaults` as follows:               function dont_show_comments($defaults) {       $defaults = array(         'fields'               => array(),         'comment_field' => '',         'must_log_in'          => '
' .  sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
',         'logged_in_as'         => '',         'comment_notes_before' => '',         'comment_notes_after'  => '',         'id_form'              => 'commentform',         'id_submit'            => 'hide',         'title_reply'          => __( 'You need to have accepted the terms to leave a reply' ),         'title_reply_to'       => __( 'Leave a Reply %s' ),         'cancel_reply_link'    => __( 'Cancel reply' ),         'label_submit'         => '',        );          return $defaults;     }      This mostly works, but I'm left with an unlabelled button (the submit button). What's the best way of not showing the form at all - preferably via a hook, and preferably not using CSS.


title: Site Stuck in Maintenance Mode

text: My site is stuck with the "...site undergoing maintenance" error. The usually fixes have not worked (no .maintenance file to delete, plugins all check out) It seems that it is a problem with the theme but the developer says that it all checks out. please help. I've tried several installs of wordpress and the theme, many hours with host also. site url: yciw.net restored the database also. Thank you Matt


title: "This site is under development" when sharing on Facebook

text: I have some issues when sharing my website's url on Facebook. There is a text saying " **This site is under development** ", and there is no thumbnail. That only happens when sharing the main url (the url of my site). When I share an url from a post, or another page of my site, this does not happen. It only happen when sharing my front page url. This is the url with that problem http://www.randomizado.com/ As I said, this problem doesn't happen with a page url like this: http://www.randomizado.com/contacto/ Please help. Thank you.


title: Best Wordpress Multi-language Plugin?

text: What is the best multi-language plugin for WordPress? WordPress does not have multi-language support itself, so you need to use a plugin to obtain multi-language functionality. Do not suggest the usage of different WordPress sites for obtaining the multi-language functionality because this would create more problems that solving. Please answer only if you successfully implemented such solution and explain what current limitation it has. Also it would be a good idea to specify what other solutions you tested before choosing this one. Things to consider:   * language URLs, like /en/... /fr/..   * being able to fallback to default language for untranslated pages   * browser language detection


title: Hook/action after WP_Query gets posts to query custom tables for post-related meta

text: I see that there are hooks for manipulating WP_Query before it gets its posts (parse_query, pre_get_posts), but I can't seem to find any hooks for **after** the WP_Query object is populated. I have a custom table for my plugin-specific post-associated meta data that I would like to fetch from after a WP_Query object is populated.


title: Featured Image meta box not showing up

text: I have featured images switched on in my theme:               add_theme_support('post-thumbnails');     set_post_thumbnail_size(256,128, true);     add_image_size('icon', 128, 128, true);      but the Featured Image box isn't showing up anywhere when I edit a page. What's confusing is that the exact same theme, the same set of plugins and approximately the same data is working fine on another site. Is there some config setting that might prevent the Featured Image feature from working?


title: Display custom post type from template

text: I have this template file called Events. The purpose of this file is just to display the latest post with custom type Event. I have solved it with a very ugly solution. There must be a simpler and more correct way to do this. If you check my code im sure you understand what im trying to accomplish :) Thanks in advance!               <?php     /*      * Template Name: Event     */     ?>          <?php     $permalink = get_permalink($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type = 'event' ORDER BY post_date DESC LIMIT 1"));     ?>     <html>     <head>     <script type="text/javascript">     window.location = "<?php echo $permalink; ?>";     </script>     </head>     <body>     </body>     </html>      **Cleaner solution:**               <?php     /*      * Template Name: Event     */     $permalink = get_permalink($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_type = 'event' ORDER BY post_date DESC LIMIT 1"));     header('Location: '.$permalink);     ?>


title: Is it possible to compare the current time with a custom "start" and "end date

text: I need to be able to display a custom post type if the current date is between the start and end custom meta field dates. Here is my code so far, it seems to just be ignoring the query and displaying all 3 of the posts, I have probably made a mistake as I have been been working on it for 3 days straight now, any help would be greatly appreciated. I am not even sure if this can work, I have successfully been able to show the posts that are after the end date and posts before the start date but can seem to get the ones that are between the two dates.                   $todaysDate = date('Y/m/d');     $args = array(     'post_type' => 'exhibitions',     'orderby' => 'meta_value',     'post_status' => 'publish',     'meta_query' => array(              array('key' => 'start_date', 'value' => $todaysDate, 'compare' => '>=', 'type' => 'DATE'),         array('key' => 'end_date', 'value' => $todaysDate, 'compare' => '<=', 'type' => 'DATE')      ) );


title: Yoast SEO plugin - Sitemap links greyed out & page priority

text: I have a sitemap - http://www.teamworksdesign.com/page-sitemap.xml Why are some of the links within the sitemap greyed out? Also is it worth changing the priority of some of the pages to achieve better seo results?


title: Page not found for custom post type UI plugin and taxonomy

text: I am using Custom post type UI and when I try to go to the post created under the post type projects page is redirected to page not found page. I have page created with same name before but I have changed that page name to other name and also parmalink. I have also created custom taxonomy named but when I tried to list the projects under post type projects page not found page is displayed. I found that to make taxonomy work i have created different pages like taxonomy-taxname.php and also tried creating taxonomy.php but the page redirected to page not found. Can anyone suggest me the solution? Thanks in advance


title: How to sum values from all custom posts metabox

text: I got a metabox that hold a monthly budget per client...   that meta box is inside a custom post type called clients. Inside that metabox the only thing entered is numbers. I want to get the sum of all the clients.   Any ideas? Altough i think its pure php.. somehow using foreach - to the request of @Fahd Murtaza i am trying to add parts of my metabox... i am using alchemy as the base to create my meta boxes so would add some parts.. Hope this doesnt confuse more..               <?php     // structure of my metabox usign alchemy     $clients = new WPAlchemy_MetaBox(array     (         'id' => '_project_description',         'title' => __('Client Info Card', 'sagive'),         'template' => get_stylesheet_directory() . '/metaboxes/clients-meta.php',         'types' => array('portfolio'),         'context' => 'normal',         'priority' => 'high',         'autosave' => TRUE          ));      .               // call for budget section in my meta box     <p>     <label><?php _e('Clients Budget:', 'sagive'); ?></label>         <?php $mb->the_field('client_budget'); ?>         <input type="text" name="<?php $metabox->the_name('client_budget'); ?>" value="<?php $metabox->the_value('client_budget'); ?>"/>     </p>        .   The rest of the code is way to long and i think not relevant to show... correct me if i am wrong and would add it via pastebin or similer.. .   **THIS IS HOW I QUERY THE POSTS...**               <?php          query_posts(array(              'post_type' => 'portfolio',             'showposts' => 10          ) );                             $count_posts_portfolio = wp_count_posts( 'portfolio' )->publish;     ?>


title: Using BuddyPress > 'Register page'

text: Can someone help me figure out the Buddy Press plugin. I have a magazine Wordpress website created with an open source theme and style and very slight html alterations and customizations. I've downloaded all the necessary BuddyPress plugins: **BuddyPress   BuddyPress Sliding Login Panel BuddyPress Template Pack** And it allows me to set/define pages for 'groups, members, and activity' but I cannot figure out how to implement a 'Register' page for people to register as that's the whole point of using the plugin. Now the screen where I "can" select which page to devote to register, no matter which I set it to, it just redirects to my home page. It allows me to create forms for a sign-up/register page, but can't implement it and get it to appear. Can someone help? _Cheers as always_


title: How to display specific posts with WP_Query?

text:
I need some help with displaying some specific WordPress posts. User's on my site can click on an 'Add to favorite' link which will then store that post ID in the `user_meta` table for that user as an array. So when I put the following in my `author.php` template page...               <?php      print_r ($curauth->user_favourite_post) ;     ?>      ... it returns with this...               Array     (         [0] => 2387         [1] => 1307         [2] => 1149         [3] => 1156         [4] => 474         [5] => 50         [6] => 1131         [7] => 1473         [8] => 2388         [9] => 2544     )      ... which is all good. This is the post ID's that the user has 'Favorited'. My question is, how can I display these posts on the author page? I have this...                   <?php     $my_query = new WP_Query();     $my_query->query(array( 'post__in' => array($curauth->user_favourite_post)));     while ($my_query->have_posts()) : $my_query->the_post();      ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
      <?php endwhile; ?>      ... But it just displays all of the posts and not the ones that have been 'Favorited' by the user. I've tried a number of different ways and they all just return every post.


title: Changes in code only show after changing theme

text: I have a weird problem that happens only in one of my Wordpress sites (which is on a development server with many other wordpress sites that don't have this problem): When I make changes in code - be it php, css or html - I can't just go to my site and refresh the pages for the changes to show up. I have to go to the themes page in the admin area, change to a different theme, then change back to the original theme, and only then can I refresh the page and see that changes I made. Could it be a server configuration, something to do with caching? Or is it a plugin that might be causing the problem? P.S I don't even know how to tag this question. Any help will be appreciated.


title: Can i have more than one form for front end posting in one template

text: I'm building a front end post form for car dealing. I have the "if statement validation" at the begining of my template, before get_header() function, after that i have the form. Can i have two or more forms in that template without a conflict?


title: Ajax save data to database on document ready, no data being saved

text: I have written a plugin which collects stats on document ready. Keep in mind that my database table is already created. I've added the following code to do the ajax code               add_action( 'wp_head', 'zkr_stats_ajax' );     function zkr_stats_ajax(){     ?>             <script type='text/javascript' >             jQuery(document).ready(function() {             //jQuery(window).load(function() {                          //set data varialbel with values                               var data = {                             action: 'action_stats',                             zkr_filename: '<?php echo $_SERVER['PHP_SELF']; ?>',                             zkr_ip: '<?php echo $_SERVER['REMOTE_ADDR']; ?>',                             zkr_referer: '<?php if(isset($_SERVER['HTTP_REFERER'])){ echo $_SERVER['HTTP_REFERER'];}else{ } ?>',                             zkr_browser: '<?php echo $_SERVER['HTTP_USER_AGENT']; ?>',                             zkr_method: '<?php echo $_SERVER['REQUEST_METHOD']; ?>'                               };                          var ajaxurl = '<?php admin_url('admin-ajax.php'); ?>'; // set the admin ajax url                     jQuery.post(ajaxurl, data, function(response) {                          });                                 });                  </script>     <?php     }      Then there is a function that handles the data being sent from the ajax above and stores the data into the mysql database table.               add_action('wp_ajax_nopriv_action_stats', 'zkr_stats_update'); //ajax callback     function zkr_stats_update(){             global $wpdb;                  if(isset($_POST)){             $filename = $_POST['zkr_filename'];                  $ip = $_POST['zkr_ip'];             $referer = $_POST['zkr_referer'];             $browser = $_POST['zkr_browser'];             $method = $_POST['zkr_method'];                                $table_name = $wpdb->prefix . "zkr_stats";                 $row = $wpdb->get_results( "SELECT * FROM ".$table_name." WHERE ip = '$ip' ");                 if($wpdb->num_rows == 0){                          $num = 1;                          $wpdb->query( $wpdb->prepare( "INSERT INTO ". $wpdb->prefix ."zkr_stats(ip, filename, referer, browser, method, timestamp, number) VALUES('".$ip."', '".$filename."', '".$referer."', '".$browser."', '".$method."', NOW(), '".$num."')" )) or wp_die( 'Could not save data!' ); //insert new data if the current ip was not used before                 }                 elseif($wpdb->num_rows == 1){                      foreach($row as $rows){                 $num = $rows->number + 1;                 }                 $wpdb->query( $wpdb->prepare( "UPDATE ".$table_name." SET number = '".$num."' WHERE ip = '".$ip."'" ))or wp_die( 'Could not update data!' ); //update visit data for old ip                      }             }                              }      Now when the page loads, I can see in firebug that data is being posted via ajax, but nothing is getting saved. Only when I add the function zkr_stats_update() to the header of the theme does it save but then it saves double, one empty and one with data. What am I doing wrong? Thanks guys


title: Create an archive listing based on meta array

text: I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (here). Now, I'm trying to create a listing of the archives, sort of like wp_get_archives would work. Example: 2012   * January   * February   * March   * etc 2011   * January   * February   * March   * etc The query I'm running to gather up all the dates from the meta_key is this:               $query = $wpdb->get_col( "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'event_date' ORDER BY meta_value DESC" );      But I'm not sure how I can take that data and list it out like the above example. I know I can output the unique dates as is with a foreach loop. That, my output is as follows: 2012-07-15 2011-06-07 2011-01-10 Trying to get it all sorted in the list format, I'm completely unsure of. Any help with this one is greatly appreciated!


title: How to check user's password?

text: I am trying to check the passwords of users I created on my WP multisite, but the ones I find in the `sw_users` / `user_pass` do not match what I get when I do a _MD5 hash_ of the passwords I received during the user signup process. Here is an example from the table `sw_users`: (11, 'user5', '$P$BiwskWiaqZIQLzDUTAhSyvACr0Jpnl.', 'user5', 'user5@domain.com', '', '2012-03-28 11:44:08', '', 0, 'user5', 0, 0), so I would assume that > $P$BiwskWiaqZIQLzDUTAhSyvACr0Jpnl. is the result of MD5 hash of the password. Is this correct? And why can I not match this when I run MD5 to the given password which is either > EJnltoRrQC6K or > fnxIwBW9Sjrm


title: Help with if and else statement

text:
I have this custom loop, which, if It doesnt get any result should display some text, like 'There are no news regarding this item". But I´m not sure how to. Code:               <?php     // Loop in the ten latest news with the same taxonomy term as the current post     $backup = $post;  // backup the current object     $found_none = '';     $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy     $param_type = 'fastighetslista'; //e.g. tag__in, category__in, but genre__in will NOT work     $post_types = get_post_types( array('public' => true), 'names' );     $tax_args=array('orderby' => 'none');     $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);     if ($tags) {         foreach ($tags as $tag) {             $args=array(                 "$param_type" => $tag->slug,                 'post__not_in' => array($post->ID),                 'post_type' => $post_types,                 'showposts'=> 10,                 'caller_get_posts'=>1     );     $my_query = null;     $my_query = new WP_Query($args); ?>     <?php     if( $my_query->have_posts() ) {     while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php the_time('d'); ?>

<?php the_time('M'); ?>

                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>

              <?php $found_none = '';     endwhile;     }     }     }     if ($found_none) {         echo $found_none;     }     $post = $backup;  // copy it back     wp_reset_query(); // to use the original query again     ?>        Where can I put my 'else' statement? Thanks Edit (again). Ok I modified the code, It looks like this now, but it´s not working at all.                                       <?php                 $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy                 $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work                 $post_types = get_post_types( array('public' => true), 'names' );                 $tax_args=array('orderby' => 'none');                 $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);                 if ($tags) {                   foreach ($tags as $tag) {                     $args=array(                     "$param_type" => $tag->slug,                     'post__not_in' => array($post->ID),                     'post_type' => $post_types,                     'showposts'=> 10,                     'caller_get_posts'=>1                 );                 $my_query = null;                 $my_query = new WP_Query($args); ?>                      <?php if( $my_query->have_posts() ) : ?>                 <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>

<?php the_time('d'); ?>

<?php the_time('M'); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                                  <?php endwhile; else : ?>                                  <?php endif; ?>      Edit. Ok I got this working. Code:                               <?php                 $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy                 $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work                 $post_types = get_post_types( array('public' => true), 'names' );                 $tax_args=array('orderby' => 'none');                 $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args); ?>                 <?php                 if ($tags) ?>                   <?php foreach ($tags as $tag) ?>                   <?php                     $args=array(                     "$param_type" => $tag->slug,                     'post__not_in' => array($post->ID),                     'post_type' => $post_types,                     'showposts'=> 10,                     'caller_get_posts'=>1                 );                 $my_query = null;                 $my_query = new WP_Query($args); ?>                      <?php if( $my_query->have_posts() ) : ?>                 <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>

<?php the_time('d'); ?>

<?php the_time('M'); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

                                  <?php endwhile; else : ?>                 Blablabla                                <?php endif; ?>


title: Unable to Call More than One Meta Box Output

text:
I have a custom meta box with multiple text fields. I use this to call the information in the first box:               <?php the_post(); echo get_post_meta( get_the_ID(), 'dbt_text', true ); ?>      And this to call the second field:               <?php the_post(); echo get_post_meta( get_the_ID(), 'dbt_text1', true ); ?>      **Here's the problem,** when used individually they work perfectly. But if I have both on the same page, only one outputs. I need them to be separate but I need them both to produce their respective outputs from the meta box. I have tried to troubleshoot this and I just don't know enough about PHP and the WP core to figure this out on my own. Help is appreciated! Here is the code for my custom meta boxes:               $prefix = 'dbt_';     $meta_box = array(         'id' => 'my-meta-box',         'title' => 'Titles',         'page' => 'page',         'context' => 'normal',         'priority' => 'high',         'fields' => array(             array(                 'name' => 'Primary Title',                 'id' => $prefix . 'text',                 'type' => 'text'                 ),             array(                 'name' => 'Secondary Title',                 'id' => $prefix . 'text1',                 'type' => 'text',                )         )     );          add_action('admin_menu', 'mytheme_add_box');     // Add meta box     function mytheme_add_box() {         global $meta_box;         add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);     }          // Callback function to show fields in meta box     function mytheme_show_box() {         global $meta_box, $post;         // Use nonce for verification         echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';         echo '
';         foreach ($meta_box['fields'] as $field) {             // get current post meta data             $meta = get_post_meta($post->ID, $field['id'], true);             echo '
',                     '', $field['name'], '	',                     '';             switch ($field['type']) {                 case 'text':                     echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />',                         '
', $field['desc'];                     break;                       }             echo    '',                 '
';         }              echo '
';     }          add_action('save_post', 'mytheme_save_data');          // Save data from meta box     function mytheme_save_data($post_id) {         global $meta_box;              // verify nonce         if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {             return $post_id;         }              // check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return $post_id;         }              // check permissions         if ('page' == $_POST['post_type']) {             if (!current_user_can('edit_page', $post_id)) {                 return $post_id;             }         } elseif (!current_user_can('edit_post', $post_id)) {             return $post_id;         }              foreach ($meta_box['fields'] as $field) {             $old = get_post_meta($post_id, $field['id'], true);             $new = $_POST[$field['id']];                  if ($new && $new != $old) {                 update_post_meta($post_id, $field['id'], $new);             } elseif ('' == $new && $old) {                 delete_post_meta($post_id, $field['id'], $old);             }         }     }


title: How can I define the RSS feed content length?

text: I’m trying to shorten the content of my RSS feed. Right now it displays way, way too much for each entry and I’ve tried to select the “Excerpt” in the Syndications setting in my option panel but it hasn’t done anything. I’ve tried different approaches but little has it helped. Is there a simple way (possible add_filter) where I can set the RSS feed content length to, say, 200? Thanks   - Mestika


title: How to exit a plugin's execution mid-stream?

text: I have a plugin that I want to ensure runs ONLY on singular posts, pages, etc. I'm using the is_singular() function and it works great - except that all it does is return execution to the rest of the plugin if I do this:               function singular_check(){         if(is_singular())             return;     }      I'm executing it in a hook like so:               add_action('wp', 'singular_check');      I need to actually make my entire plugin bail out at that point, and return to executing whatever else was downstream of my plugin. Anyone know how to do so?


title: Best, most easily-themed mailing/newsletter setup?

text: Currently theming MailPress, finding it somewhat annoying as a PHP novice. Any suggestions? (new to Wordpress... this was easy with Drupal)


title: Display SQL that wordpress is running

text: I am wanting to see the actual SQL that worpress is running to build certain pages, is there a debug method or some other way to outpout this or view it?


title: Theme settings keep getting reset/erased

text: I bought a theme from Themeforest called Anan. I am currently hosting the site on Bluehost. Here's the problem: every few days the theme settings keep getting erased (reset) so I have to re-upload logos and background images and it's driving me crazy. :) Here's a copy of the functions.php file in a text file in my public dropbox folder if anyone can look at it: http://dl.dropbox.com/u/4016505/functions.txt Thanks for the help!


title: List posts under meta_value heading

text: I need to list completed (meta_value) projects for each year (meta_value), like this: 2006   - Project 1   - Project 2   ... 2005   - Project 3 ... I found (here) a great piece of code to deal with I'm after:               <?php // List posts by a Custom Field's values     $meta_key = 'year';  // The meta_key of the Custom Field     $sql = "        SELECT p.*,m.meta_value        FROM $wpdb->posts p        LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)        WHERE p.post_type = 'post'           AND p.post_status = 'project'           AND m.meta_key = '$meta_key'        ORDER BY m.meta_value, p.post_date DESC     ";     $rows = $wpdb->get_results($sql);     if ($rows) {        foreach ($rows as $post) {           setup_postdata($post);           if ($post->meta_value != $current_value) {              echo "<h3>$post->meta_value</h3>";              $current_value = $post->meta_value;           }           // Put code here to display the post           the_title();        }     }     ?>      But I still have (1) a further request on the code and (2) a problem with it, which are:   1. I need to filter the query by another meta_key (key state: value completed).   2. I use WPML and the post list displays both the post and it's translation (it should only get the current language posts)


title: Making plugin to use different table prefix cause permission problem

text: I have multiple wordpress websites that uses the same files and database but with different table prefixes, I use a plugin "Shortcode Exec PHP" and I would like to use the same shortcodes on all the sites, but this plugin doesn't use it's own table, it used the update_option function from wp to store the data. So I tried just adding this on top of the plugin's code:               $wpdb->prefix = "mainsiteprefix_";      But I get the error: > You do not have sufficient permissions to access this page. On all the admin pages of the sites that don't uses that prefix and have the plugin activated. So, how could I make the plugin to use any db prefix I want without having permission problems?


title: Slightly modified options framework Colour picker

text: I'm using slightly modified options framework for a theme I'm working on, I have used this before with other themes but never had a need to use the colour picker. I need to be able to allow the user to change the colour of the navigation bar. this is what I have done so far. **functions.options.php**               $of_options[] = array(  "name"      => "Navigation Color",                         "desc"      => "Pick a background color for the theme (default: #fff).",                         "id"        => "nav",                         "std"       => "",                         "type"      => "color"                 );      **footer.php**               .nav { background-color:<?php print $smof_data['nav']; ?>; }      Have I just missed something completely?


title: WP e-commerce: How to select the shipping costs calculation method according to delivery location

text: commerce experts, I'm developing an e-commerce website using WordPress and WP e-commerce. All works fine but I have a little problem. I would like to select the shipping costs calculation method according to delivery location:   * if the delivery location is local I would use the "Table rate" method   * if the delivery location is internation I would use the "Flat rate" method How can I add this feature? Is there an extension (also commercial)? Alternatively, where can I edit the PHP code? Thanks


title: Output after specific post in the loop

text: I'd like to hook into the loop with a plugin, and output some code after a post index in the loop. Two example I can think of are:   * output code after the 1st post in the loop   * output code in the middle (after num posts / 2)


title: $post->ID and the_id() always return the wrong value

text: I have a site where I display the same exact footer on every page. There is one exception, though. On one certain page I need to change one small part of the footer. I figure the simplest way to do this is to check, within the footer, whether I'm on that page or not. It wouldn't make sense to change the whole entire footer for that page since I'm only changing a tiny part of the footer, deep within the footer. The problem is that whenever I call `$post->ID` or `the_id()` from within the footer, it gives me an ID that clearly doesn't match the post I'm on. It always gives me `89`, no matter what page I'm on in the site. I figure I must be doing something wrong. Can anyone tell me what it is?


title: Output before and after the loop

text: I'd like to hook into the loop, ie. have_posts() maybe? and output some code before and after. Is there a filter for this so I can use it in a plugin without needing to edit themes?


title: Text and image in taxonomy page

text: I want my taxonomy pages have some custom text and an image before the list of posts and excerpts. I need it for a personal travel blog. I have a "travel" taxonomy that keeps all travels I've made ("egypt", "china", "italy"...) and now I want to show some introductory text before te list of post related to this _travel_. For example, if you go to _www.domain.com/travel/italy_ you will find: > Italy is an European country [photo] > > Post 1 - excerpt > > Post 2 - excerpt .... If you click on _www.domain.com/travel/china_ : > China is the most populated country in the world [photo] > > Post 1 - excerpt > > Post 2 - excerpt I know I can get it easily by creating a page for each travel, but then the list of post for the given travel taxonomy won't be automatically generated (I need this feature).


title: Get attachments only for this post

text:
I have the following code:                     <?php           while (have_posts()) : the_post();               if(get_the_title() == 'Archive') query_posts('posts_per_page=1&cat=1');               $category = get_the_category();               if ($category[0]->name) echo '
'.$category[0]->name.'
';                     $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );                foreach ( $attachments as $attachment_id => $attachment ):                 $image = wp_get_attachment_url( $attachment_id, 'medium' );                 echo $image."
";                endforeach;                    the_content();           endwhile;          ?>           <?php edit_post_link('Click here in order to edit this page'); ?>
      This code is in `page.php` where by default I list a post.I want to get the attachements only for that post `query_posts('posts_per_page=1&cat=1');` now it also get the attachements for the page., how can I do this?


title: List category posts - Thumbnails are not displaying

text: we've been using List Category Posts to display different category posts on one page and it was working great until recently when the thumbnail images disappear. The 'thumbnail=yes' option is there. We can't figure out how to get the thumbnail images to appear again. Any help is greatly appreciated. Here's the page: www.tomorrowsyouth.org/programs/international- internships/tyo-intern-alumni/ We're using Version 0.22.3


title: how to change the number of posts returned in a specific loop without making it global?

text:
the website i'm referring to is technibility.com. If you look at it the slider on top is using this piece of code               <?php if(is_home()) { ?>

          <?php while (have_posts()): the_post(); ?>

          <?php if (has_post_thumbnail()): ?>     <a href="<?php the_permalink(); ?>">      <?php the_post_thumbnail(); ?>          <?php endif; ?>
<a href="<?php the_permalink(); ?>"> <?php the_title(); ?>

     <?php endwhile; ?>

     <?php } ?>      problem is that if i used               query_posts('showposts=20');      its going to affect the entire site and show me 20 articles in the carousel and the posts on the page. How can i force it to only take affect with the slider? also is there a way to have the_post_thumbnail() not stretch the image and use 150px height and any width but keeping it under 300px ?


title: add_submenu_page function to show videos table

text:
wondering if its possible to show the attachments admin list for videos by using a custom menu link? Any pointers welcome! D.               add_action('admin_menu', 'mt_add_pages');     function mt_add_pages() {         add_menu_page('Directors & Showreels', 'Directors & Showreels', 'manage_options', 'dsv_menu', 'wps_theme_func',null,2);         $videos_page = add_submenu_page('dsv_menu', __('Videos','showreel_videos'),  __('Videos','showreel_videos'), 'edit_posts', 'sub-page-videos', 'display_showreel_videos');          }     function display_showreel_videos(){ ?>

Videos

<?     }      > got this working with class TT_Example_List_Table extends WP_List_Table with > help from links below... Looks fine but can't get edit or delete delete > links to work properly.               $media_query = new WP_Query(         array(             'post_type' => 'attachment', // get attachments only             'post_status' => 'inherit', // attachments are not 'published', so set it to inherit             'posts_per_page' => -1, // display all             'post_mime_type' => 'video' // grab files with the mime type 'video'         )     );          $list = array();          foreach ($media_query->posts as $post) {              $list[] = array('thumbnail'=>'', 'ID'=>$post->ID,'title'=>$post->post_title);          }          //Create an instance of our package class...     $testListTable = new TT_Example_List_Table();     $testListTable->setContent($list);     $testListTable->prepare_items();     $testListTable->display();


title: Limiting post list by taxonomy

text:
I currently have the following code pulling the 10 latest posts from a specific category, I would like to filter those posts to a certain custom taxonomy which I've set up called article type. What do I need to modify to incorporate this filter?

Features
             <?php $btcc_query = new WP_Query('category_name=btcc&showposts=10'); ?>
     <?php while ($btcc_query->have_posts()) : $btcc_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="Permanent Link to:      <?php the_title_attribute(); ?>">     <?php the_title(); ?>
     <?php endwhile; ?>
Read more from the BTCC Archive


title: Dynamically exclude menu items from wp_nav_menu

text:
I tried looking for info about how to exclude/remove nav menu items from custom menus, and the only thread I found did not have any answers that were useful to me. **1. Background:** I put together a Dock menu using WP custom menus (wp_nav_menu) and jqDock on my site. Since jqDock needs continuous images or image links to work its magic, I' using a custom walker so the nav menu HTML output looks smth like this:
                    etc...
      The code for my custom walker is:               class custom_nav_walker extends Walker_Nav_Menu      {         var $tree_type = array( 'post_type', 'taxonomy', 'custom' );         var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );              function start_lvl(&$output, $depth) {             $indent = str_repeat("\t", $depth);             $output .= "\n$indent
\n";         }              function end_lvl(&$output, $depth) {             $indent = str_repeat("\t", $depth);             $output .= "$indent
\n";         }              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;             $classes[] = 'menu-item-' . $item->ID;                  $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';                  $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );             $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';                  //$output .= $indent . '
';                  $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        ) .'"' : '';                  $description  = ! empty( $item->description ) ? esc_attr( strtolower( $item->description )) : '';             $item_title   = ! empty( $item->attr_title )  ? esc_attr( $item->attr_title ) : '';                  if ( strpos($description, ';') !== false ) {             $description_array = explode (';', $description);                 $image_name = $description_array[0];                 $image_alt = $description_array[1];             } else {                 $image_name = $description;                 $image_alt = $item_title;             }                  $item_output = $args->before;             $item_output .= '';             $item_output .= $args->link_before .''.$args->link_after;             $item_output .= '';             $item_output .= $args->after;                  $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );         }              function end_el(&$output, $item, $depth) {             $output .= "";         }          }      The jqDock script then catches the menu ID ('menu-first') and replaces the wp_nav_menu output with the Dock menu's. The Dock menu's HTML output changes based on the options specified when loading jqDock. **2. The Question:** I would like to not display (i.e., exclude) certain menu items according to where the user is on the site. For example, I would like to only show the Home item when the user is not in the Home, and the Random post item only when he is. **3. Discarded solutions:** _a. Muliple menus:_ Registering and creating multiple menus and then calling them conditionally could work; however, I don't think this is an ideal nor a clean solution at all for many reasons. Also, multiple menus are not easy to maintain or update. _b. Regex Search and Replace:_ This might force me to change the _needle_ parameter every time I change the jqDock options because the HTML output is modified. _c. CSS 'display' property:_ Hiding the items through the CSS display property works, but since it has to be applied to the jqDock menu output, it affects the visual rendering of the menu. **4. Failed Solutions:** *a. Filter to wp_nav_menu_items*: I tried catching the '$items' variable (string) and assigning it different values through conditional tags with the following code:               function userf_dynamic_nav_menu ($items) {         $items_array_home = explode('<a', $items);         $items_array_nothome = $items_array_home;              unset($items_array_home[1]);         unset($items_array_nothome[2]);              $items_home = implode('<a', $items_array_home);         $items_nothome = implode('<a', $items_array_nothome);              if ( is_home() ) {             $items = $items_home;         } else {             $items = $items_nothome;         }         return $items;     }     add_filter('wp_nav_menu_first_items', 'userf_dynamic_nav_menu');      This works only partially, because the menu items do change, but the conditional tags are ignored. I guess this makes sense because of the moment in which the filter is applied. _b. Custom nav menu function_ : I tried creating my own custom nav menu function to be able to add an exclude argument to the $defaults array and to use this slightly modified code from `wp_list_pages` to populate the additional argument:               $exclude_array = ( $args->exclude ) ? explode(',', $args->exclude) : array();     $args->exclude = implode( ',', apply_filters('wp_nav_menu_excludes', $exclude_array) );      Any ideas?


title: How to sort custom post type by multiple custom fields?

text: How to display posts with 'agenda' custom type ordered by custom fields 'agenda_date' and then by 'agenda_time'? 'agenda_date' is date custom fields. agenda_time is text custom fields I tried this, but it doesn't work:               $agenda_arg = array('post_type' => 'agenda',      'cat' => $cat_id,      'posts_per_page' => -1,      'meta_query' => array(             'key' => 'agenda_date',             'value' => date("Y-m-d"),             'compare' => '>='         ),         'orderby' => 'meta_value',         'meta_key' => 'agenda_date',         'orderby' => 'meta_value',         'meta_key' => 'agenda_time',     );


title: Most wp_nav_menu parameters ignored

text:
I'm trying to get a text-based navigation menu for the footer of my site. I'm using the `wp_nav_menu()` parameters as directed by Codex. He're a snippet of code (in `footer.php`):
         <?php wp_nav_menu(array('depth'=>1, 'after'=>'|')); ?>

...

...

...

      So, my goal is to make the menu look like `Home | About | MorePages` with only the root-level pages included. ## The problem: The `after` parameter is ignored! If I try `before` and `items_wrap`, along with other parameters, they are also ignored. I've been able to get `after_link` and `before_link` to work, as well as `depth`. I've tried escaping things and not passing HTML, but neither helps. I'm building based on the Sandbox theme, but `nav-menu-template.php` and `nav- menu.php` appear unchanged from the WP core. **How can I get these custom parameters to work?**


title: How to enable site wide BuddyPress members in multisite?

text: I have installed buddypress and mu wordpress. I want make users, groups and activities to work sitewide. Each site will have groups which can't be accessed by other sites. Each site have site specific activity. I am added               define ( 'BP_ENABLE_MULTIBLOG', true );       in `wp-config.php` file. But it is not make sitewide members, groups and activity. How can I do it?


title: How to get post object on blog template

text: I have a big issue on catching attributes from global `$post_object` in a page template file. I have a `Template Name: Blog Page` which is `template-blog.php` On that page I use the current page permalink to load more posts using Ajax. So basically I do Ajax Requests in the same URL, and on `template-blog.php` is a condition if `$_POST['load_more']` is true, if yes than return a portion of posts. My problem is I cant get the page ID or page permalink using the `$post` variable when this page is set as the Blog Page on WordPress (Settings- Reading-Posts Page). When the `template-blog.php` is set-up as the posts page, the `$post` variable is the first post which `$wp_query` has on it's post's array. I hope I was clear enough. ### Description On normal page State the Permalink is the Page Permalink:               get_header();     $link = get_the_permalink();      But when this page is set-up as Posts Page the Permalink is the Permalink of the first posts on $wp_query:               get_header();     $link = get_the_permalink();


title: product_tag to style an image

text: I want to style my product images depending on product tags (not only the first tag, but all of them). I am using this:               <img class="<?php echo get_the_term_list( $post->id, 'product_tag'); ?>"      and it is not working, because Woocommerce/Wordpress is styling the product tags as a link. Help appreciated!


title: Using wp_enqueue_script with social media buttons?

text: I want to embed a social sharing button in the theme. Following is the standard code to embed the twitter button.               Tweet           However, WordPress recommends to use the `wp_enqueue_script` to include any kind of javascript code. So I am wondering how can I include the above script code properly in a WordPress theme? Thanks.


title: Why execute the_post()?

text: When I'm getting custom post types with WP_Query->query(), it isn't really necessary to execute the the_post() function, because you can iterate over the query result array. Is it considered good behaviour to do this, or is it truly just a convience method?


title: Custom Post Type View Button in Admin Gives 400 Error

text: I have a custom post type, Project:               /*******************************     Projects Custom Post Type     *******************************/     add_action( 'init', 'register_cpt_project' );          function register_cpt_project() {          $labels = array(          'name' => _x( 'Projects', 'project' ),         'singular_name' => _x( 'Project', 'project' ),         'add_new' => _x( 'Add New', 'project' ),         'add_new_item' => _x( 'Add New Project', 'project' ),         'edit_item' => _x( 'Edit Project', 'project' ),         'new_item' => _x( 'New Project', 'project' ),         'view_item' => _x( 'View Project', 'project' ),         'search_items' => _x( 'Search Projects', 'project' ),         'not_found' => _x( 'No projects found', 'project' ),         'not_found_in_trash' => _x( 'No projects found in Trash', 'project' ),         'parent_item_colon' => _x( 'Parent Project:', 'project' ),         'menu_name' => _x( 'Projects', 'project' ),     );          $args = array(          'labels' => $labels,         'hierarchical' => true,              'supports' => array( 'title', 'editor', 'excerpt' ),         'taxonomies' => array( 'project_categories' ),         'public' => true,         'show_ui' => true,         'show_in_menu' => true,                   'show_in_nav_menus' => true,         'publicly_queryable' => true,         'exclude_from_search' => false,         'has_archive' => true,         'query_var' => true,         'can_export' => true,         //'rewrite' => true,         'rewrite' => array('slug' => 'our-work/%project_categories%', 'with_front' => false),         'capability_type' => 'post'     );              register_post_type( 'project', $args );     }      And a Taxonomy, Project Categories:               /*******************************     Projects Category Taxonomy      *******************************/     add_action( 'init', 'register_taxonomy_project_categories' );          function register_taxonomy_project_categories() {          $labels = array(          'name' => _x( 'Project Categories', 'project_categories' ),         'singular_name' => _x( 'Project Category', 'project_categories' ),         'search_items' => _x( 'Search Project Categories', 'project_categories' ),         'popular_items' => _x( 'Popular Project Categories', 'project_categories' ),         'all_items' => _x( 'All Project Categories', 'project_categories' ),         'parent_item' => _x( 'Parent Project Category', 'project_categories' ),         'parent_item_colon' => _x( 'Parent Project Category:', 'project_categories' ),         'edit_item' => _x( 'Edit Project Category', 'project_categories' ),         'update_item' => _x( 'Update Project Category', 'project_categories' ),         'add_new_item' => _x( 'Add New Project Category', 'project_categories' ),         'new_item_name' => _x( 'New Project Category', 'project_categories' ),         'separate_items_with_commas' => _x( 'Separate project categories with commas', 'project_categories' ),         'add_or_remove_items' => _x( 'Add or remove project categories', 'project_categories' ),         'choose_from_most_used' => _x( 'Choose from the most used project categories', 'project_categories' ),         'menu_name' => _x( 'Project Categories', 'project_categories' ),     );          $args = array(          'labels' => $labels,         'public' => true,         'show_in_nav_menus' => true,         'show_ui' => true,         'show_tagcloud' => true,         'show_admin_column' => false,         'hierarchical' => true,              //'rewrite' => true,         'rewrite' => array('slug' => 'our-work'),         'query_var' => true     );              register_taxonomy( 'project_categories', array('project'), $args );     }               add_action( 'init', 'register_cpt_leadership' );      In my Taxonomy archive template, I build out the URL to include the taxonomy term. So if "Project A" is in the "Awesome Stuff" category, the URL displays as: [my domain]/our-work/awesome_stuff/project-a All of this works perfectly on the front end. What doesn't work is when clicking buttons from the Admin side to view the project. If I'm editing "Project A", and click the View Project button under the permalink section, or the Preview Changes button on the right. ![View Project Button](http://i.stack.imgur.com/1cnyD.jpg) It returns a 400 Bad Request page, and sends the browser to: [my domain]/our-work/%project_categories%/project-a How can I make the preview/view buttons in the admin go to: [my domain]/our-work/project_categories/project-a That URL works, and since the preview links aren't tied to a specific Taxonomy, this would be the preferred solution. **EDIT:** I'm unsure if I'm explaining this right. I do not need to alter the way permalinks are being handled across the site. All I need is a way to hook into any link in the admin section (the button pictured above, the preview button, and the View links on the list page). I need to just set the %project_categories% variable to "project_categories" if the link is generated via the admin.


title: Display 1 category only with get_the_category (by ID or slug)

text: After hours of unfruitful Googling, I am asking for your help on this issue. My objective is to display only 1 category with get_the_category if the category ID matches the ID or slug set in the get_the_category function. Basically I'm asking for something like this: let's say there's a category titled "important". I want to exclude all other categories assigned to the post and only show "important" if the post is within that category. If the post isn't in important, nothing should be displayed. This should be too hard, but I could figure it out. Here's the closest thing I found to this, but it only displays the first category for the post, no option for manual selection by ID or slug:               <?php      $category = get_the_category();      if($category[0]){     echo 'term_id ).'">'.$category[0]->cat_name.'';     }     ?>      Thank you for your contributions.


title: Excerpt length: get first paragraph

text: I'm trying to figure out if it's possible to get an excerpt from each post, grabbing the first paragraph from each one. I'm currently using the ACF plugin and have custom post types and custom fields.   Here's my code:               function custom_field_excerpt() {         global $post;         $text = get_field('news');         if ( '' != $text ) {             $text = strip_shortcodes( $text );             $text = apply_filters('the_content', $text);             $text = str_replace(']]>', ']]>', $text);             $excerpt_length = 20; // 20 words             $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );         }         return apply_filters('the_excerpt', $text);     }      This works great, but it only trims the first 20 words (or however many words you specify), I'm trying to adjust this to pull in the first paragraph of each post instead of the first 20 words. Is this at all possible?


title: Separate Media Library for each user

text: I'm creating a theme for a client and one of their requests is to allow users to upload images for their own use, but there may be an option to share the images. Here are some of the caveats:   * Each user has the ability to upload their own images to their own Media Library.   * These images must be capable of being 'tagged' exactly similar to how we 'tag' 'posts' now.   * The Admin can manage these images also. Firstly is this possible and is it possible to create a 'tag' taxonomy for images? Thanks for your help.