How to list users like an archive page 10 users on page and have navigations

How can i list registered users like an archive page? and how can i make a link on user name to point to user profile page? Please see the link http://postimg.org/image/9wkp6kfib/               <?php     /*     Template Name: Registered Users     */     ?>     <?php get_header(); ?>

       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">Registered Users

             Poza	             Name	             Inregistrat	             Nume	             User Level	             User Role	             Vezi Profil

            <?php                $wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");               foreach ( $wp_user_search as $userid ) {                 $user_id = (int) $userid->ID;                 $user_info = get_userdata($user_id);                                                     $user_picture =  get_avatar($userid->ID, 40);                 $formid = $user_info->formid;                 $user = new WP_User( $user_id );                 echo '' . $user_picture .  '	';                 echo '' . $user_info->display_name . '	';                 echo '' . $user_info->user_registered . '	';                 echo '' . $user_info->nickname . '	';                 echo '' . $user_info->user_level . '	';                 echo ''; if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ) echo $role; } echo '	';                 echo '' . $userid->ID . '	';                                                     echo '
';               }                                              ?>

             Poza	             Name	             Inregistrat	             Nume	             User Level	             User Role	             Vezi Profil

       <?php endwhile; endif; ?>

     <?php get_footer(); ?>


Display movies that apear this day next

This code retrive me the movies that are comming in cinema, i want to be able to list movies that apear this day, next day ... 7 day week Ex: Today is 13.05.2013, i want to list the movies that apear this day ( - the code down list me all the movies that are comming)... and if the day pass to 14.05 i want the box post disapear from page. The code down do that but it display all upcomming movies. I want to list only today movies Something like this : http://tvpedia.org/program-tv How can i do that? Thanks in advance                <?php // Get today's date in the right format         $todaysDate = date('Ymd');         ?>         <?php $loop = new WP_Query( array(         'post_type' => 'post',         'posts_per_page' =>3,         'meta_key' => 'premiera_cinema',         'meta_compare' => '>=',         'meta_value' => $todaysDate,         'orderby' => 'meta_value',         'order' => 'ASC'         ) ); ?>         <?php while ($loop->have_posts()) : $loop->the_post(); ?>


Best plugin for most viewed post

I just want to show how many user viewed a post (says 12 views) and a widget for top viewed blog list in the sidebar any plugin for the above concepts Thanks, Edvin


Hide "Gallery Settings" and "Insert into Post" button from Attachment window

I'm using different method to form a gallery in Wordpress, so I would like to hide an option to insert images and galleries into post for anyone but Administrator. Can someone show me an example how it's done?


How to hook update_post_meta and delete_post_meta?

I'm still struggling to get my head around this whole hooking into things, so I'm really stuck on trying to do the following task: If update_post_meta is fired then check to see if the meta_key is equal to something (I want to trigger some code if a particular meta_key is used). If the meta key I'm looking for then run some code that will need to know the `$post->ID` of the meta key being updated. I need to hook into the delete_post_meta too that kind of does the reverse as above. Can anyone provide me with some example code for hooking into update_post_meta and delete_post_meta?


Multiple ajax nonce requests

I have a feature in my current project that will be allow multiple ajax requests - I've got a single nonce request worked out (via this tute), but am somewhat unsure how to figure in multiple nonce requests. functions.php: localize, create a single nonce                wp_localize_script(            'B99-Portfolio',            'B99ajax',            array(                 'ajaxurl'        => admin_url( 'admin-ajax.php' ),                'requestNonce'   => wp_create_nonce('b99-request-nonce')            )      );      calling js:               $.ajax({             type    : 'POST',             url     : B99ajax.ajaxurl,             data    : {                 action          : 'b99-ajax-submit',                 requestNonce    : B99ajax.requestNonce             },...      receiving php               public function b99_ajax_submit() {             $nonce = $_POST['requestNonce'];             if ( ! wp_verify_nonce( $nonce, 'b99-request-nonce' ) )          ... sql, response      At this point, I can reuse this nonce repeatedly, but I think that defeats the purpose of the nonce check. My solution will be to request a new nonce in the receiving php, assign `B99ajax` js object that variable, and send it back to the requesting page for the "next" ajax sequence. Is there a better way?


Has anyone seen a 'visual anatomy' type graphic of the Buddypress plugin?

As someone learning Wordpress for the purpose of customizing a Buddypress installation, I'm looking for a graphic representation of how Buddypress works and augments a standard Wordpress Multi-User installation. There are a number of examples of Wordpress diagrams including this one by Yoast.


Moving WordPress.com theme and widget settings to self-hosted site?

> **Possible Duplicate:**   >  Migrating from WordPress.com to self-hosted site and autoforward visitors? How can I move theme and plugin (widget) settings from a WordPress.com site to a self-hosted installation? My client is moving from `hissite.wordpress.com` to his own host at `hissite.com`. I have moved over the content using the Import/Export feature, but I can't access the theme and widget plugin files, since WordPress.com offers no FTP access. We also don't want to pay WordPress.com to move these files over.


Is there a plugin to display certain posts on certain pages?

On the homepage I want to display the latest 4 posts from the 'news' and 'events' category, whereas on the events page, I just want to display all posts in the 'events' category in WP's usual paginated form if there is a lot of them. Do you know of any plugin that handles this kind of rules based post generation? If not, what would be the best way of going around this?


WPML - how to get the permalinks to display also the default language

Currently WPML adds /fr/ to permalinks to identify a url as French. The default language of the site is English, however WPML does not add /en/ by default for the default lannguage (English) permalinks. Is there a way to have the default language also show up in the permalinks?


Exclude a category from the_category in the single post page

I want to include something like the the_category function in a WordPress post, which by default echoes a list of links to all categories the post is attached separated by comma, but I want to exclude some categories from listing in certain views. In some cases I have to exclude all children ones from appearing, in others a top category or random specific categories.


I'm using a filter to remove the <p> tags auto wrap, but there still wrapped elements?

I have this in my **functions.php** : The images inside the slider were added as **custom post types** called " **Page Content**." I'm not sure if the filter only applies to the main **Posts**.               /**      * Remove paragraph tags around content and excerpt      */     remove_filter( 'the_content', 'wpautop' );     remove_filter( 'the_excerpt', 'wpautop' );      The the posts in the admin look like this: ![enter image description here](http://i.stack.imgur.com/thnF3.png) But something still wrapping the images of my Nivo Slider with p tags: ![enter image description here](http://i.stack.imgur.com/rMkU6.png) ![enter image description here](http://i.stack.imgur.com/Nruuj.png) CSS:               #slider-wrapper {         float: left;         height: 560px;     }     #slider {         float: left;         border: 1px solid #DDD;         position:relative;         background:url(images/loading.gif) no-repeat 50% 50%;     }     #slider img {         top: 0px;         left: 0px;         display: none;         float: left;         position: absolute;         width: 958px;         height: 458px;     }     .nivo-controlNav {         margin: 490px auto 0;         overflow: hidden;     }     .nivo-controlNav a {         background: url(images/bullets.png) no-repeat;         border: 0;         float: left;         text-indent: -9999px;         width: 22px;         height: 22px;     }     .nivo-controlNav a.active {         background-position: 0 -22px;     }     .nivo-directionNav a {         display: block;         width: 70px;         height: 70px;         background: url(images/arrows.png) no-repeat;         text-indent: -9999px;         border: 0;     }     a.nivo-nextNav {         background-position: -70px 0;         right: -20px;     }     a.nivo-prevNav {         left: -20px;     }     .nivo-caption {         text-shadow:none;         font-family: Helvetica, Arial, sans-serif;     }     .nivo-caption a {         color:#efe9d1;         text-decoration:underline;     }      Any suggestions to remove the p tags?


How come pending comments are appearing in admin?

How come pending comments are appearing in our admin dashboard? We haven't enabled comments in any way and aren't really interested in that feature. How did someone manage to "add" a comment. Some of them do appear to be genuine mentions of our blog post in Twitter, while others are rubbish. What would happen if we approved them?


Wordpress Blog and SEO

I need some support on restructuring the directories and settings with my current WP site for better SEO purposes. I have the following settings:   1. WP is installed in the root.   2. Permanent Links are set to /year/month/.... e.g.   3. There's a static home page (index.php) and several other static pages (created with WP Pages) in the root directory.   4. Currently when people click on the blog link on the static page, the web browser takes them to -> /category/blog/ (where all the posts are under category "blog") I think this is not the most efficient setup for SEO purposes, since the static pages and the blog posts are all referenced from the root directory (e.g. /2011/12/20/post1..... and page "/ABout-Us"... Ideally, (without having to restructure too many things, or reinstalling WP, if possible), I would like to figure out how to setup the following:   1. All the blog post goes under /blog/ directory, the static pages created in WP goes in the root directory.   2. Categories also gets redirected under the /blog/ directory. I think it has to do with the WordPress Address and Site Address... Thanks for the help in advance. Vincent


Code to pull in a PHP file named after the category ID

I use this code to pull in an image based on a post's category. Images are named after the category they represent, so a post in category 50 pulls in 50.jpg.               <?php      foreach((get_the_category()) as $category) {          echo '<img src="/path/to/file/' . $category->cat_ID . '.jpg" alt="' . $category->cat_name . '" />';      }      ?>      I'd like to be able to do the same but to include a php file (also named after the category - so 50.php using the above example). What's the best way to do this?


Styling readme.html in plugin?

I am making `readme.html` file for a plugin with some detailed setup instruction that need to include screenshots. As rest of UI I want it be consistent with WordPress style and so I looked at its own `readme.html`. It includes stylesheet with relative path:               <link rel="stylesheet" href="wp-admin/css/install.css?ver=20100228" type="text/css" />      So for a plugin file I might go with:               <link rel="stylesheet" href="/wp-admin/css/install.css" type="text/css" />      But it is good way to include styling? There are really many ways to do it:   * link to `install.css`;   * bundle copy of `install.css` with plugin;   * bundle own CSS file with plugin;   * embed style in `readme.html`. I am not aware of any recommendation about providing HTML documentation with plugins. Had you included HTML documentation with plugins (or themes, whatever)? What method had you chosen to style it and what was you reasoning for it?


Submenu pages delete settings from options array when saved

I'm writing a theme and adding a menu with several submenu pages. It works fine, except that I'm trying to use only one array to save all the settings into the database and this is causing some issues. The problem is that when each submenu pages is saved, it only saves the values from that page to the array and removes all the other values from the other pages that were stored before so the array only ends up holding the values from one page at a time. Here are the functions where I create the pages and register the setting.               add_action('admin_menu', 'theme_add_admin');     add_action('admin_init', 'register_theme_settings');          function theme_add_admin() {          add_menu_page( 'Theme Settings', 'Theme Settings', 'update_themes', 'themesettings', 'settings_messages_page');     add_submenu_page( 'themesettings', 'messages', 'Titles and Messages', 'update_themes', 'themesettings');     add_submenu_page( 'themesettings', 'layout', 'Layout', 'update_themes', 'settings_layout', 'settings_layout_page');          add_settings_messages();     add_settings_layout();          }          function register_theme_settings() {     register_setting( THEMENAME . '_settingsgroup', THEMENAME . '_settings', 'validate_options' );     }      In add_settings_messages() and add_settings_layout I add the sections and fields:               function add_settings_layout() {          add_settings_section('layout_styles', 'Archive Layout', 'settings_layout_styles_fn', __FILE__);          add_settings_field('layout_index', 'Home Page Post Style', 'layout_home_fn', __FILE__, 'layout_styles');     add_settings_field('layout_paged', 'Paged Archives Post Style', 'layout_paged_fn', __FILE__, 'layout_styles');          }      And here's the page display function:               function settings_layout_page() {      ?>

Layout
              <form action="options.php" method="post">         <?php settings_fields(THEMENAME . '_settingsgroup'); ?>         <?php do_settings_sections('settings_layout'); ?>
             <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
              </form>
     <?php     }      I'm probably missing something obvious here, any help would be appreciated.


Localized WordPress is much slower?

I'm using xdebug and webgrind to profile my WordPress installation because it's a bit slow. As there are some 20 plugins activated, I figured xdebug will be able to find the bottleneck. However, to my surprise, it appears that localizing routines are taking the majority part of the execution time. And yes I'm using a localized version of WordPress. Please see the following output from webgrind of a single ajax page load: ![webgrind output](http://i.stack.imgur.com/82NUL.png) I can see some of my plugins taking less than 1% execution time each (measured in percentage of execution time). But translation routines, `Translation_Entry`, `MO`, `POMO` are using more than 30% of the total. I'm wondering why this is, and whether I should prevent from using a localized version? Or am I using the wrong approach to profile performance?


How To Remove The Filter That Adds JetPack Related Content To Dom

I am trying to remove the filter in JetPack's Related Posts module that adds the element to the DOM that the module's JavaScript populates with the related posts. Once I remove it, I can achieve my actual goal of being able to add it to various places besides the options the plugin provides. The content filter I'm trying to remove looks like this:                  public function filter_add_target_to_dom( $content ) {         if ( !$this->_found_shortcode ) {             $content .= "\n" . $this->get_target_html();         }              return $content;     }      I've tried this, in a separate plugin:               add_action( 'plugins_loaded', 'slug_remove_jp_content_filter' , 2001 );     function slug_remove_jp_content_filter() {        $jprp = Jetpack_RelatedPosts( get_current_blog_id() );        remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' )    );     }      I have also tried this:               class myclass{          function __construct() {         add_action( 'plugins_loaded', array( $this, 'remove_default_content_filter' ), 2001 );     }     function remove_default_content_filter() {         $jprp = Jetpack_RelatedPosts( get_current_blog_id() );         remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' ) );     }               }          new myclass();      In both cases I tried getting the JetPack Related Post class object with `$jprp = Jetpack_RelatedPosts::init();` instead. In the debug console I am able to get an object of the class with both `$jprp = Jetpack_RelatedPosts::init();` and with `$jprp = new Jetpack_RelatedPosts( get_current_blog_id() );` Not sure what else to try.


Where are the files that control the multisite user dashboard?

In multisite where are the files that control the dashboard for the multisite user admin? Also where are the files for the normal, standard, wordpress admin dashboard? I want to tweak the mu user dashboard to have some things the normal wordpress admin has. Thanks - Brandon


Git beginner: Keeping track of on-server changes

So I'm starting to get to grips with Git (never used any VCS before). Some Git users tell me to only push to production server and never pull from it to my local dev server. That leaves me with this scenario. I run WordPress 3.0 in a Multi Site environment. On the production server, I create a new blog (let's call it no. 6) from the dashboard and need a custom theme for it. I download the db from the live server and install it locally to have the latest plugin settings, blogs etc. I install the database, tweak all the urls to match localhost. But! the folder with the new blog will be missing from the wp-content folder because I'm not syncing that folder from liveserver to devserver. Can i, with Git, checkout the most current repo from my live server to my local machine (or something like GitHub and then ) when I need to complete a task like this? Or am I looking at it the wrong way?


is_plugin_active function doesn't exist

I'm using WordPress 3.0.5 and have tested with 3.1rc4. In the main PHP file of my plugin, when I try to call is_plugin_active I get `Call to undefined function is_plugin_active()`. I can call add_action and add_filter. What should I check/change to fix this? This is happening inside of the admin on the Plugins page. At the top of my main plugin file I have, `if (function_exists('is_plugin_active')) {` which always returns false. I also can't see the functions from my main plugin file in other plugins (if that helps any).


How do I rewrite a url to use %taxonomy% instead of %category% when multiple taxonomies are present?

I would like to have the option to use taxonomy in the url instead of only having category like "uncategorized." Note that I have multiple taxonomies (countries, states etc), some of which have thousands of terms (if that even matters). Edit: I failed to mention that this is an offshoot of another question: Pros and cons of using [taxonomy name] in place of [category name]? The goal is a permalink that looks something like domain.com/2011/taxonomy- term/post-name. So if I have a taxonomy named countries and a post about Egypt, I want to be able to plug the Egypt term into that url.


How to change the WordPress favicon?

I'm looking for a way to change the WordPress favicon. Any hints how to do this?


Numbering sections and block-level elements in wpautop(); Wordpress as CMS for long-form writing;

I am starting to learn how to write plugins for Wordpress. I'm interested in using WP as a CMS for long essays (6000-9000 words or more). My problem is what I call the Kindle problem, which is how do you reliably address the different parts of an unpaginated document which can be read on a variety of screens/devices, and will reflow differently in each case. If I'm citing an ebook on my e-reader or in a browser, it's hard to refer to a specific passage and know that my reader will be able to follow it to the exact text location because there's no absolute "page number." One possible solution is putting HTML anchors in the text. Is there any way to get Wordpress to do this automatically? Even better, is it possible for Wordpress to treat elements as if they were the beginning of an SGML element, and then automatically generate hierarchically numbered anchors for each heading, each sub-heading, and each paragraph or block 'enclosed' with them. I'm thinking of some way of doing what LaTeX does to \section{} tags. Has this been done? Where exactly would this filter apply? Adam Brown says that there are over 1500 hooks you can use! That's pretty amazing, but also daunting too. Thanks for your help. Cheers, Ryan http://rschram.org/


Preserve white-space in Page

I frequently post pages with code examples. However, Wordpress strips out whitespace, thus ruining the indentation and formatting of my code. So this:               <pre>         selector {            property: value;            property: value;         }     </pre>      becomes this:               selector {property: value;property: value;} I found the _Raw HTML_ plugin, which fixes linebreaks, but even with _Raw HTML_ , the spaces aren't preserved, so it looks like this:               selector {     property: value;     property: value;     } I also have played with the _Preserved HTML Editor Markup_ plugin, but it does not support `<pre>` or `<code>` tags, which is exactly where I need it. How can I preserve multiple contiguous spaces? Edit: Just to clarify, the white space is stripped out by Wordpress before it is sent to the browser: viewing the source code reveals that the spaces have been collapsed.


return get_the_tag_list with whitespace removed

I need to `get_the_tag_list` but want to remove whitespace **within** individual tags. Thus, `firefox, internet explorer, opera` becomes `firefox, internetexplorer, opera` All the filters I found removed whitespace from the HTML, not the content itself.


What do spammers gain by signing up as a user?

The majority of new user signups I receive on my Wordpress blog look dodgy, with @someblog.com, @somearticle.com, or @gmail.com addresses. What do they gain by signing up as a new user?


How do i remove approved spam comments by date?

Need to remove 1000 spam comments within a data range without removing legit comments


Settings API updated messages won't show if custom admin page not hooked into add_options_page()

Been playing around with the Settings API and found that messages (for success or errors) are only displayed when a settings page is hooked into WordPress menu via add_options_page(). Anything else will not work e.g. add_dashboard_page(). Would like to know if this is true? Sample code I tried with is the answer containing the "RegisteredSettingsTest" class at Where to hook register_settings for Settings API when also want to update options outside of Settings API?


wordpress htaccess is hijacking my .mp4 files

I am running wordpress 3.2rc2 multisite. I inserted a few .mp4 videos into the root of my domain so that I can run a few basic tests with the jw player. When I try to access the url to the .mp4 video, I somehow end up with a wordpress 404 page. This is also causing errors within the jw player saying that either the file is not found, or access is denied. Permissions are 644 on the mp4 files, and the owner/group is correct. Why is this happening and how do I fix it so that wordpress stops messing with my mp4 files? Also: can someone please add the mp4 tag, I don't have enough rep to do this yet. Here is my htaccess file:               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).*) $2 [L]     RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]          AddType video/ogg  .ogv     AddType video/mp4  .mp4     AddType video/webm .webm      **Edit** If I use the wordpress media uploader, then I can access the mp4 videos just fine. I just can't place them anywhere else on the server which is a problem. Anyone have any further ideas as to why wordpress is screwing with my mp4s when in other directories or even when they are in the root?


Trouble with responsivitizing my twentythirteen header

I'm using the **twentythirteen** theme and trying to get the header to adapt to screen resolution. I've uploaded several image files with the required resolutions, and changed my **custom-header.php** source code according to what is suggested here. The website, www.ensemblepourviroflay.org/wp/ (can't link more than twice with newbie account), does not seem to be displaying any of the images, at whichever resolution. I have pasted the content of my custom-header.php file here. I would appreciate it if a kind stranger would have a look.


Save default value for empty or missing post meta

I am using WordPress and I am using a custom field that has the name `ecpt_carprice` for each post I am publishing, the field is saved in `wp_postmeta` the same as the attached image: ![](http://i.stack.imgur.com/WtdnP.png) Some of my cars (posts) do not have a meta key `ecpt_carprice`.   Can you provide me with any means (WordPress/PHP or SQL query) to store for every post without the meta entry a new entry with value 0? I have this code but I don't know how to use it               if ( has_term( '', 'car_brand' )) {          //check if the meta field has a value     $meta_values = get_post_meta($post->ID, 'ecpt_carprice', true);          if(empty($meta_values)){     //add a default value     add_post_meta($post->ID, 'ecpt_carprice', '0');     }      }


publish_post hook isn't working for scheduled posts

I had a bit of an issue with wp-to-twitter publishing a tweet linking to a post that was set as 'pending' that i had emailed to my wordpress.org site. The email included a footer, which included my mobile number. I decided to create my own plugin.               add_action('publish_post', 'tcr_tweet');          /* the function */     function tcr_tweet($postID)     {              if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {                 /* get the post that's being published */                 $post = get_post($postID);                  $post_title = $post->post_title;                      /* get the author of the post */                 $author_id=$post->post_author;                 /* author needs a twitterid in their meta data*/                 $author = get_the_author_meta('twitterid',$author_id );                      /* get the permalink and shorten it */                 $url = get_permalink($postID);                 $short_url = getBitlyUrl($url);                      //check to make sure the tweet is within the 140 char limit                 //if not, shorten and place ellipsis and leave room for link.                          if (strlen($post_title) + strlen($short_url) > 100) {                            $total_len = strlen($post_title) + strlen($short_url);                            $over_flow_count = $total_len - 100;                            $post_title = substr($post_title,0,strlen($post_title) - $over_flow_count - 3);                            $post_title .= '...';                                         }                      //add in the shortened bit.ly link                 $message =  "New: ".$post_title." - ".$short_url." by @".$author." #hashtag";                       if ( $post->post_status != 'publish' ) return;                 //call the tweet function to tweet out the message                 goTweet($message);         }      } my plugin is a simple plugin, it calls out to my bit.ly function and then to a different function that tweets, these function are used elsewhere and work perfectly well. My issue is that if i schedule a post nothing gets tweeted, if i click publish on a new post i get a white screen, but tweet is sent. How can i target scheduled posts correctly ? I've looked at my `$_POST` data and it seems ok. Code seems pretty straightforward, so i'm missing something.. thanks Edit: I have some confusion on how WordPress works with scheduled posts `post_status='future'` when the time comes and the post needs to be made live, surely it becomes `post_status='publish'` as it's no longer a 'future' post. so my function should be triggered when                add_action('publish_post', 'tcr_tweet');       add_action('publish_future_post', 'tcr_tweet');       add_action('future_to_publish', 'tcr_tweet');      these actions are triggered. Do I need to check that the date has passed instead, if a post_status stays as 'future' ?


Intercepting Before W3 Total Cache

I am writing a plugin where I want to read user agent and send custom headers back on certain agents. Unfortunately however several people have the W3 Total Cache plugin and what it's doing is that, when I have a condition that sends back the custom header, it then sends back that custom header for ALL user agents, not running my event logic. I tried to load my event with...               add_action('plugins_loaded','MY_PLUGIN::checkRules',-1000000000);      ...but W3 Total Cache intercepts via .htaccess or by some other mechanism. Unfortunately I have to do it at the `plugins_loaded` level because I need to query `get_option`. How can I make my plugin work even if W3 Total Cache is engaged?


Clean up images, delete unused image sizes attached to a post type

I found this post: How do I delete all generated images from my server except those currently used in posts which describes how to delete all image sizes but the original uploaded image file. I need to do this on a post by post basis for a custom post type named "gallery". None of the images are in the post content, they are simply attached ot the post. There is no content entered for my gallery custom post type. How would I go about altering the code in the above post to fit my needs? A simple push in the right direction would be greatly appreciated. Thanks!


Code for Log Out Button Yields Strange URL

I'm using some code that I found here in order to create a login/logout form on my sidebar. The login works just fine, but what's weird is that on logout, the user gets redirected to "personaldomain.com/%2F", and I get an error that says > Not Found > > The requested URL // was not found on this server. The code for the logout button is:               <a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout
      Any advice?


Jetpack Blog Subscriptions on Multisite

I am using Jetpack on Multisite. When I connect with WordPress, it note the MultiSite Blog Address, and uses this when a user subscribes to get emails for any posts from the site. Subscriber get confirmation email, and then get all new posts. Works well. BUT my clients frequently have their site pointing to a Mapped Domain. To a subscriber, the multisite domain sent in the conformation email can look suspicious. Q. Is there (or can there be) any way to cater for mapped domains in Multisite in jetpack?


Parse shortcodes from another site in WP Multisite

I'm retrieving a list of posts from various sites in a multisite installation using the following method:               $posts = lc_main_eh_posts();          foreach ( $posts as $post ) {         setup_postdata($post);              if ( $post->blog_id == get_current_blog_id() ) {             get_template_part('list-medium', get_post_format());         } else {             get_template_part('list-medium_auxblog', get_post_format());         }     }      Where `lc_main_eh_posts()` retrieves the posts from all sites using `WP_Query` and `switch_to_blog()` and returns an ordered array of `WP_Post`s. It also assigns the blog id each post belongs to in `$post->blog_id` for later use. In `list-medium_auxblog.php`, I'm doing:               <p>         <?php              $content = strip_tags(strip_shortcodes(get_the_content()));         $trimmed_content = wp_trim_words($content, 20, '...');              echo $trimmed_content;              ?>     </p>       The problem arises when there's a shortcode in use in a post that belongs to a different blog/site. I've tried `apply_filters('the_content', get_the_content)`, `do_shortcode(get_the_content())`, and `strip_shortcodes()` is in use there and it doesn't even work. The shortcodes just appear as raw text. I also tried adding `switch_to_blog()` and `restore_current_blog()` before and after the template tags shown above, with no luck. I suspect this is due to the fact that those shortcodes are not registered network-wide. I can't just enable them, because they display data that is only in the database of specific sites. What other options do I have? How can I parse shortcodes from posts that belong to other sites in the MS as if the current blog was that one ?


Let users comment on categories in WordPress

I'm working with a client who wants visitors to be able to post comments on categories instead of on individual posts, but I am unsure on how to go about it. Is it possible to display the comment form in a category? Just pasting in `<?php comments_template(); ?>` didn't do it, unfortunately.


PHP variables in mysql query

What is the consensus on how to insert variables in a MySQL query using the `$wpdb->insert` syntax: `($table, array($column=>$value),$format)`? I know this hasn't worked:               $wpdb->update('wp_mytable',     array('product'=>"$product"));      Nor this:               $wpdb->update('wp_mytable',     array('product'=>$product));      Nor this:               $insert_row = $wpdb->query($wpdb->prepare("INSERT INTO wp_mytable                                                            ( product )                                                            VALUES (%s)                                                            ",                                                            $product));      Where echoing $product indeed echoes the string I want to insert. The other syntax that has worked for me in the past (but not via the $wpdb syntax) is:               INSERT INTO wp_mytable ('product') VALUES '%s', $product;      I'm still getting a blank field value in the database with all above methods. The row is created but the value is missing. \-- **Update**               $insert_row = $wpdb->insert( 'wp_mytable',                                             array( 'product' => $product,                                                     'votes' => 1),                                             array(  '%s', '%d' )                                             );      This still produces a blank entry under the product column. The vote is counted for the row but the product field is left blank. This is how I declare $product:               $product = wp_get_object_terms($post->ID,'product');     $product = strval($product[0]->name);      I'm selecting the first object term's name and making sure it's a string. Also what's interesting about the update query is that although the WHERE clause has its own array, it requires an AND for multiple clauses. This is confusing if you are declaring variables for the WHERE parameters:               $update_vote = $wpdb->update( 'wp_mytable',                                              array( 'votes' => $new_votes ),                                              array( 'product' => $product                                                     'company' => $company), // WHERE DOES 'AND' GO?                                              array( '%d' ),                                              array( '%s', '%s' )                                                        );


Multi category dropdown doesn't work can't select subcategory

I've been working on multiple dropdowns where the first dropdown selects the parent category and the second the child of that parent. Now the form pops up and i can select the main category fine, but i can't seem to select the child category, the form says i haven't selected a parent yet, but even if i do the form won't change and show the results. Can anyone point me in the right direction?               function parent_child_cat_select() { ?>


A better Media LIbrary Experience

I've spent a good amount of time reading through everyone's suggestions about better file management with the Media Library -- and at the end of the day, I haven't come across any clear winners at the moment. I saw this question/answer about adding taxonomies to the Media Library -- but it looks like that experience is an open text-field (not incredibly user friendly). Is that the best we'll get with that at the moment. What I would hope for is an experience just like any other taxonomy screen. I've seen Custom Upload Directory which is falling pray to some PHP errors (so I can't properly test) and Media Categories which while nice -- doesn't satisfy the needs of adding the media itself. Here's a run-down of what I was looking for:   * Allow categories in the Media Library (once a suitable UI solution is found -- that initial answer looks like it can then provide the ability to sort by a taxonomy   * Add that same category selection-box to the media modal pop-up   * Allow users to filter by a specific category (select or open-text field) based on a taxonomy   * Automatically assign uploaded files a category either based on image-type or post-type As I typed that it seems like it's more of a wishlist than a proper question to go on here -- but I have tried to do my due diligence in researching beforehand -- just not sure if this will be a clusterf*** of the possible solutions here. Any hints in the right direction? Thanks!


admin-ajax.php " Missing argument 2" warning

I have the following code in functions.php               <script type="text/javascript">     var post_id = "1055"; // hardcoded post id for testing purposes     var type = "some_type";     var data = {action: "get_variations", parent_id: post_id, item_type: type};     jQuery.post("/wp-admin/admin-ajax.php", data, function(response){         alert(response);     });     </script>     <?php     function get_variations($parent_id, $item_type){          // etc..          }          add_action('wp_ajax_get_variations', 'get_variations', 10, 2);     ?>      When ajax tries to call get_variations I always get: Warning: Missing argument 2 for get_variations() What am I doing wrong?


Any way to assign Post Categories and Tags to Links?

I would like to assign post categories and post tags to the links in my 'Links' section, and (ideally) remove the link categories feature since it would be redundant. Anyone know how to do this?


Wordpress: Displaying all the post tags from within a specific taxonomy's term

Okay so I understand that the default "Categories" is a taxonomy, and posts live within those categories. I created a new Taxonomy (like Categories) that houses a custom post type. The posts of that post type also have tags.               [New Category-Type Taxonomy]        1. Category Name 1           a. Custom Post 1                This entry has post tags           b. Custom Post 2                This entry has tags as well           c. Custom Post 3                And this one too             2. Category Name 2           a. Custom Post 4                This entry has post tags           b. Custom Post 5                This entry has tags as well           c. Custom Post 6                And this one too      What I'm trying to do is round all the posts tags from the Category Names So I can list 1a 1b 1c on the Category 1 page, and 2a 2b 2c on the Category 2 page. If I can figure out what to query or how to navigate through arrays I can do some kind of for each loop and get these post tags into * tags that can I add jQuery to for extended functionality.


embed the_content

Im trying to wrap video urls and embed code in a classed div so that I can style it. The vid code is being pulled from the custom meta value I've setup for the video post type. Nothing I've been able to find via the forum or google seems to quite answer my question. Use case: The user either enters a youtube url into the video meta field, or they plunk in the entire embed code. Either way I need to wrap the output in some classed divs (fitvid). Im new with WP and was hoping someone could explain: Why the urls Im passing to the_content in the code below, not being phrased by the [embed] shortcode? And what do I have to do to get it to? From what I can tell, my options are either get [embed] to recognise the urls as video and do their magic -- or try to do the detection myself (which is a bit beyond my reach ATM :) ). Here is what I have so far:               <?              $mykey_values = get_post_custom_values('_format_video_embed');              foreach ( $mykey_values as $key => $value ) {                     if (!empty($value)) {                 // I can get one or the other to work but not both                 //$var = apply_filters('the_content', "[embed]" . $value . "[/embed]");                  //this will only return the url - but why?                 $var = apply_filters('the_content', $value );                 }                 echo "
$var
";                }  ?>                  <?php the_content();  ?>        Hey - and thanks in advance for your experience.


Access bloginfo, get_option, and plugins_url from a non-core php file

I am creating a plugin that has a php file in the plugin directory which is accessed directly via a custom rewrite url. I need this file to be able to use the three functions mentioned in the title. At the moment, I am including the wp-load.php file which gives me access to all of these functions. However, I've been reading that wp-load shouldn't be included because it may not always be in the same place and it includes wordpress files that may not be needed. This is how I'm including wp-load:               $wp_base = explode($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_FILENAME']);     require($wp_base[0] . '/wp-load.php');      I've found that the functions I need are located in these wordpress files:               wp-includes/general-template.php     wp-includes/functions.php     wp-includes/link-template.php      Should I instead include only these three files, and will they always be located in the same place? Or is there a better way to go about do this? Thanks


WordPress is creating a lot of draft posts

My WordPress install (with the following plugins) randomly creates Draft posts whenever I load the posts page. Is there a way to find out which plugin is doing this (aside from deactivating)? Has anyone had this problem? ` Admin Tree View Advanced Custom Fields ACF: Flexible Content Field ACF: Repeater Field Breadcrumb NavXT Disqus Google Analytics Dashboard for WP Google Analytics for WordPress Gravity Forms Gravity Forms Campaign Monitor Add-On iframe IPU-Chart Simple Sitemap sxss Admin Notes TablePress W3 Total Cache WordPress SEO WP-Mail-SMTP `


How to get the slug of the homepage when editing it in WP admin?

According to the WP_Class reference, `$post->post_name` holds the value of the slug of the current page being viewed. If I'm currently viewing the WP admin edit screen for my homepage as set under Settings > Reading > Front page displays > A static page > Front page, what would be the value of `$post->post_name` if I do the following?               global $post;     echo $post->post_name;      I wasn't aware my homepage had a slug. Would the value be an empty string? Hoping someone can help clarify. Thanks in advance.


Code displaying plugin for a mobile Wordpress blog?

Do any wordpress plugins for displaying/formatting source code in a blog work well on mobile devices out of the box?


extract post image to be featured images

I been working with featured images more lately and I been adding them to my posts as I go. However I have a bunch of older posts that do not have the featured image set and I want to use it for such things as wptouch etc. So I have like 300 posts and to be honest I dont want to go into 300 posts and set the images manually. IS there anyway either by plugin or code that you can code it where the featured images area will grab the first image in each post?


Wysija Newsletters: Redirect After Subcription

I am using Wysija Newsletters plugin. After I click button "Subscribe", I want to be redirected to custom page. How to do I this? Can you can do this? This is my page: http://cheapproducts4you.com/index.html


Different thumbnail sizes

Is it possible to set a different thumbnail size for different pages? For example, I want the thumbnails on my category, archive and tag view to be bigger than on my home.php. Right now I have the following code in my function.php:               add_theme_support( 'post-thumbnails' );      set_post_thumbnail_size( 250, 165, true ); Do I have to modify my function.php or is it also possible to modify the thumbnail size in the home.php where I want the size to be different from index.php?


Groups of capabilities: users with multiple roles?

I'm pretty sure I understand the roles and capabilities setup in WordPress: granular capabilities, grouped together in roles that can be assigned to users. Code should check the granular capabilities, not the roles (because the capabilities for particular roles can change). Roles are not necessarily hierarchical (though the default roles are). Is there any way of assigning multiple roles to users? Alternatively, having a number of groups of capabilities, and associating one or more group to a user? The way my site works, there are a number of obvious responsibilities: updating web pages, moderating forums, updating the events calendar, and so on. Each responsibility has a group of capabilities that are needed in order to perform the tasks associated with it. I'd like to enable a user to perform one or more responsibilities. So user A could update web pages and the events calendar but not moderate the forums (not nearly tactful enough), but user B could moderate forums, update the events calendar, but isn't allowed near the web pages. Short of defining a role for each possible combination of responsibilities, is there any way of doing this?


How can I use wp_insert_comment to write a comment when a post is edited?

This would mean that when post A was edited by User1, a new comment would appear under post A that reads 'edited by User1', so that the post edit history can easily be seen. A link to the post revision could also be useful here. Perhaps wp_new_comment would be a better choice?


Sidebar not appearing on page template with custom posts

Hi I've been googling for a while and I can't find help for this. I've got a page template that is listing a bunch of custom posts...I'm using this code before the loop to display my custom posts:                   <?php query_posts( array( 'post_status' => 'publish' , 'post_type' => array( 'ncp_news'     )  ) ); ?>      When I remove this to make it a normal page I can display my custom sidebar fine so I know it's got to do with the blog (custom) posts... Here's the full code:
              <?php query_posts( array( 'post_status' => 'publish' , 'post_type' => array( 'nyacp_news' )  ) ); ?>          <?php if (have_posts()) : while(have_posts()) : the_post(); ?>          <?php          $sidebar_position = vp_metabox('_page_sidebar.sidebar_position');     $main_classes     = 'main';     $aside_classes    = 'aside';     if (!empty($sidebar_position)) {     $opp            = (($sidebar_position == 'left') ? 'right' : 'left');     $main_classes  .= " grid-9 $opp";     $aside_classes .= " grid-3 $sidebar_position";     }          ?>          <section id="content"<?php echo qualia_build_class(array("content", "section", "color-        palette-1", "separator-{$qualia_content_separator}")); ?>>

                  <div<?php echo (!empty($sidebar_position)) ? ' class="grids"' : ''; ?>>                           <div class="<?php echo $main_classes; ?>">                          <article id="page-<?php the_ID(); ?>" <?php    post_class('original-content'); ?>>
<?php echo get_the_title($ID); ?>
                          <?php the_content(); ?>

              <?php //echo qualia_spacer(array('size' =>    $qualia_content_bottom_spacing)); ?>
          <?php endwhile; endif; ?>          <?php wp_reset_query(); ?>
                      <?php if (!empty($sidebar_position)) : ?>                 <div class="<?php echo $aside_classes; ?> inner_sidebar">                     <?php if ( !function_exists('dynamic_sidebar') ||       !dynamic_sidebar('innerpage-sidebar') ) : endif; ?>
                 <?php endif; ?>                    <?php get_footer(); ?>      How do I make my sidebar appear while displaying custom posts?


Change the name of the wp_editor tab "html/text"

I'm using the German version of WordPress and in wp_editor the two tabs for "visual" and "html" are named "visuell" and "text". I would like to change the "text" tab to "html". Do you know how I can achieve that? Here is a screenshot to show you exactly which tab I am talking about. http://s1.directupload.net/images/130423/mtor72tu.png


Add a class to post title if a link ends with a certain extension

I am using a Page Links To plugin that allows me to link the post title to an external web page, rather than to the content of the post. And I link some of the post titles to external pages, and others – to pdf files, stored in the uploads folder of my site. I want to add a little pdf icon to those post titles that are linked to pdf files. To be able to do so, I want to add `.pdf` class to those post titles whose links end with `.pdf`. Here's how the corresponding part of the page source looks:

                 My WordPress Post Title

                           <time class="entry-date" datetime="2013-04-23T13:19:30+00:00">April 23, 2013</time>
      What would be the best way to do that in WordPress?


I want to add facility to add country, State, City in my custom plugin

I am working on a plugin for trip adviser, In that i am to add service for user that he can add country, state, city in which his company provides the trips. What should i prefer for that, Please suggest me some effective things or links.


How can I resolve a .htaccess internal server error setting up a WordPress multisite?

I am stuck in .htaccess file creation for multisite. I am getting an error in page now internal error 500 and when i checked my log in apache it says C:/www/vhosts/localhost/wordpress3/.htaccess: RewriteEngine not allowed here. I allowed it in httpd.conf by removing the hash from LoadModule rewrite_module modules/mod_rewrite.so, still getting an error and it says page cannot be found. Can you please help me in this.


How to add a category or tag to media at upload time with the browser uploader?

I don't use WordPress very often... I hope this makes some sense :-) Is there a way to sort media files into categories? I want to give some order to the media that are being uploaded to the website, and 'attaching' media to a Post is not cutting it :-) After a quick search, I found these two plugins. Does anyone have any experience with them? Would anyone recommend another route? http://wordpress.stackexchange.com/questions/496/can-i-add-a-category-metabox- to-attachment http://wordpress.org/extend/plugins/media-tags/ Both plugins would add the functionality that I'm after. Perhaps the only grievance is that media 'tagging' at upload time doesn't work with the 'browser uploader'...


Trying to understand nature of hacking

Today we saw suddenly two files created in root folder in one of our wordpress websites - file name `owp.php` and `gmail.html` On investigating the access logs following entries were found which seem to be malicious and similar to time in which this files were created.               91.207.9.226 - - [23/Apr/2013:17:41:19 +0530] "GET / HTTP/1.1" 200 19928 "http://remont-mobile-phones.ru/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.01"     91.207.9.226 - - [23/Apr/2013:17:41:21 +0530] "GET / HTTP/1.1" 200 19928 "http://remont-mobile-phones.ru/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ru) Opera 8.01"      Can anyone help in understanding the nature of attack and suggestive actions to be taken now.


Stop underlining image links

One my widget bar, I have an image which is hyperlinked. The problem is that CSS underlines it. How do I remove the underline? Update: Just noticed that this is what is causing the underline:               }     .entry a,     .secondaryColumn a,     #commentsContainer h3 a,     .commentlist .comment-author a {         border-bottom: 1px solid #ddd;         color: #3c6c92;         font-weight: bold;     }     .entry a:hover,     .secondaryColumn a:hover,     #commentsContainer h3 a:hover,     .commentlist .comment-author a:hover,     .commentlist .comment-meta a:hover {         color: #3c6c92;         border-bottom: 1px solid #3c6c92;     }      changing the border-bottom to 0px does the trick, but then it takes off the border across all widgets. I use Grid-focus with a wee bit of customization @ thunderror.com


Media Uploader is not working in default rich text editor in my custom plugin

I am working on my custom plugin that will store records in its own database tables. I am willing to add contents via WordPress default rich text editor. I found some code on WordPress stack exchange and Google. That is working also but only for Text in the Text editor, When i click on add media, Only a pop up comes, It never shows my library.               wp_enqueue_style('thickbox'); // call to media files in wp     wp_enqueue_script('thickbox');     wp_enqueue_script( 'media-upload');               $siteurl = get_option('siteurl');     // load script to admin     function trip_advisor_admin_scripts() {          $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/js/admin-image-uploader.js';          echo "<script type='text/javascript' src='$url'></script>";      }           function trip_advisor_admin_styles()      {          if (isset($_GET['page']) && $_GET['page'] == 'add_new_trip')          {          wp_enqueue_style('thickbox');          }      }      add_action('admin_print_scripts', 'trip_advisor_admin_scripts');      add_action('admin_print_styles', 'trip_advisor_admin_styles');      For display the text editor i used this code                   <?php         $trip_overview=""; // this var may contain previous data that was stored in mysql.         wp_editor($trip_overview,"trip_overview", array('textarea_rows'=>12, 'editor_class'=>'trip_overview'));         ?>      ![Media Up-loader in Rich text editor](http://i.stack.imgur.com/KPFsI.png) This Up-loader always shows this loading screen. I tried many codes but not succeed Kindly suggest some effective solutions.


Any built-in function to associate a post to category through a plugin?

I have a post ID and I'm just trying to find a function ( I was thinking of something similar to wp_update_post() ) where I can just pass a post ID and maybe a category ID or slug and have it associate the post to the category. Does that exist or have you seen a plugin doing that where I can peek at what they did?


Get the search element only on 404

I know `get_sidebar( );` is used to get the widget sidebar , but how do I request one element from it? For instance, if I want to show the search or most read only? I know there is a way to specify the sidebar for page like `get_sidebar('404' );` for example How do I do this? I've created the `404.php` page. Do I have to register other sidebar or do I have to create "404_sidebar.php"? So, how do I get the "search" element only when my website return error 404?


wp_ajax() question.. not using wp_enqueue_script?

hey guys, weird situation... I'm trying to use wp_ajax() for the first time. I'm normally using a normal jQuery ajax request but in my current case I get a lot of bugs so I thought about trying wp_ajax(). **I don't get it though!** The following piece of code...               // embed the javascript file that makes the AJAX request     wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.js' );          // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)     wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );      ends in...


how to call a function only in specific pages and exclude it from other pages

I have the below functions               require_once(GABFIRE_FUNCTIONS_PATH. '/review-options.php');     require_once(GABFIRE_FUNCTIONS_PATH . '/custom.php');     require_once(GABFIRE_FUNCTIONS_PATH . '/shortcodes.php');     require_once(GABFIRE_FUNCTIONS_PATH . '/post-types.php');      i want them to be called only on specific page or exclude from specific pages. ##  I'm confused on how to do this in function.php please help! the functions i showed above, does conflict with Q&A plugin. this takes place in qa pages. once i try to answer a question, the answer doesn't appear.answers appears only if i remove those functions. Thus I'm looking for a way how I can disable calling those function in qa_pages


Display Facebook photo albums and photo comments?

I'm looking for a way to pull in photo albums from a Facebook Fan Page into a Wordpress site and have the photos open up in a Lightbox with Facebook comments. I've found a few plugins but nothing quite like what I'm looking for and I haven't seem any with comments. Anyone know whether this is possible? Thanks


Posts picking up old Permalinks, how to reset?

I've come across a small bug with my yoast breadcrumbs. I've rebuilding a site and have imported some old posts and content and have come across a problem where yoast things the permalinks are still the old ones. I've flushed out all the old categories and tags, etc and have used flush_rewrite_rules() to try and fix it which has resulted in some broken links. Am I missing something in the DB?


How to disable tinyMCE button added by a plugin?

I know how to disable `TinyMCE` default buttons with `add_filter('tiny_mce_before_init')` using `theme_advanced_disable` parameter, but a button added by a 3rd party plugin seems impossible to hide with `tiny_mce_before_init` The available array with `add_filter('mce_buttons')` returns only the default tinyMCE buttons. How to disable this tinyMCE button?


Get the first Category / Term only in single-custom-post.php

found close stuff but none that exactly answers my question.. so.. How do i get the only the first taxomony (category) of a custom post type...   i can get all - no problem.. this what i am using to grab all of them               <?php foreach ($terms as $term) {echo 'slug, 'sitecat').'">'.$term->name.',';} ?> >> <a href="<?php the_permalink(); ?>"><?php the_title('', ''); ?>
      Would appreciate an answer using my code but any help is most welcomed Thanks, Sagive.


How do I get just the title from wp_get_attachment_image

I can get the image to appear fine in this bit of gallery code. However the flex slider gets its caption from a `<p>` tag (`class="flex-caption"`) and I just need to `echo` out the image title inside that paragraph.               <?php if (!empty($flex_gallery)) {?>

                      <?php                     foreach ($flex_gallery as $att) {                         echo ( '
' . wp_get_attachment_image( $att , 'blog-full-width' ).                         '

' . I NEED JUST THE IMAGE TITLE HERE . '
');                      }                 ?>

                   <?php } else { ?>                <?php the_post_thumbnail(             'blog-full-width',             array('class' => 'featured-full-width-top'));         ?>           <?php } ?>


How do I know if author field was changed on post save?

I'm writing a plugin that sends notifications on various post events. One of the notifications should be sent when a post is assigned to a different author. How can I know that the post author was changed ?


Displaying custom posts by category

I can get custom posts to display on my site. However, I want to filter the posts by category. The custom posts are displaying on this page: http://www.africanhealthleadership.org/resources/toolkit/ The custom posts are the tools i.e. Desk Research and Assessment Tool Under Preparation, I only want to show Desk Research. However ALL the tools are displaying under Preparation. I used this code to get the tools to display. Clearly category_name is not working, but I am not sure how to fix. Thank you for any help.               <?php $loop = new WP_Query( array( 'post_type' => 'portfolio', 'category_name' => 'preparation' ) ); ?>          <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>          <?php the_title( '
', '
' ); ?>      `


How can I remove <div ="mceTemp"> using built in wordpress filters

I'm getting image fields wrapped in tags and would like to remove the surrounding divs, but only if they are of class "mceTemp". Anyone know of an efficient way to do this? Also, should those Divs even be there?


How to make number of blog posts a custom field?

I'm using advanced custom fields and I have the following code:               <?php     $args = array( 'numberposts' => 3 );     $lastposts = get_posts( $args );     foreach($lastposts as $post) : setup_postdata($post);     ?>      Where the number of posts = 3, I was wondering if I could turn this into a custom field in the editor so that my client can easily change how many posts per page should display. Now using my 'simple this is how it should work' PHP brain, I thought I could use the following:               <?php $numposts = <?php the_field('number_of_posts', $number_of_posts); ?>; ?>      But it doesn't quite work. Any tips? Thanks.


How to: Avoid a bunch of useless Auto Draft ID entries related in posts table and disable autosave feature in 'post-new.php'?

I got it! Buuuuut I had to edit 2 core files, yes! 2 core files :( I know is not a cool plugin hack, but maybe a cool patch for WP, Im using 3.3.1 version. Well, here is my little hack/contribution: **wp-admin/post-new.php** # 1 Comment:               //wp_enqueue_script('autosave');      # 2 Change:               $post = get_default_post_to_edit( $post_type, true );     $post_ID = $post->ID;      by:               $post       = array();     $post_ID    = 0;      **wp-admin/post.php** # 1 Change:               if ( isset( $_GET['post'] ) )         $post_id = $post_ID = (int) $_GET['post'];     elseif ( isset( $_POST['post_ID'] ) )         $post_id = $post_ID = (int) $_POST['post_ID'];     else         $post_id = $post_ID = 0;      by:               if ( isset( $_GET['post'] ) ) {              $post_id = $post_ID = (int) $_GET['post'];          } elseif ( isset( $_POST['post_ID'] ) ) {              if ( empty($_POST['post_ID']) ) {                  $post_type = wp_kses($_POST['post_type']);                  if( !post_type_exists($post_type) ) {                      $post_type = 'post';                  }                  check_admin_referer('update-' . $post_type . '_' . (int) $_POST['post_ID']);                  global $user_ID;                  $defaults = array(                                 'post_status'   => 'draft',                                 'post_type'     => $post_type,                                 'post_author'   => (int) $user_ID,                         );                  $postarr    = wp_parse_args( $_POST, $defaults );                  $post_ID    = wp_insert_post($postarr);                  $post_id    =  (int) $post_ID;                  redirect_post($post_id);                  exit;                 } else {                  $post_id = $post_ID = (int) $_POST['post_ID'];              }                    } else {              $post_id = $post_ID = 0;          }      I am using JQuery to hide: add media stuff. Just only a unique ID entry is created in posts table (and not a bunch of useless Auto Draft entries related) and media stuff will be visible after user manually saves current post. **Rare behavior: When a user logins for the first time and is redirected to Dashboard, WP creates an Auto Draft entry in posts table, hmmm, crazy! Somebody knows why it works like that?** A better solution: perhaps not altering at any chance core files? It will be a great one! For example, with a checkbox in Settings to check or uncheck if we want the "autosave" feature or not (get_option). Somebody else wants to apply the patch? Thanks in advance.


Why won't pagination work?

I am using a page template with code to display all blog posts:               <?php /* Template Name: Blog */ ?>          <?php get_header(); ?>
          <?php     // ACF Page number variable     $numposts = get_field('number_of_posts_per_page');     $args = array( 'numberposts' => $numposts );     $lastposts = get_posts( $args );     foreach($lastposts as $post) : setup_postdata($post);     ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                  <?php the_time ('j F, Y'); ?>  •  Posted by: <?php the_author(', '); ?> in: <?php the_category(', '); ?><?php the_tags( '  • &nbspTags: ', ', ', '
' ); ?>                  <?php the_content(); ?>
     <?php endforeach; ?>               <?php wp_pagenavi(); ?>
          <?php get_footer(); ?>      The problem I'm having is I cannot get any pagination to work. Above I have pagenavi installed but nothing appears. I have set the post limit to 5 in both my custom field (which shows 5, there are 6 posts) and in WP settings. Can anyone shed any light? Thanks.


Assigning Multiple Layout Designs with Custom Pages in WordPress?

( **Moderator's note:** This question was previously titled _"How to add multiple custom page in wordpress"_ ) I am developing a WordPress site and right now I have a custom home page and others are default WordPress pages. Now I want to add one **another custom page** for some landing page. It will not be sub-page. This page's layout & design is different. How Can I add this to my wordpress website?


How to create a drop down menu like in twenty eleven theme?

I really like the drop down menu solution of twenty eleven theme: http://twentyelevendemo.wordpress.com/ and would like to create a similar one but I cannot figure how it works, or is it based on some existing code for dropdown menus? Is there any source code that can be used, or can someone explain the principle behind it? I know internet is full of both js and non-js solutions, I've even made some myself, but IMO nothing comes near this menu, so help is appreciated:)


Sort Posts Best Practice

I have a custom post type "Properties". These properties posts are being listed out on page "Properties For Let". Each property post has various custom meta including price, and number of bedrooms. The properties will initially be listed in the order defined by the original wp query I set. However at the top of the page I wish to have links that upon click will sort the posts by Price, Date Added and Number Of Bedrooms. What is the best practice for doing this? I have seen people advise on addin query strings to URLs etc but would like some solid advice Thanks in advance for any help John


How to set path to the image instead of alt in media.php?

I need to modify the default gallery code, I need the alt of the image to be the path to the big image. I've modified media.php like this:               function wp_get_attachment_image(...........     'alt'   => $src,     'title' => trim(strip_tags( $attachment->post_title )),     ..........      But now my alt is the path to the thumbnail of the image, I need the path to the big one, how can I do that? Thanks for your time.


See the all uploaded images of a user as an admin

I can see the user uploded images in the media library. I click the name of a user to see all the images he/she uploaded but all is a blank page. The url is like: http://mysite.com/wp-admin/upload.php?author=$author_id How can i solve this?


template_redirect and title

I pass a template_redirect in wordpress as hook but I want to have a personnalized title for this page and I miss to do that. Has someone any idea ?               add_action( 'template_redirect', 'virtual_pages' );     function virtual_pages() {         global $wp;         if (strtolower($wp->request) == 'virtual-page'){              remove_all_actions( 'builder_add_title' );             add_action( 'builder_add_title', "<title>Custom Title</title>\n" );             include( get_stylesheet_directory() . '/test.php' );            exit();         }     }


has_archive=false on the default post type

On the default `post` type, why does the `has_archive` property equals to `FALSE`?               $type_obj = get_post_type_object('post');     var_dump($type_obj->has_archive); // FALSE


why some permalinks adding characters/ruining links

I am using a gallery to link to some sub categories. Some of the links within the category work exactly how they should. However there are a few that are adding strange characters on the end, I've re-done the permalinks but it still does it, you cannot see the extra characters in the link section of my gallery admin. Obviously by adding these characters, it is preventing the link from working and giving me the 404 message. It is vital to my website that my links work. Can anybody think of a reason why they would not? I have tried disabling plugins and also looked for invisible characters. "%20%E2%80%8E" variants of this are what is being added. Really hoping someone can help me to solve this! Thanks.


Restored Wordpress on new Server - Can't auto-update plugins

I have installed a new Ubuntu server and have set everything up for Wordpress. I have also extracted mySite directory in the /var/www/ and did a `mysql -u mysqlusername -p databasename < blog.bak.sql` to restore the data to the database. It all worked smooth and works beautifully. The only problem I have discovered is when I try to auto-update the plugins. Please click to see the screenshot (I don't have enough reputation to insert a screenshot here) http://img690.imageshack.us/img690/970/76811016.png Well, I have never setup any FTP on my previous server. How comes this is now asking me this information? And yes I was able to auto-update plugs on my other server without a problem. Thanks,


How To Conditionally Change Menu In Same Theme Location

Is it possible to change to a different menu using conditional tags but using the same theme location? I have 2 menu's created which I want to display conditionally in the same them location which is the secondary menu location.


Downloadable Documents

I have Press Release Section on my page where i would like to be able to add documents pdf, ms doc's etc. Every time when i add new document to a post I would like download button to appear so user will be able to download that document. Could anyone point me at right direction or maybe there is a plugin existing which does that. Many thanks,


WordPress: update_option, don't update empty options?

How would I go about not letting empty data into wordpress?               <?php      foreach($_POST['eirepanel_inline_ads_options_name'] as  $post_eirepanel_inline_ads_options_name):     if(empty($post_eirepanel_inline_ads_options_name)):          echo 'empty';     else:          update_option('eirepanel_inline_ads_options', $_POST);         $eirepanel_inline_ads_options = get_option('eirepanel_inline_ads_options');     endif;      endforeach;     ?>


Adding a "most liked post" box, based on facebook ranking?

I would like to have a list of my most liked posts from facebook, and place it in the sidebar. Is there a way for doing it? (and if so, how?)


update_usermeta don't work

When I return in the function $setfound, I become a white screen and when I return $setlink, it works fine.               function editsteamlink(){     $setlink = $_POST['steamlink']."/?xml=1";     $setresponse = wp_remote_get($setlink);     $setbody    = wp_remote_retrieve_body($setresponse);     $setxml = simplexml_load_string($setbody);     $setfound = $setxml->steamID64;     return $setfound;     }               function be_save_custom_avatar_field( $user_id ) {              if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }                  update_usermeta( $user_id, 'steamid64',editsteamlink());             update_usermeta( $user_id, 'steamlink', $_POST['steamlink'] );          }


Contact form redirecting to page not found on send

I have a contact form that I used lot's of times before on other non WP sites but it doesn't seem to work on my current WP site, it just redirects you to a page not found. I don't want to use any plugins to create it. Here's the code:               <form class="form" method="POST" action="<?php the_permalink(); ?>">

Company Name:
                     	                      	                     <input type="text" name="companyname" id="companyname" />

Your Name:
                     	                      	                     <input type="text" name="name" id="name" />

E-mail:
                     	                      	                     <input type="text" name="email" id="email" />

Telephone:
                     	                      	                     <input type="text" name="tel" id="tel" />

Enquiry:
	                     <textarea name="enquiry"></textarea>

                     <button class="blue medium awesome awesomeforward" type="submit" name="submit">Send message</button>

                  <? if(isset($_POST['submit'])) {           $to = "rob@teamworksdesign.com";     $subject = "Teamworks contact enquiry";     $companyname_field = $_POST['companyname'];     $name_field = $_POST['name'];     $email_field = $_POST['email'];     $tel_field = $_POST['tel'];     $enquiry_field = $_POST['enquiry'];               $body = "Hello Teamworks,\n\n You have an enquiry from the website, please see the details below:\n\n Name: $name_field\n Company Name: $companyname_field\n E-Mail: $email_field\n Tel: $tel_field\n Message:\n $enquiry_field\n\n Please reply to the enquiry asap.\n\n Kind Regards \n The Teamworks Website";          mail($to, $subject, $body);          echo "
Thank you for getting in touch, we will contact you shortly.";          } ?>     </form>


Create template "author" with a plugin

I'm creating a plugin to modify the user profile into wp panel. I'd like to add an author template with the same plugin. I don't know if there is the file author.php into directory of theme. So I'd like to create a file author.php (if author.php not exist) or modify it (if author.php exist). All this via plugin. How can I?


Wp PageNavi only works with default permalinks on a custom post type?

I have tried many solutions to no avail and really need some help. I have a Custom Post Type named "Portfolio" that is setup to display it's contents on a page called Portfolio.php. Wp PageNavi is hardcoded into the template and works fine under the Default permalink structure. When I try to switch permalinks to /%postname%/ and the URL becomes `http://www.site.com/folder/portfolio/page/2/` it throws a 404. Here is my code:                <?php //query_posts('paged='.$paged);        $temp = $wp_query;        $wp_query= null;        $wp_query = new WP_Query();        $wp_query->query('showposts=10'.'&paged='.$paged);?>           <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 6, 'paged' => $paged)); ?>      <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>           <?php $custom = get_post_custom($post->ID);            $screenshot_url = $custom["screenshot_url"][0];            $website_url = $custom["website_url"][0];?>

<?php the_title(); ?>
         <a href="<?=$website_url?>"><?php if ( function_exists( 'get_the_image' )){get_the_image( array( 'custom_key' => array( 'post_thumbnail' ), 'default_size' => 'full', 'image_class' => 'alignright', 'width' => '280', 'height' => '187' ) ); }?>          <?php the_excerpt(); ?>
         <?php endwhile; ?>

         <?php include('includes/wp-pagenavi.php');          if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
      By everything I've read in the last few days I assume I need to either change the name of the page other than the name of the post type (which I don't think it would matter) or there is some rewrite rule I need to be adding. I've reset all the posts in the portfolio, and reset the permalinks many many times, Default always works but anything else breaks the following pages. What am I missing here?


Is it ok to have one wordpress installation for server.com and www.server.com?

I am about to install Wordpress and I want to know if I have to redirect let's say url server.com to www.server.com if I want to have only one Wordpress installation. I want users to be able to use both www.server.com and server.com It would be nice if the typed url won't change (from server.com to www.server.com) but it is not necessary.


Why does WP rename similar "term name"-slugs in separate taxonomies?

I have several custom taxonomies and within two of those ( Company Categories and Photographer Categories ) I have a term that is similar. The Company Category called Boudoir and the Photographer category called Boudoir Photographers. When I created the Boudoir Photographer term in the Photographer Categories it renamed the Boudoir term in the Company Categories to Boudoir Photography. Why did this happen? The number of posts for either taxonomy term doe snot change, only its name and the slug. Thanx in advance!


How to properly print a 404 error without redirecton? (i.e. keeping the current URL)

There are some pages on my BuddyPress install that I would like to hide by printing a 404 error. With the help of the following question: Redirect Restricted Page to 404 I came up with this code:               global $wp_query;     $wp_query->set_404();     status_header( 404 );     get_template_part( 404 );     exit();      Most of the page is hidden nicely and a 404 error is printed, however what has been printed before this code remains (including the header title of the page I want hidden). Unfortunately I can't move this code higher up, before anything gets printed. So is there a way to **clear everything that has been printed before** and then **print a fresh 404 error** but with **keeping the current URL**? (So no redirection to the 404.php page.)


Translating a theme without POT files

I am currently working on a Wordpress project that requires translations into multiple languages. I won't be doing the translations, the client will when I hand it over to them. I want it to be as easy as possible for them to translate certain pieces of text and I don't think that the "POT/PO/MO" process will suffice. Are there any other ways to provide translations suited to the `_()`, `__()`, `_e()` family of functions that are more user friendly? For example, Magento uses csv files and caches the results. This is obviously a very similar idea to PO files, but is more user friendly.


Display single post inside accordion based on form submission results

*Note - for full background see previous question here: http://bit.ly/1gaF673 Ok, so after fixing the problem above and a couple of issues that followed. My form submission returns the results I want. The code that does this is as follows:               //THIS CODE CONNECTS TO THE NON-WP-TABLES WE MADE INSIDE THE WP DATABASE     global $wpdb;     //get list of localities     $localityRow = $wpdb->get_results( "SELECT Name, LocalityID FROM tblYBSLocality ORDER BY     Name ASC" );     //get list of schools     $schoolRow = $wpdb->get_results( "SELECT Name, SchoolID FROM tblYBSSchool ORDER BY Name      ASC" );     //get school ID if form has been submitted     $SelectedSchoolID = $_GET['schools'];     //get location ID if form has been submitted     $SelectedLocationID = $_GET['localities'];     //get selected school name     $selectedSchoolName = $wpdb->get_var( "SELECT Name FROM tblYBSSchool WHERE      SchoolID=".$SelectedSchoolID );     //get selected location name     $selectedLocationName = $wpdb->get_var( "SELECT Name FROM tblYBSLocality WHERE      LocalityID=".$SelectedLocationID );     //get route ID     $getRouteID = $wpdb->get_results( "SELECT Name, RouteID, Description, RoutePageURI     FROM tblYBSRoute WHERE RouteID IN ( SELECT RouteID FROM tblYBSRouteSchool WHERE SchoolID =      $SelectedSchoolID ) AND RouteID IN ( SELECT RouteID FROM tblYBSRouteLocality WHERE      LocalityID = $SelectedLocationID ) " );          //THIS CODE DISPLAYS THE RESULTS BASED ON WHAT THE USER HAS SELECTED IN THE CODE OMITTED     if (isset($SelectedLocationID) && isset($SelectedSchoolID)) { ?>

Search results for routes between:
     <?php echo $selectedLocationName; ?> and <?php echo $selectedSchoolName; ?>
     (Click on route to view timetable and map)

     <?php     if ($getRouteID) {     foreach ($getRouteID as $route) {     $RouteName = $route->Name;     $RouteID = $route->RouteID;     $RouteDescription = $route->Description;     $RoutePageID = $route->RoutePageURI;     ?>     <a href="../../<?php echo $RoutePageID;?>">Route: <?php echo $RouteName;?>
 <?php echo $RouteDescription;?>
     <?php     }     } else {     ?>

Results:
     No Route found for your selection.

<?php } ?>

<?php } ?>      This works as is, but I want to change what happens. Currently, there's a link to the individual post ID where the results are - which is awesome. But I want to do some scorcery and put that post inside an accordion. I found a starting point here: http://bit.ly/1nqT6Pw \- but need to get my head around how to make it more specific to what I'm trying to do. The code from the link above is (as it is in that post):               <?php if (have_posts()): ?>
     <?php while (have_posts()) : the_post();?>

<?php the_title();?>
     <?php the_excerpt();?>

<?php the_content();?>
     <?php endwhile; ?>
     <?php else:?>
<?php _e('No posts'); ?>
     <?php endif;?>      I know you can pull a post apart by title, excerpt, and content - but I can't seem to get this to work properly to put them into an accordion. I've modified the above code to be the following:
 <?php     if ($getRouteID) {     foreach ($getRouteID as $route) {     $RouteName = $route->Name;     $RouteID = $route->RouteID;     $RouteDescription = $route->Description;     $RoutePageID = $route->RoutePageURI; ?>
 <?php     while (is_single($RoutePageID));?>

<?php the_title();?>
     <?php the_excerpt();?>

<?php the_content();?>

<?php } } else { ?>

Results:
     No Route found for your selection.

 <?php } ?>
      This works better than you'd think. It creates the divs but with no content except for the title (wait for it....) but the WRONG title. It gives me the title of the page and not the title of the post. So the while statement is detecting that yes $RoutePageID is valid and it is a single post - but then returns the current pages title. Is it because I've connected to other tables and $wpdb needs to be told to go back to the original table? Or should I be doing something with get_post (can't link to codex as need more reputation but I know where to look). As always, any and all help is greatly appreciated. Thanks yo!


How to permanently delete a taxonomy

I want to delete a taxonomy (both form wordpress and database) created long time ago and now no more used. How to do it? I found this function but I think it will delete all my taxonomies... and I don't know how to choos only 1 taxonomy. Could you please help me? Thanks               <?php     require_once($_SERVER['DOCUMENT_ROOT']."/wp-load.php");     $results= $wpdb->get_results("select * from {$wpdb->prefix}term_taxonomy where `taxonomy` LIKE  'post_tag'",ARRAY_A );     foreach ($results as $row){              $wpdb->query("delete from {$wpdb->prefix}terms where `term_id` =  '".$row['term_id']."'") ;         $wpdb->query("delete from {$wpdb->prefix}term_relationships where `term_taxonomy_id` =  '".$row['term_taxonomy_id']."'");         }     $wpdb->query("delete from {$wpdb->prefix}term_taxonomy where `taxonomy` LIKE  'post_tag'");          $wpdb->query("delete from {$wpdb->prefix}icl_translations where `element_type` LIKE  'tax_post_tag'");         ?>


Plugin generating unexpected output - on WP mysql dump import

I am developing my plugin and I am getting this error: The plugin generated 357954 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. Now my activation hook looks like this:                   function _activate() {         global $wpdb;         require_once(ABSPATH . 'wp-content/plugins/my-plugin/sql.php');          require_once(ABSPATH . 'wp-admin/includes/upgrade.php');          dbDelta($sql);      }      and sql.php which does import like this:               $sql .= $wpdb->query($wpdb->prepare("CREATE TABLE IF NOT EXISTS `wp_car_makes` (       `makes_id` int(11) NOT NULL AUTO_INCREMENT,       `makes_name` varchar(60) NOT NULL DEFAULT '',       PRIMARY KEY (`makes_id`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=350170"));      $sql .= $wpdb->query($wpdb->prepare("INSERT INTO `wp_car_makes`     (`makes_id`,`makes_name`) VALUES      (1, 'Acura'),      (2, 'Alfa Romeo'),     .... and it has a 300k+ inserts     (350169, 'Yugo');     "));      Now - everything is imported properly in DB, and plugin is working OK, it's just that this error is annoying - and I don't have white-spaces after opening/closing tags etc... Any tips why is this happening ?


Using preg_replace to filter custom textarea

I am developing a `custom post type`, which, among others includes the possibility of sending an email from within the post editor. The email body textarea is populated through a custom settings page and saved into a `post_meta array` which also includes the email and subject. Until here all fine. The standard email content from the settings page includes `%%PROPOSAL_LINK%%` and `%%PROPOSAL_LINK_URL%%` which are supposed to be filtered out and replaced with a html link and a normal link to the permalink of the post where the email has originated from. The following is the function as i have it right now:               function filter_email_text_for_post_link( $post ) {          // retrieve the 'proposal_email' post_meta (array)     $post_meta = get_post_meta( $post->ID, 'proposal_email', TRUE );     // retrieve email body 'proposal_email_text' from array     $email_content = $post_meta['proposal_email_text'];          // bail if email has no content     if( $email_content == '' ){ return; }          // patterns to look for in email body     $link_pattern = '%%PROPOSAL_LINK%%';     $url_pattern  = '%%PROPOSAL_LINK_URL%%';          // returns for each pattern     $proposal_link = 'here';     $porposal_link_url = get_permalink( $post_id );          // match and replace with the above patterns     $email_content = str_replace( $link_pattern, $proposal_link, $email_content );     $email_content = str_replace( $url_pattern, $proposal_link_url, $email_content );          // update the post_meta     $post_meta['proposal_email_text'] = $email_content;     update_post_meta( $post->ID, 'proposal_email', $post_meta );          }          add_action( 'save_post', 'filter_email_text_for_post_link' );      for some reason, this just isn't working; at all, no errors, no nothing! Initially i tried invoking this function (slightly edited) in the function which saves the data on save_post but that wasn't working either. Any suggestions? Thanks in advance.


Is W3 Total Cache still useful with CloudFlare?

I noticed that both do the same thing, ex: caching, minifying.


Add span in top menu item with nested itens

I found examples adding a class to top level itens, so we can display an arrow in menu itens with subitens, but is seems terrible to cope with the already builtin WordPress classes, can't display the arrow with current and css hover, it just ruins all states. Is there someway to add a `<span class="arrow"></span>` within the parent `li` instead?! Thanks a lot!


Wordpress: Using the category slug get the category ID using mysql query

basically, I have a cookie with the category slug stored, using this data I want to query the database and return the ID of the category. I am new to mysql and this seems like an advanced query that may need to use joins, any help or guidance would be much appreciated. Thank you! Reference: http://codex.wordpress.org/File:WP3.0-ERD.png


How to output placeholder image if no featured image set?

I am using the Multipostthumbnails plugin - https://wordpress.org/plugins/multiple-post-thumbnails/ And it has a certain naming convention to it. I know the usual way to output a placeholder if no featured image set, but not with their code? I obviously want something like -               if ( has_post_thumbnail($post->ID) ){        $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'news-large');     $image = $image[0];     echo '';     } else {       $image = get_template_directory_uri() .'/assets/img/placeholders/placeholder.png';      echo '';     }      But their existing code to show a featured image is -               if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'header-image', NULL, 'header-image-full', array('class' => "custom-header-image") ); endif;      Just cannot see how to adjust this to fit my code at the top? For Blog Pages - Standard Code -               if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail( 'page', 'header-image', get_option('page_for_posts'), 'header-image-full', array('class' => "custom-header-image") ); endif;      My attempt to try and show placeholder -               if ( class_exists( 'MultiPostThumbnails' ) ) {                              MultiPostThumbnails::the_post_thumbnail( 'page', 'header-image',     get_option('page_for_posts'),                                 'header-image-full',                                  array('class' => "custom-header-image") );                                   } else {                                   $image = get_template_directory_uri() .'/assets/img/placeholders/header_placeholder.png';                                  echo '';                             }      Many thanks


How to create Image gallery Metabox in wordpress

I want to create a metabox like woocommerce product gallery. ![enter image description here](http://i.stack.imgur.com/6ev4s.png) I search on google find out related tutorial, plugin, example but unfortunately i don't get anything. So please, anyone can help me. solved this problem. Thanks


qTranslate: How to use anchors and avoid "(Language)" in title tags?

I'm using the qTranslate plugin to enable multiple languages on a WordPress blog. My question is actually made up of three different questions that may or may not be connected, listed below:   * How should I use #anchors in my theme in a way that I can jump to sections both on the same page (e.g. `example.com/#products`) and on other pages (e.g. `example.com/contacts#map`) and keep the selected language on? I'm using a pretty permalink structure. What I'm trying to know here is the best way to use #anchors with qTranslate, in all possible scenarios.    * I'm hardcoding navigation links (e.g. `<a href="<?php bloginfo('url'); ?>/about">About</a>` and `<a href="<?php bloginfo('url'); ?>/#footer">Details</a>`), but qTranslate isn't appending the selected language to the URL. What should I do to make my hardcoded links work with qTranslate?   * All my product titles look great in the default language. Although when I switch the language and hit products with no translations available, there's an e.g. _(English)_ keyword appended to the title. In this case, it's always the default language name showing up. How can I remove this language name in a way that the original titles always show up the same, no matter the language used (I never translate titles anyway)? I'm wrapping all these questions in one single thread because I have no idea if they're related or not, so apologies in advance for the mess. So, any suggestions?


$wpdb->update multiple rows, like IN in normal SQL

I was wondering if it is possible to use $wpdb->update to update values for multiple rows like with IN in "normal" SQL. I want to accomplish something like this example;               UPDATE [table]     SET [column_1] = [updated_value]     WHERE [column_2] IN ([comma_separated_ids])      I've been searching around for how this would work, but I'm yet to find another question asking this or any kind of answer/blog post explaining whether it can be done or not. For now I'm using a query instead, but it would be nicer with a simple one liner Thanks in advance, Ludvig Sjöbeck


How to change upload directory in wp_handle_upload

I am trying to work out how to use the wp_handle_upload function for a custom plugin so that i can specify my own own upload directory. The code so far takes a file from my plugin settings page and uploads to the folder uploads folder with the year and month. I came across this link which I thought might have some clues - http://yoast.com/smarter-upload-handling-wp-plugins               if(strtolower($_SERVER['REQUEST_METHOD']) == "post"){               $overrides = array('test_form' => false);          $file = wp_handle_upload($_FILES['binaryFile'], $overrides);               echo "<pre>" . print_r($file, true) . "</pre>";     }      **How can I upload to a directory of my choosing?** Any help much appreciated guys.


wp_nav_menu check both hierarchy fail?

I see that in menu exist to kind of hierarchy to find the parent and ancestor. They look for "category or page" hierarchy or for "menu item" hierarchy. But when both exist in a depth tree branch, they dont work well. e.q. IN menu tree               • Page 1       • Category 1       • Page 2     • Page 2      IN admin real hierarchy ` • Category 1 > • Post 1 ` • In this case, if I am in (frontoffice) "Category 1" it's parent in menu tree, "Page 1", has class "current-menu-ancestor current-menu-parent" • If I am in Post 1 (frontoffice) within "Category 1" this one has "current- post-ancestor current-menu-parent current-post-parent". But the "Page 1" even if have not direct connection with Post 1, still are parent of "category 1". But it's not marked as Parent or ancestor. I try by custom walker or even filter the "nav_menu_css_class" to find way that check, if any child of current is ancestor this is ancestor too. We have to check menu tree or real admin tree, category or page. Because if level 2 it's ancestor level 1 should be too.


Second menu not showing

I am running WP 3.2.1 on a dedicated server and having a little trouble with a second menu. I have a menu at the top of the page which is working fine but I've added a secondary left menu to the left column which is currently showing the top menu despite it being selected in the admin to show the left menu. In my functions.php I have:               register_nav_menu( 'left-menu', __( 'Left Menu', 'rsi' ) );     register_nav_menu( 'top-menu', __( 'Top Menu', 'rsi' ) );      Then in my theme files I've called them up using:               <?php wp_nav_menu( array('rsi' => 'left-menu' ));?>     <?php wp_nav_menu( array('rsi' => 'top-menu' ));?>      What am I missing?


Theme thumbnail in dashboard

I'm not sure whether this question belongs here but I don't know where else to ask it : do WordPress designers/developers usually create a dashboard theme thumbnail when they completed the WP theme for their client? If so, do they put their own logo on it or a screenshot of the home page?


Some users getting a 404 when previewing draft posts/pages

I have a WP network and have found that users with roles other than "super user" (admins, editors, authors, etc.) are getting a 404 when trying to preview draft posts/pages/custom post types. Any idea why this would be? I have the following:   * Version 3.1.4   * Subdomain network install   * Domain mapping plugin (if this matters) Thanks.


Can I assign a template to a custom post type?

can I assign a template file to custom post types? I have created a custom post type called `items`, and I would like to assign templates to the items like you can do with pages.


How to make wordpress use www.example.com/blog/wp-includes/ instead of www.example.com/wp-includes/?

I have WordPress at address http://www.example.com/blog/, now I want it to be accessible as http://www.example.com/ without moving wordpress to root directory. I have made appropriate .htaccess changes. wp-config.php:               define("WP_HOME", "http://{$_SERVER["HTTP_HOST"]}");     define('WP_CONTENT_DIR', $_SERVER["DOCUMENT_ROOT"] . "/blog/wp-content");     define('WP_CONTENT_URL', "http://{$_SERVER["HTTP_HOST"]}/blog/wp-content");      One thing that doesn't work is WordPress uses www.example.com/wp-includes/ instead of www.example.com/blog/wp-includes/ There are even includes like www.example.com/%post-name%/wp- includes/js/jquery/jquery.js?ver=1.7.2 I have fixed it through .htaccess:               RewriteRule wp-includes/(.*) /blog/wp-includes/$1 [L]      Is threre a better way?


Using the same database on another Subdomain

Hi i am currently replacing my blog run on wordpress with another neat theme. I tried the preview template feature and everything is fine, just that i don't trust everything so easily when it comes to web-applications. So i want to use the same database currently used[meaning not to use same database for both sites, but make a copy of the database/something with the data/posts] with the post/article and then perfect the theme with the data then replace the old with new. I would like detailed steps for just the database part others i can handle :) thanks for any and every help