Custom Taxonomies and parents

How can I create a group of custom taxonomies with parents that would include a description for the parent and child taxonomy? Here's what I have so far. The parent and child are created with the descriptions but the child taxonomy is not listed under the parent.               $categories = array(        'Category 01'=>'Category 01',         );          foreach($categories as $category => $cat_desc){         wp_insert_term(           $category, // the term           'style', // the taxonomy           array(             'description'=> $cat_desc,             'slug' => $category ,           )         );     };          // List out all Categories with subcategories     $styles = array(         'Category 01' => array(             'Subcategory 1A'  => 'Subcategory 1A Description
Subcategory 1A Description',              'Subcategory 1B'  => 'Subcategory 1B Description
Subcategory 1B Description',              'Subcategory 1C'  => 'Subcategory 1C Description
Subcategory 1C Description',             'Subcategory 1D'  => 'Subcategory 1D Description
Subcategory 1D Description',             'Subcategory 1E'  => 'Subcategory 1E Description
Subcategory 1E Description',                     )                  );          // Import each array as taxonomy with parent     foreach($styles as $bjcp_category => $bjcp_styles ){     $parent_term = term_exists( $bjcp_category , 'style' ); // array is returned if taxonomy is given     $parent_term_id = $parent_term['term_id']; // get numeric term id     foreach($bjcp_styles as $bjcp_style => $bjcp_style_desc){         wp_insert_term(             $bjcp_style, // the term              'style', // the taxonomy             array(               'description'=> $bjcp_style_desc,               'slug' => $bjcp_style,               'parent'=> $parent_term_id             )         );     }      I have a feeling that I'm creating the arrays in a less than efficient method. What would be the best way to accomplish this as I have over 100 custom taxonomies to import into my CPT and would like to have it done in one plugin. My question is, how would I structure an array to include the parent and child taxonomies with descriptions for each?


How to change the login URL

I want to change the login URL per a client request. so, instead of mysite.com/wp-login.php or mysite.com/wp-admin it is this: mysite.com/someotherpagename.php   or mysite.com/someotherpagename I do not want to use /login. It's too obvious, per the client. Thanks in advance.


How to count media attachments?

How do I count the number of media attachments a specific post has? Output example: This post has 22 photos. Thanks!


wp_get_archives() - Get CSS selector for current month

I'm looking for how to get a class in the wp_get_archives functions to get the current month (when we are in a month archive) just like when we call wp_list_categories, the current category has a ".current-cat" selector for CSS or when we call wp_list_pages we have a '.current_page_item' selector.


How to check if a specific page uses a page template?

I'm trying to get a page which uses a specific template. I have the page_id. Here is my code :               $pids = $wpdb->get_col( $wpdb->prepare(       "SELECT ID FROM {$wpdb->posts}         WHERE post_author = %d AND post_status = 'publish'         AND post_type='page'", $user->ID     ) );          foreach($pids as $post_id)     {        wp_set_post_terms( $post_id, $tag, $taxonomy );             // I need permalink only if that page use a specific template (say blog.php)        $permalink_n = get_permalink($post_id);             set_cimyFieldValue( $user_id, 'HOMEPAGE', $permalink_n );     }


How do I choose not to display the title header on a specific page?

I would like to have one specific page on my WordPress blog omit the header . Is there a way to wrap that title code from page.php in my WordPress theme in an if clause that specifies the page I do not want the title to appear on? For instance, if page is 135, do not display title, else display. Thanks!


How to query the latest 5 posts and sort them by title?

I'm looking to draw a menu listing of the latest "n" number posts, where the number "n" will be a user defined setting stored as an option. n = 5; //Pull the latest 5 posts from the database. The script I'm currently using (below) pulls all of the posts from the database and then only displays the latest 5 out of that collection. This works fine until I decided to sort the list by title. When I do that, rather than sort the latest 5 posts by title, its sorting the entire collection of posts, without regard to when they were posted Any tips on how I can change this query to only pull the latest "n" posts, then sort by title of those 5 only. ( **Note** : I'm really interested in the get_posts() query inside the UL element. The first query ($myquery) is just here to make sure we have posts to display before proceeding.)               function recent_posts(){         $catHidden=get_cat_ID('hidden');         $myquery = new WP_Query();         $myquery->query(array('cat' => "-$catHidden",'post__not_in' => get_option('sticky_posts')));         $myrecentpostscount = $myquery->found_posts;         if ($myrecentpostscount > 0){ ?>         <ul>         <?php          global $post;         if(get_option('mySort') == 'asc'){             $sortOrder='title';$sortDirection='asc';         }         $myrecentposts = get_posts         (             array             (                 'post__not_in' => get_option('sticky_posts'),                  'cat' => "-$catHidden",                 'numberposts' => get_option('cb2_latest_count'),                 'orderby' => $sortOrder,                 'order' => $sortDirection             )         );              foreach($myrecentposts as  $idxrecent=>$post) {              //DRAW THE POST MENU         }     wp_reset_postdata();     }


Modify message displayed on post save

After a post is updated there is a message displayed, how can I change the displayed text? I would like to remove the "view post" link and change the 'Post published' text. I'd like to do this for a particular post type. Here is the html WordPress outputs:

Post published. View post


Change the HTML output of comments

I'd like to customize the HTML output of the comment form. I've been reading I've been reading how to alter some variables of the comment_form(). The previous link provides a rather good guide to play with that function. But I'm still unable to change the HTML output of the form. And I would like to wrap some fields inside a container. With older wordpress versions this could be changed at will in the comments.php function, but doing it that way will break nested comments, so it is not an option. Is it possible at all to change this html output? Thanks, Upon request, a bit more of inormation :) The default html output of comment_form() is:
Name *<input id="author" name="author" type="text" value="" size="30" aria-required='true' />

Email *<input id="email" name="email" type="text" value="" size="30" aria-required='true' />

Website<input id="url" name="url" type="text" value="" size="30" />
      I would like to wrap all three paragraphs inside an html element (ie. DIV).


Full Width Main Post

On my site I want to add a section just below Navigation and above-content (from where posts starts to show up on front page) which would show a panel where I can put any BREAKING NEWS (not always, whenever I want) with its excerpt and image. That panel should stretch with max-width. I want to pull that BREAKING NEWS from a specific category say - category_breaking. Is it possible? If yes, then how? Thanks for the help. I want to achieve exactly like this - (http://i.imgur.com/4D9kE.png)


How to add terms to taxonomy with wp_insert_terms?

I have a huge excel database of locations which I want to add as terms to my current taxonomy. However, I don't know the best way to do this, as inserting manually could take weeks.   I have looked at: http://codex.wordpress.org/Function_Reference/wp_insert_term   but not sure how to use it correctly. My Taxonomy is called: **location** I would like to add the following example terms:   **London, Glasgow, Bristol, Bournemouth** Is this possible? Additionally, if there is hierarchical relationships, is this also possible to add automatically? For instance: London (Parent), Kensington (child of london).


Embed interactive pdf

I have interactive pdf documents that I need to put on a wordpress site. Visitors need to be able to fill these in and print them out to sign and post. They do not need to be emailed or saved to the site. I have tries embedding them with all kinds of plugins but all they do is embed a non fillable pdf. What I need is this : http://download.belastingdienst.nl/belastingdienst/docs/aangifte_bpm_verzoek_teruggaaf_bpm_bpm0162z3plfol.pdf Hope anybody can help. Kind Regards, Marja


Fetch data from database from multiple tables matching condition

I want to fetch data from the database. I have three tables in my database: `listing_master_residential`, `listing_master_condo` and `listing_master_commercial`. There is one primary key, `Ml_num`, in all tables. I want to search the data from one table which matches mls number table.               if (isset($_POST['search'])) {         $mls=$_POST['mls_number'];         $sql = "SELECT * FROM listing_master_residential,             listing_master_condo,              listing_master_commercial               INNER JOIN listing_master_residential AS res ON res.Ml_num=Ml_num             INNER JOIN listing_master_condo AS con ON con.Ml_num=Ml_num             INNER JOIN listing_master_commercial AS com ON com.Ml_num=Ml_num             WHERE Ml_num='$mls'";         $result = $wpdb->get_results($sql) or die(mysql_error());         foreach ( $result as $row) {             echo $row->Lot_code."
";             echo $row->Ml_num."
";             echo $row->Acres;             echo $row->Addr."
";             echo $row->Bath_tot;             echo $row->Br;             echo $row->Br_plus;         }     }      With the above, I get an error: > Column 'Ml_num' in where clause is ambiguous


Taxonomy term breadcrumb; how?

Given a taxonomy term (perhaps in a taxonomy*.php template) how to construct a breadcrumb going up the full ancestry of the term? Is there any shorter way other than a "brute-force" loop to query current term's parent -> query term's parent -> query term's parent etc.?


get_search_link() redirects to 404 template page

I built a custom theme, and in it, there is a 404.php page and a search.php page. Elsewhere in the template, I wanted to link to the search page directly. So, I used the get_search_template() function to get the search page link, which results in a link like this: http://example.org/search When I click the link, I get sent to the 404 page template. Why is it going to the 404 page template instead of the search page template?


Category Specific Archive

I'm trying to display a monthly archive but only for a certain category. How can I do this?


modify buddpress adminbar only in admin pages

I have modified the buddpress admin bar by creating the following plugin which adds a simple text link to the bar:               function bp_adminbar_currentsite_menu() {          global $bp;     ?>
          EXAMPLE LINK TEXT
     <?php     }     // Call The Function Above     add_action('bp_adminbar_menus', 'bp_adminbar_currentsite_menu', 999);      However, I do NOT want the above link to be shown when logged into the wordpress admin backend (so for example when an admin is editing a post). I thought about just doing a `php_self` check to see if it contained "/wp- admin/" but figured that there has to be a more elegant wordpress/buddypress hook here. How can I get the above code to only show when you are viewing a normal blog page, NOT in the admin area? Thanks


get_template_part function and add images

Added this function in any page:               get_template_part('recent', 'posts');      And:               if(have_posts()){     while(have_posts()){ the_post(); ?>
<?php the_content(); ?>
     <?php }     }      It's working, show 5 blog post on my page. But it's have only title and publish date. I want add thumbnail images on this post. How can I do it?


Wordpress 3.1 .htaccess contents keep dissappearing?

I have Wordpress 3.1 installed in a subdirectory of a shared hosting account, it's a linux server and mod_rewrite is enabled and working fine elsewhere. The contents of the .htaccess file disappear whenever I try and change the permalinks structure, leaving just the begin/end wordpress comments with nothing in between. I have no plug-ins installed. Thanks.


Adding a class to last post in the_date

I'm using `<?php the_date('l jS F Y','<h2>','</h2>'); ?>` inside the loop in order to group/sort posts by date. This all works great but I would like to add a different class to the last post for each date, effectively seperating each date section. Does anybody know how to do this please? I can't seem to find anything! Many thanks, S. Code below:               <?php while ( have_posts() ) : the_post(); ?>     <?php the_date('l jS F Y','
','
'); ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
                                              <?php the_excerpt(); ?>
 <?php endwhile; ?>
 //want this to appear at the end of each date/section      Updated code based on Bainternet's answer below:               <?php while ( have_posts() ) : the_post();                  $curent_date = $post->post_date;                 $curent_date = substr($curent_date,0,strpos($curent_date," "));                 $next_post = get_adjacent_post(false,'',false) ;                 if (!$next_post == ''){                 $next_date = $next_post->post_date;                 $next_date = substr($next_date,0,strpos($next_date," "));                 if ($next_date != $curent_date){                 $hrbtm = '
';                 echo $hrbtm;                     }                 } else {                 $hrbtm = '';                 }                 ?>                       <?php the_date('l jS F Y','
','
'); ?>      Then I echo `$hrbtm` just before the `endwhile`:               <?php echo $hrbtm; ?> <?php endwhile; ?>


How can I change a function in a parent theme via a child themes functions.php

I have a function in a parent theme:               function cyberchimps_logo_icons() { ?>
             <?php if (function_exists('cyberchimps_header_logo') ) {                 cyberchimps_header_logo();             } ?>

             <?php if (function_exists('cyberchimps_header_social_icons') ) {                 cyberchimps_header_social_icons();             } ?>
          <?php }     add_action('cyberchimps_header_content', 'cyberchimps_logo_icons');      I want to remove the social icons by removing the second half of this function. What's the best way to ADD something to a child themes functions.php to over ride this? I tried copying and pasting this into the child themes functions.php file, and deleting what I wanted gone, but the same function name can't be called twice.


Making custom woo themes

I have recently decided to step into WordPress but I am needing to create a few themes for eCommerce that are currently built in Open Cart. My experience from eCommerce comes from Open Cart but I am completely new to using one for WordPress. After a few months of research I decided I would like to try and create my own theme from the Woo theme Mystile. My questions are followed:   1. If making a custom theme is the preferred method to only modify the `custom.css`?   2. When updates are released for their themes are they also updating the `.css` files or is there a standard set of files being updated?   3. Woocommerce appears to not have a **standard** framework for customizing so is there a better alternative then using Mystile or Artificer?    4. If using the `custom.css` to create a theme wouldn't that theme be considered a child? EDIT:   1. Is the preferred method to install the woo extension and build around Twenty Twelve?


How can I give Wordpress child custom post type the same title and slug as its parent?

I have two custom post types, one is the child of the other (the parent is more of a modal post). I want the child post to inherit the same title and slug as its parent. I've tried to use the following action hook:               function copy_parent_post_title( $post_id ) {              $new_post = get_post($post_id);              if($new_post->post_type == 'child-post-type') {              $parent_title = get_the_title($new_post->post_parent);         $post_slug = sanitize_title_with_dashes($parent_title);              $post_update = array(             'ID'           => $post_id,             'post_title' => $parent_title,             'post_name' => $post_slug         );                      // To stop infinite loop:         remove_action( 'wp_insert_post', 'copy_parent_post_title' );         wp_update_post( $post_update );         add_action( 'wp_insert_post', 'copy_parent_post_title' );              }          }     add_action( 'wp_insert_post', 'copy_parent_post_title' );      The problem is that `$new_post->post_parent` is always giving `0`. I've tried replacing it manually with the actual parent ID and the above works fine. Why is `$new_post->post_parent` not giving the correct parent post ID?


jQuery form plugin, submit in the wordpress way

Trying to use jQuery form plugin in wordpress site to upload files. HTML markup:               <form id="myForm" action="process.php" method="POST" enctype="multipart/form-data">               <input type="file" value="" name="file_upload"  class="file_upload"/>

          <input type="submit" value="Submit" class="btn_submit" name="btn_submit" />               </form>      and the JS snippet :                      The form processes its element values in `process.php` which is a non-template file. As a result Wordpress codex functions are not available in that page . So what I need to do is to use the jQuery form plugin's ajax submission in the wordpressian way. How to implement that ? * * *


What tool are available in the wordpress API for debugging a plugin?

I am very new to plugin development. I have created my first plugin but when I activated it, it caused the majority of every page on the site to stop being generated. I have echoed something from the end of the php script to confirm that it was completing without an error. But other than that I have no idea what I should do to debug this problem. I would like to be able to work on this on a public site that will be getting traffic while I work, is there a way I can have the plugin only activated on one page or only for me and not for guests? I would like to be able to show debug messages, is there a convenient way to do this? Are there points outside of my plugin that would be helpful for debugging? I don't know where to look that might be leading to the problems.


How do I paginate a get_posts() request inside another page loop (Paginating childpages)

The heading says a lot, so I'll repeat it here "How do I paginate a `get_posts()` request inside another page loop?" I'm using a page to display child-pages and I need to paginate them. **Edit:** Should I use a custom `WP_Query` instead? Would this make any difference? The code I use inside the normal page loop looks like this right now:               // Set up the arguments for retrieving the pages     $args = array(         'post_type' => 'page',         'numberposts' => -1,         'posts_per_page' => 1,          'paged' . get_query_var('page'),         // $post->ID gets the ID of the current page         'post_parent' => $post->ID,         'order' => ASC,         'orderby' => title     );     $subpages = get_posts($args);     // Just another WordPress Loop     $child_counter = 1;          foreach($subpages as $post) :         setup_postdata($post);              if ($child_counter == 2 || (($child_counter)%3)-2 == 0) {             echo '
';         } else {             echo '
';         }         $child_counter++;
<?php the_title(); ?>

<?php the_excerpt_max_charlength(200); ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php _e('Les mer', 'monster'); ?>

<?php next_posts_link('« Older Entries') ?>

<?php previous_posts_link('Newer Entries »') ?>

     <?php endforeach; ?>      I can't get my head to understand how I can retrieve the pagination information for the child loop and not the main loop. So I have no clue how to paginate the childpages. Remember this `get_posts()` call is inside a normal page loop. Happy for all answers, hints or tips!


How can I prepopulate the URL address for the add media button

I was wondering if there is a way to get the URL address to prepopulate with my web address so I don't have to type it in every time I want to insert an image. Example. Click on the upload/insert "add media" button --> click "from URL" and instead of having a blank box, I would like it to prepopulate with: http://mysite.com/images/ this way the only thing I would have to type in is: nameofimage.jpg


How to include custom post type posts on a page?

I need help adding a Portfolio page to one of my main Pages. I don't know what information is needed, so I'll just throw in some of the important stuff. Basically I have my main menu, (Welcome, About, Contact, etc.) which includes a tab called 'Work'. Under that tab, I have two pages called Portraits and Modeling. I want to somehow insert a few portfolio pages (each with a separate photo shoot) into the Modeling page. Ideally, I want it to show a one image preview and the full shoot once clicking on the image.


Own Custom Tags/Category page ( posts)

I want to make a page where on each **tags** : My page should look alike : http://www.missmalini.com/aamir-khan-2/ Above page is coming from http://www.missmalini.com/celebrity-fan-pages/ this are categories with **Tags** : I also know that the patten is like Big Image is First ( **First** latest Post of resp. tag )... then 4 image with title are from **Second** post )and then only title after **sixth** post .. its means they have **divide latest 10-12 post** with this structure.. 2 } if u see on top ( above Ten Latest Aamir Khan Updates ) there is " **Aamir Khan Full Bio** " which is **_different_** for resp. **tags**. 3 } If Scroll Down there is **Photos and Videos** of resp. celeb ( which is tags or may be category wise ) Hence how i can do this ( means how i can make such Own Custom Page code ) can any one let me know.


Admin ajax add tag callback

Is it possible to add an additional callback to admin ajax? Basically, I'm trying to increment the value in an input field of the add form for a custom term after the form is submitted. After the form is submitted via ajax, the response that comes back appends the new row at the top of the table of terms on the right side of the add form. I want to be able to update a field in the add form itself. Something like the following is what I need executed after the ajax call is made:               function add_tag_increment_num() {              echo '<script>                 var num = $("#num-field").val();                  var incrementedNum = parseInt(num) + 1;                  $("#num-field").val(incrementedNum);              </script>';              die();      }          add_action( 'admin_ajax_add_tag', 'add_tag_increment_num' );      Any help would be greatly appreciated.


How to have embedded images from smugmug take full width of blog posts

What I'm trying to achieve: Have images in blog posts take the full width of a blog post, and keep image proportional. Aka, a portrait image will end up being bigger than landscape. The challenge, I'm not using images from my wordpress server, but from smugmug. Hense, I'm using embed images like this one (just drop the link in a post written in html, not wysiwyg) http://nickpelletier.smugmug.com/Category/From- nickpelletiercom/21943413_P6Mzn6#!i=1750174498&k=5SsSHBq&lb=1&s=A I tried through settings here: Settings -> Media -> Embeds and leaving a blank value for width. This worked for landscape images, but not for portrait images. Portrait images were still using the height making the resulting width different for any picture with a different size ratio. I tried many template (including ten eleven) and all have the same problem. Hence, I think this is how Wordpress is actually made to work. This being said, I'm looking for how I can change this behavior in the code (template if possible, wordpress if worst case). I'm a programmer by day doing backend code. I'll probably be ok with the code part, but I have no clue of php, wordpress (this is my first blog I'm setting up) and am fairly new to web\html. Any clue of where to look first would be appreciated. --Edit Here is a page with a portrait image (first from smugmug, second from flickr) http://nickpelletier.com/2012/03/19/alphonse-et-dorimene-desjardins/ The current value in setting -> Media -> Embeds are width:nothing and height:1500 I would have liked the image to go to max width of column instead of having a height of 1500


Display Image for a category using get_categories, or show an image from any child post

I am using get_categories to list the child categories of a parent category. I want to add an image to the child categories, using the get_categories output.   * I can either take the featured image from any of the posts that are children of the category that I am using get_categories on, IE the grand-child of the parent category. I do not want to show any other grand child information, and would want just one featured image from each set of category children. The code I currently use is               $args = array('child_of'  => 1  );     $categories = get_categories($args);       foreach($categories as $category) {          echo '
Category:'. $category->name.'
 ';         echo '
 Description:'. $category->description . '
';         echo PUT CAT IMAGE HERE;          }         * Or I could add an image to a category using some plugin, and show it in the `foreach($categories as $category)` output. But what is the best (and easiest) way to implement this?


How to add custom javascript into <head> from custom plugin

I wrote a plugin but it keeps adding custom javascript into section not into section of every page. Can anyone help me or give me a hint how to add js into section?               public constructor {         add_action( 'init', array( $this, 'custom_js_register' ) );         add_action( 'wp_head', array( $this,  'custom_js_print' ) );     }          function custom_js_register() {         wp_register_script('custom_button', 'http://xxx.xxx.xxx/js/Button.js');     }          function custom_js_print() {         wp_enqueue_script('custom_button');     }                 also instead of just loading js, I want to be able to do something like this.               <script type="text/javascript" src="http://xxx.xxx.xxx/js/Button.js" charset="UTF-8">     </script>


Multiple sites with pretty permalinks with nginx

I'm trying to set up a new local development server and instead of Apache I've decided to go with nginx. What I'd like to do is have each WordPress site live within its own directory inside `/usr/share/nginx/www`. The sites are only going to available on our local network. So for example: `/usr/share/nginx/www/ourcompanywebsite` -> `http://192.168.2.250/ourcompanywebsite` `/usr/share/nginx/www/firstclientwebsite` -> `http://192.168.2.250/firstclientwebsite` `/usr/share/nginx/www/secondclientwebsite` -> `http://192.168.2.250/secondclientwebsite` `/usr/share/nginx/www/sitefortestingthings` -> `http://192.168.2.250/sitefortestingthings` Getting that setup is fairly trivial. In fact, I've got it working just fine. The problem is that pretty permalinks do not work. Unfortunately I don't know enough about nginx to make this happen. Here's my current nginx sites-enabled/default.conf file. Please excuse any obvious amateur mistakes; I really cannot stress how little I know about setting up nginx.               server {         listen 80;         listen [::]:80 default ipv6only=on;              root /usr/share/nginx/www;         index index.php index.html index.htm;              location / {             auth_basic "You shall not pass!";             auth_basic_user_file /home/mojo/src/config/nginx/htpasswd;             try_files $uri $uri/ /index.html;         }              location /doc {             root /usr/share;             autoindex on;             allow 127.0.0.1;             deny all;         }              location /images {             root /usr/share;             autoindex off;         }              error_page 500 502 503 504 /50x.html;              location = /50x.html {             root /usr/share/nginx/www;         }              location ~ \.php$ {             fastcgi_pass 127.0.0.1:9000;             fastcgi_index index.php;             include fastcgi_params;         }              location ~ /\.ht {             deny all;         }     }      I've seen guides on how to setup pretty permalinks with nginx but they all seem to assume that you'll just have one site or that your separate sites are on separate domains. So, is the setup I want possible? If so, what do I need to do to make it happen? If not, or if it's a really bad idea, then what is a similar setup that lets me have multiple WordPress installs with pretty permalinks? Any other useful tips that might improve my configuration are appreciated. Worst case scenario I can go back to Apache (where I had my desired setup working), but I'd rather figure this out.


Navigation that Runs Above and Below Header Image

Is there a way to have a navigation div(s) on the Twentyeleven theme or similar themes that runs over the header image and finishes below the header image? Basically so overflow runs below the image. Here's an example: Link to Website


Why does WordPress load jQuery in my header instead of footer?

Here's a site I'm working on... 198.1.77.196/~larog/ I've taken an older WordPress theme (Twenty Ten) and modified it to be my own theme. Anyways, the site isn't anywhere near done, I'm just in the process of building it. One of the things I'm curious about though is why WordPress loads jQuery in the head of my site when I am always hearing people saying that you should load jQuery in the footer of your site (or after the tag) so that it helps the page to load faster. I've Googled this and found nothing that answers my question. Any input is appreciated!


How to add shortcode tags in single.php

In my theme has one shortcode tags to display tags of post and function to load content post. But in function doesn't include shortcode tag. Now I want to add it to function but i don't know how to do it. Hope everyone help me out. Thank in advance. **Shortcode tag**               function wwl_post_tags( $atts ) {         if( $tags = get_the_tag_list( '', ', ' ) ) {                  $defaults = array(                 'before' => __( 'Từ khóa: ', 'icy' ),                 'after'  => '. ',             );             $atts = shortcode_atts( $defaults, $atts );                  return sprintf( '%1$s%2$s%3$s',                 $atts['before'],                 $tags,                 $atts['after']             );         }     }     add_shortcode( 'post_tags', 'wwl_post_tags' );      **Function to load content post**               function wwl_post_content() {         global $more;              if ( ! is_single() ) {             $more = 0;           }              do_action( 'wwl_before_post_content' ); // Hook              if ( ! is_single() && of_get_option('post_content') == 2 || is_search() ) :         ?>
                 <?php wwl_thumbnail(); ?>                 <?php the_excerpt(); ?>

         <?php else : ?>
                 <?php wwl_thumbnail(); ?>                 <?php the_content( '', false, '' ); ?>                 <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'icy' ), 'after' => '
' ) ); ?>

         <?php endif;     }


Problem accessing values from $wp_query in plugin

I am creating a custom plugin where I am passing parameters in the url and trying to access the values of those parameters using $wp_query directly in the plugin, but it returns an empty array. I presume it is because $wp_query doesn't exist yet when my plugin is executed.                global $wp_query;      print_r($wp_query); // this is empty      But If I create a filter first then the contents of $wp_query are accessible within it                add_filter('wp_head', 'get_values');           function get_values() {        global $wp_query, $id;        print_r($wp_query); //complete array        $id = $wp_query->query_vars['id']; // value exists      }      I need to be able to access the contents of $wp_query outside of a filter, in the main part of my plugin, so I can make calls like this                global $wp_query;      if ($wp_query->query_vars['id'] == 1) {        remove_action('wp_head', 'rel_canonical');        // do a bunch of other stuff      }      I thought I could set $id be a global variable within the filter and then access it later outside of the filter but that doesn't work either. Any ideas or workarounds?


Image Manager Plugin

I'm looking for a simple plugin that allows me to manage groups of images. Wordpress does this, but you would need to link the gallery to a page or post. Since i'm looking to create a site banner with dynamic images, i don't want to link a gallery to an specific page. Is there a good image manager plugin for this simple task or do you know a way to do it natively in wordpress?


Add stylesheets and js to template files when shortcode is used

After looking for days throught the net and no avail - i'd like to ask all of you guys. PROBLEM: i need to add custom code to the head of the file as part of shortcode use for my plugin. The same files and code insert fine in the admin page (backend) but fail to load in the template file. The files are inserted in the admin head with add_action('admin_print_scripts', 'add_swm_scripts'); & add_action('admin_print_styles', 'add_swm_styles'); calls pointing to functions that use wp_enqueue_script() and wp_register_style() / wp_enqueue_style() This does fine - however - when i try to get the same files registered in the function of the shortcode (for use in the template), nothing workds. I checked that the shortcode is read and it's according function is fired, but neither add_action( 'wp_enqueue_scripts', 'swm_scripts' ); , add_action('init', 'register_swm_scripts'); nor add_action('wp_head', 'print_swm_scripts'); will work. I've tried more than this not don't find a working solution. If somebody knows a valid trick - i more than appreciate some advice. Thanks in advance! Herbie


Changing Wordpress blog name and web address

I created a self-hosted WordPress blog (on Dreamhost) several years ago. I've never truly been happy with the name and URL/domain of the blog, and I've decided that I want to change it. Here's what I'd like to do:   1. Register the new domain name. (Say www.newblog.com for example.)   2. Redirect traffic from the old domain name (www.oldblog.com) to the new one (www.newblog.com).   3. Begin using www.newblog.com as the new web address. I'll be staying at the same web host through all this. I know there are lots of smaller steps I need to take in here, so I'd appreciate it if someone could help me fill in the blanks. Thanks!


Display list of most used tags in the last 30 days

I am looking for a way to display the most used tags over the last 30 days. I am no coder, but I have come up with this mashup to display a list of the most used 28 tags (preference to fit my theme). I cannot, for the life of me, figure out how to limit the tags to the most used in the last 30 days. Here is what I have:
         <?php             $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC', 'number'=>28) );                 foreach ( (array) $tags as $tag ) {                 echo '
term_id) . '" rel="tag">' . $tag->name . '
';                 }         ?>
      ## Update This is the full code I am using right now, following One Trick Pony's code below.
     <?php     global $wpdb;     $term_ids = $wpdb->get_col("        SELECT DISTINCT term_taxonomy_id FROM $wpdb->term_relationships           INNER JOIN $wpdb->posts ON $wpdb->posts.ID = object_id           WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= $wpdb->posts.post_date");          if(count($term_ids) > 0){            $tags = get_tags(array(         'orderby' => 'count',         'order'   => 'DESC',         'number'  => 28,         'include' => $term_ids,       ));     foreach ( (array) $tags as $tag ) {     echo '
term_id) . '" rel="tag">' . $tag->name . '
';     }     }     ?>
      The website is slightly less than ~4 weeks old, so to test, I changed `INTERVAL 30 DAY` to `INTERVAL 3 DAY` and the tags being returned seem random and some haven't been used in 2+ weeks and have only been used a single time. As well, only 8 tags are being displayed, when more have been used. To check that the correct number of days have been queried, I did the following: Completely deleted all items in the trash for posts and pages, I don't have any custom post types. Did the same with drafts. Ran a query in phpmyadmin to delete all post revisions - `DELETE FROM wp_posts WHERE post_type = "revision";` Ran a query in phpmyadmin to check if the results are the posts from the last 3 days - `SELECT * from wp_posts WHERE DATE_SUB(CURDATE(), INTERVAL 3 DAY) <= post_date` The results from the phpmyadmin query were, in fact, the posts from the last 3 days, but the front-end display did not change. # Update 2 Here are some screen shots. Maybe the screenshots can help find where my code is wrong. **Blog Post with Category and Tags** ![Image of blog post](http://i.stack.imgur.com/ZTTAo.png) **`wp_posts` table with the post `ID` of above post** ![wp_posts](http://i.stack.imgur.com/mZOVs.png) **`wp_terms` table with the `term_id` of the tags used** ![wp_terms](http://i.stack.imgur.com/F3tpl.png) **`wp_term_taxonomy` with the tags' `term_id` as `term_taxonomy_id`** ![wp_term_taxonomy](http://i.stack.imgur.com/iNpIH.png) **`wp_term_relationships` with `term_taxonomy_id` assigned to post as `object_id`** ![wp_term_relationships](http://i.stack.imgur.com/PTr44.png) # Update 3 I think I figured out the problem, but do not know how to fix it. The SQL query gets the `term_taxonomy_id`, not the actual tag ID and `get_tag_link` uses `term_id`


MultiPostThumbnails and media queries

I am using the plugin "MultiPostThumbnails" and it's setting my width to 700px. Is there a way to get it to not set the width and height at all? I want it to resize when I use media queries and instead what is happening is that the image "box" is getting smaller but the image is not because of the width and height settings in the `<img>` tag...


How to sent one form values to 2 different sites in wordpress

I am trying to post values in a form into 2 different urls. Is this possible? Basically i want to have a form send the form optin values into aweber and send a email with the filled in values. I am on wordpress site but can have a php or html page if this is not possible using wordpress. I currently have the aweber form to collect the info would like to send these values as email. Is this possible using any plugin or any hack Thanks Prady


WordPress plugin to publish to multiple remote WordPress blogs

I have a WordPress (.org) blog (let's call it blog1) that is used by many authors, who may create, edit and publish posts (on blog1). Each author has her/his own WordPress blogs, hosted elsewhere. The authors would like to be able to publish their posts from blog1 to their remote blogs. Is there any plugin I can use for this task? Notes: 1) WP multisite is not a solution to this problem since it hosts multiple blogs on one host, and also since the authors of blog1 have their popular blogs already hosted elsewhere. 2) I need the functionality to be able to publish from blog1 to remote WP blogs, and not vice-versa. Thanks!


Reblog WordPress to another WordPress?

1.Is there any way to reblog only the excerpts of WordPress posts to another WordPress with the featured image(option to choose the size of the image we prefer) and link to the WordPress site to see the full post from specific category/ies or tag/tags? 2.Will it cause me any problem to my page rank and the Google search results if I do something like this?


How to get attachment file name not attachment URL

I'm using this code to list the image attachments of a post:                     <select name="chb_homes_for_sale_specifics_floor_plan" style="width:100%;">             <option value="">Select</option>             <?php             $args = array(                 'numberposts'     => -1,                 'orderby'         => 'menu_order',                 'order'           => 'ASC',                 'post_type'       => 'attachment',                 'post_parent'     => $post->ID,                 'post_mime_type' => 'image'             );             $image = get_posts($args);             if($image) {                 foreach($image as $key => $data) : ?>                          <option value="<?php echo $data->ID; ?>"><?php echo $data->post_title; ?></option>                      <?php endforeach;             }             ?>           </select>      But what I'm showing currently is the attachment `post_title` but I want to show the file name instead. I could maybe use get attachment URL then parse the URL to get the file name but was wondering if there is a ready made way in WordPress to get the file name.


just can't get date-based archives per post-type to work

I expected that wp3.1 with the support for archive-{post_type}.php would solve my problems. However, I am still struggling to get it working. What I want is: a custom date-based archive page per post-type, which displays years and months. Once you click on a year of a month, you'll go to another archive page which outputs the relevant posts. First of all: I am clueless on how to create a date-based archive page for certain post-types anyway. Is there a certain page-template which automatically gets called when going to {post-type}/archive? `<?php wp_get_archives(); ?>` doesn't seem post-type aware. Second of all my date-based permalinks doen't work. A simple {post- type}/2010/01 gives an error404. I've created all my archive-.php pages with simple content:               get_header(); ?>                  <section id="content" class="hfeed">     <?php get_template_part('posts'); ?>             </section>          <?php get_footer(); ?>      Any clue?


Is there any plugin which enables users to rate comments in thumbs up-down way?

* The plugin should work with un-registered users also.   * Its not mandatory for plugin to add rating system to posts/pages. I need thumbs up-down rating system only for comments.


How to make post templates to include shortcodes only?

I used to post same shortcodes every time (shortcodes loads dynamic contents). So, I want to pack these shortcodes in a template for my posts. How can I do this?


Using author_can() on custom post types in WordPress

I'm trying to conditionally display some content in a theme using custom roles and capabilities. First, I define a custom role: `add_role('free_vendor', 'Free Vendor Listing', array('read', 'edit_posts', 'delete_posts', 'display_map'));` This is run directly from functions.php (do I need to add it to an action somewhere?) Then I use the `display_map` capability I defined to conditionally display the map: `if (author_can($post, 'display_map')) echo '<li><a href="#map">Map</a></li>';` The only problem is, it doesn't work! Is there some issue in using author_can() with custom post types? Am I not calling add_role() properly? I can't really find any decent documentation on using `author_can()` with anything other than vanilla posts. Is this just not possible?


Rewrite Rules for Multiple (more than 2) Taxonomies

I am using woocommerce and have some 'product attributes' which are just a taxonomies. I have the following taxonomies:   * pa_color    * pa_material   * pa_style the pa_ stands for product attribute and it is built-in to WooCommerce handles these taxonomies, so I can't change that. WooCommerce also comes with product categories (product_cat) and product tags (product_tag) taxonomies. the following query gets me all the Red, Vinyl products in the Fabrics product category > ?product_cat=fabrics&pa_material=vinyl&pa_color=red I'd like to turn this into a pretty permalink, something like: > product-category/fabrics/material/vinyl/color/red This answer gets me pretty close to what I am trying to achieve: URL rewrite rules for multiple taxonomies query in that I can get my URL to handle 2 taxonomies (product_cat + 1 attribute taxonomy), but I am stuck on how to get 3 (or more) parameters. So I can get: > /products-category/fabrics/color/red or > /product-category/fabrics/material/vinyl but not all 3 together > /product-category/fabrics/material/vinyl/color/red edit / though i think it'd be ideal to have the URL be /fabrics/vinyl/red i'm not sure that is possible? end edit/ WooCommerce also has some settings for modifying the permalinks (like prepending the URL with 'shop' or changing the product-category slug) so i'll need to account for that eventually, but right now I need to get this first step down. for simplicity's sake, this is a stripped down version of my code. I'm actually getting the taxonomies from built-in woocommerce functions, but the question isn't limited to woocommerce... as it pertains to any site w/ a lot of taxonomies.               add_action( 'init', 'wpa_init' );     function wpa_init() {          $taxonomies = array ('pa_color'=>'Color','pa_material'=>'Material','pa_style'=>'Style');     $base = 'product-category';                  foreach ($taxonomies as $taxonomy=>$mask):                       $attribute = strtolower(sanitize_title($mask));                 add_rewrite_rule( $base.'/(.+?)/'.$attribute.'/([^/]+)(/page/(\d+))?/?$', 'index.php?product_cat=$matches[1]&'.$taxonomy.'=$matches[2]&paged=$matches[4]', 'top' );                      endforeach;          }      this was the best resource i've found on taxonomy query permalinks: http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/ but it, too, seems stuck at 2 taxonomies.


Redirection with a wildcard

I have put my wordpress installation liek these : http://www.mydomain.com/cms for the testing time, and time to implement thing in the database. Now i have switch the whole thing to : http://www.mydomain.com/ (root). How is it possible to tell all the request to /cms to be / (root). i know htaccess can do that, but i prefer a plugin or how to migrate an installation from one directory to another seemlessly ?


Total number of posts in last year

How can i echo total number of posts in last year ? I‚m writing article with stats, and want to get number of posts i published last year. There is something here, but not for last year http://perishablepress.com/press/2006/08/28/display-total-number-of-posts/ It displays only total number of all posts


How can I add an Export option to a WP_List_Table

I have an admin page that extends the WP_List_Table class to generate a table of results from a custom database table. I am trying to add a button that will enable the admin user to export the results (as filtered by any search terms) to a CSV file. Here is the challenge:   * The WP_List_Table class passes search terms etc through GET query parameters. If my "Export" button goes to a separate page, I think I will have to manually add the GET parameters for the Export button.   * The CSV export will require me to send HTTP headers (specifically, Content-type and Content-Disposition). If I simply have the Export button be a special submit button with a specific name/value, I don't know how to get the WP_List_Table to check the GET parameters for the Export button's status prior to triggering early output hooks like admin_head(). I'm sure there's a method that I've overlooked. Can anyone give me some advice?


Deploying WordPress development updates to multiple sites?

I have a wordpress site with many copies,and hosted in many servers.This uses child theme.I have my local copy of it and developing is going on this copy.in local copy i have added many files,pages and some database changes.I want to update all server copies from local developed copy.How can i do this?.Can i achieve this by simply updating theme from backend?


How to reverse the order of Wordpress blog posts?

WP 3.0.2 I've tried adding                 <?php query_posts($query_string . "ℴ=ASC") ?>      above                 <?php if(have_posts()) : ?>      in the page.php file, with no result


How to show Small Box Inside Content Area, which holds (text, images, links)?

I want to generate unique TEXT+Images+Link for each (single) post, the results will be visible to content area right hand side, within a BOX. I already have a plugins WP-InfoBox (http://wordpress.org/extend/plugins/wp-infobox/) it works similar ways but the developer who made, he didn't bothered the class, ID -- so it's messed-up the entire theme. I tried to change the class, ID names from the plugins but it's not working anyways. It's overlapping and I almost spend 3-4 hrs but I couldn't able to resolve it. However, Basic things, I'm looking for   * Include images+text+link form WordPress CUSTOM area   * Visibility in the location (see images) Can anyone help me with that issue, that would be great.


adding my posts (author posts) in menu

I want to add "my posts" to main menu. By clicking on this, each logged-in user will see his/her own posts. I don't know how the link structure should be to add on the menu.


How to filter a static post page with ajax and $wp_query

I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then 'filter'(return with ajax) only the posts that fit the search. I also want it to be paginated. I've found several ways to manipulate `$wp_query` so that I can use the same loop for the ajax call. Unfortunately when I look `global $wp_query` in functions.php where my callback action is, it is basically null or initialized to default parameters. I debugging everything locally, I wonder if that would affect anything. I haven't confirmed it but shouldn't that global variable stay the same unless something explicitly happens to it(like navigating to a new page)? This is the callback in functions.php               function cbSearch()     {         $counter=1;         $html="";         global $wp_query;                   if ( have_posts() )         {             while ( have_posts() )             {                 the_post();                 $html.="
";                 $html.=the_title('
','
');                 $date= strtoupper(get_the_date('F Y'));                 $subtitle = get_post_meta (get_the_ID(), 'subtitle', $single = true);                 $summary = get_the_excerpt();//get_post_meta (get_the_ID(), 'summary', $single = true);                 $html.="
".$subtitle." - ".$date."
";                 $upload_dir = wp_upload_dir();                 $html.="";                 $html.="
";                 $html.=$summary;                 $html.=" › READ MORE";                 $html.="
";                 if ($counter != count($posts))                 {                     $html.="
";                 }                 ++$counter;                      $html.="
";                 echo $html;                 $html="";             }         }         $html.="
";         $html.="";         $html.=get_previous_posts_link(" P ");         $html.="";         $html.="";         $html.=get_next_posts_link(" N ");         $html.="
";         echo $html;              die();     }      I use a breakpoint in this function to find the `$wp_query` parameters. This is what is returned when I do a var_dump immediately after calling `global $wp_query;`               object(WP_Query)[145]       public 'query' => null       public 'query_vars' =>          array           empty       public 'tax_query' => null       public 'meta_query' => boolean false       public 'queried_object' => null       public 'queried_object_id' => null       public 'request' => null       public 'posts' => null       public 'post_count' => int 0       public 'current_post' => int -1       public 'in_the_loop' => boolean false       public 'post' => null       public 'comments' => null       public 'comment_count' => int 0       public 'current_comment' => int -1       public 'comment' => null       public 'found_posts' => int 0       public 'max_num_pages' => int 0       public 'max_num_comment_pages' => int 0       public 'is_single' => boolean false       public 'is_preview' => boolean false       public 'is_page' => boolean false       public 'is_archive' => boolean false       public 'is_date' => boolean false       public 'is_year' => boolean false       public 'is_month' => boolean false       public 'is_day' => boolean false       public 'is_time' => boolean false       public 'is_author' => boolean false       public 'is_category' => boolean false       public 'is_tag' => boolean false       public 'is_tax' => boolean false       public 'is_search' => boolean false       public 'is_feed' => boolean false       public 'is_comment_feed' => boolean false       public 'is_trackback' => boolean false       public 'is_home' => boolean false       public 'is_404' => boolean false       public 'is_comments_popup' => boolean false       public 'is_paged' => boolean false       public 'is_admin' => boolean false       public 'is_attachment' => boolean false       public 'is_singular' => boolean false       public 'is_robots' => boolean false       public 'is_posts_page' => boolean false       public 'is_post_type_archive' => boolean false       public 'query_vars_hash' => boolean false       public 'query_vars_changed' => boolean true       public 'thumbnails_cached' => boolean false      I know that ajax function is working. Can anyone tell me why $wp_query turns into garbage somewhere between page load and the http request? EDIT: After considering the logic a little bit more I don't think typical pagination will work with ajax. Since next/previous_posts_link provides a url for a link, that means $wp_query parameters are loaded based on the page template any additional parameters in the url. Only when $wp_query knows it's loading a page template next/previous_posts_link will return http://domain.com/new/page/2/ instead of http://domain.com/wp-admin/admin- ajax.php?paged=2. I'm considering using `get_posts()` in the ajax call and returning the posts for one page and creating next/previous links that call the ajax function with an offset representing the page number.


Hide echo of no categories from get_object_taxonomies

The following code works perfectly to show all the categories for a custom post type. However when there are no categories it echos 'No Categories'. How would I remove this?                                   <?php //Category Display for Custom Post type - Video                         $customPostTaxonomies = get_object_taxonomies('opd-music');                         if(count($customPostTaxonomies) > 0)                         {                                  foreach($customPostTaxonomies as $tax)                             {                                      $args = array(                                     'orderby' => 'name',                                     'show_count' => 0,                                     'pad_counts' => 0,                                     'hierarchical' => 1,                                     'taxonomy' => $tax,                                     'title_li' => '',                                     'echo' => 0,                                     'style' => 'simple'                                 );                                 echo '';                                     echo  'All';                                 echo str_replace( '
', '', wp_list_categories( $args ) );                                 echo '';                                  }                              } ?>


Which are the hooks run before/after when a category's deletion?

What are the actions that a plugin can hook on to for processing when the user deletes a category?


In wordpress I am manipulation 404 response. I want to give the response before 404 error is given to google

May be the question in title is not explaining what exactly I want. So I will explain one logic and then ask what problem I am getting from that. We are using wordpress. We have 2 categories Option1(Having 64 different values) and Option2(Having 8 different values). We wanted url like ourdomain/Option1/Option2 depending on users location. And data on that url will be specific according to that Option1 and Option2. We dont wanted all this 64*8 actual wordpress pages to be created. So after searching much on net we had one solution that I implemented one plugin for routing. IN that code snippet was as follow.               function site_router() {          global $route,$wp_query,$window_title;     error_reporting(E_ALL);     if ( $wp_query->is_404 )          {             $wp_query->is_404 = false;             $cUrl="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];             $targetUrl="";             switch($cUrl)                     {                     /* According to condition  I had written diffent cases like below.                     */             default :                 {                            include(get_template_directory() . "/home.php" );                  $template =locate_template('pagepath/home.php');                             $window_title = 'dynamically it will come';                             if ($template) {                             load_template($template);                             die;                             }                         }                                             }              }     }          add_action( 'wp', 'site_router');      So by this my purpose was fulfilled successfully. But now problem is that google is saying they are getting back a 404 error. I think obviosly it will give as after it gives the error we are doing all template loading and all stuff. So Can any body guide me how can I do this before that 404 response is given to google.


Adding content to sidebars

I am working on a three-column layout where all three columns will have differing content depending on the post/page in the main column. How would I go about giving the ability to change and update the sidebar content and display it in templates using something like `<?php the_content() ?>` ? Since the sidebar content is related to the post I will need a way to reference the right sidebar content for the post. Thanks in advance Yours sincerely, nav


How to store and receive variables in WP sessions?

I have a form with some checkboxes and inputboxes selectboxes and it shows what the user wants via an ajax call. The problem is that when the user click on the item and the detail page is shown and then decide to go back to the previous page he needs to click and select his previous choice again. I would like to make WP to store all the options in the session when the button to the detail page is clicked and save actual info in the session and then when he visits the page again the values will be chcecked in sessions and set if any are found. Could that be done in WP? If yes, how? Let's oversimplify that and say that we have something like this in our form:               <input class="car_color" type="checkbox" name="car_color" value="1" />     <input class="car_color" type="checkbox" name="car_color" value="2" />     <input class="car_color" type="checkbox" name="car_color" value="8" />     <input class="car_color" type="checkbox" name="car_color" value="4" />     <input class="car_color" type="checkbox" name="car_color" value="6" />      I don't use submit button in my form, it's handled via AJAX on input change. And in my results get via ajax I have a link to the detail page:               <a class="detail-info-link" href="<?php echo $url ?>">      Any idea how can I store my values in Session and call them when revisiting/reloading/back button in the browser? I need to be able to read the session stored stuff and use it via ?Javascript? and trigger my search fuction via ajax which is already working well. I just need to store (probably before going to $link in href of by detail button and read and send session variables (if they exist).


Query author's posts & posts that have author's id as meta value

I am trying to get posts with an author's ID as a meta value in the `author.php` template using additional request parameter. For example I want posts with john's ID as a meta value using a request like this               http://localhost:8888/twitgreen/author/john/?eco=somemetakey      So far I can make it using a `new WP_query` in author.php like this               if ( get_query_var('paged') ) {         $paged = get_query_var('paged');     } elseif ( get_query_var('page') ) {         $paged = get_query_var('page');     } else {         $paged = 1;     }          if($_GET['eco']=='somemetakey'){         $lot = array(             'meta_query' => array(                 array(                     'key' => 'somemetakey',                     'value' => $current_view->ID                 )             ),             'post_type'=>'lot',             'paged'=>$paged ,         );     }          $wp_query = new WP_Query($lot);          //and some loop here
<?php next_posts_link( __( '← Older posts', 'clonecell' ) ); ?>

<?php previous_posts_link( __( 'Newer posts →', 'clonecell' ) ); ?>
           But unfortunately it doesn't work on the next pages. The URL, `http://localhost:8888/twitgreen/author/verifikator/page/2/?eco=somemetakey` points to the 404 page. **The Question**   * How can I query posts with an author's ID as a meta value in the author.php?   * How can I query posts with an authors's ID as a meta value or post from that author in author.php?   * How can I do this requests using WordPress hooks? Thank you in advance.


Writing a custom Glossary plugin

I'm just about to start work on a Glossary plugin for my fishkeeping website. My fish guru has suggested that he would like to be able to   * include images and    * easily link to other glossary entries. To begin with I was intending just to write a taxonomy : title, slug, description, parent. with parent being the initial of the glossary entry for easy searching. That probably won't do the trick however - how could I thus incorporate images or linking? What would be the most effective way of going about this?   * A Custom Post Type?    * How can I provide the Glossary entry authors with a simple way of linking to another Glossary entry? **EDIT** I'm specifically looking for a glossary, with the following kind of entries: > **Cyanobacteria** - Phylum of generally blue-green coloured bacteria, often > confused with algae, that obtain their energy via photosynthesis and include > unicellular and colonial species. Some species occur commonly in aquaria > where they're normally regarded as pests. and.. > **Ich** - Common name for Ichthyophthirius multifiliis, a protozoan which > infects freshwater fish. Also referred to as white spot.


How do I Add images uploaded in the post to a default custom field

I'm trying to add the URL of the post images in to a default custom field. Here is the code I got so far... Here is how I add the default custom field:               add_action('wp_insert_post', 'mk_set_default_custom_fields');         function mk_set_default_custom_fields($post_id)         {             if ( $_GET['post_type'] != 'post' ) {                 add_post_meta($post_id, 'Image', '', true);             }             return true;         }      Now I need a function that fills the value with the URL from the image uploaded. If there is no image uploaded the field can be empty. Here is the code to fill the value with info, but I need the thumbnail url in the value               add_post_meta($post_id, 'custom field name', 'custom field value', true);


WordPress is replacing double minus signs in Post Title, how to disable it?

sometimes i have Post Titles that contains 2 minus signs side by side (--) but wordpress is always removing one of the minus sign. Looks like: `My--Text` into `My-Text` any idea how to disable it? Best regards, Chris


Retrieve all term IDs of post

I have an array of term IDs that I'd like to filter my query with, but most wordpress functions seem to need the 'taxonomy' field entered too. Is there a reason for this? Passing the taxonomy ID seems to be unnecessary, if all term IDs are unique anyway, unless I'm missing something. As it seems as though I can't query this with Wordpress direct, I'd be looking for something like:               $terms_array = get_term_ids( get_the_ID() );      Any ideas of the best way to pull this off?


User activation in wordpress

I want my users to first to activate their accounts so they can use all the features in the site.   There is a field in `wp_users` table named `user_status` which its default value is `0`.   I wonder what's that field for?   Should I use a `user_meta` to indicate the activation status of my users. P.S. The registration of users is handled manually through a plugin I'm writing.


How to extract all ID variables from a query string?

What is the best php method to extract all IDs from a query string and display them in a comma separated list? I have a function that grabs specific posts from the database and am trying to enter those ID's into a new wp_query loop.               Array (         [0] => stdClass Object (             [ID] => 162             [post_author] => 1             [post_date] => 2011-10-22 09:25:46             [post_date_gmt] => 2011-10-22 14:25:46             [post_content] =>             [post_title] => Paper III             [post_excerpt] =>             [post_status] => publish             [comment_status] => open             [ping_status] => open             [post_password] =>             [post_name] => paper-iii             [to_ping] =>             [pinged] =>             [post_modified] => 2011-12-22 09:22:05             [post_modified_gmt] => 2011-12-22 14:22:05             [post_content_filtered] =>             [post_parent] => 0             [guid] => http:/mysite.org/?post_type=album&p=162             [menu_order] => 0             [post_type] => album             [post_mime_type] =>             [comment_count] => 0             [user_nicename] => matt         )         [1] => stdClass Object (             [ID] => 166             [post_author] => 2             [post_date] => 2011-12-22 11:32:46             [post_date_gmt] => 2011-12-22 16:32:46             [post_content] =>             [post_title] => mtayla's album             [post_excerpt] =>             [post_status] => publish             [comment_status] => open             [ping_status] => closed             [post_password] =>             [post_name] => mtaylas-album             [to_ping] =>             [pinged] =>             [post_modified] => 2011-12-26 20:23:00             [post_modified_gmt] => 2011-12-27 01:23:00             [post_content_filtered] =>             [post_parent] => 0             [guid] => http:/mysite.org/?post_type=album&p=166             [menu_order] => 0             [post_type] => album             [post_mime_type] =>             [comment_count] => 0             [user_nicename] => mtayla         )         [2] => stdClass Object (             [ID] => 308             [post_author] => 2             [post_date] => 2012-01-31 15:04:29             [post_date_gmt] => 2012-01-31 20:04:29             [post_content] =>             [post_title] => another album             [post_excerpt] =>             [post_status] => publish             [comment_status] => open             [ping_status] => open             [post_password] =>             [post_name] => another-album             [to_ping] =>             [pinged] =>             [post_modified] => 2012-01-31 15:04:29             [post_modified_gmt] => 2012-01-31 20:04:29             [post_content_filtered] =>             [post_parent] => 0             [guid] => http:/mysite.org/?post_type=album&p=308             [menu_order] => 0             [post_type] => album             [post_mime_type] =>             [comment_count] => 0             [user_nicename] => mtayla          )     )


Optimal approach for replacing the 8 header images in a child theme?

After creating a child theme which is made of `style.css` only (base on `twentyeleven`), the time has come to replace the images. I found this great tip for accomplishing this by hacking the functions in `twentyeleven` but my main concern is minimizing work after a WordPress update. I thought of simply replacing the images in `/wp- content/themes/twentyeleven/images/headers` (while keeping the original names as came with `twentyeleven`) but is this better? It looks like either way I will have re-apply my customizations after updating WordPress in the future. Is there a way to replace the 8 images, _for a child theme_ , and still maintain the changes after an update?


Need post_type_archive_title function but in 'single'

I'm trying to pull a custom post type name/title out for use in the breadcrumb of a single-[cpt].php template file. In the archive-[cpt].php I can use post_type_archive_title() and it echo the name. How would I get this same title in a single view? Thanks! I've trawled though the codex and haven't seen a function, but might have missed it!


Setting Custom Email From name and email address in wp_email()

I am writing a custom plugin that sends an email to users from admin/front end section. I am using wp_email() to send emails and emails are being sent fine. I am testing this on a plain WP installation with only my plugin installed and hostgator as my hosting server. Whenever the email is sent, the email is sent from xyz@gator39.hostgator.com and not from the email address of WP admin account. I have also tried setting custom hooks as mentioned here and setting custom headers, but none of them is working. I am not sure what mistake I am doing. Can you please guide me on solving this issue. Code provided below **EDIT** I have also tried testing it from another dedicated windows server and getting same error.               // new name     function smartsms_mail_from_name() {         return "WebMaster";         //$name =  get_option('blogname');         //$name = esc_attr($name);         //return $name;     }          // new email-adress     function smartsms_mail_from() {         return "webmaster@example.com";         //$email = get_option('admin_email');         //$email = is_email($email);         //return $email;     }     add_filter( 'wp_mail_from', 'smartsms_mail_from' );      add_filter( 'wp_mail_from_name', 'smartsms_mail_from_name' );          //$headers = 'From: '. get_option('blogname') .' <' . get_option('admin_email') . '>';                 $headers = 'From: webmaster@example.com' . "\r\n" .'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();                  $mail = wp_mail($to, $subject, $message, $headers);      > After Brady's answer below, edited the code as below..but no email was sent. > However, I get the message as "Message was sent successfully" :(               if($to!="")             {                 //$headers = 'From: '. get_option('blogname') .' <' . get_option('admin_email') . '>';                 //$headers = 'From: webmaster@example.com' . "rn" .'Reply-To: webmaster@example.com' . "rn" . 'X-Mailer: PHP/' . phpversion();                  add_filter('wp_mail_from', 'smartsms_mail_from'); // add filter to modify the mail from                 add_filter('wp_mail_from_name', 'smartsms_mail_from_name'); // add filter to modify the mail from name                 add_filter('wp_mail_content_type', 'smartsms_wp_mail_content_type'); // add filter to modify the mail content type                 $mail = wp_mail($to, $subject, $message); // send mail                 remove_filter('wp_mail_from', 'smartsms_mail_from'); // remove applied filter                 remove_filter('wp_mail_from_name', 'smartsms_mail_from_name'); // remove applied filter                 remove_filter('wp_mail_content_type', 'smartsms_wp_mail_content_type'); // remove applied filter                 //$mail = wp_mail($to, $subject, $message, $headers);                            if($mail)                 {                     echo 'Your message has been sent!';                              }                 else echo 'There was a problem sending your message. Please try again.';             }          // new name     function smartsms_mail_from_name() {         return "WebMaster";         //$name =  get_option('blogname');         //$name = esc_attr($name);         //return $name;     }          // new email-adress     function smartsms_mail_from() {         return "webmaster@example.com";         //$email = get_option('admin_email');         //$email = is_email($email);         //return $email;     }          function smartsms_wp_mail_content_type() { return "text/html"; }


Parent Child Custom Fields with Advanced Custom Fields

i have a navigation menu for Year, Make, Model of cars. Is it possible to Parent, Child custom fields so that if I have selected 2011, Honda, CRV I don't want other Models from non hondas being shown after I have Honda selected http://ansamaverick.com/inventory/


Why would get_posts be ignoring posts with 2-digit ids?

I'm using this code to list child pages of the current page and similar code to get child pages of all ancestors to use in a sidebar contextual hierarchical nav menu:               $pageset = get_posts('numberposts=0&post_type=page&post_parent='.$wp_query->post->ID);      For some reason, both iterations are ignoring posts with a two-digit post id. Everything else shows up fine. Am I missing something? Do I have a setting that's incorrect? I'm banging my head here...


I want to edit an AJAX Wordpress Pagination

I am using this code to be able to load my content using Ajax (loading content without refreshing the page). The code I found fades out the content and fades in the new content. I want to add the new content under the old ones. In other words, similar to Wordpress's Twenty Thirteen Theme. Can someone help me This is the script after the `wp_header();` in header.php                     This is how my html code looks like
          <?php $my_query = new WP_Query( $args );             if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>


Wordpress Twenty Eleven PhP - forcing php code to skip first post on homepage?

![What I want to fix](http://i.stack.imgur.com/TjZDM.png) I have set up my Wordpress to add the wordpress Featured Image thumbnails to all posts on the homepage. How do I make the code skip adding [wordpress Featured Image thumbnails][3] to the first post [the_content() ~ in the code below] and only add them to [wordpress Featured Image thumbnails][4] the other posts [the_excerpt() ~ in the code below]? Code I put in content.php to make it put [wordpress Featured Image thumbnails][5] on homepage. Link to pastebin code Here                   <?php if ( is_search() | is_home() ) : // Edit this to show excerpts in other areas of the theme?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">         <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
                           <?php  if($wp_query->current_post == 0 && !is_paged()) { the_content(); } else { the_excerpt(); }     ?>
                 <?php else : ?>
                         <?php the_content( __( 'Continue reading →', 'twentyeleven' ) ); ?>                         <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentyeleven' ) . '', 'after' => '
' ) ); ?>
                 <?php endif; ?>


In a MS install, can you allow different users to have their own themes?

Is it possible in a MS install to allow network site admins to edit their own themes? For example, I would like to give everyone access to theme ABC, but if one user edits that theme, they seamlessly create their own instance of the theme, so no other user's theme is affected. I believe the short answer is "no" so I'm wondering if there are any good ideas about how to implement this kind of system.


woocommerce_payment_complete hook only called after accepting payment?

Is there a particular paypal setting that allows WooCommerce to execute `woocommerce_payment_complete` without manually accepting the payment? I have a function that hooks on it. It basically updates a record in the database once the client has finished purchasing the product. Thoughts?


Correct Approach for Validating Custom Field Input

I have a custom post type with several custom fields. I am looking to do some validation on these fields because they will be used downstream by other services. So, it is important that it can't be saved until it is correctly entered. The validation is reasonably complex and requires custom logic. Unfortunately, it also won't work to use a plugin in this particular case. Is there an ideal hook to use in this case? At a high level -- whats the best way to go about this.


Add-action in function

How can i get add_action to work in a function, I want to hide a few admin menu item but not make the user and editor.               function my_remove_menu_pages() {         remove_menu_page('tools.php');         remove_menu_page('themes.php');         remove_menu_page('options-general.php');         remove_menu_page('plugins.php');     }          add_action('admin_init', 'check_username');     function check_username()     {         $user = wp_get_current_user();              if($user && isset($user->user_email) && 'username@example.com' == $user->user_email)         {             add_action( 'admin_menu', 'my_remove_menu_pages' );         }     }


Register Taxonomy earlier so it can be used in functions.php and admin-ajax.php

This is a follow up to this post, outlining why I can not use the get_terms function while in functions.php (actually calling via ajax/admin_ajax.php). I can grab the terms (custom tax) on any post, on any page, except when in my ajax function. I receive the dreaded 'taxonomy does not exist' error when dumping the value of get_terms. The problem is, the taxonomy is registered _after_ I call the function to find the terms. The question is, how do I register the tax early enough so I can use this function? My code to register the custom post type and taxonomy is first in my functions.php (included via an external php to keep functions.php clean)               /************************************************      *     * 1.0 ------------------ Events ----------------     *     ************************************************/               // 1. Custom Post Type Registration (Events)     add_action( 'init', 'create_event_postype', 0 );          function create_event_postype() {       $labels = array(         'name' => _x('Events', 'post type general name'),         'singular_name' => _x('Event', 'post type singular name'),         'add_new' => _x('Add New', 'events'),         'add_new_item' => __('Add New Event'),         'edit_item' => __('Edit Event'),         'new_item' => __('New Event'),         'view_item' => __('View Event'),         'search_items' => __('Search Events'),         'not_found' =>  __('No events found'),         'not_found_in_trash' => __('No events found in Trash'),         'parent_item_colon' => '',     );          $args = array(         'label' => __('Events'),         'labels' => $labels,         'public' => true,         'can_export' => true,         'show_ui' => true,         '_builtin' => false,         '_edit_link' => 'post.php?post=%d', // ?         'capability_type' => 'post',         'menu_icon' => get_bloginfo('template_url').'/images/icons/events.png',         'hierarchical' => false,         'rewrite' => array( "slug" => "events" ),         'supports'=> array('title', 'thumbnail', 'excerpt', 'editor', 'custom-fields') ,         'show_in_nav_menus' => true,         'taxonomies' => array('post_tag', 'tf_eventtype')     );          register_post_type( 'tf_events', $args);          }          // 2. Custom Taxonomy Registration (Event Types)     add_action( 'init', 'create_eventtype_taxonomy', 0 );     function create_eventtype_taxonomy() {            $labels = array(         'name' => _x( 'Event Type', 'taxonomy general name' ),         'singular_name' => _x( 'Event Type', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Event Types' ),         'popular_items' => __( 'Popular Event Types' ),         'all_items' => __( 'All Event Types' ),         'parent_item' => null,         'parent_item_colon' => null,         'edit_item' => __( 'Edit Event Type' ),         'update_item' => __( 'Update Event Type' ),         'add_new_item' => __( 'Add New Event Type' ),         'new_item_name' => __( 'New Event Type Name' ),         'separate_items_with_commas' => __( 'Separate event types with commas' ),         'add_or_remove_items' => __( 'Add or remove event types' ),         'choose_from_most_used' => __( 'Choose from the most used event types' ),     );          register_taxonomy('tf_eventtype','tf_events', array(         'label' => __('Event Type'),         'labels' => $labels,         'hierarchical' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'event-type' ),     ));     }      Here is some pseudo code to show how I'm calling this function from a custom page, I call a function via AJAX (ajax-admin.php)               $.ajax({                   type: "POST",                   url: "<? bloginfo('url'); ?>/wp-admin/admin-ajax.php", //Built in WP AJAX                 data: data,                  success:  function(data){                              //console.log('search complete');                              $("#event-list").html(data)                                                                                }           });      Here is the function that calls a custom query, and where get_terms fails.               /****************************************************************     *     * 1.0 Calendar AJAX Queries     *     ****************************************************************/     // if both logged in and not logged in users can send this AJAX request,     // add both of these actions, otherwise add only the appropriate one     add_action( 'wp_ajax_nopriv_calendar_search', 'calendar_search' );     add_action( 'wp_ajax_calendar_search', 'calendar_search' );          function calendar_search() {                     $args = array(                 'post_type' => 'tf_events',                          'post_status' => 'publish',                 'order' => 'ASC'             );                  $query = new WP_Query( $args );                   // - loop start -             if ( $query->have_posts() ) {                   while ($query->have_posts()) : $query->the_post(); /*Shows the posts that are available. */                          //Event Type                     $cats = get_the_terms($post->ID , 'tf_eventtype'); //the function that fails. All other custom data works fine                           echo                      '
ID . '"  itemscope itemtype="http://schema.org/Event">                                               <time></time>
'. get_the_title() . '

';                            if($cats) foreach($cats as $cat){                                  echo " | " . $cat->name;                            }                            echo                           "

";                      endwhile;               } else {                 echo "
Sorry, no events found!
";                           }              die(); // this is required to return a proper result            }


Where to post/upload the new theme for WordPress theme repository

After a long dedication, I developed a GPL Theme for WordPress. I want it to be available for FREE to WordPress.org Theme Repository. But consulting many Codex resources, I found no direct link where I can post/upload my theme for the WP Theme Repository. **Q: Where can I upload my theme for WP Theme Repository?**


Get Latest Plugin Version from WP API

I'm writing a plugin that checks and collects data from WP - including info about installed plugins. I can get most of the data I require using `get_plugins()` - however, I'd also like to check for the latest repository hosted version of each plugin - but I can't seem to find an API method for this. Sorry, I've got no code to paste for commenting.. but I've had a good search around - honest! Where I can find a simple and efficient way to check?


How to remove the suffix from tag title of the current archive

Hi I am new to WordPress. I am developing a website. I am listing the name of all categories as my menu bar. The problem is that when I click on a category from the menu bar, the word 'Archive' is displayed along with the name of the category. It is displaying the same with all categories in the menu bar. How can I remove the word 'Archive' from the title from being displayed? Please help me.


Add content to /wp-admin/plugin-install.php admin screens

I would like to add some external content to the plugin information displayed on the `/wp-admin/plugin-install.php` admin screens. `/wp-admin/plugin-install.php` calls the following:               $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');      And if I hack this core file as a test, I can add the content, I want, OK. However as a new WP developer I am really struggling to see how I can add this content via a plugin. `class WP_Plugin_Install_List_Table` extends `WP_List_Table` so I don't think I can extend this any further. Is there a way to add content via a plugin to these screens?


Multisite behind Varnish

I'm trying to use varnish with a wp 3.0.5 site with Network (Multisite), when I access the varnish URL, I get this message:               Multisite only works without the port number in the URL.      Do I need a custom VCL to make this work? I'm using the same backend config for other wordpress sites that work fine.. If I need to ask this on serverfault, let me know and I'll ask there.


wp_insert_user email confirmation

I'm creating a new user once they leave a comment, i am doing this with wp_insert_user function create_comment_user($comment_ID){ global $wpdb;               $comment = get_comment($comment_ID, ARRAY_A);     if($comment["user_id"] == 0){         $user = get_user_by('email', $comment["comment_author_email"]);         if(! $user){             $new_id = wp_insert_user(array(                     'user_pass' => wp_generate_password(),                     'user_login' => $comment["comment_author_email"],                     'user_email' => $comment["comment_author_email"],                     'user_nicename' => strtolower(str_replace(' ', '-', $_POST['author'])).'-'.strtolower(str_replace(' ', '-', $_POST['author_last'])),                     'display_name' => ($_POST['author']).' '.($_POST['author_last']),                     'first_name' => ($_POST['author']),                     'last_name' => ($_POST['author_last']),                     'role'      => 'Subscriber'                 )             );             if($new_id)                 wp_new_user_notification( $new_id );         }     }     return;     }     add_action("comment_post", "create_comment_user", 10, 1);      The email confirmation does not get sent, but the user is being created. Any ideas why?


I changed my site from HTTPS back to HTTP and now it is broken- Cannot access Admin panel on HTTP URL

I have a WordPress site that I was running every page over SSL for the past year. I just added a new website to the same server and have to share IP with the new site and the new site needs SSL much more then the old site. So I have gone through the process of changing all my `https` links back to `http`. My site loads fine now over regular `http` except I have 2 issues. 1) When I view source, it is showing a lot of stuff still linked to `https` however none of it is from the Database. IT is instead all places where `home_url()` is used to generate the URL! I have done a search and replace of the whole entire database to ensure all https links are back to http however it is acting as if my sites URL is still HTTPS when I call the WordPress settings for the URL. 2) Because of this bizarre behavior I cannot access my Admin panel as it redirects to `https` now! Like I mentioned the database does not contain HTTPS anywhere anymore. I have no plugins that force Admin or anything to use HTTPS either. So I cannot for the life of me understand why `home_url()` prints out an `https` URL instead of `http` when the DB has all `http` url's. Also note these details...   * that I do not have any caching!   * I have deleted all Transients as well   * There is nothing in the htaccess file that is making my admin panel redirect to https yet it does redirect to https which no longer exxist so I cannot login to admin panel anymore.   * All database files have been updated and converted from `https` to `http` in every wordpress related table. posts, options, etc...   * There is no plugin that I can see that would be doing this so far   * I also do not see any code in my functions or any other included custom file that would be changing my `home_url()` function into `https`   * There is nothing in my `wp-config.php` file causing this.


image class removed in excerpt

I have inline images in my post content that have classes. the classes are available as I go to single page like this:                      , but are removed as I look them at my homepage by using excerpt.                     does wordpress manipulate the classes, in excerpt?


how to deactivate a plugin without using a WP function?

I wish to deactivate my plugin, but WITHOUT using update_option() or any other core WP function. What's the best way to go about this? Direct DB connection and modification?


Is there any Reference of Wordpress hook and hacks?

I am searching for a website to have lots of Wordpress hacks and hooks. Some hooks like activating debug mode or etc. Can you give me lots of this futures ?


Newbie Question: How to create a "latest news" page showing a list of posts from blog category

I am using the Modest theme from elegant themes at http://lilsaintz.co.nz Under the slider on the homepage, there are three content areas that are generated from pages. I would like to make one of the content areas a "Latest News" element showing the last 5 posts from the blog (category = blog). Bearing in mind that I am a complete WP novice - although I am really good at following instructions :) - what would be the best way to go about doing this? Thank you!


How to output built-in widgets with number in range as class?

I'd like to make my theme mobile friendly by turning the widget-containers into touchable buttons, having their contents flying out when hovering. Therefor, I will have to absolutely position the content of each container a few pixels more than its previous one. Well, I could achieve that by planning how to arrange the widgets before the site goes live and then rely on the class-names WP generates commonly, but since I wanna leave the order up to the customer, this is not a solution. The trick would be to pass each widget a class name in regard to its position in range. Is there a way to do this?


Fallback if statement based on the number filtered from it

I'm trying to add three ads on a page. I have a custom post type called 'ads' and I'm using advanced custom fields to add a start date an end date and an option to select which pages to associate them with. I want to set a fallback image for the ads if there aren't any ads that fit within this criteria..               if ( $start_date <= $current_date && $end_date >= $current_date && in_array( $page_id, $page_ids ) )      So lets say I have 6 ads setup and only 1 fits that criteria and is still active. The `else statement` doesn't take into consideration how many ads are active, so if there is only 1 ad active it will still show 3. I would like to have it only show the fallback ads if there are zero ads that fit in that `if statement` but can't figure out how to do that at this point in the loop. I have the `posts_per_page` set to unlimited because I need to filter them by date and pages associated with them, so I'm using `$i < 3` on the while loop to limit it to three ads from that point. Basically don't show any fallback ads unless there are zero ads that fit the `if statement`. This is probably more of a PHP question but it includes the wp loop so figured this would be the better place to ask. Anyone have any ideas? Thanks               <?php     $current_date = date('Ymd');     $page_object  = get_queried_object();     $page_id      = get_queried_object_id();          $args = array(         'post_type'      => 'ads',         'posts_per_page' => -1,         'orderby'        => 'rand'     );          $ads = new WP_Query( $args );          if ( $ads->have_posts() ) : $i = 0;         while ( $ads->have_posts() && $i < 3 ) : $ads->the_post();             $start_date = get_field( 'start_date' );             $end_date   = get_field( 'end_date' );             $link       = get_field( 'link' );             $display    = get_field( 'display_on_page' );             $page_ids   = array();                  // Store ID's in an array             foreach ( $display as $post_object ) {                 $page_ids[] = $post_object->ID;             }                  // Show ads that are inbetween start & end dates and match the page_ids selected             if ( $start_date <= $current_date && $end_date >= $current_date && in_array( $page_id, $page_ids ) ) {                 ?>

                         <a href="<?php echo $link; ?>"><?php the_post_thumbnail( 'ads' ); ?>

                 <?php             } else {                 // Will loop 3 times for fallback ads ?>

                         <img src="<?php bloginfo( 'template_url' ); ?>/images/ad-listing.jpg" alt="Advertisement">

                 <?php             }        $i++;        endwhile;     endif;     ?>


Use of global variables within plugin

I am creating my first plugin ever and I found my self having to call the same option variables within various parts of the same page therefore I sought for a solution and stumbled upon global variables which seems to be working for me, however after reading a few articles people seem to be against using global variables and also, I'm not entirely sure if I'm using them the correct way. Here is what I have;               /************************     * Variables     ************************/     global $bClass, $cClass, $dClass, $cExpiry;            $bClass = $cClass = $dClass = $cExpiry =  get_option('myoption');      Then since I use a single option to save relevant variables in an array, I would echo the value like this **jquery**               expires: <?php global $cExpiry; echo $cExpiry['cExpiry']; ?>,      and then I would also use it in other functions within the same page. So, it works for me, however I am still wondering whether I am doing it right. **update** Thanks for the explanation guys, I ended up using local variables and also found a mistake in my code; Since I have all my variables saved in a single option, I just used a single local variable;               $options = get_option('myoption');      Then I would get access to the array by placing the variable inside brackets               <?php echo $options['var1']; ?>      Whereas before I was doing `$bClass = $cClass = $dClass = $cExpiry = get_option('myoption');` which is bad.


How to add multiple values with add_query_arg?

Let's suppose I am on this url of my site http://demo.com/?cat=1+2+3 And now someone clicks on a link generated with add_query_arg(). How can I make this link go to http://demo.com/?cat=1+2+3+4 Im trying to create a taxonomy filter and this is what I have:               foreach ( $sub_terms as $st ) {         echo 'term_id ,"http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) ).'" class="subterm">'. $st->name .'';     }      Instead of appending my term id to the url, it just replaces cat with the new value: http://demo.com/?cat=4 I hope it's clear enough Thanks!


Building a Member Directory Site on WordPress with Facebook API Integration?

I'm looking to build a member directory for one of my WordPress sites that hooks into the Facebook API. Site users would be able to browse through the directory of members and view their Facebook profile and information such as e-mail address, phone number, website, etc. Basically, I'm thinking that members will need to login to facebook from the site and "allow access." Then, WordPress can pull member data from Facebook such as e-mail address, phone number, website, etc. and store it as custom meta in WordPress. One problem with this approach would be when a user updated their facebook profile, the WordPress site wouldn't get updated until they log back into the site and the "update" process kicks off again. Am I way off base? Is there an easier way to do it? Is there anything that would get me started with this, or would it need to be built entirely from scratch?


Live blogging plugins?

What do you all use for live blogging? I've found Live Blogging by Chris Northwood (more than I need) and Twitter LiveBlog by Mashuqur Rahman (I want it to stay within WordPress). Are these really the only two games in town?


How can i loop through custom post type according to custom meta field?

I have a winery website with the custom post type "wine", each wine has various custom meta fields like "vintage", "pH", "Varietal-Composition" etc... Now, i would like to list all wines where vintage=2005. Any pointers?


Adding custom text in items titles from wp_nav_menu()

I need to add something after each title of a specific menu called by wp_nav_menu() I tried               add_filter('wp_nav_title', 'testing_stuff');      with               function testing_stuff() {     $item->title = $item->title . ' testing';     return $item->title;      } without any success, i'm not familiar enough with hooking. My purpose :   * when I called menu ID = 4;   * for each title of each item   * i pull out data from current page meta with $meta_value = get_post_meta( $post->ID, $meta_key, true );   * I add this data after the anchor text in a  So every item of the menu will have a specific data added to its content, data I could manipulate from custom field. I would appreciate any clue that get me on the right path. Thank you.