title: Editor cannot access Theme Options

text:
I created a custom theme for Wordpress and customized the backend to have a white label look and feel. I am able to load up the options page and save settings (which push to a CSS file) from the Administrator menu. When I try to access this from the Editor level it attempts to load: http://MYURL.COM/wp-admin/functions.php rather than http://MYURL.COM/wp-admin/admin.php?page=functions.php I was originally able to pull up the options menu with the Editor account. When I would attempt to save it, I would receive the error that I couldn't save. While changing access levels the problem seems to have gotten worse. I read through 3-4 pages of search and couldn't find something that was relavant to my issue, sorry! Below is the code for my functions.php:               <?php     $themename = "Sleek v0.1";     $shortname = "sleek";     $options = array (          /*Declare the variables needed*/          array( "name" => "General Settings",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Call Analytics Number",     "desc" => "This is the call tracking number for the marketing campaign.",     "id" => $shortname."_phone_number",     "type" => "text",     "std" => "(888) 555-5555"),          array( "name" => "MerchEngines Customer ID",     "desc" => "This is the Customer ID in the MerchEngines dashboard",     "id" => $shortname."_cust_id",     "type" => "text",     "std" => "0000"),          array( "name" => "Navigation",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Navigation Bar Background Color",     "desc" => "This is the background color for the top navigation bar and footer. (Default: #000000)",     "id" => $shortname."_navBarColor",     "type" => "text",     "std" => "#000000"),          array( "name" => "Navigation Bar Text Color",     "desc" => "This is the text for the top navigation bar and footer. (Default: #ffffff)",     "id" => $shortname."_navTextColor",     "type" => "text",     "std" => "#ffffff"),          array( "name" => "Current Tab Color",     "desc" => "This is the tab color for the current page (Default: #920000)",     "id" => $shortname."_currentTabColor",     "type" => "text",     "std" => "#920000"),          array( "name" => "Hover Tab Color",     "desc" => "This is the tab color for the current page. (Default: #920000)",     "id" => $shortname."_hoverTabColor",     "type" => "text",     "std" => "#c00000"),          array( "name" => "Call to Action",     "type" => "title"),          array( "type" => "open"),          array( "name" => "Stand Out Font Color",     "desc" => "This is the contrast color used by the CTA phone numbers and the stand out wording within the inForm. (Default: #c00000)",     "id" => $shortname."_CTAstandOutColor",     "type" => "text",     "std" => "#c00000"),          array( "name" => "Base Color",     "desc" => "This is the base color used by the CTA text and the base wording within the inForm. (Default: #000000)",     "id" => $shortname."_CTAbaseColor",     "type" => "text",     "std" => "#000000"),          array( "name" => "Checkmark Color",     "desc" => "This is the color of the 'Feature' checkmarks. Color options are: red, darkred, blue, darkblue, green, darkgreen, purple, and orange (Default: red)",     "id" => $shortname."_checkMarkColor",     "type" => "text",     "std" => "red"),          array( "name" => "Bottom Call to Action Text",     "desc" => "This is the bottom call to action text following the phone number. (Default: for more information!)",     "id" => $shortname."_bottomCTAText",     "type" => "text",     "std" => "for more information!"),          array(  "name" => "Test Drop Down",         "desc" => "Test for a drop down box.",         "id" => $shortname."_test_dropdown",         "type" => "select",         "std" => "red",         "options" => "red, green, blue"),          array( "type" => "close")          );          function mytheme_add_admin() {          global $themename, $shortname, $options;          if ( $_GET['page'] == basename(__FILE__) ) {         if ( 'save' == $_REQUEST['action'] ) {             foreach ($options as $value) {             update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }             foreach ($options as $value) {         if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }          header("Location: themes.php?page=functions.php&saved=true");     die;              } else if( 'reset' == $_REQUEST['action'] ) {             foreach ($options as $value) {             delete_option( $value['id'] ); }          header("Location: themes.php?page=functions.php&reset=true");     die;          }     }          add_menu_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');          }     function mytheme_add_init() {       $file_dir=get_bloginfo('template_directory');       wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");       }           function mytheme_admin() {          global $themename, $shortname, $options;          if ( $_REQUEST['saved'] ) echo '

'.$themename.' settings saved.

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

'.$themename.' settings reset.

';          ?>

<?php echo $themename; ?> Settings
          <form method="post">          <?php foreach ($options as $value) {     switch ( $value['type'] ) {          case "open":     ?>
          <?php break;          case "close":     ?>

          <?php break;          case "title":     ?>

<?php echo $value['name']; ?>

          <?php break;          case 'text':     ?>
     <?php echo $value['name']; ?>	     <input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php     echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings(     $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />

     <?php echo $value['desc']; ?>

          <?php     break;          case 'textarea':     ?>
     <?php echo $value['name']; ?>	     <textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea>

     <?php echo $value['desc']; ?>

          <?php     break;          case 'select':     ?>
     <?php echo $value['name']; ?>	     <select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select>

     <?php echo $value['desc']; ?>

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

     <?php echo $value['desc']; ?>

          <?php break;          }     }     ?>
     <input name="save" type="submit" value="Save changes" />     <input type="hidden" name="action" value="save" />
     </form>     <form method="post">
     <input name="reset" type="submit" value="Reset" />     <input type="hidden" name="action" value="reset" />
     </form>
     <?php     }add_action('admin_menu', 'mytheme_add_admin');     add_action('admin_init', 'mytheme_add_init');     ?>


title: How to modify Publish metabox?

text: I'm trying to remove "Pending Review" (Status) and "Password protected" (Visibility) options from Publish metabox. Any ideas how can I do it?


title: admin search of pages returns custom post types

text: I was looking for a particular page today and got search results that surprised me. Here's what happened:   * start on Dashboard->Pages->All Pages   * search "standard"      * URL= http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=page&action=-1&m=0&paged=1&action2=-1   * get list of some pages, some posts, some custom posts of types ash_dyeing and ash_loomsong   * try searching a different term and receive error message: "Invalid post type" So I wondered if all the admin post searches were wonky. I tried again from   * Dashboard->Posts->All Posts      * http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=post&action=-1&m=0&cat=0&paged=1&mode=list&action2=-1     * posts, pages and custom post types returned   * Dashboard->Dyeing Samples->All Dyeing Samples      * http://example.com/wp-admin/edit.php?s=standard&post_status=all&post_type=ash_dyeing&action=-1&m=0&paged=1&mode=list&action2=-1     * posts, pages and custom post types returned As you can see, all the urls are the same except for post_type=X, which appears to be ignored. Why might that happen and how can I fix it? System details: -wp 3.3.1 -theme: Suffusion 3.9.6 with child theme ETA: Turns out this _is_ a plugin problem, specifically Events Manager 5.0.51. It can be resolved by setting the plugin's 'Include in WordPress Searches?' option to 'yes'


title: Media > Image Sizes aren't being applied to uploads

text: Under Media Settings I edited the Image Sizes to the following:   * Thumbnail size: 170x80   * Medium size: 550x170   * Large size: 550x320   * ("Crop thumbnails to exact dimensions" is checked)   * Maximum embed size: Width 1000, Height 1000 My problem is when I upload an image it ignores these dimensions. For example, when I upload a 550x320 image, and then try to add it to a post, it has been cropped to the following sizes (uploads folder shows the same):   * Thumbnail size: 137x80   * Medium size: 292x170   * Large size: (unavailable)   * Original size: 550x320 How can I get these image sizes working correctly?


title: Can I change ownership of my plugin?

text: By adding a new committer and removing the original committer can I effectively change ownership of plugin? I would like to transfer a plugin to a new wordpress.org profile. I am the author.


title: Confirmation required on email change

text: I'm just wondering why wordpress doesn't send confirmation mail every time user change his/her email address. How do we know that email address is not fake or mistyped? So can anyone give me some snippet to implement this function? ## Update: Here is the idea.   1. user changes his/her mail   2. We send confirmation email.   3. If the user confirm that email in X days by clicking confirmation link, then the email should be changed. Else we should use existing email.


title: Send Notifications to All Admins

text: I want to, hopefully without a plugin, get and loop through all admin accounts and notify each admin when a comment has been posted or a user has registered, etc. I tried to look into this but all the solutions pointed to plugins and all the plugins are either bulky or outdated which totes sucks. Is there a nice little filter that someone knows about where I can hook into notifications and send the notification to each / every administrator?


title: Removing height and width from images with a caption

text:
I am using WordPress with Twitter Bootstrap 3 and have an issue when it comes to images with captions. Images with captions are given a height and width attribute which stops them from being responsive. I tried the following code below but this only works for images without captions:               function change_uploaded_image_html( $html ) {         // Removes height and width attribute from images when they         // are uploaded.              $classes = 'img-responsive';              if ( preg_match( '//', $html ) ) {                  $html = preg_replace( '/()/', '$1 ' . $classes . '$2', $html );         }         else {             $html = preg_replace( '/(/', '$1 class="' . $classes . '" \/>', $html );         }               $html = preg_replace( '/(height|width)="\d*"\s/', "", $html );     return $html;      } I then tried another method from another post on this forum which sets the width attribute to nothing but I did not get any success as the width and height attribute on the image remains:               function my_img_caption_shortcode_filter( $val, $attr, $content=null ){         extract( shortcode_atts( array(             'id'    => '',             'align' => '',             'width' => '',             'caption' => ''         ), $attr ) );              if ( 1 > ( int ) $width || empty( $caption ) )             return $val;              $capid = '';         if ( $id ) {             $id = esc_attr( $id );             $capid = 'id="figcaption_'. $id . '" ';             $id = 'id="' . $id . '" aria-labelledby="figcaption_' . $id . '" ';         }              return '
'         . do_shortcode( $content ) . '
' . $caption . '

';     }     add_filter( 'img_caption_shortcode', 'my_img_caption_shortcode_filter',10 ,3 );      I am looking for a way to do this with PHP and WP's in-built filters and I think I am close to the answer but do not know in which direction to go exactly. Many Thanks, nav


title: Using the wp_remote_post response body

text: I don't have great PHP skills, but can usually fumble my way through with a little bit of direction, so I'm hoping someone on here can help me. I am doing a http post submission from a form to a third party API and am having trouble using the response value. They are returning a URL with a query string value that I need to capture in order to determine the correct confirmation method to display. I am using `wp_remote_post()` as follows:               $response = wp_remote_post($post_url, array('method' => 'POST', 'body' => $body));      The submission works but I get the returned URL as an HTML stream in `$response['body']` but I cannot seem to get any query string values from it. So my question is: Is there a way I can capture the actual URL value with query string that they send, rather than this being interpreted as an HTML stream? To test their response, I created a very simple HTML form and when submitted, the URL of the page that the HTML form is on, does change from `example.com/form` to `example.com/form?status=1`. Hopefully someone can point me in the right direction.


title: List category-posts not work properly

text: I have downloaded list=category-post and activated it. However, when I am just wanting to display a category e.g. `[catlist name="news"]` it shows all my posts from the site instead of a single category. I am using WP 3.8.


title: Displaying custom field according to date

text:
I am not sure whether this is an Advanced Custom Fields-related question, or a general PHP question, so I have also posted this to the ACF support forum, for those of you who are also looking for similar help.      I'm currently working on a local directory website, focussed specifically at it nightlife. I have a Nightclub custom post type, with a number of ACF- powered fields, including events on each night. So far, the events are structured as Monday - Poster Image, Title. Tuesday - Poster Image, Title and so on.      What I'd like to do is only display events that are on tonight on the front page, but am having trouble narrowing the query down to ones with entries that are today. Here's the query I've done so far:

On Tonight
             <?php $date = date('l' ); ?>             <?php $args = array( 'post_type'  => 'nightclub' , 'posts_per_page'  => 10, 'key'  => 'event_$date' , 'value'  => '' , 'compare'  => '!='   );             $loop = new WP_Query( $args );             while ( $loop->have_posts() ) : $loop->the_post();             ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>             <a href="<?php the_field('event_$date' ); ?>"><?php the_field('event_$date_desc' ); ?>      At the moment, only the venue titles and links are showing. Now, I'm fairly sure I've got my variable calls wrong, and I'm concerned that the structure of the 'the_field('xyz') is going to make it a bit more complicated. I'm still starting out with PHP, so there is an excellent good chance I've just written bad code! Any help would be great, Tristan


title: Is there existing plugins to "Click-to-Launch" embedded Flash / SWF content?

text: I'm aware that there is existing FlashBlock plugins that users can install on their browsers, but I would like a Wordpress approach to be able to:   * Replace SWF content by a thumbnail / screenshot of the Flash content (could be manually prepared).   * When clicked on, activates it OR launches a "popin" DIV container to play the Flash file inside of it.   * When other SWF content exists on the same page, automatically close other SWFs (only one can play at a time). If you know of anything that works similarly, I'd be interested to know about it :)


title: get_current_screen and the WP_Screen class

text: So I'm trying to figure out how to properly use the get_current_screen. For learning sake, I'm just popping an alert for a specific page. I've looked at http://www.deluxeblogtips.com/2012/01/get-admin-screen-information.html and the codex on WP_Screen and get_current_screen (hit my max links cause my rep isn't 10 yet) I thought I was doing this right...but not getting it to work. What I'm hoping for is that when I go to /wp-admin/post-new.php?post_type=product I can do stuff (will be enqueueing a script). Did pretty much a straight copy and changed the post type...but, what am I missing here?               add_action( 'wp_enqueue_scripts', 'rw_enqueue_scripts' );     /**     * Enqueue scripts for 'post' page of 'product' post type only     *     * @return void     */          function rw_enqueue_scripts()          {          $screen = get_current_screen();          // Check screen base and current post type     if ( 'post' === $screen->base && 'product' === $screen->post_type )     {         echo "<script type='text/javascript'>alert('worked');</script>              ";     }     }      Thanx in advance, Brian


title: How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?

text:
I have a custom hierarchical taxonomy containing only two levels of items. First Level the title, second level items of the taxonomy. Is it possible to add a "meta box" to the posts editor of Wordpress, so all elements in the second level are shown as checkboxes, first level as title and the author can select one or more of the item? eg.
Bathrooms
     <input type="checkbox"/> Bath tub     <input type="checkbox"/> Shower     ...
Living Room
     <input type="checkbox"/> Dining Table     ...      aso. There are plenty of items in this taxonomy, so I think the "normal" way to select taxonomies in the sidebar of the editor might not be enough. **Update:** In the mean time I changed some things and found, that if I just move the taxonomy box to the left on the editor it's good enough for what I want. If I want to show checkboxes and items of the custom taxonomy on the frontend I am using the following snippet:                       <?php             $addFeatureGroups = get_terms('additional_features', array('hide_empty' => false, 'parent'=> '0'));             foreach ($addFeatureGroups as $group){                 ?>

<?php echo $group->name;?>

                 <?php                 $items = get_terms('additional_features', array('hide_empty' => false, 'parent' => $group->term_id));                 foreach ($items as $item){                     ?>                     <span class="fl user_define" title="<?php echo $item->description;?>">                         <input name="additional_options" type="checkbox" value="id-<?php echo $item->term_id;?>">                         <?php echo $item->name;?>                                          <?php                 };                 ?>

                 <?php             };             ?>      Thanks.


title: Common user login for two different wordpress installation and bbpress

text: I have situation, that i need common user login for   1. Blog A   2. Blog B   3. bbPress I found the solution Single use login for two wordpress installation from Justin Tadlock Blog. Installing two WordPress blogs with the same users But What for bbPress ? Is there any plugin can work for me ? Should i use wordpress multisite (i am using it)? Thanks In Advance !


title: Facebook comment into my blog

text: I want that whenever I post my blog in facebook, anyone who comment in FB will automatically reflect those comments in my blog.   Is this possible? how?   My WP version is 3.3.


title: PLEASE help me to get my RSS feed working

text: Can you help me figure out why my RSS feeds do not work? I have a very standard Wordpress 3.4.2 install for this Solar Blog, however none of the RSS, RSS2, or Atom feeds will function. I am using permalinks in the following format: http://blog.paramountsolar.com/2012/12/18/sample-post/ (day and name, option #2) This appears to break the rss feed. If I set the Permalinks to 'ugly' mode it works as expected... with any other setting it fails: For example: http://blog.paramountsolar.com/feed/rss2 Kicks out this error: > This XML file does not appear to have any style information associated with > it. The document tree is shown below.               <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">     <channel>     <title>Paramount Solar Blog » Page not found</title>     <atom:link href="http://blog.paramountsolar.com/feed/rss2" rel="self" type="application/rss+xml"/>     <link>http://blog.paramountsolar.com</link>     <description>     We discuss everything about Solar Power, Solar Panels and Solar Energy!     </description>     <lastBuildDate>Tue, 18 Dec 2012 10:37:20 +0000</lastBuildDate>     <language>en-US</language>     <sy:updatePeriod>hourly</sy:updatePeriod>     <sy:updateFrequency>1</sy:updateFrequency>     <generator>http://wordpress.org/?v=3.4.2</generator>     </channel>     </rss>


title: Reversing the order of posts AFTER the query is performed

text: I'm am displaying the last 5 posts of a custom post type 'show'. This gives me the latest post first.               <?php     $args = array(         'post_type' => 'show',         'posts_per_page' => 5,         'order' => 'DESC'         );     $home_shows = new WP_Query($args);     var_dump($home_shows);     ?>      What I need is to actually have the earliest (of the array of the latest shows) first, and the latest show (in that array of latest shows) last. I am now currently getting (the show date via a custom field meta value): 3/11/12, 3/7/12, 3/4/12, 3/2/12, 2/30/12 etc. I need: 2/30/12, 3/1/12, 3/4/12, 3/7/12, 3/11/12, I tried using php's array_reverse like so (added to the above code):               $reversed_shows = array_reverse( $home_shows->posts );      Which gave me really odd results (displayed completely different parts of the post, array order was off). Any ideas?


title: Pretty permalinks for search results with extra query var

text: I'd like to know how I can rewrite a search URL that also contains an extra query var into a pretty permalink using `wp_redirect` and the `template_redirect` hook. I have taken the code from the Nice Search plugin which works fine to change `http://example.com?s=africa` into `http://example.com/search/africa`:               add_action( 'template_redirect', 'my_rewrite' ) );          function my_rewrite() {                  if ( is_search() and false === strpos( $_SERVER['REQUEST_URI'], '/search/' ) ) {                 wp_redirect( get_bloginfo( 'home' ) . '/search/' . str_replace( ' ', '+', str_replace( '%20', '+', get_query_var( 's' ) ) ) );                 exit();             }              }      But I am using a select dropdown in combination with the Relevanssi plugin to allow visitors to narrow down the search to a particular post type. This adds a `post_type` query var, e.g. `http://example.com?s=africa&post_type=features`. I would like this to have a URL something like `http://example.com/search/africa/section/features`. The Nice Search code causes the post_type query var to be lost. So I tried the following code:               function my_rewrite() {              if ( is_search() and false === strpos( $_SERVER['REQUEST_URI'], '/search/' ) ) {             if ( isset( $_GET['post_type'] ) and '' !== $_GET['post_type'] ) {                 wp_redirect( get_bloginfo( 'home' ) . '/search/' . str_replace( ' ', '+', str_replace( '%20', '+', get_query_var( 's' ) ) ) . '/section/' . str_replace( ' ', '+', str_replace( '%20', '+', get_query_var( 'post_type' ) ) ) );             } else {                 wp_redirect( get_bloginfo( 'home' ) . '/search/' . str_replace( ' ', '+', str_replace( '%20', '+', get_query_var( 's' ) ) ) );             }             exit();         }          }      but WordPress now thinks the search term is `africa/section/features`. Is there a way I can keep the search term and the query var all in a nice permalink? Thanks Simon


title: Moving to a WordPress blog. What do I need to know?

text: I'll be moving my blog from another engine to WordPress shortly. However, I am a complete noob to WordPress. So I am wanting to at least replicate the functionality my old blog used to have.   1. There are a dozen Adsense plugins, not sure how to choose. Recommendations?   2. Likewise there a ton of Google Analytics plugins. Anything in particular I should look for?   3. Anything else I should look out for?


title: get_the_excerpt() is not returning an empty string when the_excerpt is blank?

text:
In the code below represents a link list of recent posts. I'm just trying to write out the post name, along with the post excerpt if one exists. So I'm using the get_link_excerpt($post) function in order to determine if the current post in the for loop has an excerpt. It works fine if the post has an excerpt, however, if it doesn't, the get_the_excerpt() function is returning its own excerpt crafted from the current page's content. In this case, I'm placing this function on the home page, so every post that does not explicitly have a snippet is getting a virtual excerpt from the home page's content. Apparently, I'm passing $post improperly, what's the correct way to do it here?               function show_footer_recent(){         $myquery = new WP_Query();$myquery->query(array('post__not_in' => get_option('sticky_posts')));         $myrecentpostscount = $myquery->found_posts;         if ($myrecentpostscount > 0){ ?>

Latest News & Articles                 <?php global $post;$myrecentposts = get_posts(array('post__not_in' => get_option('sticky_posts'),'numberposts' => get_option('cb2_recent_count')));                 foreach($myrecentposts as  $idxrecent=>$post) { ?>
                         <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php echo get_link_excerpt(); ?>
<?php } ?>

     <?php }}           function get_link_excerpt(){         $LinkExcerpt = strip_tags(substr(get_the_excerpt(), 0, 75 ));         if($LinkExcerpt != '')         {             return ": ".$LinkExcerpt."...";         }         return false;         }


title: WordPress and Security

text: Are there some simple ways to beef up the security on a WordPress site?


title: Having issues with wordpress pagination with multiple categories

text: I’m having issues with my pagination in wordpress. Whenever I navigate to my archive section (news category), pagination works correctly. But, the issue lies with the plugin I’m using to generate a category specific archive. This plugin is dependant on permalink structure being: /%cateogry%/%year% /%monthnum% /%postname%/ When I click on the link “December 2010” (which is supposed to display a list of posts dated in Dec. 2010 from the “news” category), the plugin passes a url that looks like: www.my-site.com/news/2010/12/ That url causes the pagination to stop working because the link to page 2 looks like: www.my-site.com/news/2010/12/page/2/ Is there a way to get this to work regardless of the category name change? I’m using multiple categories Example: ## Working News archive: www.my-site.com/news/ Page 2: www.my-site.com/news/page/2/ ## NOT Working (after plugin does its thing) News archive (Dec 12): www.my-site.com/news/2010/12/page/2/


I just started using vimpress. I can write posts by typing in Vim               :BlogNew      and send them by typing:               :BlogSend      I think a lot of Wordpress developers may be using the plugin. So my question is Is it possible to list and create custom post types with Vimpress?


title: Adding custom avatar field to comments

text: I want to store a users Twitter Profile Image when I found out that they've tweeted the link of a post (by using the Twitter API), but I'm stuck with the following issue: How do I store the Profile Image URL? I figure I must add that to the comments table in the database but then when querying for comments the default Gravatar option would be used. So I think that's not going to work. So my guess would be: overriding the default avatar function to use the Twitter Profile Image URL if that's present in the database (and how would I add a custom field to the comments database?), or use Gravatar otherwise. Thanks for helping me out!


title: How to create a shortcode to let the user add the ID of a YouTube video?

text:
I use the following to add in a post a YouTube thumbnail and display the video in a fancybox:

      Basically the shortcode must have one fields to enter the ID of the video in the thumbnail, the link to the video, the link of the first div, and the id of the second div. `http://img.youtube.com/vi/(HERE)/0.jpg` and `http://img.youtube.com/vi/(HERE)/0.jpg` `<a class="fancybox" href="#(HERE)">` and `<div id="(HERE)" style="display: none;">` So the shortcode should look like:               [youtube VIDEO ID:(Enter ID)]      Does anybody know how to do this?


title: How to place a loop within another loop?

text:
I have two loops setup using WP_Query: `$latest` and `$popular` that I'm working to setup in this example layout: **Latest**                                       **Popular** ![enter image description here](http://i.stack.imgur.com/OxAQY.png) **Example HTML Output**

             <post1>                 <post2>

             <post10>                 <post9>             <post8>                 <post7>

             <ad>

             <post3>                 <post4>

             <post6>                 <post5>             <post4>                 <post3>

             <ad>

          [...]      Simply put: the **Latests** and **Popular** post divs are floated next to eachother and broken apart every few posts to accommodate an full width ad block. **My Loop**

                  <?php                  $args1 = array (                 'posts_per_page'    => 1000000,                 'order'             => 'DESC',                 'orderby'           => 'date'                  );                  $latest = new WP_Query( $args1 );                  if ( $latest -> have_posts() ) :                      $count = 0;                      while ( $latest -> have_posts() ) : $latest -> the_post();                          $count++;                          if ( $count % 5 == 0 ) :                                  get_template_part( 'template', 'post' ); ?>

                                      <?php                                      $args2 = array (                                     'posts_per_page'    => 10,                                     'order'             => 'ASC',                                     'orderby'           => 'date',                                 );                                      $popular = new WP_Query( $args2 );                                      if ( $popular -> have_posts() ) :                                          while ( $popular -> have_posts() ) : $popular -> the_post();                                              get_template_part( 'template', 'post' );                                          endwhile;                                      endif;                                      ?>

                                 <?php get_template_part( 'template', 'ad' ); ?>

                          <?php                          else :                              get_template_part( 'template', 'post' );                          endif;                      endwhile;                  endif; wp_reset_postdata();                  ?>

      Right now this is setup so that every 5th posts in the `$latest` loop the `$popular` loop and a ad-block are added. I understand why this doesn't work... Because every 5th post when the `$popular` loop is called it's starting again instead of continuing in order. Any ideas on how I can make this work?


title: Getting the chosen template when iterating through pages

text: Im trying print all the pages on a wordpress site. Im using the following code: > >     $args = array( 'post_type' => 'page'); >     $the_query = new WP_Query( $args ); >   >     if ( $the_query->have_posts() ) : >         while ( $the_query->have_posts() ) : $the_query->the_post(); >            get_template_part('content'); >         endwhile; >     endif; >   This works fine, but i want each page to be rendered with the template chosen by the admin in the admin menu. Is it possible to fetch the template name so i can provide it to the get_template_part? Best regards.


How to create a widget that has a submit form in the front end? The reason for this is I'm teaching myself plugin development and I'm struggling on how to display a form on the front end after adding the widget to the sidebar. my code thus far               function widget ($args,$instance) {         extract( $args );              /* Our variables from the widget settings. */         $title = apply_filters('widget_title', $instance['title'] );         $name = $instance['name'];         $number = $instance['number'];         $message = $instance['message'];              /* Before widget (defined by themes). */         echo $before_widget;              /* Display the widget title if one was input (before and after defined by themes). */         if ( $title )                 echo $before_title . $title . $after_title;                   ?>
                     <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'hybrid'); ?>                     <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />

                     <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('Your Name:', 'name'); ?>                     <input id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" />

                     <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Your Cellphone Number:', 'number'); ?>                     <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>"  />

                     <label for="<?php echo $this->get_field_id( 'message' ); ?>"><?php _e('Your Message:', 'message'); ?>                     <textarea id="<?php echo $this->get_field_id( 'message' ); ?>" name="<?php echo $this->get_field_name( 'message' ); ?>"><?php echo $instance['message']; ?></textarea>
         <?php              /* After widget (defined by themes). */         echo $after_widget;      }


title: About updating and localisation

text: Data: WP MU, 3.9.2 Recently I discovered that my custom Akismet's localisation was replaced by default one - 2 questions about auto updates and languages: 1) Does WP updates smth in wp-content/languages folder when auto updates? I would like to keep all my custom localizstions (of all the themes and plugins I use) in this folder but now I am afraid that after WP auto update every custom localisation just disappear or will be replaced by default. Should I be worried about this or WP does not effect these? 2) What can I do to keep Akismet's custom localisation in safe from the plugin or WP auto update? OR: How do Akismet update it's default localisation and where Akismet stores it? Regards.


title: sort events based on event date custom field

text:
I'm trying to list events (custom posttype 'kurs') by event date, which are stored as custom fields ('dato'). My loop so far looks like this:
       <?php $loop = new WP_Query( array( 'post_type' => 'kurs' ) ); ?>          <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title( '', '' ); ?>
          <?php endwhile; ?>
      What I need is a list of post(event)-titles from today forward in the future...


title: wp_dropdown_pages doesn't work with post_type argument

text: I'm trying to display dropdown menu with posts with custom "post_type". In case I insert this code, it shows dropdown menu with all "pages".               $arg=array(                 'show_option_none' => __( 'None' ),                 'orderby' => 'title',                 'hide_empty' => false,                 'suppress_filters' => true             );                  wp_dropdown_pages($arg);      But in case I insert this code, it doesn't show nothing, neither dropdown menu at all.               $arg=array(                 'show_option_none' => __( 'None' ),                 'orderby' => 'title',                 'hide_empty' => false,                 'post_type'=>'custom_post_type',                 'suppress_filters' => true             );                  wp_dropdown_pages($arg);      Thanks for any advice!! WordPress 3.9.2, PHP 5.5.1


title: How to use full length of the upper part of the content and below of it is a content with a sidebar?

text:
Can anyone help me with my problem although its simple but I'm just newbie in wordpress? Right now I'm using the default template of the theme with sidebar. So what I want to happen is above the content of the page below the menu is to put a content across the page, but only in homepage I don't want to see it to all of the page. Sorry for my English I'm having a hard time explaining it in English, Hope you understand what I'm trying to point out. Here is the current site http://ftcanada.com/ Here is what I want to insert http://awesomescreenshot.com/02a1ycnn26 Please help me... Here is the content.php When I insert a code above the article id the content appear in every page. What I want to happen is to display it just in homepage.               <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                      <?php if ( is_sticky() ) : ?>                 <hgroup>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'catchbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

<?php _e( 'Featured', 'catchbox' ); ?>
                 </hgroup>             <?php else : ?>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'catchbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
             <?php endif; ?>                  <?php if ( 'post' == get_post_type() ) : ?>
                     <?php catchbox_posted_on(); ?>                     <?php if ( comments_open() && ! post_password_required() ) : ?>                          —                                                       <?php comments_popup_link(__('No Comments ↓', 'catchbox'), __('1 Comment ↓', 'catchbox'), __('% Comments ↓', 'catchbox')); ?>                                              <?php endif; ?>
             <?php endif; ?>                        <?php              $options = catchbox_get_theme_options();             $current_content_layout = $options['content_layout'];             $catchbox_excerpt = get_the_excerpt();              if ( is_search() ) : // Only display Excerpts for Search ?>
                 <?php the_excerpt(); ?>
         <?php elseif ( $current_content_layout=='excerpt' && !empty( $catchbox_excerpt ) ) : // Only display Featured Image and Excerpts if checked in Theme Option ?>
                 <?php if( has_post_thumbnail() ):?>                     <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'catchbox' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                         <?php the_post_thumbnail('featured-slider'); ?>                                      <?php endif; ?>                 <?php the_excerpt(); ?>
         <?php else : ?>
             <?php the_content( __( 'Continue reading →', 'catchbox' ) ); ?>             <?php wp_link_pages( array(                  'before'        => '
' . __( 'Pages:', 'catchbox' ) . '',                 'after'         => '
',                 'link_before'   => '',                 'link_after'    => '',             ) );              ?>
         <?php endif; ?>                           <?php $show_sep = false; ?>             <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>             <?php                 /* translators: used between list items, there is a space after the comma */                 $categories_list = get_the_category_list( __( ', ', 'catchbox' ) );                 if ( $categories_list ):             ?>                              <?php printf( __( 'Posted in %2$s', 'catchbox' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );                 $show_sep = true; ?>                          <?php endif; // End if categories ?>             <?php                 /* translators: used between list items, there is a space after the comma */                 $tags_list = get_the_tag_list( '', __( ', ', 'catchbox' ) );                 if ( $tags_list ):                 if ( $show_sep ) : ?>              |                  <?php endif; // End if $show_sep ?>                              <?php printf( __( 'Tagged %2$s', 'catchbox' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );                 $show_sep = true; ?>                          <?php endif; // End if $tags_list ?>             <?php endif; // End if 'post' == get_post_type() ?>                  <?php if ( comments_open() ) : ?>             <?php if ( $show_sep ) : ?>              |              <?php endif; // End if $show_sep ?>             <?php comments_popup_link( '' . __( 'Leave a reply', 'catchbox' ) . '', __( '1 Reply', 'catchbox' ), __( '% Replies', 'catchbox' ) ); ?>             <?php endif; // End if comments_open() ?>                  <?php edit_post_link( __( 'Edit', 'catchbox' ), '', '' ); ?>
      Thanks


title: get_the_term_list - Return links to edit.php instead of link to taxonomy archive template

text: I would like to use `get_the_term_list` or another function if it exists to return links to the posts of the appropriate term (which has been clicked) on edit.php instead of returning links to posts of the clicked term on the taxonomy archive page. Can this be achieved?


title: Using a taxonomy value as part of a post URL

text: I'm working on a Real Estate site using the following permalink format for properties: > http://www.site.com/property/1330-5th-avenue (property is a custom post type > for listings) How can I modify the permalink for these posts to > http://www.site.com/new-york/1330-5th-avenue (being new New York a term > which is associated with custom taxonomy City) I have been researching but I really need help. Is it even possible?


title: Why can't I access Custom Taxonomy metadata?

text: I'm trying to access Custom Taxonomy metadata for all my custom taxonomy terms. The metadata is stored in options like so:               $t_id = $term_id;         $term_meta = get_option( "taxonomy_$t_id" );         $cat_keys = array_keys( $_POST['term_meta'] );         foreach ( $cat_keys as $key ) {             if ( isset ( $_POST['term_meta'][$key] ) ) {                 $term_meta[$key] = $_POST['term_meta'][$key];             }         }         // Save the option array.         update_option( "taxonomy_$t_id", $term_meta );      In my attempt to get at each metadata field, I've written the following code, but my array `$term_meta` is completely empty. Echoing `$t_id` returns all the IDs successfully, however.               <?php     $taxonomy = 'hhie_artists';     $args = array(     'hide_empty' => 0     );     $terms = get_terms( $taxonomy, $args );     foreach( $terms as $term ) {         $empty_terms[] = $term;         $t_id = $term->term_id;         $term_meta = get_option( 'taxonomy_' . $t_id );         print_r( $term_meta );         echo $t_id;         echo "<br />";     }     ?>      As an example, one of the keys in the array would be `$term_meta['release_date_meta']` **EDIT:** Using this on a page template for testing purposes.


title: Random Featured Image based on sub-category

text: I have this code below for adding a random Featured Image to a post in WordPress based on a category. (Thanks to G.M. on this WPSE post) I have two questions about it: ### First Question: It is displaying the following error: > _Warning: strpos(): needle is not a string or an integer in \wp- > content\plugins\auto-feature\autofeature.php on line 95_ Line 95 is the following line: `if ( strpos($nameNoUF, $cat) === 0 ) return $post->ID;` Don't know what is wrong. ### Second Question: I have multiple categories which all have multiple sub-categories. My goal is that each of the sub-categories have random images based on the sub-category. The main category is not important. It is all about the subcategories.   My structure is:   Main Category: House   Sub categories: Cooking / Cleaning / Savings Main Category: Garden   Sub categories: Lawn / Pond / Animals   So, I a user posts in the sub-category garden, it will randomly pick an image based on the subcategories. `UF-garden-2.jpg`, `UF-garden-1.jpg` and so on. With the code below it is not working. It just picks any image, it does not look at the (sub)category.. Here is the code:                    function autoset_featured() {          global $post;          $already_has_thumb = has_post_thumbnail($post->ID);          if (!$already_has_thumb)  {              $attached_image = get_children( "post_parent=$post->ID&post;_type=attachment&post;_mime_type=image&numberposts;=1" );              if ($attached_image) {                   foreach ($attached_image as $attachment_id => $attachment) {                        set_post_thumbnail($post->ID, $attachment_id);                   }              } else {       $cat_slugs = wp_get_post_terms($post->ID, 'event-categories', array("fields" => "slugs"));       $image = get_image( $cat_slugs );       if ( image ) set_post_thumbnail($post->ID, $image);     }          }     }          function get_image( $cats = array() ) {       $media_query = new WP_Query(         array(           'post_status' => 'inherit',           'post_parent' => 0,           'post_type' => 'attachment',           'post_mime_type' => 'image/jpeg',           // set 'orderby' to 'rand' will randomize results order           'orderby' => 'rand',                // READ CAREFULLY:           // if in the title of all images intended to be used as thumbnail           // you put something that contain 'UF' you can use the 's' param           // retrieving less results and so improving performance           // in that case uncomment next line           // 's' => 'UF'              )       );            if ( $media_query->have_posts() ) {              $lastid = false; // just an early setup              // loop through images         foreach ($media_query->posts as $post) {                // get current image url           $fullpath = wp_get_attachment_url($post->ID);                // if current image name doesn't start with 'UF-' skip it           if ( strpos( basename($fullpath), 'UF-' ) !== 0 ) continue;                // if the original post has no categories assigned, return first image ID           // images are random ordered, so first one is random one           if ( empty($cats) ) return $post->ID;                    // get current image file name (without extension) and remove the 'UF-' part           $name = pathinfo( basename($fullpath), PATHINFO_FILENAME);           $nameNoUF = str_replace('UF-', '', $name);                 // $nameNoUF contain something like 'category-name-01'           // because 'UF-' at beginning and extension were both removed                // save the current image ID in a helper variable for future possible use           $lastid = $post->ID;                // loop through categories and if $nameNoUF start with a category slug,           // return the image ID.           // this way every image named like 'UF-category-name-01.jpg' match           foreach ( $cats as $cat ) {             if ( strpos($nameNoUF, $cat) === 0 ) return $post->ID;           }         }         // if we are here no category related image was found, so return the last image ID         // images are random ordered, so last one is random one         return $lastid;       }       // no images found at all, sorry, return false (no thumbnail will be setted)       return false;     }          add_action('the_post', 'autoset_featured');     add_action('save_post', 'autoset_featured');     add_action('draft_to_publish', 'autoset_featured');     add_action('new_to_publish', 'autoset_featured');     add_action('pending_to_publish', 'autoset_featured');     add_action('future_to_publish', 'autoset_featured');                     Hope someone can help me out here.


title: *some* .jpg files not generating _wp_attachment_metadata

text: Not all .jpg files do this, but some, from as many as three different cameras, are not generating _wp_attachment_metadata. I don't think it's the PHP because some files do generate it. 2 theories:   1. The form of the metadata for some of these photos is such that it isn't picked up by the PHP. Evidence for this is that thumbnails don't show up when .jpgs are seen as attachments in e-mails while viewing in Chrome, but they do show up while viewing in Firefox.   2. It's a RAM issue, and my host isn't allocating enough nor is Google, for processing the metadata. My only problem with theory 2 is that this happens to big and small .jpg files alike. Some as big as 4.5MB and some as small as 750kB. Any thoughts/ideas?


title: TinyMCE Keyup Function

text: I am trying to run a function on Keyup of the TinyMCE Editor on new post and edit post screens. I'm having a hard time catching the keyboard action when a user types something.               jQuery(document).ready(function() {                     setTimeout(function(){                         var content = "tinymce";                         var tinyMCEcontent = tinymce.editors.content.getContent();                         console.log(tinyMCEcontent.length);                     },3000);                 });      This was my attempt at getting the content of the TinyMCE editor. I am able to see the length. How can I run this function on Keyup? I have tried something like this:               jQuery(document).ready(function() {               jQuery("#tinymce").keyup(function() {                     setTimeout(function(){                         var content = "tinymce";                         var tinyMCEcontent = tinymce.editors.content.getContent();                         console.log(tinyMCEcontent.length);                     },3000);               });      });      But it isn't catching the keyup at all. What I am trying to do is set a limit on the post type content.


title: Page template translation not working

text: I have a custom post type witch is kind of a general "under custruction" template for pages that are not released yet The problem is I done the po file like for any other page of the theme but it does not fire I found on the web also that with custom post types adding `msgctxt` helps so I also tryed that also and added the page template name but that does not seem to help either _Comment:_ The translations i use work on index,header,footer here is my .po entry               #. Text in echo     #: page-soon.php:11     msgctxt "Comming soon"     msgid "Page under cunstruction"     msgstr "Stran v izdelavi"      template file name and line numbers are correct hope someone can help with this


title: Add featured image to RSS feed through child theme functions.php file

text: I'm trying to add featured images to my RSS feed, on a blog running a pinbin child theme. When I install and activate the plugin "Add featured image to RSS feed" it works. When I try to paste the code of this plugin in my child functions.php file it doesn't work (in fact, no code I've found on the internet works when it's pasted in my functions.php file, like this one for example Can't Display Featured Image in RSS Feed ) The code is               function add_featured_image_to_feed($content) {         global $post;         if ( has_post_thumbnail( $post->ID ) ){             $content = '' . get_the_post_thumbnail( $post->ID, 'large' ) . '' . $content;         }         return $content;     }          add_filter('the_excerpt_rss', 'add_featured_image_to_feed', 1000, 1);     add_filter('the_content_feed', 'add_featured_image_to_feed', 1000, 1);      What could I be doing wrong? Of course my blog is using the child theme and I've checked that other functions in the child functions.php file are working.


title: Pagination with Custom Post Type

text: I created a custom post type named "noticias" and duplicated archive.php with name archive-noticias.php. Everything works but when pagination actived, don't work page 2, 3.... I use plugin "T5 Page to Seite" for change "page" slug with "pagina" slug.               <?php # -*- coding: utf-8 -*-     /**      * Plugin Name: T5 Page to Seite      * Description: Ersetzt /page/ durch /seite/.      * Author:      Thomas Scholz <info@toscho.de>      * Author URI:  http://toscho.de      * License:     MIT      * License URI: http://www.opensource.org/licenses/mit-license.php      */          if ( ! function_exists( 't5_page_to_seite' ) )     {     register_activation_hook(   __FILE__ , 't5_flush_rewrite_on_init' );     register_deactivation_hook( __FILE__ , 't5_flush_rewrite_on_init' );     add_action( 'init', 't5_page_to_seite' );          function t5_page_to_seite()     {     $GLOBALS['wp_rewrite']->pagination_base = 'pagina';     }     function t5_flush_rewrite_on_init()     {     add_action( 'init', 'flush_rewrite_rules', 11 );     }     }      And add this line to .htaccess               RedirectMatch Permanent ^/(.*)/page/(.*) /$1/pagina/$2      I'm trying check every posts of stackoverflow and WordpressAnswers but don't work. please, help me. MONKEYMAN REWRITE ANALYZER RESULTS http://www.vektorlab.com/rewrite.html here my custom post type in functions.php               function crear_tipo_noticias() {     $labels = array(     'name'               => _x( 'Noticias', 'Post Type General Name', 'text_domain' ),     'singular_name'      => _x( 'Noticia', 'Post Type Singular Name', 'text_domain' ),     'menu_name'          => __( 'Noticias', 'text_domain' ),     'parent_item_colon'  => __( 'Noticia Padre', 'text_domain' ),     'all_items'          => __( 'Noticias', 'text_domain' ),     'view_item'          => __( 'Ver Noticia', 'text_domain' ),     'add_new_item'       => __( 'Añadir Noticia Nueva', 'text_domain' ),     'add_new'            => __( 'Añadir', 'text_domain' ),     'edit_item'          => __( 'Editar Noticia', 'text_domain' ),     'update_item'        => __( 'Actualizar', 'text_domain' ),     'search_items'       => __( 'Buscar Noticias', 'text_domain' ),     'not_found'          => __( 'Noticias no encontradas', 'text_domain' ),     'not_found_in_trash' => __( 'Noticias no encontradas en Papelera', 'text_domain' ),     );          $rewrite = array(     'slug'                => 'noticia',     'with_front'          => true,     'pages'               => true,     'feeds'               => true,     );          $args = array(     'label'               => __( 'noticia', 'text_domain' ),     'description'         => __( 'Noticias relacionadas con Tuppersex', 'text_domain' ),     'labels'              => $labels,     'supports'            => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields'),     'taxonomies'          => array( 'category', 'post_tag' ),     'hierarchical'        => false,     'public'              => true,     'show_ui'             => true,     'show_in_menu'        => true,     'show_in_nav_menus'   => true,     'show_in_admin_bar'   => true,     'menu_position'       => 5,     'menu_icon'           => site_url().'/wp-content/plugins/my_plugin/images/logo.png',     'can_export'          => true,     'has_archive'         => 'noticias',     'exclude_from_search' => false,     'query_var'           => 'noticias',     'rewrite'             => $rewrite,     'capability_type'     => 'post',     );          register_post_type('noticias', $args);     }          add_action('init', 'crear_tipo_noticias', 0);      My archive-noticias.php loop is...               <?php while(have_posts()): the_post(); ?>         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


title: How to use/retrieve an options array, with defaults, using get_option()

text: Someone explained me that using `get_option` is not productive, it's better to implement a custom function and then save the options in a single multidimensional array. Before I thought that having an array like this one and using `get_option('the_option_id', 'default_value')` every time was a good way:               $options = array(         //GENERAL SETTINGS     array("name" => "General Settings",         "type" => "title"),     array("type" => "open"),     array("name" => "Option 1",        "desc" => "Description.",        "id" => "option_id_1",        "type" => "text"),     array("name" => "Option 2",        "desc" => "Description.",        "id" => "option_id_2",        "type" => "text"),     array("type" => "close"),     )      He said that it's better to call the function `get_option()` only one time and get everything in a custom function. Why is that, when on codex they recommend to use the simple `get_option($variable, $default)`? That's a theoretical question, but feel free to post or share your codes. How do you do work about that? (Most of the option frameworks use a custom function, also).


title: How to add title attribute to archive items

text: How can I have the title attribute to each listed archive item, so when I hover an item, it says: view all posts in archive: ''               $html = wp_get_archives( array(         'show_post_count' => false,         'echo' => true,     ) );     // Wrap the post count in a span element     $html = preg_replace( '~( )(\(\d++\))~', '$1› $2', $html );     // Output the result     echo $html;


title: How to make "Blog pages show at most" setting not affect custom queries

text: I want my blog page to display 5 posts at most. But I have many custom queries (wp_query) on my site, some of them embedded together: how to make `Settings > Reading > Blog pages show at most` setting NOT affect my custom queries?


title: Changes required to make new plugin from existing

text:
I have a gallery plugin script I found here: http://wp.rosselliot.co.nz/user- images/ This allows users of my site to upload their own gallery photos -- these photos can only been seen by the uploader which is also a plus for me. In fact, I like it so much I want to deploy it again on my site ( I know this may not make sense to some, but I have a very specific Idea). So my question is: What changes do I need to make to this plugin script to make wordpress think this is a completely different plugin, and allow me to deploy it without errors. I have tried adding I have tried changing call the "sui" with "sui2" but its giving me errors still, I don't know much about how the plugins communicate with wordpress. The Code: submit_user_images.php               <?php     /*     Plugin Name: Submit User Images     Plugin URI: http://wp.rosselliot.co.nz/user-images/     Description: Allows registered users to submit images.     Version: 1.0     License: GPLv2     Author: Ross Elliot     Author URI: http://wp.rosselliot.co.nz     */          define('MAX_UPLOAD_SIZE', 200000);     define('TYPE_WHITELIST', serialize(array(       'image/jpeg',       'image/png',       'image/gif'       )));               add_shortcode('sui_form', 'sui_form_shortcode');               function sui_form_shortcode(){            if(!is_user_logged_in()){              return '
You need to be logged in to submit an image.
';                }            global $current_user;            if(isset( $_POST['sui_upload_image_form_submitted'] ) && wp_verify_nonce($_POST['sui_upload_image_form_submitted'], 'sui_upload_image_form') ){                $result = sui_parse_file_errors($_FILES['sui_image_file'], $_POST['sui_image_caption']);              if($result['error']){                echo '
ERROR: ' . $result['error'] . '
';              }else{                $user_image_data = array(             'post_title' => $result['caption'],             'post_status' => 'pending',             'post_author' => $current_user->ID,             'post_type' => 'user_images'                );                if($post_id = wp_insert_post($user_image_data)){                  sui_process_image('sui_image_file', $post_id, $result['caption']);                  wp_set_object_terms($post_id, (int)$_POST['sui_image_category'], 'sui_image_category');                }         }       }              if (isset( $_POST['sui_form_delete_submitted'] ) && wp_verify_nonce($_POST['sui_form_delete_submitted'], 'sui_form_delete')){              if(isset($_POST['sui_image_delete_id'])){                if($user_images_deleted = sui_delete_user_images($_POST['sui_image_delete_id'])){                          echo '
' . $user_images_deleted . ' images(s) deleted!
';                }         }       }                 echo sui_get_upload_image_form($sui_image_caption = $_POST['sui_image_caption'], $sui_image_category = $_POST['sui_image_category']);            if($user_images_table = sui_get_user_images_table($current_user->ID)){              echo $user_images_table;            }          }               function sui_delete_user_images($images_to_delete){            $images_deleted = 0;            foreach($images_to_delete as $user_image){              if (isset($_POST['sui_image_delete_id_' . $user_image]) && wp_verify_nonce($_POST['sui_image_delete_id_' . $user_image], 'sui_image_delete_' . $user_image)){                if($post_thumbnail_id = get_post_thumbnail_id($user_image)){                  wp_delete_attachment($post_thumbnail_id);                      }                  wp_trash_post($user_image);                $images_deleted ++;              }       }            return $images_deleted;          }               function sui_get_user_images_table($user_id){            $args = array(         'author' => $user_id,         'post_type' => 'user_images',         'post_status' => 'pending'           );            $user_images = new WP_Query($args);            if(!$user_images->post_count) return 0;            $out = '';       $out .= '
Click to see full size
';            $out .= '<form method="post" action="">';            $out .= wp_nonce_field('sui_form_delete', 'sui_form_delete_submitted');              $out .= '
';       $out .= '
Image	Name	Category	Delete
';            foreach($user_images->posts as $user_image){              $user_image_cats = get_the_terms($user_image->ID, 'sui_image_category');             foreach($user_image_cats as $cat){                $user_image_cat = $cat->name;              }              $post_thumbnail_id = get_post_thumbnail_id($user_image->ID);                 $out .= wp_nonce_field('sui_image_delete_' . $user_image->ID, 'sui_image_delete_id_' . $user_image->ID, false);               $out .= '
';         $out .= '' . wp_get_attachment_link($post_thumbnail_id, 'thumbnail') . '	';             $out .= '' . $user_image->post_title . '	';         $out .= '' . $user_image_cat . '	';             $out .= '<input type="checkbox" name="sui_image_delete_id[]" value="' . $user_image->ID . '" />	';                   $out .= '
';            }            $out .= '
';            $out .= '<input type="submit" name="sui_delete" value="Delete Selected Images" />';       $out .= '</form>';              return $out;          }               function sui_process_image($file, $post_id, $caption){            require_once(ABSPATH . "wp-admin" . '/includes/image.php');       require_once(ABSPATH . "wp-admin" . '/includes/file.php');       require_once(ABSPATH . "wp-admin" . '/includes/media.php');            $attachment_id = media_handle_upload($file, $post_id);            update_post_meta($post_id, '_thumbnail_id', $attachment_id);            $attachment_data = array(         'ID' => $attachment_id,         'post_excerpt' => $caption       );            wp_update_post($attachment_data);            return $attachment_id;          }               function sui_parse_file_errors($file = '', $image_caption){            $result = array();       $result['error'] = 0;            if($file['error']){              $result['error'] = "No file uploaded or there was an upload error!";              return $result;            }            $image_caption = trim(preg_replace('/[^a-zA-Z0-9\s]+/', ' ', $image_caption));            if($image_caption == ''){              $result['error'] = "Your caption may only contain letters, numbers and spaces!";              return $result;            }            $result['caption'] = $image_caption;              $image_data = getimagesize($file['tmp_name']);            if(!in_array($image_data['mime'], unserialize(TYPE_WHITELIST))){              $result['error'] = 'Your image must be a jpeg, png or gif!';            }elseif(($file['size'] > MAX_UPLOAD_SIZE)){              $result['error'] = 'Your image was ' . $file['size'] . ' bytes! It must not exceed ' . MAX_UPLOAD_SIZE . ' bytes.';            }            return $result;          }                    function sui_get_upload_image_form($sui_image_caption = '', $sui_image_category = 0){            $out = '';       $out .= '<form id="sui_upload_image_form" method="post" action="" enctype="multipart/form-data">';            $out .= wp_nonce_field('sui_upload_image_form', 'sui_upload_image_form_submitted');            $out .= 'Image Caption - Letters, Numbers and Spaces
';       $out .= '<input type="text" id="sui_image_caption" name="sui_image_caption" value="' . $sui_image_caption . '"/>
';       $out .= 'Image Category
';         $out .= sui_get_image_categories_dropdown('sui_image_category', $sui_image_category) . '
';       $out .= 'Select Your Image - ' . MAX_UPLOAD_SIZE . ' bytes maximum
';         $out .= '<input type="file" size="60" name="sui_image_file" id="sui_image_file">
';            $out .= '<input type="submit" id="sui_submit" name="sui_submit" value="Upload Image">';            $out .= '</form>';            return $out;          }               function sui_get_image_categories_dropdown($taxonomy, $selected){            return wp_dropdown_categories(array('taxonomy' => $taxonomy, 'name' => 'sui_image_category', 'selected' => $selected, 'hide_empty' => 0, 'echo' => 0));          }               add_action('init', 'sui_plugin_init');          function sui_plugin_init(){            $image_type_labels = array(         'name' => _x('User images', 'post type general name'),         'singular_name' => _x('User Image', 'post type singular name'),         'add_new' => _x('Add New User Image', 'image'),         'add_new_item' => __('Add New User Image'),         'edit_item' => __('Edit User Image'),         'new_item' => __('Add New User Image'),         'all_items' => __('View User Images'),         'view_item' => __('View User Image'),         'search_items' => __('Search User Images'),         'not_found' =>  __('No User Images found'),         'not_found_in_trash' => __('No User Images found in Trash'),          'parent_item_colon' => '',         'menu_name' => 'User Images'       );            $image_type_args = array(         'labels' => $image_type_labels,         'public' => true,         'query_var' => true,         'rewrite' => true,         'capability_type' => 'post',         'has_archive' => true,          'hierarchical' => false,         'map_meta_cap' => true,         'menu_position' => null,         'supports' => array('title', 'editor', 'author', 'thumbnail')       );             register_post_type('user_images', $image_type_args);            $image_category_labels = array(         'name' => _x( 'User Image Categories', 'taxonomy general name' ),         'singular_name' => _x( 'User Image', 'taxonomy singular name' ),         'search_items' =>  __( 'Search User Image Categories' ),         'all_items' => __( 'All User Image Categories' ),         'parent_item' => __( 'Parent User Image Category' ),         'parent_item_colon' => __( 'Parent User Image Category:' ),         'edit_item' => __( 'Edit User Image Category' ),          'update_item' => __( 'Update User Image Category' ),         'add_new_item' => __( 'Add New User Image Category' ),         'new_item_name' => __( 'New User Image Name' ),         'menu_name' => __( 'User Image Categories' ),       );                $image_category_args = array(         'hierarchical' => true,         'labels' => $image_category_labels,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'user_image_category' ),       );            register_taxonomy('sui_image_category', array('user_images'), $image_category_args);            $default_image_cats = array('Suspect', 'Vehicle', 'Residence', 'Other');            foreach($default_image_cats as $cat){              if(!term_exists($cat, 'sui_image_category')) wp_insert_term($cat, 'sui_image_category');            }          }      user_images_template.php               <?php     /**      * Template Name: user_images      *      *      */          get_header(); ?>

All Approved User Images
          <?php       global $current_user;            $args = array(         'post_type' => 'user_images',         'post_status' => 'publish'           );            $posts = new WP_Query($args);            if($posts->post_count){;              $out = '';         $out .= '
';         $out .= '
Image	Caption	Category	Posted By
';              foreach($posts->posts as $user_image){                $user_info = get_userdata($user_image->post_author);                    $user_image_cats = get_the_terms($user_image->ID, 'sui_image_category');                foreach($user_image_cats as $cat){                  $user_image_cat = $cat->name;                }                $post_thumbnail_id = get_post_thumbnail_id($user_image->ID);                   $out .= '
';           $out .= '' . wp_get_attachment_link($post_thumbnail_id, 'thumbnail') . '	';               $out .= '' . $user_image->post_title . '	';           $out .= '' . $user_image_cat . '	';               $out .= '' . $user_info->user_login . '	';                 $out .= '
';              }              $out .= '
';              echo $out;            }else{              echo 'No images have been approved for publication!';            }          ?>

          <?php get_footer(); ?>


title: Navigation Menu Dissapears under categories

text: I have spent weeks trying to figure this one out. My main navigation menu does not appear under category types. The call to the header for `category.php` is identical to the pages. For example:   * http://buytongamade.com/ and all other pages will show nav menu   * http://buytongamade.com/diving (category) the nav menu does not show Any help with this would GREATLY be appreciated. I have tried numerous plugins and combinations to try and get a menu on the categories.......no luck....


title: New User Save Filter

text: I'm using the new(ish) filter `add_action( 'user_new_form', 'funcy', 9 );` to add custom fields to Create A New User page. I'm then using               add_action( 'personal_options_update', 'save_user_meta' );     add_action( 'edit_user_profile_update', 'save_user_meta' );      hooks to save my meta on other edit user pages. I've confirmed that when creating a new user WP does not hook into the above. I've tried looking through   1. `/wp-admin/user-new.php`   2. `/wp-adin/user-edit.php` but nothing stuck out as to how it was saving the new user info. The core of the question is, what can I hook into to save user_meta from the `user_new_form`?


title: Pages that don't look like blog posts?

text: I 've been scouting around for answers on creating static pages (that means NO BLOG POSTS of any kind) on pages where you don't want ANYTHING that looks blog related, (posts, leave a comment, date created, etc.) Think of pages like Contact Us, About Us, Bio, etc. The closest thing I could find is changing your homepage to static in the Reading Settings (and even that didn't do the trick!) I don't know if this matters, but I'm using Son of Blue theme. I don't understand much about coding, so if there is a line of code that needs to be changed/updated, please be very specific..


title: How to disable multiple thumbnail generation?

text: Tried setting the thumbnail size, but left medium + large to 0 0 to disable them, still all 3 were generated. Is there anyway to selectively disable these via functions.php?


title: How to set the default value of a option in a theme?

text: $shortname = "nuod";          array( "name" => "Custom Logo URL",         "desc" => "Enter the link to your site's custom logo.",         "id" => $shortname."_logo",         "type" => "text",         "std" => "newlogo.png")      How do i make the std be automatically set as the value for `<?php echo get_option('nuod_logo'); ?>`


title: Can't save checkbox option

text:
I know this is a mess, but can someone tell me why I can't save to checkbox option in this plugin?               /* Runs when plugin is activated */     register_activation_hook(__FILE__,'vigtigt_besked_install');           /* Runs on plugin deactivation*/     register_deactivation_hook( __FILE__, 'vigtigt_besked_remove' );          function vigtig_besked_install() {     /* Creates new database field */     add_option("vigtigt_data", 'Default', '', 'yes');     add_option("tweakfunction1", 'Default', '', 'yes');     }          function vigtig_besked_remove() {     /* Deletes the database field */     delete_option('vigtigt_data');     delete_option('tweakfunction1');     }          /*———————————————————————*/     function vigtig_besked_html_page() {     ?>

Vigtige beskeder!
          <form method="post" action="options.php">     <?php wp_nonce_field('update-options'); ?>

     Skriv din tekst her:	          <input size="76" name="vigtigt_data" type="text" id="vigtigt_data" value="<?php echo get_option('vigtigt_data'); ?>" />     (f.eks. Undervisning er aflyst pga. sne!)

Funktion1:	          <input size="76" name="tweakfunction1" type="checkbox" id="tweakfunction1" checked="<?php get_option( 'tweakfunction1' ); ?>" />     <?php echo  get_option( 'tweakfunction1' ); ?>

          <input type="hidden" name="action" value="update" />     <input type="hidden" name="page_options" value="vigtigt_data,tweakfunction1" />
     <input type="submit" value="<?php _e('Gem ændringer') ?>" />
          </form>                              <?php if (!current_user_can('manage_options'))  {             wp_die( __('You do not have sufficient permissions to access this page.') );         }         echo '
';         echo '
Here is where the form would go if I actually had options.
';         echo '
'; ?>
               <?php }          if ( is_admin() ){          /* Call the html code */     add_action('admin_menu', 'vigtig_besked_admin_menu');          function vigtig_besked_admin_menu() {     add_menu_page('Vigtigt', 'Vigtige beskeder!', '1','vigtig_besked', 'vigtig_besked_html_page');}     }


title: Plugin Recommendation for selling one page content

text: Hi I need a recommendation for a plugin, preferably free, that enables me to block a page's content. I only need this for a few pages, and the users must be able to buy the content on an individual page basis. Thanks


title: wp_trash_post action hook with custom post type

text: When a 'contact' cpt post is trashed, i need a metakey from another cpt 'act' to be deleted, i have been searching all over which hook i should use but unfortunatly the codex action reference page is not very helpful. Below is the code i have. Idealy, i would also like an Admin Notice to be placed in the post listing screen where the user will be redirected to. Question: 1. is this the best hook to be using ? 2. Why isn't it working as expected ? Below the code i have thus far.               add_action( 'wp_trash_contact', 'contact_cpt_cleanup' );          function contact_cpt_cleanup( $post_id ){          global $post_type;            if ( $post_type != 'contact' ) return;              // die('deleted contact');              // check to see if the current contact has any acts attached         $acts_associated = get_post_meta( $post_id, 'acts_associated', true );              // if so, delete the association from the act to the contact         if( $acts_associated ){             foreach( $acts_associated as $act_id ) {             delete_post_meta( (int) $act_id, 'contact_associated' );             }         }          }      Thanks. EDITS: Reading this post and this error report i now believe the correct syntax for this action hook is wp_{post_status}_{post_type} and not 'trash_post'. But it is still not working.


title: Show excerpts of posts on P2 Home page

text: I am looking to show the latest posts on my site home page, which is using P2 theme. I want them to be shown in excerpts. I have found the following code on a site, it said its in the `entry.php` file. Change,               <?php elseif ( 'post' == p2_get_the_category() ) : ?> <?php p2_title(); ?> <?php the_content( __( '(More ...)' , 'p2' ) ); ?> <?php else : ?>      to:               <?php elseif ( !is_singular() ) : ?> <?php p2_title(); ?> <?php the_excerpt(); ?> <?php else       When I looked in the `entry.php` file, I can not see this code, so I can only assume it was an outdated P2 theme. Does anyone know what code I need to change in the updated P2


title: Does wp_logout_url() destroy a session? (Logging out question)

text: I have a ridiculous issue with logging users out of my site. Basically, the client has sensitive data and when I call `wp_logout_url` I redirect to another url. That's fine, but the browser caches the page and can be seen by pressing _BACK_. Is there ANY way I can stop this happening, or is it a non-issue that cannot be solved? The site is protected by a login form on the front end, so it's not /`wp- admin`.


title: Custom Role can't trash Custom Post Type

text: I have a post type that I set up some capabilities for and I attached them to a new Role, however, the role can not trash them. I'm not sure why though. Here is the portion of my array for the capabilities.               'capabilities' => array(             'publish_posts' => 'publish_mro_project'             ,'edit_posts' => 'edit_mro_project'             ,'edit_others_posts' => 'edit_others_mro_projects'             ,'delete_posts' => 'delete_mro_projects'             ,'delete_others_posts' => 'delete_others_mro_projects'             ,'read_private_posts' => 'read_private_mro_projects'             ,'edit_post' => 'edit_mro_project'             ,'delete_post' => 'delete_mro_project'             ,'read_post' => 'read_mro_project'      As an admin, I can delete and trash the CPT, but when created the project admin and set the capabilities, they can add new ones and edit them, but the trash link does not appear. I'm not sure why this is the case. I used a user role editor plugin to assign all of the capabilities for this CPT if that makes a difference.


title: Wordpress Multisite - is it possible to put the main site in a subdirectory?

text: I am creating a site that has different language versions and the requirement from the client is that all language versions are:   1. A different site on a Multisite setup   2. They all have address like this: mysite.com/en Since the main site is in english, it's address actually has to be mysite.com/en, not just mysite.com If possible, I wouldn't want to make a redirect from the main site to just a subsite that has the address mysite.com/en, but would like to use the actual mainsite with the subdirectory address? Reasons: admin interface & database are cleaner + consistency.


title: Merge two databases: OLD SITE -> NEW SITE

text: I am working to a restyle of a website. I made DB dump from remote server and made local installation, then started to work on my local machine. While i've been working other post have been added to remote site, so database has new entry that i missed. Now i need to put online my restyled site and integrate the new entries in my DB. How can i do this? Using Export/import tool would overwrite my new DB? NOTE: The structure of new db is completely alterated from the old one: got new Post-type, categories, custom fields, ecc...


title: Thickbox not displaying just the image, instead showing full page in lightbox

text: I have implemented Thickbox into my wordpress theme. I have a regular Wordpress gallery that now has the lightbox when you click on any of the images. When clicked the lightbox shows up. However, instead of just the image showing up it populates the box with the correct image but displays it on one of my blank custom page templates. My code and screenshots are below for this but I have no clue what is causing this. How do I just get the image in the lightbox? functions.php               add_action( 'wp_enqueue_scripts', 'add_thickbox' );     add_action( 'wp_footer', 't5_thickbox_jquery' );     function t5_thickbox_jquery()     {     ?>     <script>     jQuery( 'a img.size-medium, a img.attachment-thumbnail' )         .parent()         .addClass( 'thickbox' )         .attr( 'rel', 'page' );     </script>     <?php     }      ![enter image description here](http://i.stack.imgur.com/P4wJf.jpg) ![enter image description here](http://i.stack.imgur.com/BrWYl.png)


title: Hierarchical Custom Post Types in Array

text: I have three custom `'location'` post types which make up a hierarchy of areas:               location1, location2, location3.      `location1` is the top level and then `location2` and `location3` are childeren of each other. For example, `location1` might be Buildings, `location2` `Floors`, and `location3` Rooms. `location2` and `location3` have metaboxes with fields `loc2_parent_location` and `loc3_parent_location` respectively. I'm looking to make an array which would populate from custom post types to show like: Post Type Reference:               location1 > location2 > location3      Echo as:               Building 1     Building 1 > Floor 1     Building 1 > Floor 1 > Room A     Building 1 > Floor 1 > Room B     Building 1 > Floor 2     Building 1 > Floor 3     Building 2      Here is the function I'm working on:               function location_types_query ( $query ) {     // get custom post types     $args = array( 'post_type' => 'location1' );     $args = array( 'post_type' => 'location2' );     $args = array( 'post_type' => 'location3' );          // create hierachy relationships     if ($location2) {         $parent_location = get_post_meta( $post->ID, 'loc2_parent_location', true );     } elseif ($location3) {         $parent_location = get_post_meta( $post->ID, 'loc3_parent_location', true );     } elseif ($location1) {         $parent_location = '';     }          // Run the query     $the_query = new WP_Query( $args );          // The Loop     if ( $the_query->have_posts() ) :     while ( $the_query->have_posts() ) : $the_query->the_post();       foreach ($location as $locations)              if (isset($location1)) {             echo $location1;         }              if (isset($location1 && $location2)) {             echo $location1 . '>' . $location2;          }              if (isset($location1 && $location2  && $location3)) {             echo $location1 . '>' . $location2 . '>' . $location3;          }              return array($locations);  // output array          endwhile;     endif;          // Reset Post Data     wp_reset_postdata();          }     ?>      What should I do to make this function work properly and spit out an array of the fields. / _-------------------------------------------------------_ /   /* Edit 10/23 - Additional Information   / _-------------------------------------------------------_ /   @Kaiser - Best way to break this down is as if I am making a real estate property management website. I have the post types like listed above. It's all dynamic from the options so a user could set up the system to be like above: Building 1 Building 1 > Floor 1 Building 1 > Floor 1 > Room A Where "building 1" is a post in cpt location1, "Floor 1" is a post in cpt location2 and "Room A" is a post in cpt location 3. OR it can be set up like (location1) > (location2) > (location3) // Post types Building 1 > Floor 1 > Apartment A // Posts Building 1 > Floor 1 > Apartment B Additionally, each post type has a metabox which has values for the details of the location.   For .. Location 1: - Location Plan - Person in charge Location 2: - Location Plan - Person in charge - Parent Location Location 3: - Location Plan - Person in charge - Parent Location I've already set up the entire location database for my real estate site. What I now want to do is add a maintenance form on WP's frontend in a secure member area so tenant's can submit a maintenance request. I decided to use gravity forms with a multiple select field. I need to populate an array like above to show the different locations in the different buildings, so user can select it and then populate the field like below using the post type array I created for locations:               /*-------------------------------------------------------*/     /* Location     /*-------------------------------------------------------*/     add_filter("gform_pre_render", "gform_prepopluate_populate_location");     add_filter("gform_admin_pre_render", "gform_prepopluate_populate_location");          function gform_prepopluate_populate_location($form){         $querytype = array('location1', 'location2', 'location3')         $formid = 5;         $fieldid = 7;              if($form["id"] != $formid)             return $form;              $posts = query_posts( array( 'post_type' => $querytype ) );         $items = array(); /* Add Blank */         $items[] = array("text" => "", "value" => "");              foreach($posts as $post)             $items[] = array("value" => $post->ID, "text" => $post->post_title);              foreach($form["fields"] as &$field)             if($field["id"] == $fieldid ){                             $field["choices"] = $items;             }         return $form;          }      I can then return the form results as a custom post type, say "maintenance_requests" and have the person doing the work (person responsible) view the request on their tablet and click location which pulls up the plan.


title: How do i add custom post types to this query?

text: I'm using the code below to display the latest post from a certain category but i am using Custom Post Types and I don't know how to insert the custom post type function into this code. I want to get the latest post from a certain category, from each post type. So how do i add that to the code below.               <?php     $queryObject = new  Wp_Query( 'posts_per_page=1&cat=23' );     // The Loop!     if ($queryObject->have_posts()) {     ?>          <?php     while ($queryObject->have_posts()){         $queryObject->the_post();         ?>          <a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Read %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>">                         <?php the_post_thumbnail('video-post');     ?>                                   <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                         <?php     }     ?>     <?php wp_reset_postdata();     }     ?>


title: Insert specific information to a posts of a predefined category

text:
I want to show some detail information on specific (for e.g. category=3) posts. Therefore I use the following coding:               function postinfo_head() {              global $post;         $script = <<< EOF          EOF;         echo $script;         postinfo();     }     add_action('wp_head', 'postinfo_head');          function postinfo() {         global $post;         echo '
post_name .'">Details
';         echo '
post_name .'">';         echo '
';         ... some detail fields         echo '
';         echo '
';     }      Unfortunately the output is shown somewhere else (on top-left of the site - over the header img). **How is it possible to show this coding below the header of a post?** I would reluctantly edit the template, if there is an other option of getting this to work. BR, mybecks


title: Trying to combine multiple Wordpress queries

text: I am trying to query multiple post types and meta values in Wordpress... the query is trying to fetch `event` post types with a _featured_ meta key, as well as `post` post types with the _featured image_ set. I am using the code below based on what I found on the Wordpress forums. It is essentially supposed to combine the two queries, grab the post IDs, and then prepare the post data.               <?php         $post_types = get_post_types('events','');         $featuredEvents = get_posts(array(             'post_type' => $post_types,             'post_status' => 'publish',             'showposts' => 5,             'meta_key' => '_ecmb_featured_event',             'meta_value' => 'on'         ));         $featuredNews = get_posts(array(             'post_type' => $post_types,             'post_status' => 'publish',             'showposts' => 5,             'meta_query' => array(                 array(                     'key' => '_thumbnail_id',                     'compare' => 'EXISTS'                 )             )         ));         $mergedPosts = array_merge( $featuredEvents, $featuredNews );         $postIDs = array();             foreach( $mergedPosts as $item ) {             $postIDs[] = $item->ID;         }         $uniquePosts = array_unique($postIDs);              $posts = get_posts(array(             'post__in' => $uniquePosts,             'post_type' => $post_types,             'post_status' => 'publish',         ));              foreach( $posts as $post ) :         setup_postdata($post);     ?>               <?php         $post_types = get_post_types('events','post');         $featuredEvents = get_posts(array(             'post_type' => $post_types,             'post_status' => 'publish',             'showposts' => 5,             'meta_key' => '_ecmb_featured_event',             'meta_value' => 'on'         ));         $featuredNews = get_posts(array(             'post_type' => $post_types,             'post_status' => 'publish',             'showposts' => 5,             'meta_query' => array(                 array(                     'key' => '_thumbnail_id',                     'compare' => 'EXISTS'                 )             )         ));         $mergedPosts = array_merge( $featuredEvents, $featuredNews );         $postIDs = array();             foreach( $mergedPosts as $item ) {             $postIDs[] = $item->ID;         }         $uniquePosts = array_unique($postIDs);         $posts = get_posts(array(             'post__in' => $uniquePosts,             'post_type' => $post_types,             'post_status' => 'publish',         ));         foreach( $posts as $post ) :         setup_postdata($post);     ?>          <?php if( get_post_type() == 'events' ) { ?>         this is featured event     <?php } elseif (get_post_type() == 'post') { ?>         this is a featured post     <?php } endforeach; wp_reset_query(); ?>      The problem is this returns 1) only the `post` post types, and 2) it throws the following error for each of the `post` post type: `Warning: Invalid argument supplied for foreach() in /MYDIR/wp- includes/functions.php on line 2688` Would someone be kind enough to point me in the right direction?


title: Hide or redirect the taxonomy/category/tag page

text: I created a taxonomy brand with two categories: nike and adidas. What I need is to prevent the creation of the page for each category, like `www.example.com/brand/nike/` or `www.example.com/brand/adidas/` or `www.example.com/brand`. I use this taxonomy only in admin panel and in some ajax filters. I need them only to tag the products and to use them for filter the items in the same page. I thought to redirect with permanent 301 by htaccess but I don't like this solution. Can somebody help me? Thank you


title: What do you think about custom designed plugin/theme options UIs?

text: You probably noticed the trend of making custom designed plugin/theme options UIs, especially in the commercial ones (on CodeCanyon for example - custom boxes, tabs, accordions etc). I personally believe that UI should be unified in the first place and that is really easy in WP to achieve using some core's default HTML structure + CSS classes => following the styling guide. However it is maybe sometimes not enough and that's why why there is that trend. Another reason could be "branding" or just some "coolness effect". What do you think about this? Do you prefer some custom designed UIs or the default one and why? P.S. The main reason I ask this is also because these days I started with plugin development and I trying to make this decision of which path to choose.


title: remove inline scripts from the_content() produced by plugins?

text: hey guys, any idea how I could filter all inline javascripts from the content()? thank you


title: Add "Page Revised" column to Admin

text: How would I go about adding a column to the Page Admin area that would show the last revision date of all pages? Alongside the Author and Published Date columns? I need to keep an eye on the page edits that other users do, and right now, the Page Admin area will only show the published date for a published page and the last modified date of a draft. So I need to show the revision date by any user of each published page. Possibly complicating things is I have post/page revisions disabled in wp- config.php to keep the database down to size, so an action can't hook into already existing page revision metadata. But the database contains a `post_modified_gmt` metadata column, so can that be grabbed by a direct database query? Not a good idea? And would I use this kind of action? http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column


title: Exclude category to "the_breadcrumb" functions

text: (sorry for my english) in my theme I Breadcrumbs function. I would like to exclude the categories, can you help me? here's the code:                   function the_breadcrumb() {         global $post;     if (!is_home()) {         echo ''.home.'';         if (is_category()) {             echo " / ";             echo single_cat_title();         } elseif(is_single() && !is_attachment()) {             $cat = get_the_category(); $cat = $cat[0];             echo " / ";             echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');             echo " / ";             echo the_title_shorten(45,'...');         }                elseif (is_search()) {             echo " / " . cerca;         }                elseif (is_page() && $post->post_parent) {             echo ' / post_parent).'">';             echo get_the_title($post->post_parent);             echo " / ";             echo the_title_shorten(45,'...');                }         elseif (is_page() OR is_attachment()) {             echo " / ";              echo the_title_shorten(45,'...');         }         elseif (is_author()) {             echo wp_title(' / Profilo');             echo "";         }         elseif (is_404()) {             echo " / ";              echo errore_404;         }                elseif (is_archive()) {             echo wp_title(' / ');                }             }                 }


title: Structure of custom post type / taxonomy?

text: I have three custom post types created already and their landing pages (page- events.php, etc): Events, Retreats, Coaching But for the first, I need some sort of categories which I am going to list on the landing page (page-events.php) as a menu, and inside them I would need blog posts. I have created a custom taxonomy for this Events custom post type:               register_taxonomy("event", array("event"), array("hierarchical" => true, "label" => "Event Type", "singular_label" => "Event Types ", "rewrite" => true));      The custom post type function for Events:               add_action( 'init', 'create_events' );     function create_events() {       $labels = array(         'name' => _x('Events', 'post type general name'),         'singular_name' => _x('Event', 'post type singular name'),         'add new, edit, etc, save space'           'not_found_in_trash' => __('No Events found in Trash'),         'parent_item_colon' => ''       );            $supports = array('title', 'editor', 'revisions', 'excerpt', 'thumbnail', 'page-attributes');            register_post_type( 'event',         array(           'labels' => $labels,           'public' => true,           'has_archive' => true,           'hierarchical' => true,           'query_var' => true,           'supports' => $supports         )       );     }      Haven't tried adding posts/pages, have just created them, I can add new Event and chose the Event type in a right side box though. But.. Is this the right approach? Will this work for me, is there anything else I can do better so I won't find a hard time to query for posts belonging to a specific taxonomy under this custom post type? I've never worked with custom post types and taxonomies and is a bit confusing for me, **I just want to make sure I get the right approach**. Thanks.


title: Count user posts and store the number for later use

text: I want to count author posts and store this number for later use even if some of the posts have been deleted in the meantime.               $rows = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT(ID) as count FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post_type' GROUP BY post_status", $current_user->ID ) );     $stats = array();     foreach ( $rows as $row )         $stats[ $row->post_status ] = $row->count;                  $post_count_published = isset($stats['publish']) ? $stats['publish'] : 0;      Any idea how this can be achieved?