Wrong WordPress language?

I'm a bit confused now. I've installed Wordpress for my Polish friend from here: http://pl.wordpress.org/ On my local machine everything works fine and is in Polish, but installing it on the web server looks like default English Wordpress ("Recent posts", "Archives" etc.). Why? Every language file I found is polish (in themes/twentyten/languages AND wp- content/languages), also wp-config is set to `define('WPLANG', 'pl_PL');`. Thanks.


category filter doesn't work

I am assuming because I don't have a category template it is defaulting to the archive template, would that affect the outcome. it seems to output all the posts that have categories: http://www.tigerstudiodesign.com/category/branding/ this is source for archive page: http://pastebin.com/a5jxtBSe


Removing Author name

I want to remove the author name from every post. O am using a website in wordpress.org. and I'm using `tweenty fourteen` theme. How to remove the author name? Do I have to go to the `Author template` (author.php)? And then will I edit here                   <?php     /**      * The template for displaying Author archive pages      *      * @link http://codex.wordpress.org/Template_Hierarchy      *      * @package WordPress      * @subpackage Twenty_Fourteen      * @since Twenty Fourteen 1.0      */          get_header(); ?>

                      <?php if ( have_posts() ) : ?>
                         <?php                             /*                              * Queue the first post, that way we know what author                              * we're dealing with (if that is the case).                              *                              * We reset this later so we can run the loop properly                              * with a call to rewind_posts().                              */                             the_post();                                  printf( __( 'All posts by %s', 'twentyfourteen' ), get_the_author() );                         ?>
                     <?php if ( get_the_author_meta( 'description' ) ) : ?>
<?php the_author_meta( 'description' ); ?>
                     <?php endif; ?>                                       <?php                         /*                          * Since we called the_post() above, we need to rewind                          * the loop back to the beginning that way we can run                          * the loop properly, in full.                          */                         rewind_posts();                              // Start the Loop.                         while ( have_posts() ) : the_post();                                  /*                              * Include the post format-specific template for the content. If you want to                              * use this in a child theme, then include a file called called content-___.php                              * (where ___ is the post format) and that will be used instead.                              */                             get_template_part( 'content', get_post_format() );                              endwhile;                         // Previous/next page navigation.                         twentyfourteen_paging_nav();                          else :                         // If no content, include the "No posts found" template.                         get_template_part( 'content', 'none' );                          endif;                 ?>

          <?php     get_sidebar( 'content' );     get_sidebar();     get_footer();      ![enter image description here](http://i.stack.imgur.com/k3nWl.png) **I don't want the author name mentioned in the picture**


Where is this strange og:description coming from?

I noticed in my home page's source code:               <meta property="og:description" content="This is an example page. It's different     from a blog post because it will stay in one place and will show up in your site      navigation (in most themes). Most people start with an About page that introduces     them to potential site visitors. It might say s" />      This is a problem since this is what Facebook uses when I post the main URL of my site to a Facebook wall... so it just looks stupid. I can't find that string anywhere in my WP admin settings, or in the "Facebook Open Graph Options" setting (as part of the "Facebook OpenGraph" plugin that I have installed). It's also not in any of my theme's template files, and it's not on my actual about page. Where can I find this description, so I can change it?! Thank you-- E


How-to debug wp_ajax_* hook callback?

I'm currently developing a plugin that uses ajax functionality. **Problem:** The callback isn't fired = no data gets processed.               if ( ! is_admin() )         add_action( 'after_setup_theme', array( 'wpseAjaxClass', 'init' ), 10 );


Display Only One Category

On my WordPress theme, it displays all of the categories a post is in on the homepage for the post block, I only want to display one category even if a post is under multiple categories. i.e. Category One, Category Two, Category Three I want it to be Category One... This is the code that is in place at the moment:
<?php the_category(', ') ?>


Why isn't get_option array contents displaying?

I've been to countless posts looking for the answer to this and have tried nearly every combination. So obviously, I'm missing a step so small that it's likely unfathomable to the Wordpress community. My code writes the options to the database, but fails to display them back. The array is NOT set. Multiple options can be added and deleted. Writes the data:               <?php          $mycontents = array('content' => $_POST['cont'], 'content2' => $_POST['cont2']);          update_option('slider_contents',$mycontents);     ?>      Here are the database entries:               a:2:{s:7:"content";a:3:{i:0;s:19:"This is content 1-a";i:1;s:19:"This is content 2-a";i:2;s:19:"This is content 3-a";}s:8:"content2";a:3:{i:0;s:19:"This is content 1-b";i:1;s:19:"This is content 2-b";i:2;s:19:"This is content 3-b";}}      Trying to read and display the data:               <?php         $the_contents=get_option('slider_contents');         foreach ($the_contents as $content) {              $content1=stripslashes($content->content);              $content2=stripslashes($content->content2);     ?>
<textarea name="cont[]" rows="3" style="width:70%;" ><?php echo $content1; ?></textarea>
<textarea name="cont2[]" rows="3" style="width:70%;" ><?php echo $content2; ?></textarea>
<input type="button" value="Delete this option" onClick="delete_field(this);"  /><input type="button" value="Add new option" onClick="add_to_field(this);"  />
                  <?php } ?>      I've also tried...               <?php         $the_contents=get_option('slider_contents');         foreach ($the_contents as $content) {              $content1=stripslashes($content['content']);              $content2=stripslashes($content['content2']);     ?>      The output of `var_dump($the_contents);` is :               array(2) {        ["content"]=> array(3) {          [0]=> string(19) "This is content 1-a"          [1]=> string(19) "This is content 2-a"          [2]=> string(19) "This is content 3-a"        }        ["content2"]=> array(3) {          [0]=> string(19) "This is content 1-b"          [1]=> string(19) "This is content 2-b"          [2]=> string(19) "This is content 3-b"        }      }


Term begins with a letter

I had a template that relied on `$terms = get_terms( "ingredient", array( 'name__like' => $letter ) );` to return all posts where the custom taxonomy `ingredient` begins with `$letter`. The behaviour of `name__like` was changed in WP 3.7 to a text search instead of beginning. What function can I use to achieve the results I had before? Do I need a custom query?


Output custom content not from the posts table?

It would be best if I started out be explaining the situation: A while ago I created a Property/Real Estate management system using PHP and MySQL. It works great and I have a lot of customers using it now but I would like to expand its capabilities to wordpress. I know a little bit about plugin development, but I do not know how to approach the project or how to design it. Basically I want to create a plugin that takes information from a database (the one with all the property information) and displays it in wordpress. I need to create 3 parts: a search form, a results list and a page to display the property information. Here are some important points:   1. I do not want to add the property information to the posts table. For example, on posts/custom-post-type per property. I want to retrieve the data directly from another table.   2. I want to be able to use friendly URLs. For example: http://mysite.com/property/56   3. I want to be able to set the title and description (in the head section) with data from each property   4. All of this has to happen from the plugin and CANNOT rely on the theme. So, what are your ideas? How should I approach this challange? Here is what I have been thinking, but I am not sure if it will work: 1. Create a custom post type called 'Property'. 2. Create a template file for displaying the property information. 3. Create a template file to show the search form and results. This could be like and archive template 4. That is as far as I got. I don't know how to make wordpress display a post that actually is not there. Anyways, what are your ideas? I appreciate the help.


Get result from Custom Field in Custom Post type

If trying to filter out some return results from a custom post type that has a custom field appended to it for location. I'm not too sure where I need to apply the case statement in my query. Or if I need to add it into the query when it pulls the info from the post type. I currently have this:               <?php     $mypost = array('post_type' => 'staff', 'posts_per_page' => 20 );     $loop = new WP_Query( $mypost );      ?>
          <?php while ( $loop->have_posts() ) : $loop->the_post();?>          <?php $items = get_post_meta( $post->ID, 'elements', true );      foreach( $items as $i){     if($i['location'] = 'local') {     echo'

' . $i['staff-name'] . '

' . $i['short-title'] . '
         ' . $i['3-areas-of-focus'] . '
              ';         }     }     ?>            <?php endwhile; wp_reset_query(); ?>

      I have the custom field for the location as a checkbox, so inside the custom post type it shows:               local, out of town      The thing is that some staff members can have a location local and out of town, but some are just local. So, I'm not sure if I need to have do a trim explode before or if there is some other way that I need to have it look up in the query or what.


Percent-encoded slug appears as decoded

What is the WordPress mechanism for creating post slugs when creating a new draft? I enter a post title, and after some seconds, a suggested permalink appears. I have traced this behaviour to the `sample-permalink` AJAX request, which jumping through many hoops leads to `get_sample_permalink` and from there to `sanitize_title`. But the real answer seems to be buried in filters: see the example below. I have tried to track this down using XDebug and webgrind, but so far no good. Let's suppose I have this UTF-8 post title (note: there is an en dash there, ligatures and some curly quotes): `Éstè día 20 % “über/Þøß” — Ñœĳçõs¿ & Köyrä = 10 € © βασιλειος` The response to the `sample-permalink` AJAX request contains the HTML elements to create the "Permalink" field, and inside the `<span id="editable-post-name- full">` element I see this: `este-dia-20-uberthos-noeijcos-koyra-10-e-βασιλειος` I'm unable to reproduce this same response in my own code using WordPress functions. I've tried:               sanitize_title( $title);      // Result:      // 'este-dia-20-uberthos-noeijcos-koyra-10-e-%ce%b2%ce%b1%cf%83%ce%b9%ce%bb%ce%b5%ce%b9%ce%bf%cf%82'          sanitize_title( $title, '', 'save' );     // Result: same as above          sanitize_title( $title, '', 'query' );     // Result:      // '%c3%a9st%c3%a8-d%c3%ada-20-%e2%80%9c%c3%bcber%c3%be%c3%b8%c3%9f%e2%80%9d-%e2%80%94-%c3%b1%c5%93%c4%b3%c3%a7%c3%b5s%c2%bf-k%c3%b6yr%c3%a4-10-%e2%82%ac-%c2%a9-%ce%b2%ce%b1%cf%83%ce%b9%ce%bb%ce%b5'          sanitize_title( $title, '', 'display' );     // Result: same as above      The result in the WordPress response can be achieved with:               urldecode( sanitize_title( $title ) );      I don't see any calls to that function, however. I'm puzzled. I checked also the Javascript responsible for the AJAX call, and nothing there, either.


is it possible open links in new page-window?

I use The List Category Post plugin and i'm very satisfied, but if i would make open the posts (list post) in another page not in the same. Thanks and sorry for my bad english


Is there a way to have a dual WP feed (full/partial)?

Is there a way to have a dual WP feed? We'd like a full feed for _one_ particular subscriber and a partial feed for everybody else. Is that possible?? Any assistance would be much appreciated.


Gravity Sum list column with post_after_submission

I want to make sure I'm doing this right. I have a gravity form with a list field with three columns. Basically, Product Name | Quantity | Notes I want to sum the value of all the values in the quantity field col[2] and add it into a custom meta field in the custom post type my field populates. This is what I came up with:               <?php          add_action("gform_after_submission_8", "calculations", 10, 4); //  replace form id 8     function calculations($entry, $result, $value, $form, $field) {             global $post;             global $wp_query;             $post_id = get_the_ID(); // $entry['post_id'];                  if (is_array($value)){                 $counter = 0; //variable used to know the row so it may be used in the validation failed message                 foreach($value as $row) {                     $col1 = $col_values[0]; //get first column, index 0                     $col2 = $col_values[1];                     $col3 = $col_values[2];                    return $col2; //failed, stop further processing and return result                 }             }             $total_cost = array_sum ( $col2 ); //return unchanged validation when not an array             update_post_meta($post_id, 'total_cost', $total_cost );     }      I'm using the GF+CPT plugin to call pick the custom post type, but I'm not sure if the post_id was created at this point in the form submission. Has anyone tried to do something like this before and have some advice on the best way to do this?


How to include category name/id in wp_query for retrieving "custom post type" from a particular category?

Here is the code I'm using right now. It fetches the posts from all the categories in the 'sp_events' post type.               <?php $feat_art = new WP_Query(array('post_type' => 'sp_events','post_status' => 'publish','posts_per_page' => 1));   while($feat_art->have_posts()) : $feat_art->the_post(); ?>      I want to display the posts only from a category named 'eventcat1'. I tried the following code, but it did not work.               <?php $feat_art = new WP_Query(array('post_type' => 'sp_events','category_name'=> 'eventcat1','post_status' => 'publish','posts_per_page' => 1));   while($feat_art->have_posts()) : $feat_art->the_post(); ?>      How to specify either the category name or the id in the query? Any help would be appreciated. Thanks


WordPress hosting optimized servers - Is this just a sales gimmick?

I have always hosted my own websites on my own hardware, this includes WordPress. I always see on shared hosting sites "WordPress Hosting" which looks to be the exact same as their regular hosting plan. Am I missing something, or is there a difference, and how can I optimize my servers for WordPress?


Moving 2 wordpress sites to one

I am working on 2 different wordpress blogs into one new domain! I used the Tools->Export to get the xml file and also chose the option to include files and attachments as I wanted to move all the articles with images. I did the same for the second site as well. On the new site, when I try to import, it failed to do the complete import and it is not done properly. XML file is not even 10mb in size but still I changed the filesize and max size setting via php.ini to a higher number. Can you please suggest a way to import both the sites into the new one? I am not sure if exporting and import .sql will help because there are chances of same post id or some common thing. How to carefully import images, users, contents etc from 2 sites into 1? Please advise!


Query Posts (post meta)

my situation: I have a frontpage which filters 12 thumbnails out of 24 (each thumbnail represents a post's featured image), and displays them. The user has the ability to hide whichever post he wants from the frontpage. Let's say the user chooses to hide thumb #4, that means we now have thumb 1,2,3,5,6,7,8,9,10,11,12. That is, we have 11 thumbnails. So we are missing the last 'thumbnail space', which should be filled with the upcoming post; in this case, thumb #13. In short, the frontpage should query the posts so that when one or more thumbnails are hidden - resulting in one or more blank spaces - it automatically 'refills' the blank spaces by pushing in the upcoming thumbnails. My front-page has this query:                           <?php                  global $wp_query;                      // First row of images                 if(!empty($options['home_thumbs'])) {                     $page_items = $options['home_thumbs'];                 } else {                     $page_items = 18;                 }                      $portCat = get_category_id($options['portfoliocat']);                      // get the desired sort order of portfolio items                 if($options['homepage_sort'] == 'DESC') { $order = 'DESC'; } else { $order = 'ASC'; }                      $hideFromHome = get_post_meta($wp_query->post->ID, 'pr_hidehome', true);                      query_posts('posts_per_page=' . $page_items . '&orderby=title&order=' . $order . '&cat=' . $portCat . '&meta_key=' . $hideFromHome .'&meta_value=' . true);                 // arrays to detect first and last columns                 $firsts = array(6,12,18,24,30,36);                 $lasts = array(5,11,17,23,29,35);                 if (have_posts()) :                     $count = 0;                     echo '
';                     while (have_posts()) : the_post();                     $custom_meta = get_post_custom($post->ID);                              if (has_post_thumbnail() && $custom_meta['pr_hidehome'][0] != true) { ?>                             <li class="<?php if (in_array($count, $firsts) ) { echo ' columnFirst'; } if (in_array($count, $lasts) ) { echo ' columnLast'; } ?>">                                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">                                     <?php                                         $atts = array(                                             'class' => "attachment-$size imageBlock",                                             'alt'   => get_the_title(),                                         );                                         the_post_thumbnail('portfolioSmall', $atts);                                           ?>
                                                <?php                             $count++;                         }                     endwhile;                      echo '
 ';                     else :                               echo '
Oops, something went wrong.
';                  endif;                  ?>                                                    pr_hidehome is the option that, when enabled, hides the respective post (but leaves that empty space I'd need to be filled in with one or more of the upcoming thumbnails). You can also see how I am trying to query the posts. However, on this article, I read that the best way to query posts by custom fields is using an array with 'meta_query' in it. So here's what I tried it:                           <?php                  global $wp_query;                      // First row of images                 if(!empty($options['home_thumbs'])) {                     $page_items = $options['home_thumbs'];                 } else {                     $page_items = 18;                 }                      $portCat = get_category_id($options['portfoliocat']);                      // get the desired sort order of portfolio items                 if($options['homepage_sort'] == 'DESC') { $order = 'DESC'; } else { $order = 'ASC'; }                           $args = array(                 'posts_per_page' => $page_items,                 'orderby' => 'title',                 'order' => $order,                 'cat' => $portCat,                 'meta_query' => array(                         array(                             'key' => 'pr_hidehome',                             'value' => 'the_value_you_want',                             'compare' => 'LIKE'                         )                     )                 );                 query_posts($args);                      // arrays to detect first and last columns                 $firsts = array(6,12,18,24,30,36);                 $lasts = array(5,11,17,23,29,35);                 if (have_posts()) :                     $count = 0;                     echo '
';                     while (have_posts()) : the_post();                     $custom_meta = get_post_custom($post->ID);                              if (has_post_thumbnail() && $custom_meta['pr_hidehome'][0] != true) { ?>                             <li class="<?php if (in_array($count, $firsts) ) { echo ' columnFirst'; } if (in_array($count, $lasts) ) { echo ' columnLast'; } ?>">                                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">                                     <?php                                         $atts = array(                                             'class' => "attachment-$size imageBlock",                                             'alt'   => get_the_title(),                                         );                                         the_post_thumbnail('portfolioSmall', $atts);                                           ?>
                                                <?php                             $count++;                         }                     endwhile;                      echo '
 ';                     else :                               echo '
Oops, something went wrong.
';                  endif;                  ?>                                                    Sadly this gave me the fallback error 'Oops, something went wrong'. That's it. I hope I explained myself well enough. If not, I'll try and rephrase everything so that you can help me out! Thank you very much. All help is greatly appreciated ;)


TImthumb not working for absolute path

Tim thumb script is working fine, My issue is with absolute path and relative path. when i give relative path, i get the output. but when i use the absolute path, i am getting 403 forbidden error. I would like to use absolute path. Pleas advise http://crizaze.com/wp-content/themes/joorang/timthumb.php?src=/wp- content/uploads/2011/01/ami166a-e1295733091216.jpg&h=80&w=80&zc=1 Thanks!


Display "Today" Instead of Date for Pubslished Posts

I have a list of `'post_status'' => 'future'` which are published at certain dates throughout the year. These posts are custom posts whith Advanced Custom Fields. Since a couple of days I'm trying to display "Today" of published posts (for that particular day). The word "Today" should only display if date of the post equals the current date otherwise the the scheduled posts should be displayed. The query which looks like this display future posts:                $future= new WP_Query(array(         'post_type' => 'hijama_days',         'date' => date('d/m/Y'),         'posts_per_page' => 1,         'order' => 'ASC',         'post_status' => 'future',     ));      The loop looks like this:               while ( $future->have_posts() ) : $future->the_post();          // next line is from Advanced Custom Field Docs     $gdate = DateTime::createFromFormat('Ymd', get_field('gregorian_date'));      I've tried this to display "Today" when the current event has been pusblished for that day:               $currentdate = new DateTime();
When is the next event date?
     <?php if( $gdate->format('d/m/Y') == $currentdate->format('d/m/Y') ){ ?>
Today
     <?php } else { ?>
<?php echo $gdate->format('l') . ' '; the_title(); ?>
     <?php } ?>
Gregorian: <?php echo $gdate->format('d/m/Y'); ?>
      Somehow I cannot figure why is not working for me. Please help me out here.


Change Parent Name with wp_list_pages?

I use the following line in a code which outputs subpages and a parent. This code outputs the name of the parent page. I would like to replace this with the word "Overview." How do I achieve this in wp_list_pages with as little code as possible? Thanks!               $children = wp_list_pages("title_li=yo&include=".$post->post_parent."&echo=0"); // list the parent page      The full code:               <?php         if ( is_page() ) {         $parent = get_post($post->post_parent);         $parent_title = get_the_title($parent);         $grandparent = $parent->post_parent;         $grandparent_title = get_the_title($grandparent);         $current_page_parent = ( $post->post_parent ? $post->post_parent : $post->ID );              // is the homepage the granparent? = third level page         if ($grandparent == is_page('0')) {             $children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page             $children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable             if ($children) {                 ?>
                   <?php echo $children; /*print list of pages*/ ?>
             <?php             }              // is the homepage the parent? = second level page         } elseif ($post->post_parent ==is_page('0')) {             $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');             if ($children) {                 ?>

<a href="<?php echo get_permalink( $parentid ) ?>">Overview
<?php echo $children; ?>
             <?php             } else {// your else stuff             } } }     ?>


Wordpress pagination with get_posts?

I need to make adjustments to a horribly written WP theme that (a custom theme that was written in tables, and bad code). The theme has several custom templates, but pagination wasn't used and get_posts was used in place of query_posts -                   <?php query_posts('showposts=1'); ?>         <?php $posts = get_posts('numberposts=10&offset=0&category_name=albertsons, carrs, dominicks, genuardis, heb, kroger, pavillions, publix, randalls,safeway,shop-rite,tom-thumb,vons,whole-foods'); foreach ($posts as $post) : start_wp(); ?>         <?php static $count2 = 0; if ($count2 == "10") { break; } else { ?>          ...              <?php $count2++; } ?>         <?php endforeach; ?>      I need to get pagination to work with get_posts, or rewrite the function to use query_posts only, so that I can add `'paged' => get_query_var('page')` When I try to rewrite to only use query_posts, the whole damn thing breaks. Update:               <?php      global $wp_query;          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;               query_posts(array('posts_per_page' => '3','paged'=>$paged,'category_name'=>'albertsons, carrs, dominicks, genuardis, heb, kroger, pavillions, publix, randalls,safeway,shop-rite,tom-thumb,vons,whole-foods')); ?>                         ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      Which shows the loop, but the pagination isn't working. If I click "older posts" the url changes to page-2, but the content is exactly the same.


Can plugins become obsolete?

I presume WordPress plugins are made by third parties. Do plugins have to be kept up to date with WordPress upgrades? Can plugins become obsolete? If they do become obsolete, say with plugins for Linkedin Share buttons, Twitter Tweet buttons, and Facebook Like buttons, would switching to different plugins cause the count of likes / tweets / shares to be lost? And if plugins becoming obsolete is possible, does it tend to happen? Or are plugins generally kept up to date? Or are they open source, so other people would keep them up to date? (As you can probably guess, I'm not a programmer.)


How Do I add a redirect rule to Wordpress?

Right now, I'm able to dynamically generate js and css, based on my theme options To do that i set up a query var, that if present redirects to a php file, which then loads itself as a javascript file. Afterwhich it then takes the jqpostID, and and grabs any options i need to generate my js. I basically have to include a script link that references a location portion of my html http://mywordpress.com/?dynamic=js&jqpostid=130 I'd like to make it more readable, and less apparent that it is being dynamically generated. maybe like this... http://mywordpress.com/dynamic/js/123 i suppose this would even be better... http://mywordpress.com/dynamic/js/123.js I figure i have to hook into the rewrite engine of wordpress somehow. And add a new rule. Any help, or references to other articles would be great, or some sample code would be awesome.


How can I add links to widget titles?

I'm using three widgets, two of them are default WP widgets (Recent Posts and Archives) and the third one is a custom widget which acts like Recent Posts but for a specific custom Post Type. My question is how can I make the widget titles clickable links? It seems that WordPress does not accept HTML in the title field and automatically removes it. Ideally I don't want to do this with a plugin even though I know the likes of Linkable Title HTML and PHP Widget exist. It isn't really what I'm after. The code for the custom widget I have so far can be seen here: http://pastie.org/1847651


Including PHP files doesn't work outside of Localhost

I have a bunch of widgets that I load from php files, like so:   I added a PHP CODE widget and inside wrote:               <?php     include '/wp-content/themes/myTheme/parts/block1.php';     ?>      This worked well on my localhost, but for some reason it stopped working   when I uploaded that website online (and switched the home and site_url of course). Any ideas?


Installing WordPress locally

I'm working on a new WP site. The WordPress installation has already been done on a live server by the ISP and now I need to skin it. I am wondering if I should bring the site down to my local machine and work off that. Having to upload constantly would be rather annoying. I'm a little concerned that I will screw soemthing up. Or... that, even if the local installation goes smoothly, when I re-upload to the live server there will be some conflicts. So what exactly are the steps once I've downloaded everything into a localhost folder?... create a database in phpMyAdmin? Do I go to wp-config.php in my browser?   What other files would need to be modified? I will be using MAMP. I'm very hazy on the database side of things! Is there any danger that my databse setting would interfere with the live installation? e.g Do they have to have the same name? I just don't want to have to approach the ISP guys if I mess up their installation! Thanks!


Get IDs of posts currently visible on archive

This probably is a easy one for many. And also probably is already answered here, but I don't know how to search for it - so sorry I did search but not found anything. I like to get the contents of all posts currently visible on a archive page, during `wp_enqueue_scripts`. If I am right a good solution would be to just `get_post_field('post_content', $post_id)` for all of them. So what I need is just the IDs for the posts that will be displayed on the current archive page. Something that involved `new WP_Query` or `query_posts` I guess, but that a area I never really touched.


Save custom post type in different table

I need to store custom post type post data into a custom table, not in wp_posts and wp_postmeta. Is it possible? anyone help please. Actually, I have created two custom post type named "truck" and "drivers". Then I have created a menu page in wordpress admin. Clicking this menu should list all drivers related to truck. There should be also drag and drop system of this interface so that I can assign any truck to any driver. After sorting, it should update table. So I need a new table for custom post type. ![see my screenshot](http://i.stack.imgur.com/77T0N.png)


How to Remove the "Restore" Link in Quick Edit?

I want to know is there any hook to remove the **`Restore`** link in the edit page - trash page? `/wp-admin/edit.php?post_status=trash` I know I can hide it with a css/jquery trick, but I prefer to use a hook for this. ![enter image description here](http://i.stack.imgur.com/rfwfO.png)


How show image upload whit guest in single post?

I use this code: function.php               function insert_attachment($file_handler,$post_id,$setthumb='false') {            // check to make sure its a successful upload       if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();            require_once(ABSPATH . "wp-admin" . '/includes/image.php');       require_once(ABSPATH . "wp-admin" . '/includes/file.php');       require_once(ABSPATH . "wp-admin" . '/includes/media.php');            $attach_id = media_handle_upload( $file_handler, $post_id );            if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);       return $attach_id;     }      and in custom php file               if ( $_FILES ) {     $files = $_FILES['upload_attachment'];     foreach ($files['name'] as $key => $value) {         if ($files['name'][$key]) {             $file = array(                 'name'     => $files['name'][$key],                 'type'     => $files['type'][$key],                 'tmp_name' => $files['tmp_name'][$key],                 'error'    => $files['error'][$key],                 'size'     => $files['size'][$key]             );                  $_FILES = array("upload_attachment" => $file);                  foreach ($_FILES as $file => $array) {                 $newupload = insert_attachment($file,$post_id);             }         }     }          }      This code I found here: gist.github.com/daltonrooney/1737887 What i want: I want to upload multiple images and to display in the article where I've uploaded. And the first image to be thumbnail If you use `<input type="file" name="upload_attachment[]" multiple="multiple" />` The image appears in the article with the same ID and is displayed as a thumbnail ![enter image description here](http://i.stack.imgur.com/bMRTD.png) If you use two input                <input type="file" name="upload_attachment[]" multiple="multiple" />      <input type="file" name="upload_attachment[]" multiple="multiple" />      Image upload in second input appears in the article with the same ID and is displayed as a thumbnail, and first image apear in other id. ![enter image description here](http://i.stack.imgur.com/ISBZ9.png) Could you tell me about what I can to do upload multiple file and how show to post? First image must be thumbnail. I think we should do something whit _wp_attached_file


Howto put advertising as post number 1,2,3 etc

I would like to put advertising as post number 1,or 2 or 3,etc ( I can pick any number basicly). Anyone know how to do it? So basicly just like post number 1 is normal standard post and then post number 2 is advertising (banner ads,adsense), and then post number 3 is just normal standard post again,etc Help please UPDATE: My current loop code is:
          <?php if( get_sub_field( 'format_main_title' ) ): ?>
<?php the_sub_field( 'format_main_title' ); ?>
         <?php if ( get_sub_field( 'format_sub_title' ) ): ?>         <?php the_sub_field( 'format_sub_title' ); ?>         <?php endif; ?>          <?php endif; ?>          <?php     /**      * Get the format name which will filter the section      * Check if format is standard or something else     **/     $format_name = get_sub_field( 'format_section_name' );          if ( get_sub_field( 'format_section_name' ) == 'standard' ):         $format_args = array(                 'taxonomy' => 'post_format',                 'field' => 'slug',                 'terms' =>  array( 'post-format-video', 'post-format-gallery', 'post-format-audio' ),                 'operator' => 'NOT IN'             );     else:         $format_args = array(                 'taxonomy' => 'post_format',                 'field' => 'slug',                 'terms' => 'post-format-'.$format_name             );     endif;          $posts_to_show = get_sub_field( 'format_posts_per_page' );          if ( get_sub_field ( 'format_pagination' ) == 'pagination_on' ){              $paged = 1;         if ( get_query_var('paged') ) $paged = get_query_var('paged');         if ( get_query_var('page') ) $paged = get_query_var('page');              $wp_query = new WP_Query(             array(                 'post_type' => 'post',                 'posts_per_page' => $posts_to_show,                 'paged' => $paged,                 'tax_query' => array( $format_args )             )         );     } else {         $wp_query = new WP_Query(             array(                 'post_type' => 'post',                 'posts_per_page' => $posts_to_show,                 'tax_query' => array( $format_args )             )         );     }          if ( $wp_query->have_posts() ) :      ?>
              <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>                         <article <?php post_class("grid-4"); ?>>
                              <a href="<?php the_permalink(); ?>">                         <?php                         if ( has_post_thumbnail() ) {                             the_post_thumbnail( 'medium-size' );                         } elseif( first_post_image() ) { // Set the first image from the editor                             echo '';                         } ?>                                                       <?php                         // Add icon to different post formats                         if ( 'gallery' == get_post_format() ): // Gallery                             echo '';                         elseif ( 'video' == get_post_format() ): // Video                             echo '';                         elseif ( 'audio' == get_post_format() ): // Audio                             echo '';                         endif;                         ?>

                            <?php the_time( get_option( 'date_format' ) ); ?>

                             <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                         <?php if( $ti_option['site_author_name'] == 1 ) { ?>                                                      <?php _e( 'By','themetext' ); ?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" rel="author"><?php the_author_meta( 'display_name' ); ?>                                                  <?php } ?>                                               <?php if ( get_sub_field( 'format_excerpt' ) == 'enable' ) { ?>
                         <?php the_excerpt(); ?> uu
                     <?php } ?>
                  <?php endwhile; ?>
              <?php          if ( get_sub_field ( 'format_pagination' ) == 'pagination_on' ){ // Enable/Disable the pagination             ti_pagination();         }          ?>          <?php else: ?>

                 <?php _e( 'There are no posts with this format yet', 'themetext' ); ?>

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


Rewrite rule for admin-ajax.php

I went through a lot of posts and googled a lot, but still couldn't get this to work. I'm trying to create a rewrite rule for admin-ajax.php, to achieve the same results shown here: Adding admin-ajax.php to the frontend. Good or bad idea? However, I don't want to use htaccess file. Instead, I need this to work by dynamically adding a rule (like using add_rewrite_rule), for instance, because the ajax function to be called lies inside a plugin I'm writing and I want to provide a friendly URL to be called. I seem to have followed all best practices regarding that approach. I hooked the rule flush on activation and deactivation hooks of my plugin. Also did the route adding on the init action:               add_rewrite_rule('/api', '/wp-admin/admin-ajax.php', 'top');              All I get are 404's, though. Edit: this is how I'm doing right now:               // rewrite rules and API hooks     add_action('init', array('MYCLASS', 'add_custom_rules'), 1);      add_filter('query_vars', array('MYCLASS', 'add_custom_query_vars'), 1, 1);     add_action('parse_request', array('MYCLASS', 'add_custom_parse_request'), 1, 1);       On add_custom_rules, I do:               add_rewrite_rule('my-api.php$', 'index.php?my-api=1', 'top');      On add_custom_query_vars, I do:               $query_vars[] = 'my-api';     return $query_vars;      On add_custom_parse_request, I do:               if (array_key_exists('my-api', $wp->query_vars)) {         $action = $wp->query_vars['action'];         $API = new myAPI();         $API->{$action}();         exit();     }      What am I still missing? Thanks again.


Image upload with one size going into a custom directory

I have added several sizes with `add_image_size( 'x', y, z );`. All those sizes are saved to the uploads directory, which is alright.               if ( function_exists( 'add_theme_support' ) ) {     add_theme_support( 'post-thumbnails' );        set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions     }     if ( function_exists( 'add_image_size' ) ) {      add_image_size( 'blogimg', 780, 9999 ); //780 pixels wide (and unlimited height)     add_image_size( 'backgroundimg', 1500, 1500 );     add_image_size( 'galleryimg', 900, 900 );     }      Now, one of those sizes, called/slugged "backgroundimg", should be saved directly and automatically to a different custom directory, for example "uploads/backgroundimages". The other sizes/slugs can stay in "uploads". Maybe someone does know a solution? Thank you in advance, guys.


Remove ALL css for a specific plugin page

I'm now writing a plugin that hook with a [TAG] on a page. From now every thing work well except for the custom css. I've writing my plugin on a developement station with basic theme (20-14 I think). When I've put my plugin in the real site, that was very ugly because site theme css where not handle. There is a way to reset or remove all css in a plugin. I ask this because if one day I want to change my theme, I will have to rewrite my plugin to handle more theme css. From now i've tries the hard way with wp_deregister_style('slug').               add_action( 'wp_enqueue_scripts', 'my_scripts_method');                function my_scripts_method() {         //    wp_deregister_style('open-sans-css');     //    wp_deregister_style('rs-settings-css');     //    wp_deregister_style('rs-captions-css');     //    wp_deregister_style('rs-plugin-static-css');     //    wp_deregister_style('wp125style-css');     //    wp_deregister_style('u-design-reset-css');     //    wp_deregister_style('u-design-text-css');     //    wp_deregister_style('u-design-grid-960-css');     //    wp_deregister_style('u-design-superfish_menu-css');     //    wp_deregister_style('u-design-pretty_photo-css');     //    wp_deregister_style('u-design-style-css');     //    wp_deregister_style('u-design-custom-style-css');     //    wp_deregister_style('u-design-responsive-css');     //    wp_deregister_style('u-design-style-orig-css');     //and continue....      But it's doesn't work. Even if this work, I will have to completly re-begin if I change my theme. There is a way to put a reset css like or put everything to 0? Sorry for my bad english, i'm french. Francois


Create a new usermeta field for users

How do I create a new usermeta field with a drop down selection values? Im want to create a conditional statement for all users with a certain value of the new custom field I want. For example, The new field would be: Approved The drop down values are: Yes and No The conditional statement will recognize all users with the Approved field value of Yes. Then it will post a code. Im working with the wp_get_current_user function(), which does exactly what I need, but I just need a new custom usermeta field. In the example the new usermeta field would be "artwork_approved." Example:               wp_get_current_user();     if ($current_user->artwork_approved == 'Yes'){         echo 'Thank you for approving your artwork!';     }      There seems to be no plugin for this and I _really_ need this feature. I would really appreciate some advice on creating a new usermeta with drop down options. Thanks a lot!


'x' Converted to html code in example: 5x10

I've created a page that includes a size such as 5x10 since the given term is something people often Google for, together with some other words. Wordpress is converting 5x10 to: **_& # 2 1 5 ;_**   (without the spaces) Is there any way to prevent this? I suppose that there are places where this feature would be useful but in my case it's hindering my SEO efforts.


Cancel comment filter?

Is it possible to cancel comment submission if certain creteria are met? I want to limit the number of characters in a comment. Where do I test the length and cancel the comment if it's over a given length? Would the pre_comment_approved filter do this? And does anyone have some sample code for how to use pre_comment_approved ? Thanks


Any adverse effects of adding apply_filters to a function?

I'm going back through my older WordPress theme and making the functions filterable and also adding the function_exists checks. Is there anything I'm not thinking about that this may cause problems with existing code?               // Dummy function     if ( ! function_exists( 'custom_func' )) {         function custom_func() {             $output = "Something Awesome";             return apply_filters('custom_func', $output);         }     }      Thanks!


Is it possible to rename a post format?

Since WP 3.1, it's been possible to use Tumblr-style post formats. I want to use the 'aside' option in a theme, but I want it to have a different title in the WP admin area. So, for example, when a user is writing a post, they have the option for the post to be, say, either 'Standard' or 'Quick' -- rather than 'Standard' or 'Aside'. Is it possible to do this without modifying the core? It'd be great if it's something that could be pretty easily done via functions.php or the like. I live in hope... Thanks!


has_term if/echo else/echo function

ok so i have a nav menu with the top level of menu items being static pages. When you highlight or visit one of them there is a sub-menu that pops up. Each one of them has there own sub-menu and each sub-menu is full of custom taxonomy terms. Since WordPress will only give the current-menu-item class on an archive page i need to either add my own class or just add some custom css to show and highlight the term parent when viewing a single item. My problem is I had the code working but then it quit working. See the code below               <?      $has_news = has_term('news');     if ($has_news)         echo '<style type=text/css>#navbar{display:block}';     else         echo '';     ?>      * * * This is related to one of my other questions but I figured it would best be suite under its own with different tags. _**Related Question:_** Highlight nav menu terms _wpversion: 3.1.2_


Javascript Function Called Too Early in PHP Script

I'm working on a Google Maps plugin. My problem is that the function that initializes the map, `csf_map_maker_js()`, is getting called too early-- before the div is defined (at least that's what I think is the problem). In the PHP, I've got:               $csf_map_output .= '

';           $csf_map_output .= '';            return $csf_map_output;      I don't think that the `csf_map_canvas` div is ready when the function is called. In the javascript script, the `csf_map_maker_js()` function is defined outside of `jQuery(document).ready(function() {});` . If I move it inside, will the `csf_map_canvas` div be ready when the function is called.? If so, how do I change the function call in the PHP script in order to call a function in an anonymous function? How do I get around the scope issue? Is there another way?


Proper way to create taxonomy queries

How to build taxonomy queries dyniamically? I have this code for dynamically creating an array for color and price:               $color = $_POST['color'];     $price = $_POST['price'];          if (!empty($color)) {         $query_color =  array(                             'taxonomy' => 'color',                             'field' => 'term_id',                             'terms' => $color             );     } else {         $query_color = array(                         'taxonomy' => 'color',                         'field' => 'term_id',                         'terms' => ''         );     }          if (!empty($price)) {         $query_price =  array(                             'taxonomy' => 'price',                             'field' => 'term_id',                             'terms' => $color             );     } else {         $query_price = array(                         'taxonomy' => 'price',                         'field' => 'term_id',                         'terms' => ''         );     }      And I have this code for a query:               $args = array(             's' => $search,             'post_type' => array( 'post' ),             'posts_per_page' => 99999,             'tax_query' => array(                 'relation' => 'OR',                 $query_color,                 $query_price,             )     );     $wp_query = new WP_Query( $args );      But, it's not working good. It always shows all posts ad not just the things from the $color and $price array. Any idea what am I doing wrong?


How to loose the image 'alt' attribute in my custom post type?

I've created a custom post type but now I cannot seem to figure out how to loose the image name (under the image) once a project is opened. When a project is clicked all I need it to show except for the image would be the projects name and the tweet link. Link to the test site. In my functions.php I have:               <?php          require_once('portfolio-type.php');     add_filter('excerpt_length', 'my_excerpt_length');          function my_excerpt_length($length) {     return 25;      }          add_filter('excerpt_more', 'new_excerpt_more');       function new_excerpt_more($text){            return ' ';       }            function portfolio_thumbnail_url($pid){     $image_id = get_post_thumbnail_id($pid);       $image_url = wp_get_attachment_image_src($image_id,'screen-shot');       return  $image_url[0];       }     ?>      In portfolio-type.php:                <?php           if ( function_exists( 'add_theme_support' ) ) {      add_theme_support( 'post-thumbnails' );     set_post_thumbnail_size( 270, 170, true ); // Normal post thumbnails     add_image_size( 'screen-shot', 720, 540 ); // Full size screen      }           add_action('init', 'portfolio_register');             function portfolio_register() {        $args = array(           'label' => __('Portfolio'),           'singular_label' => __('Project'),           'public' => true,           'show_ui' => true,           'capability_type' => 'post',           'hierarchical' => false,           'rewrite' => true,           'supports' => array('title', 'editor', 'thumbnail')          );            register_post_type( 'portfolio' , $args );        }            register_taxonomy("project-type", array("portfolio"), array("hierarchical"  =>  true, "label" => "Project Types", "singular_label" => "Project Type",   "rewrite" => true));      ?>      And finally in my index.php I have:
                                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                                      <?php                                     $title= str_ireplace('"', '', trim(get_the_title()));                                     $desc= str_ireplace('"', '', trim(get_the_content()));                                 ?>
                                      <a class="project-wrp fancybox" title="<?=$title?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>">

f
<?php the_post_thumbnail(); ?>

<?php echo $title; ?>

<?php echo $desc; ?>

                             <?php endwhile; endif; ?>


Anyway to retrieve a feed of posts that have BOTH tags?

If I use the URL "/tag/tag1,tag2/feed", it will retrieve posts that have both tags. Is there anyway to do this and just get posts that have BOTH tag1 and tag2?


Add specific custom fields to post formats

I am trying to find a simple way to customise my wordpress backend and register different custom fields for each post formats. I know this is easy to do with custom post types but is it at all possible to register different custom fields for the post format video than the post format audio for example? I could not find anything in the wordpress codex or on any google search Want to achieve this via code not a plugin, any ideas as to which functions to hook into?


How to write a plugin to add users to a mail list

I run a multi-site blog with about 300 sites. I have an idea that I want to write a plugin that in order to add all administrators of blogs to a MailMan mail-list. I just want administrators though, I don't want to add editors and subscribers to this email list. I want to capture the event of being assigned an administrator of a blog. Then I'll send an email to the subscribe email address of my mail list to automatically add the person. So I was wondering which hook should I use ? I think I want to send an email every time a person is set as an administrator. I don't care if they are removed as an administrator.


woocommerce product categories in menu

I am using woocommerce plugin, and added some product categories in appearance->menu. I mentioned that if I logging off, the product categories is not showing at all... please help. sorry for bad english.


Changing WordPress sort order for returned child pages

I have a custom `WP_Query` that looks like this:               $this_page_id=$wp_query->post->ID;       $images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id ) );      My problem is that when using the `orderby` parameter (see here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) to sort by `menu_order` (which I need to do for the project). The sort order is not working. I'm 99% certain the reason it's not working is because I'm directing it to query all children of a specific post and the `orderby` parameter doesn't "dig that deep into the query" if that makes sense to anyone. Can anyone offer some help? doing this (the expected solution yields nothing):               $this_page_id=$wp_query->post->ID;           $images = new WP_Query( array( 'post_type' => 'menu-item', 'post_parent' => $this_page_id, 'orderby' => 'menu_order' ) );


Search results - need help

When I search, it's working, I get a result entry like this: > FA Example and Sons a: 2240 Example Road, Bentley FL 34744 t: 407.281.3345 > e: info@example.com w: www.example.com h: 9:00am - 6:00pm Mon - Fri & > 10:00am - 3:00pm Sat But, what I would like it to display the search results like the following: > FA Example and Sons   >  a: 2240 Example Road, Bentley FL 34744   >  t: 407.281.3345   >  e: info@example.com   >  w: www.example.com   >  h: 9:00am - 6:00pm Mon - Fri & 10:00am - 3:00pm Sat   > Is there anything I can do to make this happen? I've put in hard returns, using `<br/>` and I've tried bulleting the entry, but nothing works. Any help would be great.


pre_get_posts OR relation between taxonomy and author

I have a custom taxonomy called `coauthor`. On the `edit.php` screen, I am trying filter and only show posts authored by the current user **OR** posts coauthored by the current user. I can get the posts **_authored_** by the current user:               function get_authored_posts($query) {         global $user_ID;         $query->set('author',  $user_ID);         return $query;     }     add_filter('pre_get_posts', 'get_authored_posts');      I can also get the posts **_coauthored_** by the current user:               function get_coauthored_posts($query) {         global $user_ID;         $user = get_userdata($user_ID);         $query->set('taxonomy', 'coauthor');         $query->set('term', $user->user_login);         return $query;     }     add_filter('pre_get_posts', 'get_coauthored_posts');      I believe the results yield posts authored **AND** coauthored by the current user. I am looking for posts authored **OR** coauthored by the current user. I am expecting the results from the first and the results from the second to be displayed. Note: To clarify, _coauthors_ are stored as terms as part of the `coauthor` taxonomy. The term is the user_login value. == EDIT == I am currently storing the author as a coauthor. I feel like this is a "work around" for a better solution. How/Can I use a direct query (ignoring the WP_Query object) and return that from the pre_get_posts filter?


WordPress Multisite Completely FUBAR?

My instance of a WordPress Multisite is completely screwed up. I was having very slow loading times on pages and admin sites. Thought if I upgraded to WordPress 3.2.1 things might (fingers crossed) resolve themselves and it has only seemed to make things worse. I think the problem may have been a plugin that grabbed other posts from another WordPress blog (that is on the same domain but not same WordPress instance) and inserted those posts into a site on the current multisite instance that is screwed up. From what I have read this has caused big problems for other multisite users. Unfortunately I can't seem to recover from the original problem of slow loading pages. I cheked on mysql and the WordPress tables don't seem to be corrupt. I deactivated all plugins and still seem to have this issue. So i tried upgrading to 3.2.1 and now I can't even really get to some Admin pages for sites, other still slow loading. What would be my best course of action? I do have a copy of the DB pre update as well as a copy of all WordPress files. The thing I thought to do was to revert back to 3.19 and export each site, start with a fresh install of 3.2.1 and then import each site. Anyone have any better ideas which are less time consuming? Better ideas in general? Im running Apache 2.2.20, PHP 5.2.17 and Mysql 5.X on a Windows Server. Hosted by me. The rest of the site is not slow at all and I have other WordPress sites workign


Custom Post Type Next/Previous Link?

I have a custom post type called portfolio. I need a previous/next link WITHOUT a plugin. Anybody have a solution? Example post: http://themeforward.com/demo2/archives/portfolio/boat               <?php get_header(); ?>

               <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
         <?php the_title(); ?>
               <?php the_content(); ?>
         <?php the_tags('Tags ',' / ','
'); ?>

             <?php previous_post_link('%link', '« Previous post', TRUE); ?>

             <?php next_post_link('%link', 'Next post »', TRUE); ?>

          <?php endwhile; else: ?>
No matching entries found.
     <?php endif; ?>

     <?php get_footer(); ?>


How to restrict access to uploaded files?

I have a restricted area on a website that can only be accessed by logged in users. For that I created a page template with a 'current_user_can()' condition. My problem is that the documents attached to the restricted pages are still accessible to anyone if you put the complete path into the browsers address bar. Is there a way to restrict the access to uploaded files ? EDIT : I want to clarify, the files should be accessible only to logged in users.


Link posts together (relative, not grouped)

I have a Custom post type called 'Stories', which holds 'stories'. I need a way to link stories together. For example, i have Story A. I need a way to define story B as a relative to story A. I could do this with taxonomies, but i need a more 'relative' way not a 'grouped' way. Any ideas?


Admin Bar CSS left over after removal

I am using the following code to remove the admin bar (client request).               add_filter( 'show_admin_bar', '__return_false' );      Trouble is, it leaves some autogenerating CSS, which places a massive white line at the top of my page in its place (via a 28px top margin rule). How can I turn this off as well?


shortcode help require

i am having a wordpress function to display the latest 5 tweets of the user, this tweets can be displayed by two ways one is through direct entering the user ID in admin menu which i created, and second is through custom fields, here i want to avoid custom fields and want to start with shortcode, i know i am weak in short-code cause this is my second question related with it but need short-code in this function here is the code               function tweet_fetcher(){     global $post;     $doc = new DOMDocument();     if((get_option('tweetID'))!=null){     $meta=get_option('tweetID');     $feed = "http://twitter.com/statuses/user_timeline/$meta.rss";      $doc->load($feed);           }     elseif((get_option('tweetID'))==null){     if ( $meta =get_post_meta($post->ID, 'username:', true) ) {      $feed = "http://twitter.com/statuses/user_timeline/$meta.rss";      $doc->load($feed);      }     }            $outer = "
";       $max_tweets = 5;          $i = 1;       foreach ($doc->getElementsByTagName('item') as $node) {         $tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;         //if you want to remove the userid before the tweets then uncomment the next line.         //$tweet = substr($tweet, stripos($tweet, ':') + 1);            $tweet = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@',                '$1', $tweet);         $tweet = preg_replace("/@([0-9a-zA-Z]+)/",                "@$1",                $tweet);              $outer .= "
". $tweet . "
\n";                   if($i++ >= $max_tweets) break;       }        $outer .= "
\n";       return $outer;     }     function append_the_content($content) {                  $content .="
Latest Tweets".tweet_fetcher($meta)."
";          return $content;                  add_filter('the_content', 'append_the_content');                  require_once ('tweet-fetcher-admin.php');


More tag - how do I remove preceding <br>?

Can anyone advise on how I can remove the preceding `<br>` tag when a post's "read more..." tag is generated? Any advice appreciated! This is the code that's generated -
blah blah blah blah
       …Read more
      It's that annoying little   I want rid of, so the "read more" is on the same line...!


Displaying different page links on different pages

I have a wordpress site with 100+ pages. Now suppose 5 pages are related to page 1, and I want to show them in side bar as similar pages/related pages and other group of pages in other menu in sidebar. There is no child-parent relationship between these pages all are in root including homepage. Same goes for other pages also, they all have to show different pages as related and other pages in sidebar. So every page has different links under sidebar grouped in two different menu, one related pages other other pages. The possible solution i found is using these plugins;   1. Dynamic Widgets , in this case i create lot of custom menu and show them on pages in custom menu widget and control by this plugin. Very tedious job, I have to create more than 20 custom menu.   2. Flexi Pages Widget , In this case i create several page widgets(more than 20) and control with Dynamic Widgets to show them on different pages. Now both solution i find not look good to me, any suggestions on this? One more solution come to my mind is go in PHP/code and create different sidebars, but not look feasible to me. You valuable reply in this regard is highly appreciated. Thanks in Advance! Update: Using advance custom fields plugin, with relationship fields.


add JS to multiple plugin admin pages

For a WP Theme with multiple admin screen (got its own main menu and some submenus), I want to add a common Js script to load on (only) all these pages. I know how to acheive this using the pagehooks of the individual (sub)pages lioke this:               add_action('admin_print_scripts-' . $page, 'my_plugin_admin_script');      but this way I need to reåeat this for each admin page (for each submenu pagehook) Is there a way smarter way to add the scripts, testing for the PARENT menu? so that I just need to add it with one line of admin_print_scripts-* code?


Breaking the loop?

WP loops are widely used to print lists of posts in Wordpress:               <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'ff' => 'show_ff', 'orderby' => 'menu_order', 'order' => 'ASC' ));          while ( $loop->have_posts() ) : $loop->the_post(); ?>                               <?php endwhile; ?>        Is there a way of displaying for example 3 first posts then some element (div in my case) and again 3 next posts? I know I could do 6 loops in each div, but maybe there's another way of breaking this code? Maybe some if loops inside of while loop? Here's my concept:               (...)         while ( $loop->have_posts() ) : $loop->the_post();           echo '3 first posts';          echo '

';          echo '3 last posts';         endwhile; ?>


How to use author meta in shortcode?

I am trying to create a shortcode that will return a link to a book on Amazon with a specific affiliate tracking code specific to the author. I created a user option called "amz" to hold the author's tracking code. This works fine when I'm using it elsewhere. This is the shortcode I created: ` function amazon_link_function($atts, $content = null) { extract(shortcode_atts(array( 'isbn' => ' ', 'title' => ' ' ), $atts));                 $amztrack = the_author_meta( 'amz' );            return '' .$title. '';      } add_shortcode("amazon", "amazon_link_function"); ` The isbn and title values return properly, but the tracking code stored in the $amztrack variable is displayed as plain text _before_ the paragraph the shortcode is used in:( I also tired this for the return line and got the same result:                 return '' .$title. '';


learn to run wpdb class

I want to learn how to run commands through WP rather than SQL commands I have a SQL command:               SELECT     post_id,     (select meta_value from wp_postmeta where meta_key = a 'geo_latitude' AND x.post_id = a.post_id) as lat is NOT NULL,     (select meta_value from wp_postmeta where meta_key = b 'geo_longitude' AND x.post_id = b.post_id) as lon is NOT NULL,     (select meta_value from wp_postmeta where meta_key = c 'address' AND x.post_id = c.post_id) as the address is NOT NULL     FROM elreal_postmeta x group by post_id, lat, lon, address      Can I run this command into the `wpdb` class?


pre_get_posts and BBPress in Swagger Theme

In the theme I'm using there is a custom.php file where the following code issues a pre_get_post function which adds the custom post types to the original query object. I've learned that you cannot conditionally load this... and it is breaking BBPress pages on forums.php by refusing BBP to fully load certain post types (topics, forums etc).                 if (!is_admin()){              add_filter('pre_get_posts', 'query_post_type');              function query_post_type($query) {                    global $oswcPostTypes;                    if(empty( $query->query_vars['suppress_filters'] ) ) {                 $post_type = get_query_var('post_type');                      global $oswc_reviews;                    // BEGIN CULPRIT CODE                  if($post_type ) {                     $post_type = $post_type;                     $query->set('post_type',$post_type);                     return $query;                   // END CULPRIT CODE                      } elseif(!is_page() && !is_preview() && !is_attachment() && !is_search() ) {                         $post_type = array('post');                     foreach($oswcPostTypes->postTypes as $postType){                         array_push($post_type, $postType->id);                     }                     $query->set('post_type',$post_type);                     return $query;                 }                  }             }         }      Thanks in advance, this is a tough one. EDIT: Fixed thanks to Brian McCulloh. He sent me his new theme which had a revised PGP function. The old one WAS keeping certain post types from the query, such as forum and topic PT's... Corrected Code:               if(!is_admin()) {            add_filter('pre_get_posts', 'query_post_type');         function query_post_type($query) {           //get review types           global $oswcPostTypes;               if(empty($query->query_vars['suppress_filters'])) {             $post_type = get_query_var('post_type');                      if(!$post_type && !is_page() && !is_preview() && !is_attachment() && !is_search()) {                     $post_type = array('post');                 foreach($oswcPostTypes->postTypes as $postType){                     array_push($post_type, $postType->id);                 }                 $query->set('post_type',$post_type);                 //the returned array contains the "post" post type and all of the user-defined review types                 return $query;                           }           }         }     }


wp_nav_menu including Skype URL

If I try to add a skype username as the URL for a wp_nav_menu item, the item is saved but the URL is not. The username URL is in the following format: skype:example?call Any thoughts on add skype: as an acceptable protocol? Thanks.


Does anyone know what's the plugin for this Comment Section?

http://twentyelevendemo.wordpress.com/readability-test/ The default Twenty Elevn Theme's shwocase site has a nice comments section (see link above) that allows user to connect to other services for authentications (like twitter) to comment. It's nice in a way that it doesn't seems to relay on other third party plugin like Disqus to manage my site's comment. Anyone know what's this plugin is called ? The default Twenty Eleven has a different comment section (layout and method to comment). I'm looking for the one from the showcase site, can't find any info regarding the comment section. Thanks !


How Can I Query a Specific Page From a MultiPage paginated Post

Let's say I have a post that has been paginated by adding the                <!-- nextpage -->       code provided by wordpress for this purpose. How can I then query a specific page from inside of that post. Say for instance I only want to query the contents of page 2 and there are 10 posts. Is there a way to do it?


get_post_meta in one post only

I have a rough demo here to try and illustrate my problem. http://www.ttmt.org.uk I have six pages with titles - Page One, Two etc. On a index/home page I'm creating a btn/div to link to each page. On one of the btn's I want to put an extra label/mark. On the page connected to that btn I have created a custom field with the name of label. In the loop I am checking for this custom field with get_post_meta. If it's there I'm adding a to the div. My problem is the is added to the other div's after the after the div/page that has the 'label' custom field. In the example page http://www.ttmt.org.uk I want the added label on Page Three but it also appearing on the after that.                   <?php                  $frontAgrs = array(                 'post_type' => 'page',                 'tag' => 'group',                 'orderby' => 'menu_order',                 'order' => 'ASC'             );                  $frontLoop = new WP_Query($frontAgrs);                  if($frontLoop->have_posts()):                 while($frontLoop->have_posts()):                     $frontLoop->the_post();                  if(get_post_meta($post->ID, 'label', true) != ''){                 $label = get_post_meta($post->ID, 'label', true);                 $label = ''.$label.'';             }                     $btnName = get_the_title();              ?>              <?php echo '
ID).'">'.$btnName.''.$label.'
' ?>                   <?php endwhile; endif; ?>              <?php wp_reset_postdata(); ?>


Pagination of Custom Post Types not Changing Posts

I have a custom post type, jobs, being displayed on an external page using WP_Query() - the query itself is working fine. However when I try to paginate the results, the older/newer links show up, but when I click on them, the content doesn't change - ie the page 'number' changes in the URL & the page reloads, but the posts don't move on. I've tried using Wordpress' default next_posts_link & previous_posts_link and also with the wp_pagenavi plugin. In the code below I'm using wp_pagenavi . Here's my code:               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                  $params =              array(  'post_type'          => 'job',                  'post_status'        => 'publish',                 'posts_per_page'     => 3,                  'paged'=>$paged             );                  $temp = $wp_query;             $wp_query= null;             $wp_query = new WP_Query();                       $wp_query->query($params); ?>            <?php if (function_exists('wp_pagenavi')){ wp_pagenavi(); } ?>            <?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>          // doing things with the post           <?php endwhile; endif ?>      <?php $wp_query = null; $wp_query = $temp; wp_reset_query() ?>      Any help would be greatly appreciated it - this is driving me up the wall! ^_^


Limit multisite/network site names to a property of the user

We need to limit the blog names users may choose when they create their own blogs. We have a WordPress Network configured to have all blogs share a domain name. E.g., **domain.name.com/x** , **domain.name.com/y** , etc. We have integrated our WordPress Network with our corporate Active Directory using the Active Directory Integration plugin. That plugin puts the user's **mailnickname** attribute (the part of the email address before the `@`) into the **nickname** field. I would like to allow users to self-create their own blogs but restrict blog names names so that it must match the **nickname** field of their WordPress account. E.g., a user with nickname **jdoe** could only create a blog named **domain.name.com/jdoe**. Ideally, on **/wp-signup.php** , it would be best if the **blogname** field doesn't even display. Is there a way to do this without PHP customization? I was hoping a plugin would already exist, but I can't find one.


Update Custom Field on Imported Post Creation

So I've created a function that updates several custom fields in a post when the post is created. The idea is to sanitize this information so that I can easily use it for other purposes. The function works fine when I create a post manually. However, I import hundreds of posts directly in to the site (using WP All Import), and for these posts that are imported, it seems that this function does not apply. Currently I'm using the 'save_post','publish_post', and 'new_to_publish' hooks to try to accomplish this. However none of them seem to work. Am I missing something? Is there a better way to accomplish this? Here's abridged version what I have thus far:               add_action( 'save_post', 'sterilize_vehicle_information' );     add_action( 'publish_post', 'sterilize_vehicle_information' );     add_action( 'new_to_publish', 'sterilize_vehicle_information' );     function sterilize_vehicle_information( $post_id ) {         $internet_price = get_field('internet_price',$post_id);         update_post_meta( $post_id, 'internet_price', preg_replace( "/[^0-9]/", "", $internet_price ) );     }      Thanks for the insight!


wp_insert_term is adding a term that has no name

I'm trying to insert a term for a custom taxonomy and a custom post type in Wordpress. The problem I'm running in to is that it successfully inserts a term, and at the right hierarchy level, but the term has no name. The line that inserts the term is:               $lasttermarray = wp_insert_term($categoryname, "department", array( "parent" => $parentcategory ) );      I've checked to make sure that both $categoryname and $parentcategory are set to the right values. Like I said, the term is being inserted, just with a blank name. The slug of the blank term is being set to the ID of the new term. Is there any reason why the function would not be reading the name variable and causing it to do this? Thanks for your help.


<p> tag the_content()

I'm trying to configure my content-page.php but i'm struggling with a few 'mistakes'.               <article id="post-<?php the_ID(); ?>">

<?php the_title(); ?>
     **
     <?php the_content(); ?>
**

      This is my css content               .page_content     {         width:820px;         height:auto;         margin-bottom:50px;     }          .page_tekst     {         text-align:justify;         float:left;     }      This is the result in my browser

test

This is a test based on the current css code

      My css on the .page_tekst won't work. I also understand why but is there a solution for it? Can you make a div or p tag, give it a call and put the content in this tag without making another P tag with the content?


Convert usernames listed by the Groups plugin shortcode to displayed names?

I have created a group with the Groups plugin and I want to display the members list of that group. I put the shortcode `[groups_group_info group="Group Name Here" show="users"]` in a page, but it displays only the usernames of members, like this:   * username1   * username2   * ...   * usernameX I want to display their names (`display_name`), but the plugin do not have this option (I have not found it). I opened a thread at the plugin support page, but I do not received an answer yet. **My question is:** Is possible to change the usernames listed by that shortcode with their corresponding displayed names (or first - last name) + some user metadata? Bellow is the original code that renders the shortcode `[groups_group_info group="Group Name Here" show="users"]`:               add_shortcode( 'groups_group_info', array( __CLASS__, 'groups_group_info' ) );          public static function groups_group_info( $atts, $content = null ) {         global $wpdb;         $output = "";         $options = shortcode_atts(             array(                 'group' => '',                 'show' => '',                 'format' => '',                 'single' => '1',                 'plural' => '%d'             ),             $atts         );         $group = trim( $options['group'] );         $current_group = Groups_Group::read( $group );         if ( !$current_group ) {             $current_group = Groups_Group::read_by_name( $group );         }         if ( $current_group ) {             switch( $options['show'] ) {                 case 'name' :                     $output .= wp_filter_nohtml_kses( $current_group->name );                     break;                 case 'description' :                     $output .= wp_filter_nohtml_kses( $current_group->description );                     break;                 case 'count' :                     $user_group_table = _groups_get_tablename( "user_group" );                     $count = $wpdb->get_var( $wpdb->prepare(                         "SELECT COUNT(*) FROM $user_group_table WHERE group_id = %d",                         Groups_Utility::id( $current_group->group_id )                     ) );                     if ( $count === null ) {                         $count = 0;                     } else {                         $count = intval( $count );                     }                     $output .= _n( $options['single'], sprintf( $options['plural'], $count ), $count, GROUPS_PLUGIN_DOMAIN );                     break;                 // @todo experimental - could use pagination, sorting, link to profile, ...                 case 'users' :                     $user_group_table = _groups_get_tablename( "user_group" );                     $users = $wpdb->get_results( $wpdb->prepare(                         "SELECT * FROM $wpdb->users LEFT JOIN $user_group_table ON $wpdb->users.ID = $user_group_table.user_id WHERE $user_group_table.group_id = %d",                         Groups_Utility::id( $current_group->group_id )                     ) );                     if ( $users ) {                         $output .= '
';                         foreach( $users as $user ) {                             $output .= '
' . wp_filter_nohtml_kses( $user->user_login ) . '
';                         }                         $output .= '
';                     }                          break;             }         }         return $output;     }


Query custom post types and a specific page?

I'm using this query `WP_Query('post_type=product&posts_per_page=8')` I need to include a specific page into the query but not sure how to add it since I'm only specifying the custom post type? Is it possible to add in a page?


Remove "Continue Reading" Link From the Teaser Excerpt Only

I want to remove the "Continue Reading" link from the teaser excerpt only and not from the automatic excerpt, which filter is easily available. This is the original code; it's from the Showcase Template Page Template:                   <?php while ( have_posts() ) : the_post(); ?>          <?php         if ( '' != get_the_content() )             get_template_part( 'content', 'intro' );     ?>          <?php endwhile; ?>      Here is the Intro:
         <?php the_content(); ?>         <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'mytheme' ) . '', 'after' => '
' ) ); ?>         <?php edit_post_link( __( 'Edit', 'mytheme' ), '', '' ); ?>
      -->


Shortcode for a link and thumbnail

<?php               // Add Shortcode     function blog_shortcode( $atts ) {          // Attributes     extract( shortcode_atts(         array(             'id' => '',         ), $atts )     );          // Code     if (has_post_thumbnail()) {         $url = wp_get_attachment_url( get_post_thumbnail_id( $id ) );     }     if ( isset( $id ) ) {         return '' . get_the_title( $id ) . '';     }          }     add_shortcode( 'blog', 'blog_shortcode' );               ?>      I'm trying to make a shortcode to where I can basically type [blog id="xxxxxx"] and I'll get a link and thumbnail. Right now I'm getting the link but the thumbnail isn't working. I don't think I fully understand how to get the thumbnail ID to become a url for the  tag. Any help will be appreciated.


Is it possible to create a form post wordpress custom navigation link?

I work with a church that has a donate button on their site. The button uses a form post to connect with their simple checkout item and they want a button on the navigation to link to the donation page as well. ![navigation linke](http://i.stack.imgur.com/xQJ6o.jpg) How do I create this link that will do this, is this possible? Or will I need to create a static button?


How to remove 'wordpress...' text from page titles in tabs

I am working on a site and sometimes I run into an error when logging out and on the site tab it says 'Wordpress Failure Notice'. I am trying to remove all instances of wordpress so users dont know Im using it, but I can not figure out how to remove the text from the tab. I dont have no code to try and show because Im not even sure where to start. The text shows up on the wp-login.php page and happens when trying to log out. That's all I know. So my question is how would I remove this, and change the text to something different? Thanks


wp_trash_post not firing

I want to call a function when a post is placed into the trash. I want to do something more complicated than the following, but have simplified to what's below just to see if it'll work and it doesn't.               function gna_my_function() {         echo 'trashed ';     }     add_action('wp_trash_post', 'gna_my_function');      Thanks


GravityForms to Salesforce API, problem with people who leave out company

I use GravityForms in my WordPress site, and have the GravityForms to Salesforce API plugin that adds people who fill out a form as leads in Salesforce. It works fine, except for when people don't enter a company name. Is there a way to have it default to their full name if they don't enter a company? Here's my code. I added alert boxes to help debug, but they don't even run!               add_filter('gform_after_submission_1', 'create_company_full_name', 10, 4);      function create_company_full_name($entry, $form){          $field_we_are_checking = '77';          $name = $entry['1.3'].' '.$entry['1.4'];               if(empty($entry[$field_we_are_checking])){              $entry[$field_we_are_checking] = $name;          }          return;     }       http://www.gravityforms.com/ http://wordpress.org/plugins/gravity-forms- salesforce/ UPDATE: Here's the code that worked in the end:               add_filter('gform_pre_submission_1', 'create_company_full_name', 10, 2);     function create_company_full_name($entry, $form){         $field_we_are_checking = 'input_77';         $name = $_POST['input_3'].' '.$_POST['input_4'];         if(empty($_POST[$field_we_are_checking])){             $_POST[$field_we_are_checking] = $name;         }         return;     }      where 1 (from `gform_pre_submission_1`) is the id of the form and `input_77`, `input_3`, and `input_4` refer to the IDs of the fields in question (company, first name, last name)


Is it acceptable for a WordPress theme to not accept widgets?

I'm developing my own WordPress theme, and I was going through the Theme Unit Test as described by the Wordpress Codex. Now, at some point, the Codex mentions that I should verify that > All widgets display correctly Now, on the other hand, I have seen in the Widget help page that is instructed for users to verify if their theme supports widgets at all. So, **is it ok if my theme does not support widgets?** My goal is to have it published at some point and available to users through the Wordpress.org site, but since the design is quite minimal, I had decided not to support widgets. Am I asking too much?


Is there any way to rename or hide wp-login.php?

Any way to change the wp-login.php url? It seems insecure that everyone that's ever used Wordpress could easily see if your site is using it, and get right to the login page. There used to be a plugin called "Stealth login," but it wasn't updated. (And hence our reluctance to rely on plugins).


Passing page url into a custom field via the Press-This bookmarklet

Howdy, WordPress Answers Community! Here's my situation. I want to use a modified version of the Wordpress Press- This bookmarklet to pass the current page URL to a custom field on my post. In this case, lets say my custom field is linked_list_url. I'm guessing there are four pieces to this:   * Add a custom input field to the page generated by the bookmarklet   * Grab the URL of the page the bookmarklet was used on and store it   * Pass the stored URL to the custom input field    * Pass the contents of the custom input field to wordpress, setting it as the key for the custom field I've modified the bookmarklet to have a custom input field and it's pulling the URL off of the page and passing it to the input box, but when I submit the bookmarklet, nothing is passed to Wordpress. Here's my press-this custom bookmarklet: http://pastebin.com/UjNkpNrE **Specifically: Once I have the URL passed to the custom input field in the bookmarklet, how should I go about having the contents of that field passed to wordpress into the custom field linked_list_url??** Thanks!


if plugin is active? check wheter plugin is enabled or not?

I'm using the mingle plugin and the mingle-forum plugin. I want to show a certain part on my site only if those two plugins are active. How can I solve this?               <?php if ( is_plugin_active('mingle-forum') ) { ?>
<?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?>
                     <?php } ?>      This throws a php error. Call to undefined function is_plugin_active Any idea what I'm doing wrong? update:               <?php if ( plugin_active('plugin-directory/mingle-forum/wpf-main.php') ) { ?>
<?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?>
                     <?php } ?>


specify meta_key / meta_value condition for prev_post_link and next_post_link

I've got a custom post type (CPT) called `event`. Every event has got an associated `meta_key` called `event_date`. I want to make sure that events with empty `event_date` won't appear in my list of all events and in the prev/next event navigation when viewing a single event. I also want to order events by the `event_date` meta_key. I managed to exclude events with empty `event_date` and order them correctly in the overall list of events by hooking into `pre_get_posts` hook. Is it possible to hook into `prev_post_link` and `next_post_link` functions to specify `meta_key` select condition and `meta_key` order condition without the plugin? Is there a hook for it?      [P.S. note]: I also tried using Ambrosite Next/Previous Post Link Plus plugin. I figured out how to order events by meta_key. However, the events with empty `event_date` meta_value are still appearing in the prev/next navigation when viewing a single event. It doesn't seem to be possible to hook into WP before the plugin, because I think it constructs its own SQL. I could use `ex_posts` with the list of all the event ids to exclude, but that would mean extra query to the db. Many thanks, Dasha


Is It Possible To Have Shared Wordpress Custom Post Types?

I am developing a website for a record label and the basically it uses quite a few custom post types for various pieces of information. My problem is that I feel the same bits of information are being repeated, rather than shared. I have an artists custom post type, however on the homepage there is a carousel with artists as well but different pieces of information to display. So I have a "homepage carousel" custom post type of which I have to enter the artist names and info, as well as an image and also an "artists" custom post type with some of the same information entered again. The client is probably not going to like having to enter the same information into multiple custom post types all of the time, is it possible to make a post type inherit from another? So I can tell my "homepage carousel" post type to inherit from an artists post type so the artist information is shared and doesn't have to be re-entered again? At present I have created a custom taxonomy called artists and entered in all possible artist names and then for example in the "homepage carousel" post type I select the artist in the right hand side as being the category. This works well in a way, however you still need to enter a title or you get some "Autosave" nonsense being saved as the title which will make editing and sorting difficult down the track. Is there perhaps a way to set the title as the category "artist" that has been selected? Let me know if you don't quite understand and I'll try and elaborate a bit more. I basically want to share a centralised list of artists and information of which I can inherit from in other post types. *** Update *** A bit more elaboration on my original question. Here are my defined post types and the information that they hold. What I want to do is set up a shared relationship between my "artists" post type and other post types that relate to the artist in some way. **Post type** : artists   **Fields** : Title, Wysiwyg Editor, Featured Image, Facebook URL, Twitter Username, Website URL. **Post type** : homepage_carousel   **Fields** : Title, Learn More Link, Buy CD Link, Buy MP3 Link A carousel item corresponds to an artist defined in the artists post type above. So the ability to relate this post type to the artists post type is what I want. **Post type** : videos   **Fields** : Title, Video Embed Code (455px), Video Embed Code (466px), Video Embed Code (608px), Video description. A video item corresponds to an artist defined in the artists post type. I want to be able to assign a video to an artist. As you can see I want to basically set up a many-to-one relationship or is it one-to-many relationship? One of those (I think). I've started messing with this plugin: http://wordpress.org/extend/plugins/posts-to-posts/ - but I don't quite understand how to properly use it yet, I think it's something that I want. So if someone has used this before, your help would be appreciated. Whilst I am aware of custom taxonomies and terms, I think that what I am wanting goes way beyond the requirements I am seeking as I am dealing with multiple pieces of information and merely want to tie 2 post types together some how.


AJAX filter posts on click based on category

This is my first foray into AJAX, I've been splicing bits of code from various tutorials which probably hasn't helped. I have a list of categories on my homepage (index.php) and a list of the most recent posts. When a user clicks on a category I want this list of posts to be updated without refreshing the page. Currently when I click a filter all the posts are being loaded into my response container (it's not filtering by category) and the only content being loaded in is the_content(), even though my template (listing-post.php) asks for the thumbnail, the category etc. I'm using Bones as my starter theme, hence why wp_localize_script is in this file (it's working). I've only included code that I know has issues, (I know that the rest of the site and JS is working fine). **bones.php**               //Add AJAX path to use in load-posts.js     $getPath = array('ajaxURL' => admin_url('admin-ajax.php'));     wp_localize_script('main-js', 'pathToFile', $getPath);      **functions.php**               //AJAX Category Filter     add_action( 'wp_ajax_load_cat_posts', 'load_cat_posts' );     add_action( 'wp_ajax_nopriv_load_cat_posts', 'load_cat_posts' );          function load_cat_posts () {         $cat_id = get_post_meta($_REQUEST['cat']);         $args = array (           'cat' => $cat_id,           'posts_per_page' => 10,           'order' => 'DESC'         );              $posts = get_posts($args);              ob_start ();              foreach ( $posts as $post ) {           setup_postdata( $post ); ?>                <?php get_template_part( 'partials/listing', 'post'); ?>             <?php } wp_reset_postdata();             $response = ob_get_contents();        ob_end_clean();             echo $response;        die(1);     }      **index.php**               <?php $categories = get_categories(); ?>
         <?php foreach ( $categories as $cat ) { ?>             <li id="cat-<?php echo $cat->term_id; ?>">                 <a class="<?php echo $cat->slug; ?> ajax" data-cat="<?php echo $cat->term_id; ?>" href="javascript:void(0)"><?php echo $cat->name; ?>
         <?php } ?>
      **listing-post.php**
         <article id="<?php echo sanitize_title_with_dashes( get_the_title() ); ?>" <?php post_class(); ?> role="article">                  <?php if (has_post_thumbnail()) { ?>
                     <?php the_post_thumbnail(large); ?>
             <?php } ?>
                 <?php foreach((get_the_category()) as $category) { ?>                     <?php echo $category->cat_name . ' ';?>                 <?php } ?>

<?php the_title(); ?>

                         <?php printf( __( '<time class="updated" datetime="%1$s" pubdate>%2$s</time>', 'bonestheme' ), get_the_time(), get_the_time(get_option('date_format'))); ?>

                     <?php the_content(); ?>

      **load-posts.js**               function cat_ajax_get(currentCat) {                 $('a.ajax').removeClass('current');                 $('a.ajax').addClass('current');                 $('#loading-animation').show();                 $.ajax({                     type: 'POST',                     url: ajaxurl,                     data: {action: 'load_cat_posts', cat: currentCat },                     success: function(response) {                         $('.article-listing').html(response);                         $('#loading-animation').hide();                         return false;                     }                 });             };          ajaxFilters: function() {                 $('.category-filters a').on('click', $.proxy(function(clickEvent) {                     $clickTarget = $(clickEvent.currentTarget);                     var currentCat = $clickTarget.attr('data-cat');                     cat_ajax_get(currentCat);                 },this));             }


How-to inspect filter-able $vars?

_Note: This is more of a tutorial/wiki than a real question and should be a reference for later Questions. If you got something to add, please feel free to add an answer. Working answers get upvoted. :)_ * * * ### Szenario You want to modify the output of some wp core function and instead of modifying the core directly (which is always bad), you have found a call like this:   `$filterable_var = apply_filters( 'name_of_filter', $filterable_var );`.   The filter function allows you to modify eg. `$filterable_var` and therefore the output of the wp function. ### The Problem You don't know what exactly the function wants as input. ### The Taks Check what you can modify. * * * Possibly Related Q:   _[Fell free to add your own Questions here.]_   * How-to inspect global variables?


Get post-meta value of all custom-posts - lowest to highest year-count?

probably tough to describe: I have a `custom-post-type` called `wr_event` and a custom-field for it called `event_date`. I have a lot of posts and each of those posts has set an `event_date`. Pretty straight forward. All I'd like to do now is list all the years in which `events` have been posted. So I'd like to have this …               2012 | 2011 | 2010 | 2009 | 2008      How do I do that? I thought of looping through all posts and listing the years, but somehow I can't figure out how to do so.                 $loop = new WP_Query( $args );       while ( $loop->have_posts() ) : $loop->the_post();           global $post;           $this_year = get_post_meta( $post->ID, 'event_date', true );           $this_year = date('Y', $this_year);           echo $this_year;       endwhile;      What's the best and simplest solution to do so? **UPDATE**                   rsort( $years ); // sorts the years array into reverse order         foreach ($years as $year) {             echo ''.$year.' | ';         }