the_post() in RSS feed

I'm got an issue here that's stumping me. I'm trying to create a custom RSS feed using `add_feed()`. The feed seems to have been created successfully, but I'm quite stuck on some bug in the feed template I'm writing. For some reason, in my code, `the_post()` seems to return nothing inside the loop. (I've verified this by using `print_r`). I just don't have access to the typical post-related information that I'd expect. Even stranger: `get_defined_vars()` outputs nothing inside the template as well. I wrote up a test script to hosted on another vhost on the same physical machine to verify that PHP is configured correctly, and it seems to be. Stranger still: despite all of the above, my `<item>`s aren't coming through blank. _Some_ of the wordpress functions seem to work - just not all of them :/ As a reference, here's the entire template file I'm working on. It's very minimal, but based off of the `wp-includes/feed-rss2.php` file: View it on pastebin. (Sorry, tried to put it here, but the formatter was getting pretty confused by it.) Any help is tremendously appreciated. I'm stumped!


Display only posts with comments

I have this code to show recent posts from one category. I need to show only the posts which have comments. How can i do that via shortcode?               /* Shortcode to output recent posts from one category */          function display_cat_recent_posts() {     $args = array(     'post_type' => 'post',     'posts_per_page'=> 5,     'cat'=> 10,     );     $cat_recent_posts = new WP_Query( $args );     if( $cat_recent_posts->have_posts() ):     $output = '
';     while ( $cat_recent_posts->have_posts() ) : $cat_recent_posts->the_post();     $output .= '
' . get_the_title() . '
';     endwhile;     $output .= '
';     endif;     return $output;     wp_reset_postdata();     }     add_shortcode( 'recent-posts', 'display_cat_recent_posts' );      Thank you...


User specific content (posts) / limiting visibility

I need some help. My wife teaches french, and I would like to set up website for her. The problem is I don't know so much about wordpress and googling did not help as well. I know how to make simple wordpress site, but how do I make something like intranet. I mean that every one of her students would have there own simple page, so she can put their homework and so on. Can someone please point me to the right direction. Some tutorials or plugins, so I could dig into it. * * * ## Update: I will try to explain more, because I think I'm doing it wrong way. So basically now, when some student logs in, he can see a new link (homework - for example), and when he clicks on it, he sees what he needs to do and read. But this info must be specific to him, cuz she teaches students individually. So I want to have one page, where loop displays posts that are intended only for logged in user. Yesterday I tried "user specific content", it works ok, but it shows headlines of all posts. Only the text is hidden. (I mean I can still see all posts, but I can just read the ones that are assigned to me). So guys, any advice? Should I sort posts with loop? (can some plug in help me, because I'm just a novice in php).


Make future posts visible to the public—not just within WP_Query

I know I can publicly show future posts in a loop using `'post_status' => 'future'` in WP_Query. But clicking on a future post's permalink will result in a 404 if you are not a logged-in user. Suppose I have a post called Apocalypse in the post_type 'event', scheduled for 12-12-2099. The permalink is _mysite.com/event/apocalypse_. Is it possible to make _mysite.com/event/apocalypse_ and other future 'event' posts visitable **now** by the public? Ideally I'd be able to restrict future post availability to the 'event' post type, but I would settle for a solution that makes all future posts available regardless of post_type.


Is there a way to integrate WordPress within an existing PHP Framework, CMS, and Navigation system?

I am the senior developer of a modular PHP Framework system which provides my customers with a Content Management System (CMS), ECommerce system, and a variety of other modules (slideshows, testimonials, forms, FAQs, etc etc) My framework handles all URLs on the site via an existing `.htaccess` file and dispatches those URLs to the appropriate module. One feature of this framework that is very important to the users is the fact that the framework handles the generation of the entire page strutter including navigation, **providing a consistent look, feel, and navigation from page to page**. It is very important that we keep this. A number of my customers have requested we add a WordPress module. Is it possible to integrate or "embed" WordPress within an existing PHP Framework and navigation template, so that the WordPress engine parses the URL and performs all approbate actions as it normally would, but outputs only the HTML content for the body of the site, allowing my framework to handle the "template" HTML? FYI, I am an expert in PHP, but have barely touched WordPress. PHP-heavy answers don't frighten me at all (and in fact would be appreciated, if applicable)


On WordPress Network(multisite), Sub Blogs in Subdirectories or Subdomains? What's better?

Can anyone explain why one is better than the other, and in what circumstances? Things I'm considering: SEO consequences (if any), scaling issues (if any) and anything else I'm not thinking about. Facebook, for example, uses subdirectories for profile pages. Tumblr uses subdomains. Are there specific reasons why? Another consideration: domain mapping. Hope the question isn't too general, but I haven't found a clear answer. Thx.


A link to a page including an anchor doesn't go to that anchor - URL gets changed

My WordPress site is set up with "Post name" permalinks. Now I created an anchor in every page at a certain place: But I find that when I try to link to that page, and its anchor, like this: http://example.com/mypost#my_anchor .. it doesn't work. The URL gets converted on the fly to: http://example.com/mypost/#my_anchor ... so the link never goes to the correct part of the page. Anyone know what I'm doing wrong - how to correct this? (Note: I did see a very similar question where someone had this a problem after they put an _extra_ slash on the end, _after_ the anchor part, but I'm _not_ doing that.) Thanks. PS It doesn't work if I use a div with an id instead of the anchor, either.


I'm trying to set-up pretty permalinks for my site. WordPress has a warning that my htaccess files is not writable. It provided some code to copy and put in the htaccess file. I'm on a Mac, my local machine running WordPress 3.1.1. I coped the code WP provided and pasted it into a new new TextEdit file that I named 1.htaccess . I put the file in the root directory Sites/mysite/. Then I tried to re-name the file and remove the "1", but my Mac gave a warning that files starting with "." are system files and wouldn't let me re-name it. How can I make an htaccess file on a Mac? Thank you. -Laxmidi


How can I redirect user after entering wrong password?

I'm using `[wp_login_form()][1]` to display login form in a jQuery dialog window. If user enters wrong password, the user is taken to the backend. I don't want that. Is there a way to notify user that he entered wrong password and still remain on the same page? Before `wp_login_form()` came I was using a plugin. I'm kind of hoping I can avoid using a plugin for this. My code:               wp_login_form(array(       'label_remember' => __( 'Remember me' ),       'label_log_in' => __( 'Login' )     ));


get_posts not working on homepage?

I have a simple custom shortcode plugin where you give it a tag and it'll display the titles of all the posts with that tag. e.g. In my post if I type "[listposts tag=oct-2011]" it will output the titles of all posts tagged as "oct-2011". This plugin has been working fine for me until the v3.2 upgrade. Now, it still works fine when the post which uses the shortcode is viewed on its own. But when that post is viewed on the homepage, the get_posts() query returns 0 results. What do I need to do to fix the plugin? Here is the relevant code:               function listposts($atts) {         $atts = shortcode_atts(             array(                 'tag' = 'jan-2011',                 'numberposts' = '-1',                 'orderby' = 'post_date',                 'order' = 'asc',                 'post_status' = 'any' ),             $atts);              $catposts = get_posts($atts);         $out = '';         foreach ($catposts as $single) {             $out .= $single->post_title;         }              return $out;     }


Default Gravatar not showing for pings

Here is my comments block:
         <?php if (have_comments()) : ?>
<?php printf(_n('1 comment', '%1$s comments', get_comments_number()), number_format_i18n( get_comments_number() ), '' ); ?>

                      <?php $comments_by_type = &separate_comments($comments); ?>                 <?php if ( !empty($comments_by_type['comment']) ) : ?>
                     <?php wp_list_comments(array('callback' => 'commentslist', 'type' => 'comment')); ?>
                 <?php endif; ?>                      <?php if ( ! empty($comments_by_type['pings']) ) : ?>
Pingbacks/Trackbacks

                 <?php wp_list_comments(array('callback' => 'commentslist', 'type' => 'pings')); ?>
                 <?php endif; ?>
         <?php endif; // end have_comments() ?>
      Here is my `wp_list_comments` callback:               function commentslist($comment, $args, $depth) {         $GLOBALS['comment'] = $comment;             require_once(ABSPATH . WPINC . '/registration.php');             if ($comment->user_id || email_exists($comment->comment_author_email)){                 //comment by registered user                 $avatar = '/images/bird_comments_big.png';                 }else{                 //comment by none registered user                 $avatar = '/images/bird_comments_pink.png';                 }             ?>
             <div id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>

                                                      <?php echo get_avatar($comment, 70, get_bloginfo('template_url').$avatar); ?>
                                 <?php printf(__('
%s says:
'), get_comment_author_link()) ?>                                 <?php printf(__('
%s
'), get_comment_date('M j, Y')) ?>                                 <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

                                 <?php if ($comment->comment_approved == '0') : ?>
<?php _e('Your comment is awaiting moderation.') ?>

                                 <?php endif; ?>                                 <?php comment_text() ?>

     <?php     }      It seems to that wp_gravatar should call up the non-registered user image due to a lack of an e-mail address for pings, but instead its returning nothing.


WordPress keep redirecting me to random URLs

When I go to my homepage, http://example.com, I _sometimes_ get redirected to http://example.com/SXKSLW/ or some other random URL along that pattern that yields 404 page. I do not remember doing anything special. Tried to disable most of the plugins (except the ones that are installed after the issue has been noticed) with no avails. This issue also observed when I am at wp-admin, rendering the url to example [.] com/SJDKEW/wp-admin/... ---> obviously to another 404. Any inputs are welcomed. Thank you


Custom Taxonomy term archive template

Is it possible to have separate archive templates for custom taxonomies? Like this: Tax(categories) -Players(category) -Managers(category)


how to test for attached image

I am trying to find out whether or not a post has images. If it does, I then want to know if a featured image was specified for the thumbnail - if not, the get_thumb() function will assign an image from the gallery of that post. However, if a post doesn't have images, I want to use a span class to occupy the thumbnail space. Here's the statement I wrote:               if(has_post_thumbnail()){         the_post_thumbnail();     }     elseif(is_attachment()) {         echo get_thumb($post->ID);      }     else {              }       It adds a 150x150 span to all posts without featured images. However, where images from get_thumb() should be, the span shows up instead. Essentially, it's either the span or the featured image and the $get_thumb never appears. For reference, here's the get_thumb() function:               function get_thumb ($post_ID){         $thumbargs = array(         'post_type' => 'attachment',         'numberposts' => 1,         'post_status' => null,         'post_parent' => $post_ID         );         $thumb = get_posts($thumbargs);         if ($thumb) {             return wp_get_attachment_image($thumb[0]->ID);         }     }


Add Word Limit to Posts

Is there a way to limit the number of words per post through the the_content() function or something similar?


How to put page numbers with the next/previous on a post/category list?

Is there a way to add numbering to the latest posts/category listing pages? By default you can put older/newer, but is there a way to add numbering like page 1,2,3,4 of the list so people can skip ahead?


Multiple single templates?

Lets say i have a custom post type called 'event' that has several custom meta boxes for images, docs, etc.. Would it be possible to have two different single templates? For example: i have a page that lists all events and if i click on an event, the single view shows me all the meta-info i put in event-single.php template. now i want to have a different page that again lists all events, but if i click to view the single event, a different template is used, so i can show other meta-data connected with the event. Or better:               page-events.php lists all events -> click on event -> shows single-event.php          page-media.php lists all events -> click on event -> shows single-event-whatever.php      Is this possible with WordPress?


How can I change the prev / next buttons text to Dutch?

If you look to this page everything is alright except the previous and next buttons text are in English. Does anyone know how I can make them display in Dutch? I already tried to change them but no luck. **NB:** I'm using Contango theme. The function looks like this :               /** Contango Link Pages */     function contango_link_pages() {          $contango_options = contango_get_settings();         if( $contango_options['contango_post_style'] != 'excerpt' ) {                  return wp_link_pages( array(                       'before' => '
'. __( 'Pages:', 'contango' ) .'',                 'after' => '
',                 'link_before' => '',                 'link_after' => '',                             'echo' => 0                      )             );              }     }


How to call a FB function from an admin bar action?

I am using FaceBook's SDK inside of my wordpress application. I need to set up the application so when a user clicks log-out on the admin bar, it will fire facebook's log-out function. in order to use FB's log-out you need to initialize the SDK, then simply call it.               //initialize java script sdk     <script>         //sdk code     </script>          //call log-out function     FB.Logout();      the admin bar is dynamically loaded so it's a bit confusing to me where I should be putting my code. I've looked into 'admin-bar.php' but i cannot figure out where to put the code. How do I call a FB function from the admin bar action "log-out"? Anyone able to shed some light on this situation?


How to set file type in wp_handle_upload?

I'm using `wp_handle_upload` to allow users upload `.csv` files in the front end and it's working fine. I was wondering how can I limit this to only allow `.csv` files though since currently it accepts a wide variety of file types. According to the doc this should be possible by overriding the `$overrides` param but I'm not sure what should I pass it to do so. Thanks in advance!


How to make a second query offset -2 from current post

I would like a second `WP_Query` on a custom post type's single page to return 5 posts, starting with two before the current post, so that I get this:   1. The-one-before-the-previous post   2. Previous post   3. Current post   4. Next post   5. The-one-after-the-next post How can I do this? `offset` is only good if I know the number of the current post. In pseudo-code it's easy:               $gallery = new WP_Query(array(         'post_type' => 'artwork',         'posts_per_page' => 5,         'fake-offset' => $current->ID-2 //This is imaginary     ));      Thanks in advance!


Paging on a future post loop?

I am trying to get paging to work on my future post loop, but to no avail. I am getting no links, when I expect them at the bottom, for pagination despite there being several valid posts in the database.               <?php     $args = array(          'post_type' => 'program',         'paged' => get_query_var('paged') ? get_query_var('paged') : 1,         'posts_per_page' => 1,         'post_status' => "future",         'order_by' => 'date',         'order' => 'ASC'     );     $program = new WP_Query;     $program->query( $args );                    if($program->have_posts()): while($program->have_posts()): $program->the_post(); ?>          //The content loop     <?php endwhile; ?>
<?php previous_posts_link('« Previous'); ?>

<?php next_posts_link('More »'); ?>
     <?php endif; ?>      <?php wp_reset_query(); ?>      * * * **Update** _Further Info_ I have established that $program->max_num_pages always displays the correct number of pages, so using the `offset` argument for `WP_Query`, I have been able to roll my own paging. But this seems like it's asking for trouble!! * * * **Update** _Further Info_ I have taken the rather drastic step of extending the WP_Query object. This is really over the top, but I have to make this work:               class MF_Query extends WP_Query{         function __construct(array $args){             if(!array_key_exists('posts_per_page',$args)) $args['posts_per_page'] = 10;                  $args['offset'] = (isset($_GET['page'])?($_GET['page']-1)*$args['posts_per_page']:0);             parent::query($args);         }              function mf_next_page($link_text = "Next"){                      $curPage = intval((isset($_GET['page'])?$_GET['page']:1));//Use 1 if $_GET['page'] not set                      $link = "<a href='".remove_post_vars(curPageURL());                      if($curPage<$this->max_num_pages){                     return $link.constructQuery($this->merge(array("page"=>$curPage+1),$_GET))."'>".$link_text."";                 } else {                     return false;                 }                   }         function mf_prev_page($link_text = "Prev"){                      $curPage = (isset($_GET['page'])?$_GET['page']:1);//Use 1 if $_GET['page'] not set                 $link = "1){                     return $link.$this->constructQuery($this->merge(array("page"=>$curPage-1),$_GET))."'>$link_text";                 } else {                     return false;                 }                   }         private function constructQuery(array $query){                       $url_ext = "?";             foreach($query as $k => $v){                 $url_ext .=$k."=".$v."&";             }             $url_ext = substr($url_ext, 0, -5);//chop last ampersand off                       return $url_ext;              }         private function merge($get, $put){             //Get values from one array, and put them in another (overriding existing values if appropriate)             foreach ($get as $k => $v){                     $put[$k]=$v;             }              return $put;              }               }


Is this the correct way to add post-slug input field?

I added slug input field in my custom post type and allow users to edit it at front end. Then, when insert post, I use this:               $wp_insert_post_args = array(                 'post_status'   => 'publish',                 'post_type' => MY_POST_TYPE,                 'post_author'   => $this->creator_id,                 'post_title'    => $this->name                 'post_name'     => sanitize_title( $this->slug )                  );      My custom post type already suports 'title', so, it suppose to auto generate post_name. Now I add $slug as 'post_name' as described above, **will woredpress use 'title' to generate 'post_name', or use my 'slug'?** will wordpress perform slug exist checking as it does on normal posts, or should I take care of the checking myself?


Duplicate and change a Theme Widget

Is there a way (a common one) to duplicate and change a theme widget ? I'm asking this because, I have this widget that displays the recent news and if we click, it will display ALL news, but I wish to create a new widget that lists the latest articles (posts with a category "articles"), and if we click, that lists ALL articles. Is there any widget like this that someone knows about ? If not, where should I look at in order to duplicate and change a theme widget ? Thanks a lot


img width and height attributes being set by get_the_post_thumbnail

I'm working on a custom theme that I've inherited to maintain. At the top of the homepage there is a header area with some images generated by `get_the_post_thumbnail`. The call to `get_the_post_thumbnail` outputs img objects that are set to a specific width/height by their html attributes. Here's the code and output: **Inside a loop**               <?php echo get_the_post_thumbnail( $id, array( 300, 300 ) ); ?>      **Html output**               <img width="215" height="93" src="[img filepath]" class="attachment-300x300 wp-post-image" alt="[img name]" title="[img name]">      I need to reset the attribute height and width dimensions to something other than _215 x 93_. I can't find anywhere this is being set (checked in **wp- admin** as well as **functions.php** as well as anywhere else where I thought it might be). I am also not finding any places where `set_post_thumbnail_size` is being called with these values. Can anyone tell me where to reset these values? Thanks.


How do I set the link in the Custom Post Type admin menu?

I'm trying to create a custom button and link it to a file within the plugin. **How do I get this link pointing to the path of my choice?** ![Download Donors should point to the link I choose](http://i.stack.imgur.com/McxyC.png) I've tried the following but it does now work.               function _pfund_register_types() {         $pfund_options = get_option( 'pfund_options' );         $template_def = array(             'public' => true,             'query_var' => 'pfund_cause',             'rewrite' => array(                 'slug' => $pfund_options['cause_slug'],                 'with_front' => false,             ),             'hierarchical' => true,             'label' => __( 'Causes', 'pfund' ),             'labels' => array(                 'name' => __( 'Causes', 'pfund' ),                 'singular_name' => __( 'Cause', 'pfund' ),                 'add_new' => __( 'Add New Cause', 'pfund' ),                 'add_new_item' => __( 'Add New Cause', 'pfund' ),                 'edit_item' => __( 'Edit Cause', 'pfund' ),                 'view_item' => __( 'View Cause', 'pfund' ),                 'search_items' => __( 'Search Causes', 'pfund' ),                 'not_found' => __( 'No Causes Found', 'pfund' ),                 'not_found_in_trash' => __( 'No Causes Found In Trash', 'pfund' ),             )         );         register_post_type( 'pfund_cause', $template_def );         register_post_type( 'pfund_cause_list' );              $campaign_def = array(             'public' => true,             'query_var' => 'pfund_campaign',             'rewrite' => array(                 'slug' => $pfund_options['campaign_slug'],                 'with_front' => false             ),             'hierarchical' => true,             'label' => __( 'Campaigns', 'pfund' ),             'labels' => array(                 'name' => __( 'Campaigns', 'pfund' ),                 'singular_name' => __( 'Campaign', 'pfund' ),                 'add_new' => __( 'Add New Campaign', 'pfund' ),                 'add_new_item' => __( 'Add New Campaign', 'pfund' ),                 'download_donors' => __( 'Download Donors', 'pfund' ),                 'all_items' => __( 'Download Donors', 'pfund' ),                 'edit_item' => __( 'Edit Campaign', 'pfund' ),                 'view_item' => __( 'View Campaign', 'pfund' ),                 'search_items' => __( 'Search Campaigns', 'pfund' ),                 'not_found' => __( 'No Campaigns Found', 'pfund' ),                 'not_found_in_trash' => __( 'No Campaigns Found In Trash', 'pfund' ),             ),             'supports' => array(                 'title'             ),             'capabilities' => array(                 'edit_post' => 'edit_campaign'             ),             'map_meta_cap' => true         );         register_post_type( 'pfund_campaign', $campaign_def );         register_post_type( 'pfund_campaign_list' );     }      Notice the lines               'download_donors' => __( 'Download Donors', 'pfund' ),             'all_items' => __( 'Download Donors', 'pfund' ),      The 'download_donors' label doesn't work. I have to use the 'all_items'. Not sure why this is but when I try to add the filter it doesn't get overwritten. Instead the link points to _`wp-admin/edit.php?post_type=pfund_campaign`_               add_filter('post_row_actions','all_items', 10, 2);          function download_donors($actions, $post){         //check for your post type         if ($post->post_type =="pfund_campaign"){             //remove the default edit             unset($actions['edit']);             //set new action             $actions['download_donors'] = 'Download Donors';         }         return $actions;     }


How do I create a page that displays the homepage?

sorry for the somewhat odd question. I need to create a wordpress page that basically just displays the / page. How would i go about doing such a thing? The homepage itself isn't either a post or a page. I need it to be a page to run a script on it (can't be done through the editor either) This is a tad hard to explain.... any help would be appreciated...


Include content from one page to another

I'd like to include content from one Page (named "contact_text") to another Page in a specific spot (both of these are WordPress admin pages). I've followed this Stack Overflow thread. However I don't believe I can call a PHP function inside a WP Page, much less at the spot I'd like it to appear. Do I need to set up a shortcode for that function in order to use it?


Custom post type draft use wrong template

I have a custom post type called `agenda` with a custom post template called `single-agenda.php`. When I have a draft of an `agenda` post, this uses the content in the template `single.php`. When I publish it's ok, it uses the content in `single- agenda.php`. I would like to see my draft content in `single-agenda.php`, how can I do that?


WordPress Theme Preview Image

I'm developing a custom WordPress theme. When I go to select themes in the Appearance menu, my theme does not have a preview image. Is there something I need to do to get a preview image to show up? I can't find any resources on the web that talk about this. Maybe I'm just searching the wrong thing though...?


How to set default values for edit_post_link() in my theme?

How do I set default values for the `edit_post_link` function in my theme? I'd like to change the 'Edit This' string to a custom value, but specify this only once, so I can use instead of everywhere. Is this even possible?


Installing plugins on installation/activation

Is it possible to install extra plugins on certain plugin installation/activation? I tried to install them using:               $upgrader = new Plugin_Upgrader();      $upgrader->install(...)      But it's not working. Any suggestions? Thanks in advance!


Two Custom Post Types, Share Two Taxonomies

I have two custom post types   * Hotels    * Things to do And I have two taxonomies   * Activities    * Regions So when a user sees a **Hotel** (custom post): the user can then see   * the region it's in    * what activities they can do.  _And viceversa as well_ When the user sees **Things To Do** , he can see in which **Region** it is and what **Hotels** have the same type of **Activity** nearby. The problem if I use two custom post type and create a taxonomy for it, I have no way of discerning each taxonomy related to a custom post: > Example: **Hotels** in X **Region** I would get both the **Hotels** and **Things to do** custom post, within that taxonomy. * * * It's basically the same issue as this question (which doesn't have any great answer).


RSS dashboard widget not showing visuals

I am using a RSS feeds widget on my dashboard as shown in this Q&A. Problem is feeds doesn't show up any visual like images or videos. I verified this by looking raw feeds which I used. Here is a snapshot of my feed dashboard widget:   ![image](http://i.stack.imgur.com/kFsTQ.jpg). How can I get visuals or is this the way WordPress shows data?


Top toolbar is not showing in wordpress admin panel

Today I came over a very interesting and confusing problem. I developed a wordpress website in my localhost and it run perfectly. But when I moved that site in my server I saw a strange thing. When I logged in my admin panel (..wp-admin/index.php) my toolbar isn't showing up and any widgets that were showing fine in the dashboard in my localhost are gone! And also the screen option and help buttons aren't working. And when I hover over my menu items in the admin menu section sub menus were shown in my localhost, but here nothing. but everything works fine when i'm not in the index.php page. any idea from the experts?


How to display images that was uploaded in the media gallery and not by the current post?

I have uploaded images before in my other posts and now I want to display it in my Photo Gallery. I'm using an isotope layout so I'm not using the native gallery of WordPress. It's working just fine however I can't display the images that is not uploaded directly to that post. For example the images that I've uploaded before. If I upload a new one to this current post, then that will display. Here's my code:                       // DISPLAY ALL IMAGES FROM A PARENT GALLERY             $attachments = get_children(array('post_parent' => $post->ID,               'post_status' => 'inherit',               'post_type' => 'attachment',               'post_mime_type' => 'image',               'order' => 'ASC',               'orderby' => 'menu_order ID'));             foreach($attachments as $att_id => $attachment) {      So how can I display those past images in my gallery?


Using Conditional Statement in functions.php

I've got this code below in my `functions.php` and I'd like to add two filters with conditional statement not to effect every query_posts. Something like this               if(!is_admin() && is_page('Home')){ //two filters }      However, I don't know PHP well enough to know where to put it or how to use the `<?php>` tags. Can anyone advise? It is from this thread that was closed in WP Forums.               add_filter('posts_orderby', 'edit_posts_orderby');     add_filter('posts_join_paged','edit_posts_join_paged');          function edit_posts_join_paged($join_paged_statement) {         global $wpdb;         $join_paged_statement = "LEFT JOIN ".$wpdb->prefix."wpv_voting ON ".$wpdb->prefix."wpv_voting.post_id = $wpdb->posts.ID";         return $join_paged_statement;     }          function edit_posts_orderby($orderby_statement) {         global $wpdb;         $orderby_statement = "(".$wpdb->prefix."wpv_voting.vote_count) DESC";         return $orderby_statement;     }


Listing custom post types on archive page with array

I'm just starting to wrap my head around custom post types and for some reason can't get any of the custom post types to display in the loop. I've found some queries online but none of them are in closed php statements and I'm not sure how to integrate them. Here's what I have:               // add custom post type     add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'band_artists',             array(                 'labels' => array(                     'name' => __( 'Artists' ),                     'singular_name' => __( 'Artist' )                 ),             'public' => true,             'has_archive' => true,             'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),             'rewrite' => array('slug' => 'artists'),             'taxonomies' => array('category', 'post_tag')             )         );     }      and query with a randomizer... This was working when these were just plain ol' posts (minus the `'post_type'` obviously).               <?php query_posts(array(         'post_type' => 'band_artists',         'showposts' => 1,         'orderby' => 'rand',         'category' => '5'         ));         if ( have_posts() ) : while ( have_posts() ) : the_post();      ?>          <div id="post-<?php the_ID(); ?>" class="artistSingle">              <?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php the_post_thumbnail('medium'); ?>
         <?php endif; ?>
<?php the_title(); ?>

             <?php if(get_post_meta($post->ID, 'band', true)): ?>                 Band: <?php echo get_post_meta($post->ID, 'band', true); ?>
               <?php endif; ?>             <?php if(get_post_meta($post->ID, 'gear', true)): ?>                 Gear: <?php echo get_post_meta($post->ID, 'gear', true); ?>
             <?php endif; ?>              <?php if(get_post_meta($post->ID, 'website', true)): ?>                 Website: <a href="http://<?php echo get_post_meta($post->ID, 'website', true); ?>" target="_blank"><?php echo get_post_meta($post->ID, 'website', true); ?>             <?php endif; ?>
         <?php the_content(); ?>
             <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', '2012' ) . '', 'after' => '
' ) ); ?>

          <?php endwhile; // end of featured large loop ?>     <?php else : ?>     <?php endif; ?>


Publish page by invoking submit via jQuery

I'm looking for a solution to a bug that occured in an answer to an earlier question. The general idea is that I want to invoke submit on the post form and have the page published. What happens now is that the page reloads and the message "Page updated" appears, however the page is not published and not even drafted.      I've created a small demo to drop into your `functions.php` to test it out. In the demo I've created a secondary publish button that you can use to experience the problem, this is merely for illustration purposes, in the real case submit is invoked via ajax.                    add_action('add_meta_boxes', 'add_metaboxes_pages', 10, 2);     function add_metaboxes_pages($post_type, $post)     {         add_meta_box('pagesubmitdiv', 'WPSE_DEMO_META_BOX', 'page_submit_meta_box', 'page', 'advanced', 'low');     }          function page_submit_meta_box($post)      {?>         Secondary Publish<?php     }          add_action( 'admin_head-post.php', 'wpse_publish_admin_hook' );     add_action( 'admin_head-post-new.php', 'wpse_publish_admin_hook' );     function wpse_publish_admin_hook()     {         global $current_screen;         if( 'page' != $current_screen->post_type )             return;              ?>                  <?php     }


I have a problem with my WordPress DB after I tried to install multi-site

I tried to install WordPress Multi-Site. But I ran into some problems with the DB.               wp_1_posts: Table 'studioc_editionspanda.wp_1_posts' doesn't exist     wp_1_comments: Table 'studioc_editionspanda.wp_1_comments' doesn't exist     wp_1_links: Table 'studioc_editionspanda.wp_1_links' doesn't exist     wp_1_options: Table 'studioc_editionspanda.wp_1_options' doesn't exist     wp_1_postmeta: Table 'studioc_editionspanda.wp_1_postmeta' doesn't exist     wp_1_terms: Table 'studioc_editionspanda.wp_1_terms' doesn't exist     wp_1_term_taxonomy: Table 'studioc_editionspanda.wp_1_term_taxonomy' doesn't exist     wp_1_term_relationships: Table 'studioc_editionspanda.wp_1_term_relationships' doesn't exist     wp_1_commentmeta: Table 'studioc_editionspanda.wp_1_commentmeta' doesn't exist      What do I do?


Wordpress admin toolbar not loading styles after migration

I am really stumped by this one, have looked at various solutions online but nothing seems to work and I have the feeling I am missing something very basic. Essentially, I used manageWP to clone my site to a new server, everything works great except the frontend admin bar/toolbar does not load any css styles (shows up as a simple list at the bottom fo the page). The ID #wpadminbar does not appear link to the relevant css file. Again, this is the only such issue and it is not related to plugins and themes as the problem persists even when changing themes or deactivating all plugins. The only thing I can think of is that since the source wordpress installation was setup as subfolder (like so http://mymaindomain.com/newsite) and the new one is on the domain root (like so http://newsite.com) that there is some relative path somewhere that isn't working properly, but I have no idea where to even look or how to fix it. Any help would be greatly appreciated.


Problems with a custom meta_box

I got some information on here which I am using for an Events site I am developing. How to add option box in "Edit Post" plugin API? However, I have changed the checkboxes for text inputs and when saving the post the values disappear. Question 1: How can I get the values to save for each post? Question 2: How do I pass this data to the post page? Here is the function I am using, and here is an image of the problem. http://i.stack.imgur.com/Epg90.png               // POST PAGE EVENTS BOX          // register the meta box     add_action( 'add_meta_boxes', 'event_details' );     function event_details() {         add_meta_box(             'event_details',             'Event Details',             'event_details_content',             'post',             'normal',             'high'         );     }          // display the metabox     function event_details_content( $post_id ) {         // nonce field for security check, you can have the same         // nonce field for all your meta boxes of same plugin         wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_nonce' );              echo '
Fill in the following details for the event listings page.
';              echo '
<input type="text" style="padding:10px;" name="event-date" value="';         echo date('d-m-y');         echo '" /> Date - What date does the event start? Please type in dd-mm-yy format with dashes included
';         echo '
<input type="text" style="padding:10px;" name="event-time" value="';         echo date('H:i');         echo '"/> Time - What time is the event starting? Please type in 24 hour format with separator colon included
';         echo '
<input type="text" style="padding:10px;" name="event-subtitle"/> Subtitle - Is there an additional subtitle for the event?
' ;         echo '
<input type="text" style="padding:10px;" name="event-guests"/> Special Guests - Is there any additional guests at the event?
' ;         echo '
<input type="text" style="padding:10px;" name="event-venue"/> Venue - What venue is the event at?
';             echo '
<input type="text" style="padding:10px;" name="event-city"/> City - What city or town is the event in?
';         echo '
<input type="text" style="padding:10px;" name="event-link"/> Purchase Link - Type the URL link for TicketABC
';     }          // save data from checkboxes     add_action( 'save_post', 'event_details_data' );     function event_details_data() {              // check if this isn't an auto save         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )             return;              // security check         if ( !wp_verify_nonce( $_POST['mypluing_nonce'], plugin_basename( __FILE__ ) ) )             return;              // further checks if you like,          // for example particular user, role or maybe post type in case of custom post types              // now store data in custom fields based on checkboxes selected         if ( isset( $_POST['event-date'] ) )             update_post_meta( $post_id, 'event-date', 1 );         else             update_post_meta( $post_id, 'event-date', 0 );              if ( isset( $_POST['event-time'] ) )             update_post_meta( $post_id, 'event-time', 1 );         else             update_post_meta( $post_id, 'event-time', 0 );              if ( isset( $_POST['event-subtitle'] ) )             update_post_meta( $post_id, 'event-subtitle', 1 );         else             update_post_meta( $post_id, 'event-subtitle', 0 );              if ( isset( $_POST['event-guests'] ) )             update_post_meta( $post_id, 'event-guests', 1 );         else             update_post_meta( $post_id, 'event-guests', 0 );              if ( isset( $_POST['event-venue'] ) )             update_post_meta( $post_id, 'event-venue', 1 );         else             update_post_meta( $post_id, 'event-venue', 0 );              if ( isset( $_POST['event-city'] ) )             update_post_meta( $post_id, 'event-city', 1 );         else             update_post_meta( $post_id, 'event-city', 0 );              if ( isset( $_POST['event-link'] ) )             update_post_meta( $post_id, 'event-link', 1 );         else             update_post_meta( $post_id, 'event-link', 0 );     }               ;?>


How to change post template

I have a post featuring a product that I've created using advanced custom fields. I would like to have a link on the post that opens in a new window and displays the same product, just with a different look and info. (Note: I'm specifically looking to use a second template and not a different CSS because different info will be displayed on each template.) I've tried using the code below, but my custom template just returns a blank page. Can anyone suggest a fix? Here's the link I'm using on the original template.               <a href="<?php the_permalink(); ?>?custom-template=1">Link      Here's the code that I'm putting at the top of the custom template.               if ($_GET['custom-template'] == 1) { include custom-template.php; return; }      Thanks, John


Advanced Custom Fields - category image

I'm trying to get an image for I previously assigned to a category using ACF. here's what I'm doing:               $category_image = the_field('cat_small', $linkedcat);      where $linkedcat is something like category_280 When I echo $category_image, i see an array, like so:               261, , catsmall, , , http://localhost/current/dpf/wp-content/uploads/2012/12/catsmall.jpg, Array      Any idea what I'm doing wrong? Many thx! Alex


Detect error 404 page to find out the issue

I have a wordpress website, which when I visit > www.mywordpress.com/test/setup it throws an error 404 page. Which class in wordpress handles the request dispatching?


Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?

I have this code to display 4 posts of type "testimonial" on the Home page:               <?php                 $custom_posts = get_posts([                     'numberposts' => 4,                     'post_type' => 'testimonial'                 ]);                 ?>                      <?php foreach ($custom_posts as $post) : setup_postdata($post); ?>
                         <?php the_excerpt(); ?>                              <a href="<?php the_permalink(); ?>">Continue reading
<?php echo get_post_meta($post->ID, 'pacient', TRUE); ?>

                      <?php endforeach; ?>      This works as expected. Excerpts are shown. Sunshine rainbows. Unfortunately if I move exactly the same code to the sidebar on other side no excerpts are shown. There is content trimmed down for each post instead. In other words: This exact same code (copy/pasted) on home page produces excerpts. In the sidebar on other page it produces trimmed content with "[...]" at the end. I have no clue why. Can the problem be related to where the get_post function is called (after Query or something). Why this function behaves differently in both cases? How do I force it to show excerpt only and not the post content. Am I missing something?


How can I only show one responsive menu on mobile devices?

Here's my site: http://dev.shoeporn.com/ I'm running WP 3.5 and using this plugin: http://wordpress.org/support/plugin/responsive-select-menu It is supposed to allow you to select which menus you want to be responsive, but it doesn't seem to work. I only want the `<div id="header-bar">` menu to be displayed to mobile devices, but currently `<div id="header-nav">` is also shown. I tried messing around with CSS but I think the "Responsive Select Menu" plugin javascript is overriding it when the page loads. Any ideas?


How to redirect WP post with a specific word in the URL

I've changed the URL structure of my WordPress post (not page) from:               example.com/archive/post-id      to:               example.com/post-name      I'd like to redirect the old structure `/post/` to the new one via `.htaccess`, or plugin.


Navigate with one button through a responsive wordpress page

You can take a look at Tessellate a HTML5 responsive template to see what I'm trying to accomplish. I love this theme and I'm especcialy interested in the way you can navigate with one button to different parts of the page and I would like to do this with a wordpress website. Does anyone know how I can integrate this effect in an existing theme or do you know a theme with this kind of navigation? Thanks in advance


Global localized sort order

WP tables were created on import from another server, and most columns got the utf8_general_ci collation. The problem I'm having is that menus are sorted in the wrong order for the language of the multisite site (Swedish). Existing and new posts should be sorted according a site's language. I've tried changing the collation for the table, database, and connection to utf8_swedish_ci in phpMyAdmin, and also to set DB_COLLATE in wp-config.php to the same value. No change in menus or in wp-admin post listings. What are the steps required?


Nonce best practices: hidden input vs. wp_localize_script?

I noticed while looking at the HTML of an edit page that WordPress uses a lot of hidden input elements for storing nonces. Is there a significant advantage to using either this style of storing nonces for AJAX use or using those stored via the `wp_localize_script` style?


Problem Display Custom Post On Page

i am new in wordpress and first time i make plugin with help of tutorial i make custom post i need when i add data in custom post display on page but i still didn't find the mistake please suggest, i mention my two files code below for reference. [File 1]:   [File 2]:


Populate Array with values from another arrray

I have retrieved WP_Post object and i stored it in a variable.               Array     (     [0] => WP_Post Object         (             [ID] => 45             [post_author] => 1             [post_date] => 2014-03-10 14:22:01             [post_date_gmt] => 2014-03-10 14:22:01             [post_content] =>              [post_title] => sddddddddddd             [post_excerpt] =>              [post_status] => publish             [comment_status] => closed             [ping_status] => closed             [post_password] =>              [post_name] => sddddddddddd             [to_ping] =>              [pinged] =>              [post_modified] => 2014-03-10 14:23:57             [post_modified_gmt] => 2014-03-10 14:23:57             [post_content_filtered] =>              [post_parent] => 0             [guid] => http://localhost/bitbucket/?post_type=advertisement&p=45             [menu_order] => 0             [post_type] => advertisement             [post_mime_type] =>              [comment_count] => 0             [filter] => raw         )          [1] => WP_Post Object         (             [ID] => 40             [post_author] => 1             [post_date] => 2014-03-10 11:00:28             [post_date_gmt] => 2014-03-10 11:00:28             [post_content] =>              [post_title] => 123             [post_excerpt] =>              [post_status] => publish             [comment_status] => closed             [ping_status] => closed             [post_password] =>              [post_name] => 123             [to_ping] =>              [pinged] =>              [post_modified] => 2014-03-10 12:49:24             [post_modified_gmt] => 2014-03-10 12:49:24             [post_content_filtered] =>              [post_parent] => 0             [guid] => http://localhost/bitbucket/?post_type=advertisement&p=40             [menu_order] => 0             [post_type] => advertisement             [post_mime_type] =>              [comment_count] => 0             [filter] => raw         )          [2] => WP_Post Object         (             [ID] => 37             [post_author] => 1             [post_date] => 2014-03-05 13:56:15             [post_date_gmt] => 2014-03-05 13:56:15             [post_content] =>              [post_title] => asd             [post_excerpt] =>              [post_status] => publish             [comment_status] => closed             [ping_status] => closed             [post_password] =>              [post_name] => asd             [to_ping] =>              [pinged] =>              [post_modified] => 2014-03-10 14:26:23             [post_modified_gmt] => 2014-03-10 14:26:23             [post_content_filtered] =>              [post_parent] => 0             [guid] => http://bitbucket/?post_type=advertisement&p=37             [menu_order] => 0             [post_type] => advertisement             [post_mime_type] =>              [comment_count] => 0             [filter] => raw         )      ) Well the above is my object. Now i need to store some values from it in a custom array which would look like:               $my_array = array (                    ID => post_title                 );      and ID and post_title should be from the object above. How can i accomplish this?


Subdomain is not working

I just finished setting up my multisite. However the subdomain is not working. I believe I followed every step necessary to create a subdomain network for wordpress multiste. I also have created a wildcard subdomain               *.yofnel.com      That points to /public_html I dont know what to do now. Please help.


How do I add a favicon that only shows during viewing of my plugin's admin panel? I mean, what event do I intercept?


add_feed and flush_rewrite_rules

There seems to be quite a controversial opinion on the WordPress `flush_rewrite_rules()` function. According to the Codex, it is highly discouraged to use this function on the `init` action hook. **However:** In a plugin I am working on, I am using `add_feed()` to, well, add a feed. The Codex says that this should be run on `init` and requires a one-time use of `flush_rewrite_rules()`. See my dilemma ? I need `add_feed()` on `init`, which requires `flush_rewrite_rules()`. Hence, `flush_rewrite_rules()` on `init`, which is breaking all custom post type rewrite rules and permalinks, resulting in 404 pages. **So my question is:** how should this be done ? This is what I currently have on `init`, that is related to the issue:               add_action( 'init', 'my_foobar' );     function my_foobar() {         // getting some settings         add_feed( $url, $callback );         flush_rewrite_rules();     }      Any help would be greatly appreciated. thanks :)


How to add ASCII symbol after each recent post

How do I add an ASCII code after each recent post list item?               <?php         $args = array( 'numberposts' => '2' );         $recent_posts = wp_get_recent_posts( $args );         foreach( $recent_posts as $recent ){             echo '
' .   $recent["post_title"].'
 ';}         ?>      So that the output would be Recent post 1 >   Recent post 2 > EDIT1: If i just put &agt; after `</a>`, the symbol it wil be part of the hyperlink. I just want it to be apart from the link.
     <?php         $args = array( 'numberposts' => '2' );         $recent_posts = wp_get_recent_posts( $args );         foreach( $recent_posts as $recent ){             echo '
' .   $recent["post_title"].'>
 ';}         ?>


Compare string with post id in wpdb and do stuff when match is found

I'm looking for some help tying in with the wpdb to compare and change certain values. I'm very novice with mysql handling so I really appreciate any help on this matter! What I want to do is to go through the wp db looking for a post same id as `$page_id`. When the post is found it should check the `menu_order` value and compare it to `$page_order`. If they're the same, then do nothing, but if they don't match it should set `menu_order` to the value of `$page_order`. Here's some pseudo code:               $page_id = 45;     $page_order = 1;          if(post_id == $page_id) {         if(menu_order != $page_order) {             set menu_order to $page_order                  switch($page_order) {             case "1":                 set post meta "color_dropdown" as "pink"                     if have child pages set post meta "color_dropdown" as "pink" to them aswell                 break;             }         }     }      All help appreciated! Thanks


Attaching multiple custom taxonomies to one CPT?

So I've been developing a complex CPT lately and something came up that made me realize I need a second custom Taxonomy on the CPT. Is this impossible? Also I'm currently using tags as well, so the second taxonomy can't be subbed out for tags. Any advice is greatly appreciated.


Remove a menu item in menu

I know this has been asked many times. But from what i got after searching, i could not understand much. I have used `wp_update_nav_menu_item` to add menu items programatically. But i don't know how to remove a specific menu item. In one of the forums, it has been told to unset the array element (forum). But i did not understand it. Can anybody explain how to do it?


In my plugin when i call select page is blank

i have problem: In my plugin directory I have two files:   * `gen.php`   * `open.php` When I redirect from `gen.php` to `open.php` and I use select in `open.php`               $myrows = $wpdb->get_results("SELECT * FROM wp_ogloszenia_kupione");      My file won't open I use:               $fp = fopen(trim(trim($id)),"wb");          fwrite($fp,$content);     fwrite($fp, pack("CCC",0xef,0xbb,0xbf));     fopen(trim(trim($id)),"r");     fclose($fp);     //End 4     //5 - Otwarcie pliku                    if (file_exists(trim($id))) {         header('Content-Description: File Transfer');         header('Content-Type: application/octet-stream');         header('Content-Disposition: attachment; filename='.basename(trim($id)));         header('Content-Transfer-Encoding: binary');         header('Expires: 0');         header('Cache-Control: must-revalidate');         header('Pragma: public');         header('Content-Length: ' . filesize(trim($id)));         ob_clean();         flush();         readfile(trim($id));         exit;     }       But when I delete select everything work Good. So why does select cause this mess?


solution to prevent specific admins from altering site contents

I wonder if there is a solution already present that will restrict even the top level admins that I select from doing things such as installing plugins, disabling plugins, etc. that an admin normally has access to. I want to ensure that my team doesn't ever try to do anything on our testing or production environments that they should only be doing on a dev environment. Is there anything like this?


Adding an orderby filter, casting postmeta with multiple keys

I am using this filter to sort my query by a date field stored as text (legacy data)               add_filter( 'posts_orderby', 'my_posts_orderby_date', 10, 2 );     function my_posts_orderby_date( $orderby, $query ) {         global $wpdb;         return " CAST( $wpdb->postmeta.meta_value AS DATE ) " . $query->get( 'order' );     }      I need to tell this filter which meta_key to use, because it currently grabs the wrong meta key ($state_key) to sort on. How would I adjust this filter to do so? i.e. I need to add this to the filter, somehow               $wpdb->postmeta.meta_key = 'tf_events_startdate'      Here is the original set of args, if it helps. Thank you!               $args = array(                 'post_type' => 'tf_events',                          'meta_key' => $state_key,                 'meta_value' => $state_meta_value,                 'meta_query' => array( $relation, $date_query, $date_query2 ),                 'posts_per_page' => $limit,                  'tax_query' => array( 'relation' => 'AND', $type_query, $host_query ),                               'order' => 'ASC'             );


slide change on hover with nextgen scrollgallery

My jquery skill is pretty bad, so I can not seem to achieve this. I have a nextgen gallery album that has a scroll gallery showing the images in a slideshow. I want to change the slides on hover rather than on click. I know it is pretty simple, but I have no idea how to actually do it.


Get url/link to latest comments in a post

I have a post list in `Wordpress` where people can see the `most recently commented posts`. They will appear above the list. That's fine, but now, I have 300 comments on the same posts and I don't want the people to go `scroll` fully down when they want to read the `newest` `comments`.... Therefore I am asking if it's possible to get the url to the most recent commented posts on a particular day? For instance, my post list is updated if there is made a comment. On a day, they comment 30 times.... I want a `link` to the **first** of this 30 comments, so that they can read from there, instead of scrolling down 270 other comments. Is this possible? If so, how? Can someone help me?


Fancy-box Esay wordpress plugin fails to work on Multilingual site

I have a multi lingual site. On the site I want to display youtube movies using fancybox (or any other equivalent solution) The plugin is installed and set. When checked on the He version - all works well. On En on the other side, it redirects to youtube. EN: http://www.mtbsuisse.com/en/category/videos/ HE: http://www.mtbsuisse.com/category/videos/ Any idea why this happens ? I am using qtranslate for the multilingual support *Changed site default to HE for now


Loading wordpress menu in an external server

The scenario is like, I have two servers:   * Server A : Hosts WordPress   * Server B : Hosts Some PHP Scripts Now, I want to load the wordpress menu on **server B**. Is there any way to achieve this? Couldn't find anything helpful. I have a plan like this, so far:   * Save the complete output of `wp_nav_menu()` in the wordpress **option table**   * From Server B, connect to wordpress database **remotely** and get the value of the menu from option table, and print that on the PHP page, wrapping with css from the wordpress theme. Is there any good approach than what I have planned?


is_plugin_active() returning false on active plugin

So I have the following in an include in my theme file:               include_once( ABSPATH . 'wp-admin/includes/plugin.php' );     if ( is_plugin_active( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {       $shop_id = woocommerce_get_page_id( 'shop' );       $shop_page = get_page( $shop_id );     }      but `is_plugin_active( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php')` is returning false, despite the fact that the plugin is active. I'm wondering if `is_plugin_active()` might be tripped up by the theme customizer, because the fact that I'm doing this while hooked to `customize_preview_init` is the only gotcha that I can imagine would be causing issue. Any insights?


What is the beste practice to check for pretty permalinks?

I develop a plugin and therefore I add new RSS feeds. One feed might look like `http://local.wordpress.dev/?post_type=custom-post-type&custom- taxonomy=tax-1&feed=custom-feed` This works pretty good. But if pretty permalinks are enabled also this url works which will be redirect to the same feed `http://local.wordpress.dev/custom-taxonomy/tax-1/feed/custom-feed`. So far so good. My plugin will list all available feeds for the user. My question what is the best practice to check if pretty permalinks are active and which url version should be displayed? My idea is to look at `$wp_rewrite` which `permalink_structure` is set and decide which version to show. Is there a better way to do it?


Using Hooks. Thematic

I've added some custom fields to pages and trying to figure out the best way to display them. I was thinking I could use the get_field() option and hook into a sidebar, but am not really sure how to do this. EDIT--- Ok sorry folk, I apologize for not being specific. I am adding custom field options to each page in my theme using this plugin http://www.advancedcustomfields.com/ I was using short-codes previously to add the content into a specific page, but know I need it globally. I figured the easiest way to do this would be to hook into the side bar but an more sure exactly how to do this. The other option is to go into the loop, but I would rather leave that alone if I can. So my question is, how do you hook into a sidebar widget using functions.php?


Why is this Ajax not working?

I'm not sure if I am abusing WordPress and Ajax by doing it this way but WP and Ajax Codex a well as Plugin Development with Ajax do not seem to be very helpful. I have created the following Ajax situation:               (function($){            $(document).ready(function(){             $('a').click(function(e){               var el = $(this).prev('input[type="checkbox"]');               if(el.is(':checked')){                    el.prop('checked',false);                  }               $.ajax({                   url  : "<?php echo CORETHEME_ADMIN_TEMPLATE_HELPER_URL . 'UncheckPackageThemeHelper.php'; ?>",                   type : 'POST',                   data : { 'element_name' : el.prop('name') },                         success: function(result){                     console.log(result);                   },                   error: function(jqXHR, textStatus, errorThrown ){                     console.log(jqXHR, textStatus, errorThrown);                   }                });               e.preventDefault();             });         });       })(jQuery);      Which states that: _When a link is clicked, we unchecked the check box and pass that element name to a class._ Everything works until you see the `unset_package` method in my class               class CoreTheme_AdminPanel_Template_Helper_UncheckPackageThemeHelper{              private $_element_name = null;              public function __construct(){             if(isset($_POST["element_name"])){                 $this->_element_name = $_POST["element_name"];                 $this->unset_package();             }         }              public function unset_package(){             $option = get_option($this->_element_name);             if(isset($option)){                 $option = '';             }         }     }          new CoreTheme_AdminPanel_Template_Helper_UncheckPackageThemeHelper();      Everything works until the `get_option` - I get 500 errors. meaning that the get_option() method doesnt exist - in this instance. **I think** If I take out the `get_option` and the rest of it and replace the contents of `unset_package` with `echo json_encode($this->_element_name);` everything works and I get the element name given back. Can some one explain why this isn't working and maybe show me the proper WordPress way? The Documentation was very confusing to say the least.


Canonicalization + Custom Post Types not working as expected

I have an issue with Canonicalization where on Custom Post Types say for example: /custom-post-type/{post_id}/fake-post-name/ is loading up but not redirecting to : /custom-post-type/{post_id}/real-post-name/ It basically is allowing anything to be after post id and load that URL instead of redirecting to the correct one. Ive got my CPTs setup with custom rewrite rules using 'add_rewrite_rule' and associated my custom post links with 'post_type_link'. Have I missed a step somewhere? Many thanks. Just add to this the actual Canonical tag displays the correct url it should redirecting to. Will I need to add a filter to canonical_redirect and check the post_name of the CPT and see if it matches for the given post id and pass it back perhaps? Im not sure if this is needed/or way to fix it given the canonical in the is correct?


Separate tags with semicolon

Does anyone know if there is a way to change the callback function for a tag- like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.


Reverse order of events on homepage

I'm having problems reversing the order of events that are appearing on my homepage. I want them to appear with the next event at the top. I have tried modifying the code in index.php right before the `have_posts()` function as some tutorials suggest, but it doesn't seem to work the same with events as it does posts. The plugin I'm using for the events is The Events Calendar. I've included the code in case someone needs it. I'm on the latest version of the plugin, and the latest of wordpress. The theme is built on "Point"                   <?php $mts_options = get_option('point'); ?>         <?php get_header(); ?>

                             <?php _e('Upcoming events',"mythemeshop"); ?>

         <?php   $j=0; $i =0;    if (have_posts()) : while (have_posts()) : the_post();?>                     <article class="<?php echo 'pexcerpt'.$i++?> post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">         <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">                             <?php if ( has_post_thumbnail() ) { ?>                                  <?php echo '
'; the_post_thumbnail('featured',array('title' => '')); echo '
'; ?>                             <?php } else { ?>
                                     <img src="<?php echo get_template_directory_uri(); ?>/images/nothumb.png" class="attachment-featured wp-post-image" alt="<?php the_title(); ?>">
                             <?php } ?>
<?php $category = get_the_category(); echo $category[0]->cat_name; ?>

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

                                 <?php echo mts_excerpt(29);?>                                 <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow"><?php _e('Read More','mythemeshop'); ?>

                 <?php endwhile; else: ?>

<?php _e('No results found. We apologize for any inconvenience, please hit back on your browser or use the search form below.', 'mythemeshop'); ?>
                         <?php get_search_form(); ?>
                 <?php endif; ?>                                  <?php if ( isset($mts_options['mts_pagenavigation']) && $mts_options['mts_pagenavigation'] == '1' ) { ?>                     <?php  $additional_loop = 0; global $additional_loop; mts_pagination($additional_loop['max_num_pages']); ?>                            <?php } else { ?>

<?php next_posts_link( __( '← '.'Older posts', 'mythemeshop' ) ); ?>

<?php previous_posts_link( __( 'Newer posts'.' →', 'mythemeshop' ) ); ?>

                 <?php } wp_reset_query(); ?>
             <?php get_sidebar(); ?>     <?php get_footer(); ?>


Redirecting non www to www ONLY for domain, subdomain without www

How to set htaccess to such examples in a Wordpress Multisite:   * domain.com - redirect to - www.domain.com   * sudomain.domain.com - no redirect I have a `Error 310 (net::ERR_TOO_MANY_REDIRECTS)` when my `.htaccess` file looks like this:               RewriteEngine On      RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{HTTP_HOST} !^www.     RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]          # add a trailing slash to /wp-admin     RewriteRule ^wp-admin$ wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]     RewriteRule ^(.*\.php)$ wp/$1 [L]     RewriteRule . index.php [L]


Downgrade from latest nightly build to latest stable version

I'm currently running `3.6-alpha-23495` and want to go back to the latest stable (currently `3.5.1`). The site is now up and running. The reason that I'm going to downgrade is that the following error is appearing:               Fatal error: Allowed memory size of 33554432 bytes exhausted     (tried to allocate 311296 bytes) in     /home/USERNAME/public_html/wp-includes/SimplePie/Misc.php     on line 843      I have added `ini_set('memory_limit', '64M');` to `wp-config.php` to execute the command everywhere, and also added the code at the top of `/wp- includes/SimplePie/Misc.php`, but still no luck. Anyway I think that the best way to avoid facing with these errors is downgrading to the latest stable version. Ant ideas? Thank you


How can I create a data entry form that has Master Detail ability?

I have a patron and books for a library (in this example). One person/patron, many books. I have the two tables. I believe I could use either tablepress or roll my owne output via a custom plugin and view a report. But I'm stuck on where to get started for data entry. How can I have a form where I create the person and the books they check out all on one page? It would just add another row for each extra book for that checkout date. I have used something similar in Drupal, creating forms, but I cannot find it in WordPress.


Changing the URL Structure of a Paginated Custom Post

I have a custom post type for slideshows that creates a paginated post and each slide is a separate page. The data for each slide is saved in the custom fields and each slide has a title set saved in the custom field with key `slide{$i}-title` (`$i` being the slide number, for example `slide1-title`). Currently the url of each subsequent page is the number appended to the post permalink (which is the standard way paginated page urls are formatted) like this: http://example.com/post-title/2/ for page/slide 2 and http://example.com/post-title/3/ for page/slide 3. **How can I change this so that each page's url is appended with the slide title instead of the incremental number?** For example: http://example.com/post-title/slide-2-title/ for page/slide 2 and http://example.com/post-title/slide-3-title/ for page/slide 3.


Query 2 meta key values and a category

I have a wp query that works great - it returns a list of featured posts. WP_Query("category_name=office&meta_key=featured_post&meta_value=Yes&posts_per_page=3"); However I want to add a 2nd custom key to the query (a custom order field) then order by the numerical value of the meta value of this key.. is it possible to use 2 meta_key values in a WP_Query? If not is it possible using an SQL query statement?


Pass variable to nested shortcode

I'm setting up a plugin with a nested shortcode, i.e.               [ct_training_group]         [ct_training]     [/ct_training_group]      Here's the catch: I use the `[ct_training]` code outside of the parent as well as within it, and want to output something slightly different in each case. When it is inside a group, I need to omit the `<ul>` and `</ul>` that I would wrap the `[ct_training]` shortcode in when it is called on its own. I figure the easiest way to do this would be to pass a variable from the parent to the child. Is there any graceful way to do this where I wouldn't need to mess with globals or such? Thanks.


Multiple Custom Metabox Help

I have been trying to get this worked out for over a year and have tried numerous ways and have not been able to get it to work. I'd really appreciate it if someone could help me with this. Here's what I'm trying to do... I need to create 15 custom metaboxes for the Write screen on my custom post type for Slideshows (lom_slideshow). Each metabox will be the same except for the number of slide (Eg, Slide 1, Slide 2...). I would like the metaboxes to save each field into the seperate Custom Field. Here are the fields that need to be in each metabox:   * **Number/Text Field**     * Title: Slide Number     * Custom Field Key: slide1-number   * **Checkbox**     * Title: Hide This Slide     * Custom Field Key: slide1-hide   * **Radio toggle**     * Title: Slide Type     * Custom Field Key: slide1-slidetype     * Values: Image Slide or Video Slide   * **Text Field**       * Title: Slide Title     * Custom Field Key: slide1-title   * **Image** (this one could work several ways and I don't really care how it works as long as it does)      * Title: Slide Image     * Custom Field Key: slide1-image     * How it will function: as long as it does one of the following things I'll be happy...     * **A)** A dropdown list of all the image attachment associated with the post.      * **B)** A list of thumbnails for all the attached images associated with the post.      * **C)** An image upload field to upload an image and attach it to the post.    * **WYSIWYG**     * Title: Slide Description     * Custom Field Key: slide1-desc     * Type: wysiwyg   * **Textarea**     * Title: Video Embed Code     * Custom Field Key: slide1-embed _Slide 2 will be the same but the all the Custom Field Values will be appended with "slide2-" instead of "slide1-"_ The only other consideration is that I'd like them to be in the main content column and only visible on my Slideshow custom post type (lom_slideshow). Like I said I have tried this numerous time and never got it right. I have gotten close in the past and have gotten the whole thing working except I couldn't get multiple instances of the WYSIWYG to show up on the page. I no longer have that code because I have changed it numerous times since then. I ultimately decided on using the More Fields Plugin to do this instead of my own code and tested it with 5 meta boxes for development, but then when I tried to implement it with the 15 boxes I needed the plugin wreaked havoc on my database tables. I really don't want another plugin. I'm actually looking for someone to just tell me how to code it. I don't need links to tutorials because I am confident that I have tried them all unless it was published in the last hour or so. For some background here was what I was originally trying to do: Help Creating a Slideshow Custom Post Type with Custom Meta Boxes? EAMann provided me with a very comprehensive answer however it was outside my skill set and I couldn't implement it. I have simplified my request down to this question here in hopes of finally being done with this.


Remove/Unregister or hide a widget added by a plugin

I'm trying to figure out how to remove wordpress widgets added by plugins. I know there are a couple of plugins that do this, like https://wordpress.org/plugins/wp-remove-widgets/ and https://wordpress.org/plugins/post-lists-view-custom/, however I'd rather not use a seperate plugin for something that seems like such a small task. Specifically, I'm trying to unregister the wordpress engine powered by widget that http://wpengine.com/ loads on the widgets page. I searched the source code and found the id of the widget is `wpe_widget_powered_by` However, this does not work...               function my_widgets_init() {         unregister_widget( 'wpe_widget_powered_by' );     }     add_action('widgets_init', 'my_widgets_init');        So far the only thing I've been able to do effectively is use a combination of css/js to hide then remove the widget. I use css to hide it on page load and then remove it with jquery so there's not a blank gap where the widget is suppose to go.               function remove_wpe_powered_by_widget() {     ?>     <style type="text/css">         [id*="wpe_widget_powered_by"] {     display: none;     }     </style>     <script type="text/javascript">         jQuery(document).ready(function($) {         $("div[id$='wpe_widget_powered_by']").remove();         });     </script>     <?php     }     add_action( 'admin_head', 'remove_wpe_powered_by_widget' );      While the above works, I know it's not the correct way to do things and I'm wondering why the first function doesn't work. The codex says to do the following.               <?php unregister_widget( $widget_class ) ?>      Maybe I'm not understanding what exactly $widget_class is. Is there a way to find the widget class without searching through the plugins code? Or do I already have the correct class and it's not working for another reason (perhaps a late hook or something). I looked all through stackexchange and the internet and could only find ways to remove default widgets, but no one tells you how to remove widgets added by plugins. Sorry if I'm missing something and this is an obvious question.


Taxonomy and Date in same query?

Is is possible to combine a tax_query with a date_query in the most recent Wordpress? Here's my attempt to do so:               $args = array(      'post_type' => 'job',     'tax_query' => array(              array(               'taxonomy' => 'location',             'terms' => 'dallas',             'field' => 'slug',            )        ),      'date_query' => array(         array(             'year' => '2014',             'month' => '12',         ),       )     );     $jobs = new WP_Query($args);      However, it is ignoring the date query and only the taxonomy query works. When I remove the taxonomy query portion, the date query suddenly works. Any ideas on this?


How can I achieve this, using shortcodes

I have a plugin that restricts contents for registered users only, on the other hand I have created a shortcode for showing a chat and I want to hide it using the restrictive shortcode; [upme_private][chat][/upme_private] But it doesnt work, what would be the best aproach? The function to "Hide" restricted content uses;               function upme_private($atts, $content = null) {             global $upme;             return $upme->hidden_content($atts, $content);         }      and the shortcode that i created is > add_shortcode( 'barchat', 'barc_chat_script' ); Essentially what I want is to be able to hide the barchat shortcode from users by; > [upme_private][chat][/upme_private] But I dont know how to modify the return of the upme_private function to include do_shortcode() since its already returning another function (hidden_content)


Required Field for Comment parent only?

I am trying to make the rating required for a comment but not required when it is a reply. Its not working, can you please help.               function custom_validate_comment() {         //validate rating         if( $comment->comment_parent==0) {          if( empty( $_POST['rating'])  )                 wp_die( __('Error: Please Include Your Rating (0 to 5 Stars)')    );         }     }          add_action('pre_comment_on_post', 'custom_validate_comment');


How to add 3 weeks to the_time() function

I have a WordPress blog where I need to display an image on each post only for 3 weeks. This means that after 3 weeks have passed, since each post was published, the image will disappear. First, I made sure that the image appears each time a new post is published. This was easy. Then I needed to get the date when each posts was published and I used `the_time();` function. The problem I'm having right now is that I don't know how to use `the_time();` function to do anything (compare it with current time, adding 3 weeks etc). I tried to do this with javascript using this code which works, it outputs the current date and the date after 3 weeks.               now = new Date();     threeweeksfromnow = new Date(now.getTime() + (21 * 24 * 60 * 60 * 1000));     months = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ","October ","November ","December ");          document.write("Today's date is: " + months[now.getMonth()] + now.getDate() + "
");          document.write("Three weeks from today is: " + months[threeweeksfromnow.getMonth()] + threeweeksfromnow.getDate() + "
");       I tried to tie this code to `the_time();` function in wordpress but it didn't worked. Does anyone have any idea how I might solve this problem?


How do I attach images to a post without inserting them?

I'm developing a theme with an built-in gallery outside of the post content. So what I want to do is to allow editors to attach images to a page/post without inserting them. Kind of like the featured image, but with any number of images. Just a nice UI for uploading, and leave it to the theme to render it. I looked at some plugins, especially NextGen Gallery, but so far they all work by inserting a shortcode in the post body.


Sorting past events by month

I have a site that lists upcoming events and past events. In my category-past-event.php template, this is how I've gotten past events appear in descending order (from most recent to oldest):                   <?php                     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                     $args = array(                       'posts_per_page' => 100,                       'paged' => $paged,                       'cat' => 3709,                       'orderby' => 'meta_value',                       'meta_key' => 'Deadline', //formatted YYYYMMDD                       'order' => 'desc'                     );                          query_posts($args);                  ?>      This setup successfully lists events in the order they appeared, e.g.   * Event 6    * Event 5    * Event 4   * Event 3   * Event 2   * Event 1 How can I get it so that the past events are broken up by month? E.g. December 2012   - Event 6    - Event 5    - Event 4   November 2012   - Event 3   - Event 2   - Event 1 **Update:** I have set up pre_get_posts in functions.php as @s_ha_dum suggests and this is working. @KrzysiekDróżdż, the problem I have is that the Deadline might not correspond to get_the_time('F Y'). This is because I might create a post with the Deadline = 20131212 (i.e. taking place in December 2013), but the time of that post might be different. I.e. it is June, and I create an upcoming event for December, the time of that post is June because I created it in June. Currently using this on a production site (though I am testing locally with MAMP). The workflow for creating events is that posts are categorized as Events, and then the Post Expirator plugin switches their category to Past- Event once the date of the event has passed. Deadline exists so the posts can be sorted in ascending or descending order. Still trying to wrap my head around how in the loop in category-past-event.php I would use that Deadline to sort them by month


NGINX conf on WP Multisite enabled -- subdirectory -- images fail to load after updates

A server with nginx and WP 3.9.1 was working properly. The nginx helper plugin was updated two days ago and now no images or zip files in the uploads directory are available in the browser or the media library. Now, if I edit the image in the media library then it shows but 'disappears' upon updating. In looking at browser urls this is what WP is serving but fails `domain.com/chemistry/files/year/month/image.png` This url shows the image if put in manually to the browser `domain.com/chemistry/wp-content/uploads/sites/#_of_site/year/month/image.png` I've looked at the map feature of the plugin, tried to read the documents, but cannot figure out what happened and what was changed so I can fix it to get images to load properly. Can someone point me in the correct direction? -- disabled nginx helper plugin -- restart nginx -- reinstalled nginx helper plugin -- enabled map feature of nginx helper plugin


Documentation for IDE's

I'm using IntelliJ but this question could apply to PhpStorm, Visual Studio, etc... Is there a good way to make the IDE aware of the Javascript functions that WordPress provides? Are there any Javascript stubs available like these Google Maps stubs? I'd like to have auto-completion available, parameter info, etc...


Display featured products by category

I have this code in my themes' shortcode to display featured product rating product like this. But I need to get product by category show. Which code do I have to add. Any suggestions?               if($type == 'featured'){                  /**********QUERY FOR FEATURED PRODUCT**********/                  $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product' );                            $query_args['meta_query'] = array();                            $query_args['meta_query'][] = array(                      'key' => '_featured',                      'value' => 'yes'                  );                  $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();                  $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query();                  /**********END QUERY FOR FEATURED PRODUCT**********/              }elseif($type == 'top-rated'){                  /**********QUERY FOR TOP-RATED PRODUCT**********/                  add_filter( 'posts_clauses',  array( $woocommerce->query, 'order_by_rating_post_clauses' ) );                            $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product' );                            $query_args['meta_query'] = array();                            $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();                  $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query();                  /**********END QUERY FOR TOP-RATED PRODUCT**********/


Update postmeta after theme switch

I am trying to update the postmeta table when I switch themes. I am updating the metavalue to be template-name.themename.php. However, this only works with the default themes in wordpress. If I go to add a new theme, and activate that, it does not work. The metavalue updates correctly, but the new theme is overriding the custom template. Here is the code I have.                   <?php         add_action('after_switch_theme', 'update_templates');              function update_templates() {              global $wpdb;         $new_template = "pl-template.". strtolower(trim(get_current_theme())) .".php";         $pl_pages = $wpdb->get_results(" SELECT * FROM {$wpdb->prefix}posts WHERE pevo_page = 1");                   foreach ( $pl_pages as $pages) {                  $post_id = $pages->ID;                  $wpdb->query(                   "                     UPDATE {$wpdb->prefix}postmeta                     SET meta_value = '$new_template'                     WHERE post_id = $post_id                                          "              );              }     }         ?>      The custom template, is just blank right now and just displays the page title                   <?php         /*          Template Name: Template Name         */                   $the_title = get_the_title();              echo $the_title;        ?>      working code thanks to the answers, I used an array because this is within my plugin class.                   add_filter( 'template_include', array($this, 'plugin_page_templates'));                          function plugin_page_templates() {         global $wpdb;         $pagename = get_the_title();         $ispluginpage = $wpdb->get_var("SELECT plugin_page FROM {$wpdb->prefix}posts WHERE post_title = '$pagename'");              if ($ispluginpage == 1) {             return plugin_dir_path( __FILE__ ) . 'includes/plugin-template.php';         }              return $template;               }


Get section of input passed to the sanitize_callback

How can I find out what section each input is in when viewing the `$input` array passed to the sanitize_callback function defined in `register_setting()`? I suppose one option is to include the section as part of the field name and can then extract it. E.g. `name="section^field"` and then in the sanitize_callback:               foreach($input as $name => $val) {         $parts = explode('^', $name);         $section = $parts[0];         $field = $parts[1];         // do more stuff here     }      But this feels a little hacky. Is there a better way?


How to add different CSS for galleries

I use jetpack carousel for all of my galleries , even for my featured image, my question is, how do I style my [gallery] outcome to use different CSS for the featured image so I can manipulate it a little bit but not mess with the regular default galleries outcome?


Page that 'subscribes' to multiple categories

I'm creating a website where I need to 'subscribe' client Pages to certain categories. For example: On example.com/client/johnson-co/ show all posts in the categories 'GST', 'Estate' and 'Tax General'. On example.com/client/smith-co/ show all posts in the categories 'GST', 'Insurance' and 'Personal'. I'm not at all attached to using Pages if there's a better way :) I do however need the categories 'subscribed' to to be editable using WordPress admin; not hard-coded into the theme. * * * I've researched and experimented with the following methods to no avail:   * Giving a category multiple parents (currently not possible in WP) - this would let me give category gst a parent of johnson-co and smith-co   * Using query_posts() and including cat=x (as per the codex) - this works but is hard coded and doesn't let someone subscribe a page to categories in the admin.   * Using custom post type (set up using CCTM plugin) so /client/johnson-co/ has checkbox meta fields of GST, Estate, Insurance, Personal etc. This is the closest but I couldn't get the link between what was checked and the categories showing working, and it feels like a bit of an ugly hack. Would hugely really appreciate any ideas!


Pass custom fields values to Google Maps

I am using this script on display google maps on my wordpress site:               <head>         <script>         function initialize()         {           var mapProp = {             center:new google.maps.LatLng(51.508742,-0.120850),             zoom:5,             mapTypeId:google.maps.MapTypeId.ROADMAP           };           var map=new google.maps.Map(document.getElementById("googleMap",mapProp);         }         </script>               </head>      I have set up two custom fields "fl_long" , "fl"lat" for the longitute and latitude. How do I modify the code above so that the values are taken from the custom fields instead of being hardcoded numbers?               google.maps.event.addDomListener(window, 'load', initialize);


Adding attachment file name to email link

I'm doing up a photography site where each post is a photo project, and each post attachment will be displayed on its own attachment page (linked to from the main post page). On the attachment page, I want to give an email link, below the image. At the moment, the code is something like this: `<a href="mailto:me@whatever.com?Subject=Image: <?php the_title(); ?> \- [FILE NAME HERE]">Get in touch about this image</a>` I want the subject of the email to include the _file name_ of the attachment (not title, not meta info, not attachment page URL). Is this possible? If so, how would I do it? Thanks.


Redirect from subdomain

I'm moving a Tumblr site to WP and need to deal with a redirect. I'm using the Redirection plugin. So, I need to redirect from http://blog.example.com > http://example.com To achieve this, do I need to actually host the site at blog.example.com and redirect from there? Or do I need to setup a dummy site at blog.example.com? Really have no idea how to tackle this at all. Suggestions very welcome! Update: Can this be achieved by adding a new vhost entry?


is_page() and is_page_template() not being differentiated

I need to rearrange how my comments are displayed depending on the page template. My posts and standard pages are displayed in in the middle of the screen, and thus need to share the same comment layout. I then have a right sidebar page layout and so I need the comments pages with that template to be aligned to the left of the page. I am attempting to this like so               <?php if( is_single() || is_page()): ?>

     <?php else: ?>     <?php if(is_page_template('right-sidebar.php')) ?>

     <?php endif; ?>      However, my single stadard pages are taking the layout of the `html` under the second if condition. What am I misunderstanding about this?


How to make subcategory for custom post and and display?

I've created a custom post with categories like books, foods, and make some sub-categories like in foods cat, pizza, fastfood. But when I display them in my side bar, it's showing same as sub category. Just like: > .books > > .foods > > .pizza > > .fastfood I want them to display like this: > .books > > .foods > > -pizza > > -fastfood Here is my code of functions.php               add_action('init', 'products_register');          function products_register() {         $labels = array(             'name' => _x('products', 'post type general name'),             'singular_name' => _x('Products Item', 'post type singular name'),             'add_new' => _x('Add New', 'products item'),             'add_new_item' => __('Add New products Item'),             'edit_item' => __('Edit products Item'),             'new_item' => __('New products Item'),             'view_item' => __('View products Item'),             'search_items' => __('Search products'),             'not_found' =>  __('Nothing found'),             'not_found_in_trash' => __('Nothing found in Trash'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             //'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail')         );               register_post_type( 'products' , $args );              register_taxonomy("productcategory", array("products"), array("hierarchical" => true, "label" => "Product Category", "singular_label" => "Product Category", "rewrite" => true));          }      Here is my code to display the category on my sidebar:               <?php          $taxonomy = 'productcategory';     $terms = get_terms($taxonomy); // Get all terms of a taxonomy          if ( $terms && !is_wp_error( $terms ) ) :     ?>
             <?php foreach ( $terms as $term ) { ?>
<a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?>
             <?php } ?>
     <?php endif;?>


Creating a relationship between two post types

I want to build a TV series database using WordPress. I have followed some tutorials and I have two custom post types: one for `movies`, one for and `series`. I followed this post for the structure. My question is how can I make the relationship between the movies and series post types?


Error establishing a database connection - WordPress Multistage in Sub-Folder

I have a website running on my production server which I moved to localhost. The folder structure is as follow: localhost/xxx/main - Here are the website files. I have updates the database by changing all the url's to be localhost/xxx/main. My .htaccess looks like this :               RewriteEngine On     RewriteBase /xxx/main/     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]      wp-config.php has the following lines added :               /* Multisite */     define('WP_ALLOW_MULTISITE', true);     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'localhost');     define('PATH_CURRENT_SITE', '/xxx/main/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);     /* That's all, stop editing! Happy blogging. */      The problem I am having now is that I cant establish the connection to the database. Whenever I set up               define('MULTISITE', false);      the connection with the database is being established just fine. Any ideas please? Thanks Dom


Combining wp_current_user() and a variable

I want to match a custom field in a user's profile to a particular post the user might be on. So I've got the custom fields for user profiles setup, and they're all numeric. Then, if I'm on a post page, I want to check if that post's ID matches the custom field in their profile. Something like this, where the custom field in the user's profile is `badge-id-2000`               $current_user = wp_get_current_user();     $badge_ID = $post->ID;     if ($badge_ID == $current_user->badge-id-$badge_ID) {         return true;     }      Apparently on line 3 there where I'm using `badge-id-$badge_ID`, the variable doesn't work in that scenario. Is there some other way of doing this or getting the variable to work there?


Unable to access WP admin

I cannot access admin via: `http://xxxxxx.com/admin` or `http://xxxxxx.com/wp-admin` `Fatal error: Class 'ObjectModel' not found in /home3/xxxxxx/public_html/xxxxxxx.com/wp-includes/class.wp-dependencies.php on line 28` I have had a trojan on my website that will put own htaccess redirect stuff. And what is worse the WordPress version was up to date 3.5.1 and I have almost no plugins installed. File permissions were 644 and directories 755. How can it write to htaccess? What file permission should I set for htaccess? I am on a shared Justhost hosting.


Wordpress FTP via admin panel slow

I am trying to delete some plugins via the Wordpress admin panel. Sometimes it deletes the plugin quite quickly, but other times it hangs. I have access to my server, is there anything I can do to speed the performance up?


Custom forms with HTML

Will there be any issues with creating a custom form in the index page? Will I be able to get and post requests? It's a simple email validation form and once validated, the user will be able to download a file. Thanks