Next and previous link in custom post type in the same taxonomy term

I have a custom post type `name->('portfolio')`, with a taxonomy name `'portfolio_category'`. What I want is to add next and previous links on its single page file which is single-portfolio.php. When I click either of the links, it should redirect to the next or previous post in the same post type and in the same taxonomy term. I used `next_post_link()` and `previous_post_link()` but it seems that it only works in single post but not in single custom post type.. Any suggestions will greatly be appreciated.


Cannot login to Wordpress site after changing .htaccess for security purposes

This is the original .htaccess on my local computer                   # Block the include-only files.         RewriteEngine On         RewriteBase /         RewriteRule ^wp-admin/includes/ - [F,L]         RewriteRule !^wp-includes/ - [S=3]         RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]         RewriteRule ^wp-includes/theme-compat/ - [F,L]              # BEGIN WordPress         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteBase /         RewriteRule ^index\.php$ - [L]              # uploaded files         RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]              # add a trailing slash to /wp-admin         RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]              RewriteCond %{REQUEST_FILENAME} -f [OR]         RewriteCond %{REQUEST_FILENAME} -d         RewriteRule ^ - [L]         RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]         RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]         RewriteRule . index.php [L]         </IfModule>              # END WordPress      This is the new setting for online site on server. Please help me out as I know nothing about these .htaccess code. Which part do I have to take it off and which part should I keep in order to make the site running again just like on local but of course including well-protected security line of code as well?                   # Block the include-only files.         RewriteEngine On         RewriteBase /         RewriteRule ^wp-admin/includes/ - [F,L]         RewriteRule !^wp-includes/ - [S=3]         RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]         RewriteRule ^wp-includes/theme-compat/ - [F,L]              #disable hotlinking of images with forbidden or custom image option         RewriteEngine on         RewriteCond %{HTTP_REFERER} !^$         RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]         #RewriteRule \.(gif|jpg)$ – [F]         RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/stealingisbad.gif [R,L]              RewriteEngine On         RewriteCond %{REQUEST_METHOD} POST         RewriteCond %{REQUEST_URI} .wp-comments-post\.php*         RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]         RewriteCond %{HTTP_USER_AGENT} ^$         RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]              # protect wpconfig.php         <Files wp-config.php>         order allow,deny         deny from all         </Files>              # disable directory browsing         Options All -Indexes              <Files ~ “^.*\.([Hh][Tt][Aa])”>         order allow,deny         deny from all         satisfy all         </Files>              Order deny,allow         Deny from all         <Files ~ ".(xml|css|jpe?g|png|gif|js)$">         Allow from all         </Files>              # Protect the .htaccess         <files .htaccess="">         order allow,deny         deny from all         </files>              # BEGIN WordPress         <IfModule mod_rewrite.c>         RewriteEngine On         RewriteBase /         RewriteRule ^index\.php$ - [L]              # uploaded files         RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]              # add a trailing slash to /wp-admin         RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]              RewriteCond %{REQUEST_FILENAME} -f [OR]         RewriteCond %{REQUEST_FILENAME} -d         RewriteRule ^ - [L]         RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]         RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]         RewriteRule . index.php [L]         </IfModule>              # END WordPress


How to Import Categories with Descriptions from a CSV File?

How could I import a list of new categories and category descriptions from a file of Comma Separated Values?


Automatically delete default posts and pages on theme install?

Is there a way to automatically delete the default wordpress posts and pages when activating theme theme?


How to redirect a URL with parameters?

My redirection are working until parameters are added to the end of the source URL. What will be the proper way of implementing a redirect were the target will be a different URL but I want to pass the parameters untouched. Post with Parameters goes to 404 page Same post without parameters redirects properly I am using the following pluging for the redirects: http://wordpress.org/extend/plugins/redirection/


How to display a post's Featured Image with this code?

so this is sort of a continuation of another question that I had to ask recently. I wanted to start another conversation, since technically my last question was answered. The last question is here: Display Post Thumbnail Without Being Featured Image if you would like to get caught up on where I was, and where I'm at now. I used to call the post's thumbnail with this:               if ( has_post_thumbnail() ) {                   the_post_thumbnail();      With no issues. Then I started to think that I would need it so that my client didn't always have to set a featured image for every post. Well, with no featured image, there was so post thumbnail being shown in the post's excerpt. So, because of the answer that I was given in the last question(link posted above), I am now using the Get The Image plugin along with this:                                                                    if (      has_post_thumbnail() ) {                   the_post_thumbnail();                    }                    else                    {                     get_the_image( array('size' => 'thumbnail', 'image_class' =>     'wp-post-image'));                       }        Now, if there is no Featured Image chosen for a post, it picks the first image of the post's gallery, since there will always be a gallery for each post. The problem now is that on the actual post, I have had it set so that the Featured Image is shown in full size right in the middle of the page. Thanks to this in my functions.php file:               // This theme displays full size featured image on the Post's page     function InsertFeaturedImage($content) {                    global $post;          $original_content = $content;          if ( current_theme_supports( 'post-thumbnails' ) ) {              if ((is_page()) || (is_single())) {             $content = the_post_thumbnail('page-single');             $content .= $original_content;              }           }      return $content;     }          add_filter( 'the_content', 'InsertFeaturedImage' );       Before I added in the                              else                    {                     get_the_image( array('size' => 'thumbnail', 'image_class' =>      'wp-post-image'));                       }      It has worked fine. Now, it's just displaying the small thumbnail there right in the top middle of post's page. It should be displaying a full size image. So all this has brought me to the main two problems I'm now facing. 1) Can I edit that code in the functions.php file to still display the featured image in full size. And 2) What if there is no Featured Image chosen for a post, can I also make the functions.php code display the first image of the post's gallery, in full size? I really hope this isn't too confusing. Please see http://dependablecarcompany.com and see the post excerpt titled, "1991 GMC Sierra". This post has no Featured Image, but a thumb is still being output, thanks to the Get The Image plugin. But when you actually click through to the actual post, you'll see that the top, center image is showing the thumb. It should be the full size image. Thank you so much for anyone who can get through all this, and share some tips for me!


is_home, and is_front_page conditional problem

I have this snippet in a "portfolio-loop.php" file. I'm using get_template_part to display the loop on the front page and on other pages. I have this within the loop:               <?php if( !is_home() || !is_front_page() ) { ?>
<?php the_time('F Y'); ?>
     <?php endif } ?>      I can't seem to get it to exclude the front page. Could it because it's in it's own template? **edit** Ok I fixed some of my semantic errors thanks to s_ha_dum and Tom Nowell. I've tried the following variations:               <?php if ( !is_home() && !is_front_page() ) { ?>               <?php } else { ?>
<?php the_time('F j, Y'); ?>
     <?php } ?>                    //dropping is_home() and trying to keep it as simple as possible     <?php if(!is_front_page()) { ?>
<?php the_time('F j, Y'); ?>
     <?php } ?>      I still can't hide the time on the front page. At best '<--nada-->' will appear on both my home page (home.php) and on my archive (category-blog.php). Is my custom category page seen as a front page as well? **edit 2** What I'm trying to do in plain english: I have a loop on my front page (static, home.php) displaying three of my latest blog posts via get_template_part. The same loop is used for my category-blog.php/archive listing but shows the last 10 posts. I do not want to show the date/time on the front page to keep the layout cleaner, only on the other pages that this loop is displayed on.


Multiple Loops on a Custom Homepage

I have read many posts here and across web. I can't see why my loops return nothing (or the right query). Here is my code for multiple loops on a custom home page. Anyone know why my loops are not working - any help would be much appreciated. Also goal for the loop is to return one article from pages (1st loop with a slug of feature 1 and in 2nd loop slug of feature2)page should be published, and it should be the most recent (in case the client adds duplicate slugs - is this possible).
                                      <?php                                      // The First Query                                 $first_feature = new WP_Query(array(                                     'post_status' => 'publish',                                     'post_type' => 'page',                                     'order' => 'DESC',                                     'posts_per_page' => '1',                                     'pagename' => 'feature1'                                                                     ));                                      // The Loop                                 while($first_feature->have_posts()) : $first_feature->the_post(); ?>

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

                                                                                <?php if ( has_post_thumbnail()) : ?>
                                                                                <a href="<?php the_permalink(); ?>" class="icons">                                                                           <?php the_post_thumbnail('medium', array('class' => 'border')); ?>
                                     <?php endif; ?>

<?php mwwp_excerpt('feature1_custom_post'); ?>

                                     <a href="<?php the_permalink(); ?>" class="reading">Read Full Article
                                                                                <?php endwhile; ?>                                 <?php wp_reset_postdata(); // reset the query ?>

                                      <?php                                      // The Second Query                                 $second_feature = new WP_Query(array(                                     'post_status' => 'publish',                                     'post_type' => 'page',                                     'order' => 'DESC',                                     'posts_per_page' => '1',                                     'pagename' => 'feature2'                                                                     ));                                      // The Loop                                 while($second_feature->have_posts()) : $second_feature->the_post(); ?>

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

                                                                                <?php if ( has_post_thumbnail()) : ?>
                                                                                <a href="<?php the_permalink(); ?>" class="icons">                                                                           <?php the_post_thumbnail('medium', array('class' => 'border')); ?>
                                     <?php endif; ?>

<?php mwwp_excerpt('feature2_custom_post'); ?>

                                     <a href="<?php the_permalink(); ?>" class="reading">Read Full Article
                                                                                <?php endwhile; ?>                                 <?php wp_reset_postdata(); // reset the query ?>


Including an External File in a Post (and Using Processed Paths)

I have a post that includes a relatively large table that gets updated frequently. Instead of using the (slower) web interface to update the post each time, I installed one of the “run PHP” plugins and put a short bit of PHP code in the table body that opens an external file on the server and puts that in the table in the post. This way, I can edit the file locally in a responsive text-editor as needed and the change is reflected immediately when the the page is served (and without requiring any changes to any of the WordPress tables). This works pretty well and I am generally satisfied with it, but there is a small catch in that the path to the external text-file is relative to the store on the server (I used the media-library manager to store it, and because I’m using the multi-site feature and PHP is server-side, the path is of the form `"wp-content/blogs.dir/1/files/2011/02/foobar.txt"`). The paths to other files like images that client-side code like JavaScript uses is relative to the URL. This is obviously not ideal for several reasons. So I’ve got two questions:   1. Is there a better way to include external content in a post than using PHP?   2. (well, 1b.) If not, is there a better—ie, more consistent—way of accessing the files? (That is, a way to have PHP use URL-relative paths instead of server-relative paths?)       **Clarification:** In the post, I have something like this (code is off the top of my head, so ignore any errors):               …

foo	bar

           <?php            $fn  ="wp-content/blogs.dir/1/files/2011/02/foobar.txt";            $fh  =fopen($fn, "r");            $data=fread($fh, filesize($fn)); //no clearstatcache; TXT file is not updated *that* often            print($data);            fclose($fh);           ?>

     …      Where the text file contains something like this:
Blah	123

Foobar	asd

Test	555
     …      When the page is served, the PHP in the post is executed and pulls in the table rows from the external file, picking up any changes I made externally to it without having to go through WordPress to do so. There is also some JavaScript before the table that deals sets some images according to a switch statement—the images were imported with the media library—something like this:               case 'a': element.style.backgroundImage='url(/blogs/foobar/files/2011/02/A.png)'; break;     case 'b': element.style.backgroundImage='url(/blogs/foobar/files/2011/02/B.png)'; break;     …


JQuery Wordpress gallery

I would like to know if it's possible to create a gallery like that one using WordPress: http://jfdelsalle.com/naaman.swf Is there any plugin close to that?


Using jQuery .after inside loop

I have a bit of javascript that will dynamically add a static post to a loop. The script uses the jQuery 'after' method and on a static page it works beautifully but when inside the loop I don't get any results. Can anyone see what i'm doing wrong here? Does WP not allow DOM insertion within a loop?               function newTile(){       var adTile = "

 this is a test

";       var adLoc = 5;       var tiles = $('#article-tile:nth-child('+adLoc+')');       $(tiles).after(adTile);     }


query_vars in plugin when using custom permalinks

I am trying to do the following I need to get the category of the current page at the plugin level so before it goes to `archive.php` or`single.php` so i have a plugin to do this and based upon category it switches themes .. however i am stuggling to get the category at the plugin level when i am using custom permalinks which do not have a query string (ie seo friendly urls) So if i go to the default permalinks , I can get the category within the plugin using               $wp_query->query_vars['cat'];      However with the custom permalinks that returns null and I have not been able to think of another way of doing this , Please can anyone help ? Thanks a lot Waseem


Use plugin or custom post type for game score functionality

The last couple of days I've been working on a plug-in that adds the functionality of keeping scores from a paintball game. When I manage to finish it I want to present players with a form so they can add in stuff like: hits, deaths, wins, losses, location, role and date. That goes to a custom table in the WP database. They will also get a profile page that shows the last 5 records, win/lose ratio's and the likes. The admin also has a menu that shows this table, and should be able to manipulate the date (incase of abuse). I've got further with the plugin then I thought. Admin screen is present and loading the info from the table (sorting some columns). But I haven't yet got the edit or delete functionality to work. Which got me thinking. I've worked with custom post types before. Wont it be easier to make this plug-in in to a custom post type? Can users send data to it from the front-end? Can I query the data and do some simple math with it? Admins can change the data fairly easy with a custom post type if I'm not mistaken. Only downsides I can think of now is theme problems. I think its easier to show the data from the custom table with a plug-in via short codes then integrate custom-posts in a theme? Can I create short code's for the custom post type? So should I drop the plug-in way and go for a custom post type? I'd like to be able to share this plug-in eventually, so if I go with the custom-type I'll probably end up making it in to a plug-in that enables the custom-post-type.


paginate_comments_links() not working

I'm using paginate_comments_links() to get all the comments by the current user:               <?php     global $current_user;     get_currentuserinfo();     $userid = $current_user->ID;          $args = array(         'user_id' => $userid,        'number' => 2,     );     $comments = get_comments($args);     foreach($comments as $comment) :         echo('
' . $comment->comment_date . '
' . $comment->comment_content);     endforeach;          paginate_comments_links();     ?>      However, the pagination is not showing up. I have posted 7 comments, so I expected to see 2 comments per page, 4 pages in total. However, no pagination is showing up at all. Turning on errors in php reveals: Notice: Undefined property: WP_Query::$comments in /wp-includes/comment.php on line 788 Where am I going wrong?


How to get posts which must match both custom taxonomies?

I have searched in the stackexchange site for an answer for this question. However, I did not find any posts can help me solve the following problem: I have 2 custom taxonomies named **tax1** and **tax2** I want to create a args for WP_Query which must meet the following conditions: - The posts must be in both **tax2** and **tax2** - The posts are in the custom post_type **posttype1** I have tried to create the following args to get the posts but it did not work as I expected:               $query_args = array(             'post_type' => 'posttype1',             'ignore_sticky_posts' => 1,             'posts_per_page' => 10,             'offset' => 0,             'orderby' => date,             'order' => ASC,             'post__not_in' => array( get_the_ID() ),             'tax_query' => array(                 'relation' => 'AND',                 array(                     'taxonomy' => 'tax1',                     'field' => 'id',                     'terms' => array ( ... ), // an array of term                     'operator' => 'IN'                 ),                 array(                     'taxonomy' => 'tax2',                     'field' => 'id',                     'terms' => array ( ... ), // an array of term                     'operator' => 'IN'                 )             )         );      Could anyone help me to solve this problem please? Thanks


Benefits of storing uploads in an assets folder?

I'm trying to get up to speed with responsive theme development in Wordpress and have been looking at Bootstrap and combining it with HTML5 boilerplate. I came across this skeleton framework which combines both of them: http://www.rootstheme.com/ However, it sets up the uploads folder to be /assets/ in the root of my site. Is there any benefit to doing that? This theme looks like it's doing a load of good stuff, so I'm assuming there's a benefit to do so? Thanks Osu


Show plugin only on a specific page

I am using the plugin Connections in my website. Now I created a page exclusively for this, so the directory listing has to be only shown if the page is "Directory" and it has to be shown in center. Currently the plugin is shown in sidebar. How can I solve this issue?


API to trigger prompt on leaving page

I have a proprietary plugin that creates a metabox on the edit-post page. When the data managed by the plugin is edited and the user navigates away then we would like the user to be prompted as Wordpress (or is it TinyMCE?) does now when the body of the article is edited. Ideally, if the user modifies the metabox and the post content they would be prompted once. **Is there an API which allows us to activate Wordpress' (or is it TinyMCE's?) dirty flag?** I am aware of this similar question and the answer whcih suggests proxying the beforeunload event.


Remove site name from <title> tag

My current `<title>` tags are like this: > Blog post title | Site name How do I remove "Site name" so that the `<title>` tags will be like this: > Blog post title Except, of course, on the front page, where the `<title>` tag should be: > Site name Please take into account that I'm a complete Wordpress newbie. * * * Edit: Here's my current `<title>` tag from `header.php`:               <title>     <?php     if ( defined( 'WPSEO_VERSION' ) ) {         // WordPress SEO is activated             wp_title();          } else {              // WordPress SEO is not activated         wp_title( '|', true, 'right' );     }     ?>     </title>


Custom query variable - get wordpress to redirect to nice permalink url

I have been looking for an answer for the last couple of hours but could not find anything pointing me in the right direction. Some advice would be very much appreciated!   * What I already have:      * A custom post type `'stores'`     * A public query var using the `'query_vars'` filter hook: `'state'`.     * Added the according rewrite rule:        * Pattern: `stores/state/([^/]+)/?$`       * Match: `index.php?post_type=stores&state=$matches[1]`     * As `'state'` is a custom meta field, I added a function hooking into `pre_get_posts` action hook doing all the query magic (creating `meta_query` etc) to display only the matching `stores` in the archive page. That's all working quite well: So if I enter `www.myurl.com/stores/state/austria` my archive page is only showing Austrian stores. To filter the stores not only by url, the archive page includes a form to filter them. This is where I run into my problem: the form obviously only passes POST or GET data, e.g. like the following:               www.myurl.com/stores/?state=austria      I can deal with this by adding a check in my `pre_get_posts` filter function:               if( isset( $_REQUEST['state'] ) || $query->get('state') != "" ) {      However, this is a little dirty as I would like wordpress to automatically redirect to the rewritten URL:               www.myurl.com/stores/?state=austria      should be redirected to               www.myurl.com/stores/state/austria      the same way it is done if I enter a page or post ID and it redirects to the permalink. Is there another action hook I have not discovered yet? How would I get wordpress to automatically redirect to the pretty permalink? Thank you for every hint.


How to order adjacent posts (prev / next) by custom field value?

I am using the More Fields and More Types plugins to create a custom post type called `product`. This custom type is based on the **Post** type. One of the fields is named `lot` which is an integer representing a Lot # for an auction. I created a custom category page which generates a list of links for each Lot, ordered by the `lot` field. This works great.               $args = array(       'post_type' => array('product'),        'cat' => 3,       'meta_key' => 'lot',       'orderby' => 'meta_value_num',       'order' => 'ASC'     );      **However...** when you click on one of the lots, the Previous & Next post links aren't ordered by the `lot` field anymore, they are ordered by publish date (which is the WP default). I am trying to figure out how I can change this default sort order for `previous_post_link()` and `next_post_link()` to use custom field `lot` instead of Publish date.


What is the best way to sort posts by a custom algorithm?

I'm wondering what is the best way to sort posts on homepage using a small algorithm like `custom_field_votes / ( post_hours_old + 2 ) ^ 1.8` I have tried creating a new custom field with the result but updating all posts at once or even hourly with a cron doesn't sound very good (performance). Any opinions?


Image Attachment Url Rewrite

I'm having an issue with url rewriting for a theme I'm making, which is basically a gallery theme based on the roots theme. Here's how the site navigation works:   * Home Page (With Tiled Image Gallery) (Images link to parent pages) Current URL - `domain.com`   * Parent Page (With Tiled Image Gallery) (Images link to attachment page along with #id to link to the clicked image ). Current URL - `domain.com/landscapes`   * Attachment Page (With ALL full size images attached to the parent post). Current URL - `domain.com/landscapes/image-title/#id` What I would like to do is to remove the image title from the attachment page URL and replace it with gallery so that the URL reads `domain.com/landscapes/gallery/#id` My content-image.php uses `wp_get_attachment_image_src()` to get the image urls. With pretty permalinks disabled i get an image URL like `domain.com/index.php?attachment_id=205` When checking with pretty URL with the Rewrite Rules Inspector Plugin, that URL (`domain.com/landscapes/image-title/#id`) gets 2 matches which are as follows: RULE 1: `(.?.+?)(/[0-9]+)?/?$` Rewrite 1: `index.php?pagename=$matches[1]&page=$matches[2]` RULE 2: `[^/]+/([^/]+)/?$` Rewrite 2: `index.php?attachment=$matches[1]` From what I understand, The second rule is the one that is being applied in this case, but I have no clue what to change it to. Any idea on how to do this?


Run "get_the_post_thumbnail" with a different table prefix?

I have this site were I run two Wordpress sites on the same database (with different prefixes), on one domain. What I want is to get the post thumbnail from the second Wordpress installation, by running the function `get_the_post_thumbnail` (with a different table prefix), on the first Wordpress installation. Simplified: Two Wordpress sites, One database, Wordpress site "a" want to get a post thumbnail from Wordpress site "b" through the function `get_the_post_thumbnail` I really hope this makes sense!


How to test a WordPress plugin through the upgrade automatically feature

Last week I had released a version of a WordPress plugin that works if the user was doing a fresh install, however if they already had the plugin and upgraded it using the WordPress upgrade automatically feature, problems occurred and some of the database elements were erased. So I had to revert back immediately. I was wondering if there was a way to test the plugin through the upgrade automatically functionality before hand instead of having to release it and hoping you get it right the first time. Thanks in advance, Omar


Wordpress homepage hangs in IE browsers

Anyone has any insight why http://www.quantnet.com loads fine in FF, Chrome but hangs in IE for 20 seconds or more? I have been hunting down the problem but reach an end.


How do you properly prepare a %LIKE% SQL statement?

I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input.               SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%';      I've tried something like this to no avail:               $wpdb->prepare( "SELECT column_1 from `{$wpdb->base_prefix}my_table` WHERE column_2 LIKE %s;", like_escape($number_to_put_in_like));      How do you properly prepare a %LIKE% SQL statement using the WordPress database class?


where to find on backend to amend and edit title tage for each page on website?

I need to put a title tag on each page of my website but I can only seem to be able to do it for the home page, where can i set and edit the title tags for the other pages?


Create a constant download link that always points to latest attachment

I plan to have one attachment per post and the attachments will often be receiving updated versions with different file names. I have an issue where users copy and paste the file url and send it via email. Is there a way I can provide a constant URL for example http://domainname.org/218/?download-attachment that will always point to the attachment currently uploaded to the post?


Prevent five different copies of jquery from being included on every page

Many wordpress theme, plugin, and widget developers seem to think that the only way to use jquery on the page is to include their own copy. On some pages of the site I'm developing, there are as many as _six_ different places where I see various different copies of jquery included. **This is ridiculous.** It increases loading time, and is totally redundant. Is there any easy way, either through a plugin or a bit of my own coding, to force only _one_ copy of jquery to be included on each page? There's already a `jquery.js` in the `/wp-includes/js/jquery/` directory, which should suffice for any plugin that needs it. How can I automatically remove all of the other references to it on the page?


How do I show google ads between post content?

I want to show ads by Google between text content, like show 3 ads one after 1st para second after 3rd para and one at end of last para. I know i have to modify in `single.php` but being novice in php I am unable to do this. Would be real helpful if someone could help me do this. Thanks.


Function to return custom post type titles from blog id 1

I'm trying to create a function to retrieve all titles from a custom post type located on blog id=1. I tried to use foreach but I cannot get it to work. The closest I have been was using this:               function getctas() {         switch_to_blog(1);                  $args =  array(                 'post_type' => 'location_icons',              );                  $ctas = new WP_Query($args);             while ($ctas -> have_posts()) {             $ctas -> the_post();             $titles = get_the_title($post->ID);             restore_current_blog();             return $titles;             }          }      The issue I'm facing with this is that the function is returning only 1 post title and not all as I intend to.


Alphanumeric usernames and error message for it

I'm facing a problem where I haven't seen proper answer anywhere. What I need help with is this: How can I prevent my users registering non-alphanumeric usernames? To be exact, I could prevent it by using something like:               function validate_alphanumeric_underscore($string?) { return preg_match('/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/',$str); }      But what is the string I should/could use and how can I echo error message saying that the username inputted had invalid characters? Cheers!


How to use a custom post type as front page?

I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type _archive_ with the following code (originally posted here):               function custom_front_page($wp_query){         if($wp_query->get('page_id')==get_option('page_on_front')){             $wp_query->set('post_type','album');             $wp_query->set('page_id',''); // empty             // fix conditional functions             $wp_query->is_page = false;             $wp_query->is_archive = true;             $wp_query->is_post_type_archive = true;         }     }     add_action('pre_get_posts','custom_front_page');      Replacing               $wp_query->is_archive = true;     $wp_query->is_post_type_archive = true;       with               $wp_query->is_single = true;      calls the `single-album.php` template as I'd like to, but it still returns ALL the posts in the "Albums" category, instead of only one. Adding               $wp_query->set('posts_per_page',1);      has no effect. What should I be doing instead? _Bonus question: is there a good reference somewhere about how to manipulate the`query` this way?_


Display Widgets Horizontally in Area

I am building a custom bootstrap 3 theme. I have created a new widget area for my header and am trying to get the widgets there to display horizontally, in line. I've looked up several tutorials, but none seem to be working. Can anyone help?               **Here is my CSS for the list:**          #top-widget-container ul {      list-style-type: none;      }          #top-widget-container ul li {     display: inline;     }          **And my functions.php widget insert**          add_action( 'widgets_init', 'add_header_widget' );     function add_header_widget() {              register_sidebar( array(             'name' => 'Header Widget Area',             'id' => 'header_widget',             'before_widget' => '
',             'after_widget' => '
',             'before_title' => '
',             'after_title' => '
',         ) );     }


How to prevent parent admin page from appearring as a child admin page

I am using this code:               add_menu_page($page_title, $menu_title, $this->capability, $menu_slug, $function);      Which is adding top level admin page. When I add:               add_submenu_page( $menu_slug, 'sub menu 1', 'sub menu 1', $this->capability, $menu_slug . '_sub_menu_page_1', $function );      I get not only the desired child page, but also the parent page moves to become a child page of itself.


How can I include PHP-Code to my post?

I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags. I don't need PHP in every post, but it would be great if I could use it in some. I saw that it is possible to create custom page templates which seems to be almost what I want, but I want it for posts. How can I get it?


WYSIWYG editor with image upload for "Normal Users"

Can someone tell me is there a plugin doing this?(This has been asked over 6 years from bbpress.org) I have tried lots of plugins but no one does exactly what I need,      1) A WYSIWYG editor in bbpress for normal users(frontend).   2) With an image “upload” feature, but is not working like an attachment like “GD bbPress Attachments”.   3) All the uploaded images will be separated by folder(user name or individual name for an user).This is to avoid user use images from other users.      I am also happy to know the reason if this is impossible this meanwhile, like wordpress official has a consideration on it’s risks.


Check if empty or not

How can check if a custom user profile field [ name and age and email] is empty? If is empty display a message else display the comment form. How can i do that?


Access WordPress Tag Function From Modal

I am currently working on a plugin that will require the use of the Tag library inside the given WordPress installation. From a page, the user can click a button from the editor, which then opens a modal. In this modal I would like to have the Tags listed using the same function that one could use to select tags on a post or similar to adding it to a custom post type using 'post_tag' in the taxonomy definition. Is it possible to access these types of functions from outside a post or page? I am calling the modal from my TinyMCE button and am using SimpleModal. The modal is stored in a separate PHP file. My shortcode button and call onclick to my modal:               (function() {     tinymce.PluginManager.add('om_sc_button', function( editor, url ) {         var newurl = url.substring(0, url.length -3);              editor.addButton( 'om_sc_button', {             title: 'Insert New Searchable Media Manager Gallery',             image: newurl + '/images/source_code_32.png',             onclick: function() {                     jQuery('#popup-content').load(newurl+"/includes/shortcodebuilder.php");                     jQuery('#popup-content').modal({                         containerCss: {                             backgroundColor: "#fff",                             borderColor: "#000000",                             height: 400,                             padding: 10,                             margin: 10,                             width: 800                         },                         overlayClose: false,                         overlayId: 'popup-overlay',                         containerId: 'popup-container',                         onClose: function() {                             editor.insertContent('[MyShortcode]');                             jQuery.modal.close();                         }                     });             }         });     });     })();      The file shortcodebuilder.php has a form with a few input boxes and on THAT page I'd like to have the tag builder just like you see in a post. I apologize for not posting this but the work is for a client and is proprietary. It's also why I didn't post the code earlier. ![WordPress Tag Builder](http://i.stack.imgur.com/Tpis9.png)


How to display posts under a specific subcategory of a given category

after a long search online I have decided to post my problem here in the hope of getting a solution to this issue. Well, I have a custom post with various categories (novels, books, magazines etc..) and each of these categories have many subcategories (2002, 2004, 2005, 2006 etc) the year of publication. Basically what I need is to show a filtering menu based only on the relevent subcategories of the selected category. And when the user clicks on a subcategory menu item he will be able to get all the posts under that specific category. this is what I have done so far, but I could no find out how filter by subcategory while in a given category.                       if (isset($_GET['cat'])){         $subcat = $_GET['cat'];         query_posts( 'posts_per_page=10&paged='.$paged.'&post_type=publication&publication_category='.$maincat.**'&category__in='**.$subcat );             }else{         query_posts( 'posts_per_page=10&paged='.$paged.'&post_type=publication&publication_category='.$maincat );            }      I be so thankful to anyone who could give me a bit of his time to solve this problem.


Suspicious mesage appears instead of images

My installation is of Multisite setup . when I upload an image and try to view it, getting a message 'go home baby!!' instead of image Actually the specific sub-site is also mapped with a custom domain. I thought that it is breaking the link. So removed the mapped domain and still having the same issue Tried uploading multiple images and almost every image gives the message. Is that kind of some fraudulent activity or my files were hacked? I don't think so . I have checked the installation files and nothing suspicious found Could any one help me with this?


WordPress Attachments vs Post Meta

Apologies if this is not a _question_ and belongs more in discussion, but In dealing with image attachments for a portfolio site, what is the benefit to having images be "attached" to a post versus saving the image IDs as an array in a post_meta field?


should i be checking for jquery before enqueing it in a plugin

At the start of a typical plugin which uses jquery I have something like the following               wp_deregister_script('jquery');     wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2');     wp_enqueue_script('jquery');      Which as I understand it deregisters and re-enqueues jquery ( from google in this example but that's irrelevant here ) My question is this: is there not some way of checking to see whether the library is already enqueued ( by another plugin or the theme) to save needless deregister/register and enqueue ( or is this not very expensive in reality )


How does WordPress update plugins, without running into permissions issues?

I am developing a plugin for PrestaShop, it works but the issue is with its autoupdate. Sometimes it fails on customers server due to permissions issues. How exactly does WordPress handle plugin updates without running into permissions issues? And can they be replicated for something like a PrestaShop module?


enqueue_style is not working

I try to load the main stylesheet with enqueue_style - but it isn't working. Here is my code from functions.php:               function my_scripts() {           wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css', false, '1.0', 'all' );           }     add_action( 'wp_enqueue_scripts', 'my_scripts' );      Loading the stylesheet in the header.php by using a link-tag works fine. I can't find the error - it seems that code is ignored - but function.php is loading. I also tried to use `get_template_directory_uri()` instead of `get_template_directory_uri()`. Because it is the recommended way to link to styles and scripts I want to get this work. I also want to use enqueue_scripts for some js and jQuery scripts. Thanks for any hint or advice The solution: I forgot to call wp_head() in the header.php - added and everything works :-)


Re-ordering images in existing post in wordpress 3.6.1

I hope someone can help me. I cannot see how to re-order images once loaded to the media gallery. WordPress used to have a list view of all images in a post with a box you could enter the running order numerically or descending/ ascending etc... Now I can only see all my images in the main media library and cannot see anyway or re-numbering or moving them.


How to enqueue default scripts with dependency?

I'm developing a plugin and for that I need jQuery and jQuery datepicker. I's taught that WordPress already enqueued some scripts, and I found 'jquery' and 'jquery-ui-datepicker' there. Where the datepicker is said to be dependent to jQuery. In that codex page it's also mentioned that, we can call a dependent script like the following:               function my_scripts_method() {         wp_enqueue_script( 'custom-script', plugins_url( '/js/custom_script.js' , __FILE__ ), array( 'jquery' ) );     }         add_action( 'wp_enqueue_scripts', 'my_scripts_method' );      I got the point is right for any custom script. But what about the default scripts?   **What to put on the source (`$src`) then?**               wp_enqueue_script( 'jquery-ui-datepicker', $src, array( 'jquery' ) );      I can't put a null string (`''`) or a variable, anything, theoretically, and practically.


Contact form 7 Adding data automatically

How do i grab data from a post and insert it into the form, So when the form is sent it will have that post name and image from that page that the form was sent on? Basicly I have a get a quote button and i want them to click that and ask about the product by inputting field by contact form 7, but I want the name of the product and image of the product to be automatically inserted in to the contact form so they just needs to fill out name and email and message field and the name of the product any image of the product is already set up to be sent.


Update post meta without deleting the old entries

$old = get_post_meta($post_id, 'figure_sugsubject_repeatable_fields', true);     $new = array();          $figuresugsubjectpositions = $_POST['figuresugsubjectposition'];     $figuresugsubjectworkplaces = $_POST['figuresugsubjectworkplace'];     $figuresugsubjectlocations = $_POST['figuresugsubjectlocation'];     $figuresugsubjectfroms = $_POST['figuresugsubjectfrom'];     $figuresugsubjectstatuss = $_POST['figuresugsubjectstatus'];               $count = count( $figuresugsubjectpositions );          for ( $i = 0; $i < $count; $i++ ) {         if ( $figuresugsubjectpositions[$i] != '' ) :             $new[$i]['figuresugsubjectposition'] = stripslashes( strip_tags( $figuresugsubjectpositions[$i] ) );                  $new[$i]['figuresugsubjectworkplace'] = $figuresugsubjectworkplaces[$i];             $new[$i]['figuresugsubjectlocation'] = $figuresugsubjectlocations[$i];             $new[$i]['figuresugsubjectfrom'] = $figuresugsubjectfroms[$i];             $new[$i]['figuresugsubjectstatus'] = $figuresugsubjectstatuss[$i];              endif;     }          if ( !empty( $new ) && $new != $old )         update_post_meta( $post_id, 'figure_sugsubject_repeatable_fields', $new );     elseif ( empty($new) && $old )         delete_post_meta( $post_id, 'figure_sugsubject_repeatable_fields', $old );      I have a frontend form for post submission. I want the new entries in the form not to replace the old ones, instead I want it to be added. I guess the problem is with the update_post_meta thing. I saves the new entries over the old. Is there anyway I keep the old ones and put the new ones with new keys?


Need to create admin user without capability to create user

I need to remove user related capabilities(such as 'create_users', 'add_user', 'list_users', etc...) of an admin user. I tested the code below in an 'init' method.               global $current_user;     get_currentuserinfo();     $current_user->remove_cap('create_users');     $current_user->remove_cap('add_user');     $current_user->remove_cap('list_users');      But I found that still user is able to access interface for managing user(even after refreshing many times). Is there any solution other than creating new role for this?


Private WordPress blog, requires user registration approval, and allowing users to login with OpenID

I have the following scenario:   1. I have a private blog, running WordPress (self-hosted, not WordPress.com hosted), and I am using the jonradio Private Site to allow only logged-in users to see the site.   2. I want to approve all users prior to their gaining access to the blog, so I'm using the New User Approve plugin to leave new user registrations in a "Pending" state. According to this documentation, "Until a user is approved, the user will not be able to login to the site." Perfect, that's exactly what I want.   3. I'm using Social Connect to allow users to login with OpenID. This will result in a WordPress user being created that is linked to their OpenID identity, and (as expected) this WordPress is in a "pending" state until I approve it. However, apparently there is some miscommunication between these these three plugins, because even though an OpenID login results in a new user being created, with a "pending" state, they are still able to see the site. Going through the "regular" WordPress account registration results in the expected behavior: user created in pending state, but unable to login until approved by an admin. In summary, what I am aiming for is:   * Private blog, that only approved users can view   * OpenID login as an option. Actually, I don't mind if OpenID is a requirement--between Google, Facebook, Microsoft, LinkedIn, and Yahoo, 100% of our blog readers will have an account elsewhere. But I'm ok with users creating a WordPress user account if they really want to. Is there some combination of WordPress plugins that supports this? I see many plugins similar to jonradio Private Site, many more similar to New User Approve, and still more similar to Social Connect. The possible permutations are overwhelming... I don't think I could possibly try them all. But, perhaps one of them works? This is for a personal, non-money-making blog, but if I knew it was going to work I'd be willing to pay a small one-time fee for a commercial plugin.


How to Set a Custom Template for Blog Posts

I am trying to set a custom template for my blog posts page using the Template box on the Page Attributes section of the page. However, the template does not get used on the site. Is there a certain reason why or maybe a special process I need to go through to get a custom template to be used for the blog posts? Could it be the theme is overriding the custom page somehow? Structurally the template is fine and appears as one of the template selections in the pulldown box. Here are screen shots: **This is from Settings** ![enter image description here](http://i.stack.imgur.com/MDGld.jpg) **This is from the "Blog" Page Attributes:** ![enter image description here](http://i.stack.imgur.com/wCZK1.jpg)


Export links of custom created admin page

All right so i have created a page in the wordpress admin called Theme Options.When i export my files the links of these pages are not exported.I want the links that i have included in this page to be also exported using the export plugin. How can this be done ? Here is a screenshot: ![enter image description here](http://i.stack.imgur.com/PlWEC.png)


Embed a Reveal.js presentation in Wordpress page

How can I embed a revealjs presentation on a wordpress page without using a plugin solution, like WPPresent? Thanks,


Query Posts in a Predefined Order

I am using the query_posts function to list a 10 specific posts which lookup by post id. I have an array which looks like this..               Array     (         [0] => 17983         [1] => 17932         [2] => 18030         [3] => 18016         [4] => 17972         [5] => 18013         [6] => 18035         [7] => 17959         [8] => 18020         [9] => 18039     )      I would like to query posts showing it in that specific order, however with my code it shows them in a random order of its own. Here is the argument I use for query posts:               $args = array(         'post_type' => 'post',         'post__in' => $post_ids,         'numberposts'     => 10,     );      $post_ids is the array which I have posted above. How can I alter my code to query the posts and show them in the order of the array?


$post->id vs $post->ID problem after using Wordpress config bootstrap

I'm developing with Wordpress in a multi environment scenario. I develop on my local machine, test on a server and so on. I was using the "trick" of having a `local-config.php` file to have different configurations based on the environment. Today I discovered this: Wordpress config bootstrap. It's just a simple improvement of the default wp-config.php file. It's working fine, but on my local environment appeared this error:               Notice: Undefined property: stdClass::$id in /home/carlo/public_html/altrababele/wp-content/themes/wp-foundation/index.php on line 21      The code generating the error is this:               <?php echo get_the_post_thumbnail( $post->id); ?>
<time datetime="<?php echo the_time('y-m-j'); ?>" pubdate><?php the_time('j'); ?>
<?php the_time('M'); ?>
<?php the_time('y'); ?></time>
      I set the debug option to `false`, but nothing changes. The problem appears to be that `id` is lowercase, so writing `$post->ID` actually solves the issue. It's strange because if I use the `local-config.php` it works just fine, but all the options are the same. any suggestions?


Serve a different theme based on window size

What do you think it is the best approach to load a theme based on current window size of the client? I am not necessarily talking about resizing, but only about the size at the first load time. I made an attempt here but it is not working. I am not able to deal with the fact that the function responsible of changing the theme is also hooked to 3 filters, in addition to the async type of AJAX. Maybe if you look at the code and tell me where I can improve. It might be a hot topic to find a solution for, especially now for mobile fist approach. Thanks.


How to get tagged pages to show up with tagged posts?

I'm trying to implement tags on my pages, so pages show up in the tag clouds I have printing in various places on the site. The problem? If I tag a page, it doesn't show up in the list. Only posts do. I'm using the following in my functions.php to enable page tags:               // add tag support to pages     function tags_support_all() {     register_taxonomy_for_object_type('post_tag', 'page');     }          // ensure all tags are included in queries     function tags_support_query($wp_query) {     if ($wp_query->get('tag')) $wp_query->set('page_type', 'any');     }          // tag hooks     add_action('init', 'tags_support_all');     add_action('pre_get_posts', 'tags_support_query');      My tag.php page has the following:               <?php while (have_posts()) : the_post(); ?>          <h2 class="category-title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?    >" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" style="color:#000;"><?php     the_title(); ?>
      <?php the_excerpt(); ?>          <?php if ($wp_query->max_num_pages > 15) : ?>

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

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


How to rapidly create a dummy menu?

I want to create a dummy menu with 1 or 2 level of depth. I know I can create the menu via the administration module, but I want to know if there is something I can use to generate fast a dummy menu. I have a file with the sitemap indented by spaces that look as follow:               Home     Foo         Foo 1         Foo 2         Foo 3     Bar     Baz         Baz 1         Baz 2             Baz 2.1             Baz 2.3      Is there something to rapidly create the menu hierarchy into WordPress 3.6?


Advanced Custom Field - displaying only 1 post- how to get all posts displayed

I have two post types:   1. post type = stores   which has a title and custom field (by ACF) `storeurl`.   2. I have another post type called books with just title and custom field `bookcode` (by ACF). I assigned the post type stores as "post object" to books....the code below get the concerned fields but displays the last post only... how do i get it to loop and display all the posts ?
             <?php $storelist = get_field('storelist');               $bookcode = get_field('bookcode');                     //var_dump($storelist);              foreach ($storelist as $post) :  setup_postdata($post);              ?>
              <?php echo get_the_title($post->id);?>

                     <a href="<?php echo get_field('storeurl',$post->id); ?>">                         <?php echo $bookcode;?>
           <?php endforeach; wp_reset_postdata(); ?>
       I tried the code below, it does display the posts but the bookinfo and linkbtn get repeated more than once within the bookdetails.
     <?php      while (have_posts()): the_post();?>

             <?php                    $bookcode = get_field('bookcode',$post->id);             $bookinfo = get_field('bookinfo',$post->id);                  $storelist = get_field('storelist');                               foreach ($storelist as $post) :  setup_postdata($post);                      ?>
                 <?php echo get_the_title($post->id);?>

                 <?php echo $bookinfo; ?>

                      <a href="<?php echo strip_tags(get_field('storelink',$post->id)); ?>">                             <?php echo $bookcode; ?>
                  <?php endforeach; wp_reset_postdata();?>

       <?php endwhile; ?>


Child theme does not appear in theme selection

I'm trying to add a child theme to my wordpress installation. The theme the child should be based upon a theme called "nostalgia-landing" which is installed and works properly. I created a new folder called "nostalgia-custom" and added the the _style.css_ with the following content:               /*     Theme Name: Nostalgia Custom     Description: Nostalgia Custom is a responsive WordPress landing page.     Author: QuanticaLabs and Christoph Halang     Author URI: http://themeforest.net/user/QuanticaLabs?ref=QuanticaLabs     License: GNU General Public License version 3.0     License URI: http://www.gnu.org/licenses/gpl-3.0.html     Version: 2.0.2     Template: nostalgia-landing     */     @import url("../nostalgia-landing/style.css");      However, the theme selection in admin panel does not show my child theme and says "You only have one theme installed right now.". This is not true since there are the default themes. When I delete the child theme folder the default themes appear again in the selection. Did I miss anything? Any ideas guys? Regards, Chris


Plugins won't recognize my plugin's hidden custom fields

In a plugin i developed i created metaboxes in the new/update post page in the admin area that save data into custom fields. In order to prevent confusion or any kind of issues i created those custom fields hidden by adding "_"(underscore) to the beginning of it. Now i realize that other plugins will not recognize those custom fields and not just Wordpress so i am looking for a way to fix that as i want my plugin to be able to work together with other plugins. Obviously just removing the "_" from the name would be the fast and easy way to go. However, users that will do an update to the plugin will have issues since all their data is already saved in the old custom fields. One way i was thinking of is adding another set of non hidden custom fields that will hold the same data as the hidden custom fields. so for example if now i have "_address" i will add another fields "address" and whenever the post being saved the data will be saved in both custom fields. This way, users that already have data in the database won't have any problems using it. However, for the same users ( who updating) the data will not be exist in the new custom fields until the post will be saved again. Means that plugins will recognize the new fields but nothing will be there. So my first question is , does anyone know on of a better way i can archive that? and if not , how about a function i can add to the plugin that once a user do an update it will automatically run "save" through all the posts in his database so then i guess the data will be saved in the new custom fields ? Or maybe a function that will duplicate all the hidden custom fields in the user's database begins with underscore to custom fields with the same name just without underscore? _**[Update - pulled from a Comment]_** > Well, a quick look into the "post widget" code i found this line "`HAVING > meta_key NOT LIKE '_%'`" which hide hidden custom fields. i guess plugin > developers hide it by default.


How to change "Draft" string for status of custom post type to "Unavailable"?

**ANSWER MOD** : just an important mod to the chosen answer:               // check if you actually have drafts; also avoids extra '|' separator     if (isset($views['draft'])) {         // 'Drafts' should be added (and come first) if you don't want to end up with 'Unavailables'         $views['draft'] = str_replace(array('Drafts','Draft'), 'Unavailable', $views['draft']);     }      and the mentioned caveat is not showing up for me on 3.4. :D * * * Only for one particular custom post type `employee`, I want to change the name/string "Draft" (which stands for the `'draft'` status) to "Unavailable" for any `employee` post that has a `'draft'` status, anywhere the name shows up on the admin screens and basically throughout the entire site, i.e. ![enter image description here](http://i.stack.imgur.com/rQzvo.png) Is there a hook for this? Or is there a better way to do this?


Create widget that filters posts on current page based on entered value

Can somebody point me in the right direction wouldnt have a clue how to start programming this. I want to filter post based on price (custom value) thru a widget. So lets say you click on a post category you get a list of all the posts in that category, but then I want to give the user the option to filter on price. Been searching for a widget that does this but havent found one.


How do I remove the page listing menu in the header in the Twenty Ten Theme?

How do I remove the page listing menu in the header? I would like just the choosen header picture to show up without a listing of all of the pages on the site listed underneath. Also at the very top or the page it displays the domain and title above the header. What is the best way to eliminate that and just have the header picture hug the top of the screen? I and using the free theme Twenty Ten. Thank you in advance.


Add an image box besides featured image?

When you want to associate an image to a post which already has its own featured image, you have to use a custom field : you upload an image just as if you wanted to add an image inside your post, but then you just copy the image URL, click cancel, and put the image URL in the custom field value : burdensome. Is it possible to do that automatically without any need to copy and paste any URL, like having another featured image, but with a specific name and having the properties of a custom field ? I hope my question is understandable.


Using one slug/post-name for multiple pages

I'm creating a website and I'd like to be able to reuse the same slug/post name in the page's url. ex using `/%category%/%postname%`               foo.com/bar/page     foo.com/barz/page // Will not work. Instead it will use page-2.      I've done some research and it doesn't look like it's possible to do what I want. Before I give up on trying to get the url structure to work like I would like, I figured I would reach out to the WordPress community to see if anything has changed in a newer release to allow this behavior. I'd really like to avoid using `%post_id%` at all costs because I don't think it looks very nice in the url.


trim custom field text value and show (...)

I am using this code here:               <?php     $trim_length = 25;  //desired length of text to display     $custom_field = 'my-custom-field-name';     $value = get_post_meta($post->ID, $custom_field, true);     if ($value) {      echo rtrim(substr($value,0,$trim_length));     }     ?>      It works - but I would like to have a "(...)" at the end of the trimmed text. And _only_ if the value really was trimmed. I used `if ($value) { echo rtrim(substr($value,0,$trim_length)) . '(...)'; } ?>` But this makes the "(...)" at the end of every text from custom field.. Thank you! AD


Add Permalink to Post Thumbnail, syntax code issues

I´d like to link `the_post_thumbnail` by using the `the_permalink`. I do this ( **It Works without link** )               <?php $args = array( 'post_type' => 'xyz', 'posts_per_page' => -1, 'orderby' => 'rand' );     $loop = new WP_Query( $args );          while ( $loop->have_posts() ) : $loop->the_post();             the_post_thumbnail('wine-flow', array('class' => 'item'));          endwhile; ?>      And I´d like to do further this: ( **Syntax Error** )               <?php $args = array( 'post_type' => 'xyz', 'posts_per_page' => -1, 'orderby' => 'rand' );     $loop = new WP_Query( $args );          while ( $loop->have_posts() ) : $loop->the_post();             <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >        <?php the_post_thumbnail('wine-flow', array('class' => 'item')); ?>        </a>          endwhile; ?>      Thanks   ogni


Wordpress Custom Post Type and sort by Tags

I am currently making a custom Wordpress theme, but so far I am stuck at this little problem. I have created this custom post type. And in that page _(media.php)_ I want to be able to click on the tags, which will take me to the tag page _(tag.php)_ and from there it will only show the post under that tag I clicked on, but right now if I click on tag 1, it will take me to **tag.php** , but will show **ALL** media post, instead of the page with clicked tag. I have made a Custom Post type in **functions.php** **_add Custom Post Type (functions.php)_**               add_action( 'init', 'media_' );     function media_() {     register_post_type( 'media', array(       'labels' => array(         'name' => 'Media Post',         'singular_name' => 'Media',        ),       'description' => 'The Media.',       'public' => true,       'menu_position' => 21,       'supports' => array( 'title', 'editor'),       'taxonomies' => array('post_tag')          ));     }      and then my page custom page template will loop the tags like this **_loop the tags in custom page template (media.php)_**
         <?php            $archive_tags = post_type_tags( 'media' );              foreach( $archive_tags as $tag )              {                     echo '
<ahref="'                                . get_tag_link( $tag->term_id )                               . '">'                                . esc_html( $tag->name )                                . '
';             }        ?>
      and then I will loop through all the custom post with the post_type name _'Media'_ **_Loop the post (media.php)_**               <?php            $args = array( 'post_type' => 'Media');         $loop = new WP_Query( $args );     ?>     <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>         <?php the_content(); ?>                                  <?php endwhile; ?>      this work, I can see all the different tags, and the post in media.php. But the thing is when I go to tag.php. It just shows all the post in media.php with that post_type name. What should I write in **tag.php**? For reference, my code in tag.php look like this so far. and it looks just like media.php. **_looping the post, dosn't work (tag.php)_**                 <?php                  $args = array( 'post_type' => 'Media');             $loop = new WP_Query( $args );         ?>         <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>             <?php the_content(); ?>                                      <?php endwhile; ?>       _Example_ **Media.php**   1. Post 1, _tag: **a** , **b_**   2. Post 2, _tag: **a_**   3. Post 3, _tag: **b_** _then there is this list with all the tags available_   * tag **a**   * tag **b** _so lets say I click on tag **a_**. _It will rederict me to **tag.php_** But instead of showing me all the post like this   1. Post 1, _tag: a, **b_**   2. Post 3, _tag: **b_** it is showing all the post from **media.php**.  _NOTE_ ** I only want it to display the post from my custom-post-type: **Media**


Action hook for editing post

I'm looking for the add_action() hook for when a current post is edited and saved. I know there's `edit_post` and `save_post`, but I'm looking for something that ONLY fires when a current post is edited, not created or altered in any other way.


Is that worth it to find a designer for creating a WordPress theme for selling on ThemeForest?

I am skilled enough in WordPress and frontend development - CSS3/HTML5/JS. But I am not sure I can get approved quickly by ThemeForest team from design point of view. So I am wondering, do you think it's worth it to find some great designer, pay for PSD design that is done right way, turn it into HTML then into WordPress theme and try to publish on ThemeForest? What could you advise to do in my situation? Thanks!


Dynamic Image Links Depending on Excerpt/'Single Post' View

I'm working on a new Wordpress theme; the default index view displays the excerpts of recent posts. Some posts will be regarding file downloads, and include an image, description, and link to the location where the described files are hosted. The images for these types of posts will be anchored with links(other types of posts may contain images that are not linked). For these types of posts, I would like the images to link to their entry's full post views(single.php) when displayed in excerpts, but for the same images to link to an external download link when displayed as part of the full post view.(The links that point to an external url point to another page that hosts the files, and not to the actual files directly.) I'm not sure how exactly I would accomplish that. Any help would be greatly appreciated!


How to count the number of monthly archive?

<?PHP     $num_cats  = wp_count_terms('category');      echo $num_cats. '<br/>';         ?>      I get the number of total categories from the above code. How can I get the total categories based monthly archive? following code is not echoing the number of monthly archive:               <?php      $num_month_cats  = wp_count_terms (get_archives('monthly'));      echo $num_month_cats;     ?>       Any suggestion?


Custom Taxonomy Query

I have setup two custom taxonomies for a custom post type that I have created. The post type is called beer, and the two taxonomies are country and brewers. I would like to list them like this.                Country      -->Brewers      ----->Beers      I can pull the countries using this code.                   $terms_country = get_terms('country');         foreach ($terms_country as $term_country) {         echo "
slug."\">";         echo 'name . '">' . $term_country->name       . '';         echo "
";      I need to query the country term to list the Brewers that have that taxonomy attached to the post as well.


How can I display all the blogs where this user is editor in Wordpress Multisite?

Very similar question with correct answer I guess my question is simple, I run multisite and on some blog I want to display <> thing The link I posted does not work for me, but it is marked as correct, what's the problem?               if ( ! function_exists( 'get_user_blogs_by_role' ) ) {     /**      * Get all blog IDs where the user has the given role.      *      * @param  int $user_id      * @param  string $role      * @return array      */     function get_user_blogs_by_role( $user_id, $role )     {         $blogs = array ();         $regex = '~' . $GLOBALS['wpdb']->base_prefix . '(\d+)_capabilities~';         $meta  = get_user_meta( $user_id );              if ( ! $meta )             return array ();              foreach ( $meta as $key => $value )         {             if ( preg_match( $regex, $key, $matches ) )             {                 $roles = maybe_unserialize( $meta[$key][0] );                      // the number is a string                 if ( isset( $roles[$role] ) and '1' === $roles[$role] )                     $out[] = $matches[1];             }         }              return $out;     }     }     $blogs = get_user_blogs_by_role( 1, 'administrator' );     var_dump( $blogs ); // Array ( 2, 14, 90 )      the code returns **NULL**


count results in search page based on custom category

I have a seach page in which am showing results based on keyword and custom category search. Issue i am facing is that, I need to display the count of results. I had referred the wordpress documentation and found some codes, for eg :
Search Result for <?php          /* Search Count */          $allsearch = &new WP_Query("s=$s&showposts=-1");          $key = wp_specialchars($s, 1);          $count = $allsearch->post_count;          _e('');          _e('');          echo $key;          _e('');          _e(' — ');          echo $count . ' ';          _e('articles');          wp_reset_query();      ?>
      But this displays the total search results and I need results count filtered by found in the specified category


How to show video from specific category on sidebar?

I need to get video and content from recent posts in specific category called "Video" and show it on my sidebar. The problem is when I need to have limited text content. so, when I use `the_content();` I can see video within sidebar, but when I use `the_excerpt();` to limit text, video is gone. The code I have is doing what I need with posts and categories but I'm stuck here:               <?php query_posts('cat=6&showposts=2'); ?>     <?php while (have_posts()) : the_post(); ?>          <?php endwhile; ?>      Tho, I have one more content limit function that I can use in my function.php but as I am new at WordPress and PHP, I don't know what to do next and could use any help that you can offer.               function content($num, $more_link_text = '(more...)') {          $theContent = get_the_content($more_link_text);          $output = preg_replace('/<img[^>]+./','', $theContent);          $output = strip_shortcodes($output);         $output = strip_tags($output);         $output = preg_replace("/\[caption.*\[\/caption\]/", '', $output);         $limit = $num+1;          $content = explode(' ', $output, $limit);          array_pop($content);          $content = implode(" ",$content);          echo ($content) . "...";     }      with `<?php content(8); ?>` that I'm calling in my Loop. This do what I need with content limitation, but still doesn't show video.


Two different archive pages showing the same content

I'm trying to use Query Multiple Taxonomies with Ajax. It works with Ajax and it works without it. But unfortunately not at the same time. Basically I need an Archive page to show only the posts of my custom post type "filme" (to insert it with ajax) and another Archive page with the menue, header etc. to use it with the basic Query Multiple Taxonomies, if Javascript is disabled. I've already tried to create a page and an empty custom post archive and "convert it" by using a function hooked to 'pre_get_posts()' but without any luck. The problem is Query Multiple Taxonomies seems to need the main-query to work. I hope it's clear what I'm trying to do, It's a bit comprehensive. EDIT: I've tried to load the archive-page inside itself with AJAX too, but it was incredible slow, so I guess it's not the right way to do it.


Generating CSS Files Dynamically Using PHP Scripts?

As part of my efforts to speed up my themes for my clients I am delivering my CSS via a dynamic PHP file. At the end of the called for example `my_theme_css.php`: This allows me to add Expiry headers to my CSS and JavaScript like so:               <?php     header("Expires: Thu, 31 Dec 2020 20:00:00 GMT");     header('Content-type: text/css');     ?>      I then want to allow the user to add thir own custom CSS so I have set the following up:               <?php     header("Expires: Thu, 31 Dec 2020 20:00:00 GMT");     header('Content-type: text/css');     ?>          p{color:blue;}          /** Custom CSS **/     <?php      if(get_theme_mod('my_custom_css') != '') {       $my_custom_css = get_theme_mod('my_custom_css');        echo $my_custom_css;      }     ?>       I have then added the applicable theme options. But what I am finding is that `get_theme_mod()` doesn't work due to scope issue (I imagine.) Any suggestions on how to get around this? I could add the following code:               <?php      if(get_theme_mod('my_custom_css') != '') {       $my_custom_css = get_theme_mod('my_custom_css');        echo $my_custom_css;      }     ?>      Within `<style></style>` tags in the header and that would work fine, expect I don't want the CSS inline, I want it on the main CSS file with the expiry header.


use add_settings_field properly?

I'm using add_settings_field to add some more details to a settings menu, but not sure how I save the settings, or call them back in my theme. Here is the code thus far               add_action('admin_init','vimeo_setup');          function vimeo_setup(){     add_settings_field('vimeo_id','Vimeo ID','display_vimeo','general');     }          function display_vimeo(){           echo '<input  type="text" name="vimeo_id" id="vimeo_id" value="" size="30" style="width:85%" />';      echo '
 Enter your Vimeo ID here.
';     }


Modifying WordPress core files

### Why? Sometimes an easy fix to altering the behavior of WordPress itself or a plugin could be to alter the files of the plugin or WordPress directly. When coming up with such an idea, the usual response is: > Don't hack core. Why is it generally a bad idea to change core files? ### Consider? Sometimes, however, things that can be critical for a site is simply impossible to do, in a nice way without altering core files. When in such a situation, what do you need to be aware of, before you go ahead and starting hacking core? ### How? You have considered all the options, but the only solution is hacking core files. How should you go about doing this? How will having an altered core, influence workflows, like updating?


Best Collection of Code for your functions.php file

Please vote on the question and any answers you find useful by clicking on the UP arrow on the left hand side of the question or answer. As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my wordpress skills. Over the past 12 months I have been on a mission to substitute my use of plugins by adding code to my `functions.php` file instead. While I completely agree that plugins are very useful in many situations my experience proved that in 90% of usage cases although a plugin might exist, actually utilizing it could create unnecessary complications and compatibility issues. Additionally in a great deal of cases such plugins added menus and other admin elements which I don't want or need. More often than not I have found that by analyzing the code of plugins I was able to strip out the piece of code I wanted and hard code it into my `functions.php`. This provided me with the exact functionality I needed without having to include unnecessary elements. So, the purpose of this post is my attempt to engage you, the reader/admin/developer, to share with me and other here any code bits which you find useful and have added to your theme's `function.php` file to extend or enhance WordPress without utilizing a plugin. When you submit a response here please kindly give each code bit a title, let us know if with what version of wordpress you know its compatible with, include whatever description you feel best describes its function and (if applicable) include a link to the original plugin or source where you found the information. I am looking forward to all your responses and will of course continually add my own new finds whenever I find them.


creating a new child theme

When I create a child theme I have to create it all under the unzipped wordpress/theme file? Will it automatically add itself to my web page or does something have to be done to activate it?


Using Zoho Creator Database inside Wordpress Frame

Our agency network has an existing Wordpress-based website, and we would like to use Zoho Creator sort of like an intranet which is accessed through the Wordpress site. Basically, something along the lines of an iframe that allows users to work with Zoho to search data and also enter and/or modify data. Is this difficult to do or would it in any way conflict with our existing CMS? Many thanks for your responses and insights!


Comparing dates in custom field

I have a function which should return the future event date:               function get_upcoming_exercises( $limit = -1 ) {             $args = array(             'post_type' => 'px_event',             'posts_per_page' => $limit,             'post_status' => 'publish',             'meta_query' => array(                 array(                     'key' => '_px_event_date',                     'value' => date('m-d-y'),                     'compare' => '>=',                 ),             ),             'orderby' => 'key',             'order' => 'DESC',         );              $query = new WP_Query( $args );                return $query;     }      the dates are stored like strings(m-d-y): > 10-25-2012 > > 01-03-2013 The function doesn't work fine, because, if I test, for example, with dates greater than 11-22-2012 it doesn't show 01-03-2013. If I execute the comparison in mysql it fails too:               select * from wp_postmeta     where meta_key = '_px_event_date'     and meta_value >= '11-22-2012'      What am I doing wrong?


Post via git repository

I want to be able to post via a git repo. For example I have a repo named "blog" which contains these files:               first_post.md     second_post.md     another_post.md      I want all these files to appear in my blog like normal posts. I also want to be able to edit the files from the admin panel too (not only via git). Is there any way to do that?


How to show a full post, not just an excerpt

I have a blog page where blog posts have an excerpt on with a continue reading link below. When the link is clicked the full post should appear/or should be diverted to. This isn't that case. The user is diverted to the post, however only the excerpt is displayed along with a continue reading link which doesn't activate anything. I have deactivated all plugins, I have also played around with the settings but can't find any triggers. Blog Page - http://vikingsandc.co.uk/strength-and-conditioning-blog/ Post Page - http://vikingsandc.co.uk/2012/11/test-text-test-text/


Get an image from url in front end submission form

I am building a user generated content sharing theme so how can i allow visitors to upload an image from a url i mean to say that they enter the url and the image gets automatically attached this is the code i am currently using for               <?php     /*     Template Name: Submit Content Template     */          // if you are not using this in a child of Twenty Eleven, you need to replicate the   html structure of your own theme.          get_header(); ?>

     <?php      if(isset($_POST['new_post']) == '1') {     $post_title = $_POST['post_title'];     $post_category = 'todays_post';     $post_content = $_POST['post_content'];     $tags = $_POST['post_tags'];          $new_post = array(       'ID' => '',       'post_author' => $user->ID,        'post_category' => array($post_category),       'post_content' => $post_content,       'tags_input'    =>  array($tags),       'post_title' => $post_title,       'post_category' =>   array($_POST['cat']),  //       'post_status' => '',       'post_type' => 'post',        'winerating' => $winerating     );                $post_id = wp_insert_post($new_post);              if (!function_exists('wp_generate_attachment_metadata')){             require_once(ABSPATH . "wp-admin" . '/includes/image.php');             require_once(ABSPATH . "wp-admin" . '/includes/file.php');             require_once(ABSPATH . "wp-admin" . '/includes/media.php');         }          if ($_FILES) {             foreach ($_FILES as $file => $array) {                 if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                     return "upload error : " . $_FILES[$file]['error'];                 }                 $attach_id = media_handle_upload( $file, $post_id );             }            }     if ($attach_id > 0){     $post = get_post($post_id,'ARRAY_A');     $image = wp_get_attachment_image_src( $attach_id, 'large' );     $image_tag = '
<a href="'.$image[0].'" rel="lightbox"  title="<?php the_title();?>" >
';          //add image under the content     $post['post_content'] = $image_tag . $post['post_content'];          //add image above the content     //$post['post_content'] = $post['post_content'] . $image_tag;          $post_id =  wp_update_post( $post );          }          // Update Custom Meta          // This will redirect you to the newly created post     $post = get_post($post_id);     wp_redirect( get_permalink($post_id));     exit();     }           ?>      **UPDATE #1**                <?php      /*      Template Name: Submit Content Template      */            // if you are not using this in a child of Twenty Eleven, you need to replicate the          html structure of your own theme.          get_header(); ?>

     <?php                 if(isset($_POST['new_post']) == '1') {      $post_title = $_POST['post_title'];      $post_category = 'todays_post';       $post_content = $_POST['post_content'];      $tags = $_POST['post_tags'];       $winerating = $_POST['winerating'];                  $new_post = array(       'ID' => '',       'post_author' => $user->ID,        'post_category' => array($post_category),       'post_content' => $post_content,       'tags_input'    =>  array($tags),       'post_title' => $post_title,       'post_category' =>   array($_POST['cat']),  //       'post_status' => 'publish',       'post_type' => 'post',        'winerating' => $winerating     );                  $post_id = wp_insert_post($new_post);           // Only for outside WP Theme; if you have this in a file you will need to load "wp- load.php" to get access to WP functions.  If you post to "self" with this code then WordPress is by default loaded      require $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php";       // require two files that are included in the wp-admin but not on the front end.   These give you access to some special functions below.      require $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/file.php";      require $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/image.php";           // required for wp_handle_upload() to upload the file      $upload_overrides = array( 'test_form' => FALSE );           global $current_user;      get_currentuserinfo();      $logged_in_user = $current_user->ID;           // count how many files were uploaded      $count_files = count( $_FILES['files'] );           // load up a variable with the upload direcotry      $uploads = wp_upload_dir();           // foreach file uploaded do the upload      foreach ( range( 0, $count_files ) as $i ) {               // create an array of the $_FILES for each file          $file_array = array(             'name'     => $_FILES['files']['name'][$i],             'type'     => $_FILES['files']['type'][$i],             'tmp_name' => $_FILES['files']['tmp_name'][$i],             'error'    => $_FILES['files']['error'][$i],             'size'     => $_FILES['files']['size'][$i],         );              // check to see if the file name is not empty         if ( !empty( $file_array['name'] ) ) {                  // upload the file to the server             $uploaded_file = wp_handle_upload( $file_array, $upload_overrides );                  // checks the file type and stores in in a variable             $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );                     // set up the array of arguments for "wp_insert_post();"             $attachment = array(                 'post_mime_type' => $wp_filetype['type'],                 'post_title'     => preg_replace('/\.[^.]+$/', '', basename(        $uploaded_file['file'] ) ),                 'post_content'   => '',                 'post_author'    => $logged_in_user, // or use a static ID                 'post_status'    => 'publish',                 'post_type'      => 'attachment',                 'post_parent'    => $_POST['post_id'],                 'guid'           => $uploads['baseurl'] . '/' . $file_array['name']             );                  // insert the attachment post type and get the ID             $attachment_id = wp_insert_post( $attachment );                  // generate the attachment metadata             $attach_data = wp_generate_attachment_metadata( $attachment_id,  $uploaded_file['file'] );                  // update the attachment metadata             wp_update_attachment_metadata( $attachment_id, $attach_data );                          // this is optional and only if you want to.  it is here for  reference only.                     // you could set up a separate form to give a specific user the ability to change the post thumbnail                     // set_post_thumbnail( $_POST['post_id', $attachment_id );          }      }             $post_id =  wp_update_post( $post );          // Update Custom Meta               // This will redirect you to the newly created post     $post = get_post($post_id);     wp_redirect( get_permalink($post_id));     exit();          }           ?>               <title>Add Your Funny Pics</title>                              <meta charset=utf-8 />                                   <form method="post" action="" enctype="multipart/form-data">
     Add a Funny Pic

                         Pic File :-
          [X]

             <fieldset>

               Post Title :-         <input type="text" required="required" name="post_title" size="60" id="input-title" placeholder="Add A Title Here" class="rounded" />

                  <fieldset class="tags">                   Tags :-                                 <input  type="text" class="rounded" placeholder="Add Some Tags To Get Higher Votes"value="" size="60" tabindex="35" name="post_tags" id="post_tags"  />          </fieldset>
               <fieldset class="category">                   Category   &nbsp
<?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0' ); ?>               </fieldset>                    Text Area

     <textarea rows="5" name="post_content" cols="66" id="text-desc" ></textarea>
     <input type="hidden" name="new_post" value="1" />

<input class="submitbutton" type="submit" name="submit" value="Add"  />

     </form>

          <?php get_footer(); ?>


WordPress WP_User_Query($args) using Where and Like

I wish to return a WP user list in my plugin where the email address matches @mydomain.com. The user list I am after is for all mydomain.com users. Does anyone have a code snipit for that? Thanks.


How do I disable trackback notifications on a WordPress.com blog?

I tried http://astroclimatology.wordpress.com/wp-admin/options-discussion.php but it didn't work. I do want unregistered users to be able to comment. == What I dont want is email notifications like this: > New trackback on your post "we also analyzed zonal wind too" Website: Quora > (IP: 107.20.3.229 , ec2-107-20-3-229.compute-1.amazonaws.com) URL : > http://www.quora.com/Planetary-Science/How-can-faster-rotation-rate-lead-to- > an-increased-pole-to-equator-temperature-gradient-when-the-zonal-velocity- > of-the-jet-stream-decreases-as-predicted-by-both-t Excerpt: **How can faster > rotation rate lead to an increased pole-to-equator temperature gradient when > the zonal velocity of the jet stream decreases, as predicted by both the > Held-Hou model of circulation and one of the CAM3 simulations that I > ran?...** > > Supposedly, faster rotation rate means a stronger Coriolis effect, which > means that a tropical parcel of air that goes poleward in the meridional > direction is more likely to be deflected in the zonal direction. Yet, the > Held-Hou model of circulation pr... > > You can see all trackbacks on this post here:


$wpdb get_var issue

I've been at this for while, but can't figure out why the below isn't working. I have my date saved as a 'MM/DD/YYYY' string.               global $wpdb;     $new_day = $day->format("m/d/Y");     $qty = $wpdb->get_var( $wpdb->prepare(        "         SELECT qty         FROM $wpdb->specials         WHERE date = %s       ",       $new_day     ));


Get comments for more than one post

I would like to get all the comments for a group of post (not only one post. I tried               $comment_args = array('number' => '14', 'post_id' => '10,20,30,40'  );         $comments = get_comments($comment_args);         foreach($comments as $comment) ...      But does not work. Any ideas?


Wordpress fails to auto crop featured images

I set 2 crop sizes in the functions.php file.               // Setup Post Thumbnails     // -----------------------------------------------     add_theme_support('post-thumbnails');     add_image_size('imagePost-thumb', 970, 9999,false);     add_image_size('better-thumb', 200, 9999, false);      Then in the appropriate loops we pull one of the thumbnails based on post type.               <?php if ( has_post_thumbnail() ): ?>          <?php $size = (get_post_type() == 'imagepost') ? 'imagePost-thumb' : 'better-thumb'; ?>          <?php get_better_post_thumbnail($size); ?>     <?php endif; ?>      Get better_post_thumbnail() is a function I wrote to get the image and the caption. In it I call the the_post_thumbnail to display the image. Here is that function.               function get_better_post_thumbnail($size) {         $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');         echo '
';         echo '';           the_post_thumbnail($size);         echo '';         if( get_post( get_post_thumbnail_id() )->post_excerpt )             echo '
' . get_post( get_post_thumbnail_id() )->post_excerpt . '
';         echo '
';     }      This works great on my test server. The only problem is when I push it to the live server, the crops don't work. The images appear as the the correct size because our theme styles them but they are loading at full size. Per @MathSmith's suggestion I checked the live server to see if the different image sizes were being created and they are NOT. The test server has all the different files sizes while the live server only has the full size. We don't want to load a 1024x1024 picture when it never is displayed larger than 400x400. Of course I could crop the pictures by hand, but my bloggers are all specialists who have a harder time with 'technology' and need it to happen automatically, as it should. Our dev and live setups are identical except for the w3 Total Cache plugin on the live server, but I disabled it and tested the images, with the same results. Any ideas?


How to keep   non-breaking spaces in the visual editor?

I often add ` ` between connecting words so they break down together to a new line in important text. Switching to visual tab then back to text tab removes these. What can I do to keep them and avoid TinyMCE removing them? I found this but not sure how to apply it to WordPress: http://www.abeautifulsite.net/blog/2009/12/tinymce-removes-non-breaking- spaces/ My ugly solutions would be using a different custom string between words__like__this then later replacing them to ` ` in PHP, before display. Or just typing it on the visual tab, which translates to `&nbsp;` but then converting them with PHP.


Question about file path for include/require methods

So I am currently rather new to Wordpress development and I had a question about the file path for the include() and require() methods. I have a php script within my Wordpress installation that I would like to use in order to get posts and display them in a widget. Unfortunately, I get the error "Call to undefined function apply_filters()" so I think that some Wordpress files are not being loaded. I tried resolving this by using require_once(), however the parameter I pass in is not even being recognized as a file path. Here is the current script:               <?php      require_once('/../../../../wp-config.php');          $args = array('fb' => $cat);         $default_args = apply_filters( 'rpwe_default_query_arguments', $args );         $rpwewidget = get_posts($default_args);     echo $rpwewidget;     ?>      When I run this I get the error: require_once('/../../../../wp-config.php'); failed to open stream: No such file or directory in /home/full/file/path/without/moving/backwards/.php Any suggestions on what I am doing wrong would be much appreciated, thank you.


Can't access site after plugin activation

I get the following error after adding multiple plugins, including All In One Event Calender and BackupWP. Now I can't access anything from within the admin panel or from the front-end. I can't get into the Plugins page to de-activate any problem plugin. Can anybody help me get back to a point where my site is usable?               Fatal error:          Cannot redeclare fb_admin_dialog()          (previously declared in /home/jomoxo/public_html/angelinesoatmealoriginals.com/wp-content/plugins/facebook/fb-wp-helpers.php:2)          in /home/jomoxo/public_html/angelinesoatmealoriginals.com/wp-content/plugins/all-in-one-event-calendar/lib/facebook-php-sdk/fb-wp-helpers.php          on line 11


Where is New Relic API key?

I've installed Total Cache plugin in my wordpress application and it suggested me to create a New Relic account. I've done it, but now the plugin ask me for an API key, and no idea of where to find it. I thought it would be the license key, but not. Anyone know where is it?


Should I use the Transients API to temporarily hold edited attachements?

I'm building a store that allows users to order prints of photos. If the user orders a photo that has a different dimension than the one the photo is originally, they are prompted to crop the photo. The photo would only be held for a short time period, say twenty five minutes. Is it appropriate to use the Transients API to hold the cropped photo data?


Category Search functionality on category metabox (wordpress admin)

I have lots of categories on my blog site. When I add new post and select category, I need to scroll down to find the category. Is it possible to add a search category functionality in category metabox? Click here to view the image of the functionality that I want. I would appreciate your help. Thank you so much.