Conditionally loading Facebook PHP SDK in shortcode

Since 3.3 we can enqueue scripts conditionally right in our shortcode functions, but when I tried to do this with some PHP class (uses `session_start()` in the `__construct()` function) as you can guess it gives me the `headers already sent` error. The problem is (this is using the Facebook PHP SDK in conjunction with the JS SDK), I only want this class to be instantiated if a shortcode is present on the post and if the current post has 2 meta fields filled out already (the class needs these 2 values [App ID and App Secret]). Is there a simple solution to this? If so, what can I change in the following code to allow this?               public function fb_connect_shortcode( $atts, $content = null ) {         extract( shortcode_atts( array( ), $atts ) ); /**/ global $post;         $app_id = get_post_meta( $post->ID, $this->meta_prefix . 'AppID', true );         $app_secret = get_post_meta( $post->ID, $this->meta_prefix . 'AppSecret', true );              if( $app_id !== '' && $app_secret !== '' ) {                  /**              * This is the class I am trying to instantiate conditionally              * but since it uses session_start(), it can't send out headers              */             $facebook = new Facebook( array(               'appId'  => $app_id,               'secret' => $app_secret,             ) );                  // See if there is a user from a cookie             $user = $facebook->getUser();                  if( $user ) {                 try {                     // Proceed knowing you have a logged in user who's authenticated.                     $user_profile = $facebook->api( '/me' );                     $app_id = $facebook->getAppId();                 } catch( FacebookApiException $e ) {                     echo '
' . htmlspecialchars( print_r( $e, true ) ) . '
';                     $user = null;                 }             }                  wp_enqueue_script( 'jw-fbsdk', plugins_url( 'jw-fbsdk.js', __FILE__ ), array(), '3.3.1', true );             wp_localize_script( 'jw-fbsdk', 'jwuc', array(                 'appId' => $app_id,                 'channelUrl' => plugins_url( 'channel.php', __FILE__ )             ) );                  if( is_null( $content ) )                 $content = 'Connect with Facebook';                  if( isset( $user_profile ) && $user_profile ) {                 return $user_profile['name'];             } else {                 return '
' . $content . '
';             }              } else {                  return "You forgot to add your App ID and/or App Secret! Facebook needs these. :)";              }          }


query_posts for child pages

I am having problems looking for info on the codex on how to query for child pages. It seems to be missing the reference for the available parameters


Three level taxonomy dropdown frontend

I have a code in my functions.php to display 3-level taxonomy dropdown:                           $brand_taxonomy = 'county';                 $taxonomy_name = 'Vietovės pasirinkimas';                      add_action('add_meta_boxes', 'my_custom_metabox');                 function my_custom_metabox() {                 add_meta_box('custom-taxonomy-dropdown','Vietovės pasirinkimas','taxonomy_dropdowns_box','post','side','high');                 }                      function taxonomy_dropdowns_box( $post ) {                 global $brand_taxonomy, $taxonomy_name;                 wp_nonce_field('custom-dropdown', 'dropdown-nonce');                 $terms = get_terms( $brand_taxonomy, 'hide_empty=0');                 if ( is_a( $terms, 'WP_Error' ) ) {                     $terms = array();                 }                      $object_terms = wp_get_object_terms( $post->ID, $brand_taxonomy, array('fields'=>'ids'));                 if ( is_a( $object_terms, 'WP_Error' ) ) {                     $object_terms = array();                 }                      // you can move the below java script to admin_head                 ?>                                  <?php                 echo "Apskritis:";                 echo "<select id='custom_apskritis_options' name='custom_apskritis[]'>";                 echo "<option value='0'>Nepasirinkta</option>";                 foreach ( $terms as $term ) {                     if ( $term->parent == 0) {                         if ( in_array($term->term_id, $object_terms) ) {                             $parent_id = $term->term_id;                             echo "<option value='{$term->term_id}' selected='selected'>{$term->name}</option>";                         } else {                             echo "<option value='{$term->term_id}'>{$term->name}</option>";                         }                     }                 }                 echo "</select>
";                 echo "
Atrenkamos...
";                 echo "
";                 echo "Savivaldybė:";                 echo "<select id='custom_savivaldybe_options' name='custom_apskritis[]'>";                 if ( isset( $parent_id)) {                     $savivaldybes = get_terms( $brand_taxonomy, 'hide_empty=0&parent='.$parent_id);                     foreach ( $savivaldybes as $savivaldybe ) {                          if ( in_array($savivaldybe->term_id, $object_terms) ) {                             $parent_id_savivaldybe = $savivaldybe->term_id;                             echo "<option value='{$savivaldybe->term_id}' selected='selected'>{$savivaldybe->name}</option>";                         } else {                             echo "<option value='{$savivaldybe->term_id}'>{$savivaldybe->name}</option>";                         }                     }                 }                 echo "</select>
";                 echo "
";                      echo "
Atrenkami...
";                 echo "
";                 echo "Miestas:";                 echo "<select id='custom_miestas_options' name='custom_apskritis[]'>";                 if ( isset( $parent_id_savivaldybe)) {                     $miestas = get_terms( $brand_taxonomy, 'hide_empty=0&parent='.$parent_id_savivaldybe);                     foreach ( $miestas as $miesta ) {                          if ( in_array($miesta->term_id, $object_terms) ) {                             echo "<option value='{$miesta->term_id}' selected='selected'>{$miesta->name}</option>";                         } else {                             echo "<option value='{$miesta->term_id}'>{$miesta->name}</option>";                         }                     }                 }                 echo "</select>";                 echo "
";                   }                      add_action('save_post','save_my_custom_taxonomy');                 function save_my_custom_taxonomy( $post_id ) {                 global $brand_taxonomy, $taxonomy_name;                 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )                     return;                      if ( !wp_verify_nonce($_POST['dropdown-nonce'],'custom-dropdown'))                     return;                      $brands = array_map('intval', $_POST['custom_apskritis']);                 wp_set_object_terms($post_id, $brands, $brand_taxonomy);                 }                      add_action('wp_ajax_get_apskrities_savivaldybes', 'get_apskrities_savivaldybes');                 function get_apskrities_savivaldybes() {                 global $brand_taxonomy, $taxonomy_name;                 check_ajax_referer('custom-dropdown', 'dropdown-nonce');                 if (isset($_POST['custom_apskritis'])) {                     $models = get_terms( $brand_taxonomy, 'hide_empty=0&parent='.$_POST['custom_apskritis']);                     echo "<option value='0'>Pasirinkti vieną</option>";                     foreach ($models as $model) {                         echo "<option value='{$model->term_id}'>{$model->name}</option>";                     }                 }                 die();                 }                      add_action('wp_ajax_get_savivaldybes_miestai', 'get_savivaldybes_miestai');                 function get_savivaldybes_miestai() {                 global $brand_taxonomy, $taxonomy_name;                 check_ajax_referer('custom-dropdown', 'dropdown-nonce');                 if (isset($_POST['custom_savivaldybes'])) {                     $miestai = get_terms( $brand_taxonomy, 'hide_empty=0&parent='.$_POST['custom_savivaldybes']);                     echo "<option value='0'>Pasirinkti vieną</option>";                     foreach ($miestai as $miesta) {                         echo "<option value='{$miesta->term_id}'>{$miesta->name}</option>";                     }                 }                 die();                 }      How I can make this code work in frontend (in searchform). Thanks in advance!


Tracking post type in Google Analytics

Is there an easy way to filter between posts and pages in Google Analytics? Page is listed as a Primary Dimension when I drill down to Content but I'm not sure if that includes posts as well.


create Custom field for tv series

I want create a tv series website but i don't know how to list all seasons and episodes on one page like : My GAME Season 1 Episode 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 My GAME Season 2 Episode 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 or this website : streamxd.com/series/mon-oncle-charlie-streaming/117 and when click on episode get the player


Posts Page Featured Image

I have created a theme that uses a featured image on every page. In settings, I have setup my "Posts Page" to be "news"...how do I get the featured image from "news" to display? The following will display the id of my posts page:               <?php         $page_for_posts = get_option( 'page_for_posts' );         echo $page_for_posts;     ?>      So I was thinking that this would display the featured image for my posts page:               <?php         $page_for_posts = get_option( 'page_for_posts' );         echo get_the_post_thumbnail($page_for_posts, 'large');     ?>      But, somehow it doesn't :( Do I need to add this code in the loop or something? Any ideas? Thanks, Josh


How would one split content of a post into pages?

I would like to know if anyone see a nice plugin that split long posts into multiple pages. the posts are about 20 pages long. so, Preferably if the navigation look like this: **Previous Page | Currently Viewing Page of "Total Page" | Next Page** if anyone can write the plugin, it would be a kind of you.


Google adsense stats plugin?

Does anyone know if there's a WP plugin that shows you stats about your ads (like clicks, earnings, etc) ? I've been looking around and most plugins I've found only let's you manage the actual ad code. I found this one but it doesn't work. Thanks in advance!


want use a wordpress widget two times

I have a widget installed in wordpress i want to use this widget two times with different configuration but after first use it disappear from widget list if someone have solution for using many times widget with different configuration on each. The widget : wordpress.org/plugins/mobile-app-showcase


Error messages when adding code to function.php or trying to delete inactive plugin files

Error message below: Warning: Cannot modify header information - headers already sent by (output started at /home/content/79/7603579/html/listings/wp-content/themes/OIB theme/functions.php:519) in /home/content/79/7603579/html/listings/wp- includes/pluggable.php on line 897 EDIT: Code around `functions.php` line 519:                   <?php echo $value['desc']; ?>

          <?php break;      case "section":         $i++; ?>

<img src="<?php bloginfo('template_directory')?>/functions/images/trans.gif" class="inactive" alt="""><?php echo $value['name']; ?>
                               <input name="save<?php echo $i; ?>" type="submit" value="Save changes" />

         <?php break;        }      } ?>      And the fix, per comment below, removed this code:               function cpt_Search_category_Filter($query) {        $post_type = array('post','business_sold');        if ($query->is_search || $query->is_category) {           $query->set('post_type', $post_type);        };           return $query;     };     add_filter('pre_get_posts','cpt_Search_category_Filter');


Adding a checkbox to the theme customizer

When trying to add a checkbox to the theme customizer it seems to be 'always' selected. If you try to deselect it you cannot, almost as if there is some JS code forcing it to stay selected. I am using serialized theme options and everything is hooked up correctly. Code is similar to the following (triggered via the 'customize_register' hook):               $wp_customize->add_setting( mytheme_options[chk_hide_description], array(         'default'        => false,         'type'           => 'option',         'capability'     => 'edit_theme_options' )     );          $wp_customize->add_control( 'display_header_text', array(         'settings' => mytheme_options[chk_hide_description],         'label'    => __( 'Hide site description' ),         'section'  => 'title_tagline',         'type'     => 'checkbox',     ) );      Same issue reported here: http://ottopress.com/2012/how-to-leverage-the-theme- customizer-in-your-own-themes/#div-comment-11254.


How to translate "$before" with get text in get_the_term_list?

How can I make $before (Books:) a translateable string               <?php echo get_the_term_list( $post->ID, 'book', 'Books: ',', ', ' ', '' ); ?>      with this method?:               <?php the_content(__('Read more...', "ft")); ?>


complex restriction of items in media library

I have a need to limit items in the media library for users without a specific capability. There are a lot of examples out there for how to limit them to only items that a given user has uploaded, but my need is more complex than that. I need to limit media items for users without a specific capability to those attachments that are NOT:   1. header images (i.e., set in Appearance > Headers)   2. page thumbnails (i.e., featured images) Below is the solution I've come up.               /*      * restrict media items available to users without cap=mycap to those that are NOT:      *      * 1. theme headers (i.e., set in Appearance > Headers)      * 2. page thumbnails (i.e., featured images)      */     add_action ('pre_get_posts', 'restrict_media') ;     function     restrict_media ($query)     {         if (!is_admin () || $query->get ('post_type') != 'attachment' ||                 current_user_can ('mycap')) {             return ;             }              // get our theme's headers (i.e., set in Appearance > Headers)         $args = array (             'post_type' => 'attachment',             'post_status' => array ('inherit', 'private'),             'posts_per_page' => -1,             'meta_query' => array (                 'relation' => 'AND',                 array (                     'key' => '_wp_attachment_context',                     'value' => 'custom-header',                     ),                 array (                     'key' => '_wp_attachment_is_custom_header',                     'value' => 'antelopevalley',                     ),                 ),             ) ;         // remove ourself from pre_get_posts to avoid infinite regression         remove_action ('pre_get_posts', array ($this, 'restrict_media')) ;         $headers = new WP_Query ($args) ;         // get the IDs of the headers         $header_ids = array_map (function ($p) { return ($p->ID) ; }, $headers->posts) ;              // add ourself back to pre_get_posts for subsequent queries         add_action ('pre_get_posts', array ($this, 'restrict_media')) ;              // get posts with thumbnails         $args = array (             'post_type' => 'page',             'post_status' => array ('publish', 'pending', 'draft', 'private'),             'posts_per_page' => -1,             'meta_query' => array (                 array (                     'key' => '_thumbnail_id',                     'compare' => 'EXISTS',                     ),                 ),             ) ;         $with_thumbnail = new WP_Query ($args) ;         // get the IDs of the thumbnails         $thumbnail_ids = array_map (function ($p) { return (get_post_meta ($p->ID, '_thumbnail_id', true)) ; },             $with_thumbnail->posts) ;              // exclude all theme headers and thumbnails         $query->set ('post__not_in', array_merge ($header_ids, $thumbnail_ids)) ;              return ;     }      The above solution works; however, it seems overly complex to me! I'm wondering if anyone can suggest a simpler solution. Note: I've tried the post_{where,join} filters before for other needs and have found them too complex to maintain so I didn't even try to figure out a solution to this problem using them, but I'm more than open to one that uses them


Alternative to the filter comment_reply_link

I'm making a plugin and need to add a link to every comment on the front-end. I've used the filter `comment_reply_link` but that filter doesn't work when we're on the lowest level of threaded comments (since the reply link won't be shown). Using the filter `comment_text` works somewhat, but places the link at an awkward place when the reply link is there. I could reposition it using javascript but for posts with many comments that could put too much strain on the visitors browser. Is there a filter, action or another solution that works the same as `comment_reply_link` but will always show up?


Transfer Wordpress

I have several WordPress installs that I need to transfer. I had a single hosting plan under my host (SurpassHosting). I added a reseller account. Now. I am trying to setup accounts on my reseller system for each of these additional domains I've been hosting for friends, family and more. I've done this. But I need to transfer their Wordpress installs intact. If I copy ALL of the files over. If I phpMyAdmin > Export > SQL their DB's. What all do I need to make sure to change to get a clean transfer without losing data?


How can I unregister a custom taxonomy?

Problem: Homepage, tier 1, is able to load. Tier 2 pages always display the 404.php page. Tier 3 pages (subpages of Tier 2) load perfectly. Gathered Information:   1. functions.php - At the end of the functions.php file, the developer has registered a custom taxonomy called facebook-feeds.   2. I used a plugin called Rewrite Analyzer and i notice that it thinks my tier 2 pages are facebook-feeds for some reason. I'm not quite sure how to fix this. My first thought was to remove the registered taxonomy. BUT I need a command or a function that will completely remove and make wordpress act like it never existed. If there is a way to make it behave, that would be awesome too, but right now I'm getting some weirdness that I've never encountered before. What do you suggest?


If tag exists and equals then

I have the following code and I'm trying to check to see if a specific tag exists and if so I need it to be echo'd once. The problem I'm having is when the tag exists multiple places it gets echo'd that many times.                                       <?php                             // LOOP ARGUMENTS                             $args = array( 'post_type' => 'xyz_members', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'tax_query' => array(array('taxonomy' => 'member_types','field' => 'slug','terms' => 'current-class','operator' => 'NOT IN')));                             $loop = new WP_Query( $args );                             while ( $loop->have_posts() ) : $loop->the_post();                                  // CUSTOM CONTENT                             $postTags = get_the_tags();                         ?>                              <?php if ($postTags) while($postTags as $tag) { ?>                             <?php if ($tag->slug == '2006') { ?>
2006
<?php } ?>                             <?php if ($tag->slug == '2007') { ?>
2007
<?php } ?>                             <?php if ($tag->slug == '2008') { ?>
2008
<?php } ?>                             <?php if ($tag->slug == '2009') { ?>
2009
<?php } ?>                             <?php if ($tag->slug == '2010') { ?>
2010
<?php } ?>                             <?php if ($tag->slug == '2011') { ?>
2011
<?php } ?>                             <?php if ($tag->slug == '2012') { ?>
2012
<?php } ?>                             <?php if ($tag->slug == '2013') { ?>
2013
<?php } ?>                             <?php if ($tag->slug == '2014') { ?>
2014
<?php } ?>                             <?php if ($tag->slug == '2015') { ?>
2015
<?php } ?>                             <?php if ($tag->slug == '2016') { ?>
2016
<?php } ?>                             <?php if ($tag->slug == '2017') { ?>
2017
<?php } ?>                             <?php if ($tag->slug == '2018') { ?>
2018
<?php } ?>                             <?php if ($tag->slug == '2019') { ?>
2019
<?php } ?>                             <?php if ($tag->slug == '2020') { ?>
2020
<?php } ?>                         <?php } ?>                         <?php /* END WHILE AND RESET QUERY */ endwhile; wp_reset_query(); ?>


Plotting posts on a graph

Here is what i want to do: For a **specific date** i want the **number of posts** from a certain **tag**. For example: on **14th March** i have a certain **number** of posts tagged " **jazz** ". I want to plot that **number** on y-axis of a chart _(dont worry about how i make the chart, i just want to get the number)_ and the corresponding **date** on x-axis. Hence showing a graph of posts tagged ' **Jazz** ' over time. i just need two variables: the number of posts from a specific tags and the corresponding date. Ive searched but i could not find any plugin for that. How should i go about it? Thank you :)


How to remove slug metabox from custom post type's page?

I just discovered a new meta field on the newly created custom post type page. The meta name is slug, and it's under the wp editor field. What's that, and how can I remove it?


Wordpress not respecting template hierarchy (fetches index.php instead of single.php or page.php)

I've encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that Wordpress was actually pointing to index.php template file rather than page.php in my theme for generating the page appearance. I tried to change settings for website home and blog home in "reading" settings. I tried to refresh permalinks structure (normally I'm using %postname%). I also tried reverting to standard /?=post_id structure. In that case works fine... but anything with %postname% won't work. I disabled plugins, but nothing changes. It simply refuses to work with pretty permalinks. **Actually permalinks work fine for my custom post type and it won't throw 404 errors. But for every single page and post will try to fetch index.php rather than single.php and page.php (or subsequent templates for pages).** I checked the configuration for my custom post type... but there's no possible conflict with pages (the url rewrite is totally different than any standard wordpress string). I checked my .htaccess which is pretty standard as in most of my installations:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      UPDATE I decided to throw everything away, being a test development site and started over on a clean install. Dumped the whole DB, trashed the installation files. Clean install and enabled wp_debug=true. At the beginning I noticed an error from the Dashboard:               ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.      I think this is because I renamed the wp-content folder to "content" I've done this before on other installations with this code (of course "mydomain" is my actual domain in my wpconfig...)               define('WP_CONTENT_FOLDERNAME', 'content' );     define('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME );     define('WP_CONTENT_URL', 'http://mydomain.com/' . WP_CONTENT_FOLDERNAME );     define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );     define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );      After double checking and reloading the page somehow the error string disappeared. I was able to install the theme correctly (therefore Wordpress must have been aware of its location folder...) However, the URL permalinks problem persists (wants to fetch index.php instead of page.php template for pages or single.php for posts ). This is driving me insane since it's a clean new installation. UPDATE 2 now I'm testing with TwentyEleven/Ten and it's still throwing the same error... so I must exclude plugins and my custom theme... this has probably to do with my server config, htaccess or wpconfig probably... but I really wonder... because this is running on the same server where I have half dozen of wordpress sites configured in a similar way UPDATE 3 after changing and updating the wp-config.php file several times I got it working at times... but for some reason it keeps breaking again... single blog posts and pages get redirected to index.php (blog home) or page template holding the blog home (if set in "reading" settings from wordpress admin). Custom post types, archives and bbpress forum pages (individual posts and archives), taxonomies... they all work fine. It's just pages and posts. I double checked the php configuration and server variables, it all appears normal


Display "a generated one [avatar] based on their e-mail address"

I was looking at the discussion settings in WordPress and near the "Default Avatar" option I saw that it said the following: > For users without a custom avatar of their own, you can either display a > generic logo or a **generated one based on their e-mail address.** (I bolded the second part.) I'm just curious as to how these avatars are "generated" based on email addresses.


How to export indesign file to xml and import file xml file into wordpress as page with heading and content?

**Task** \- Converting Indesign file To WordPress pages I searched lot and got answer to do that i need to **Convert In-design file to Xml** and **Import it into Wordpress using some plugin** i need to how to convert in-design to XML format and XML structure for creating page in wordpress and Is there is any other way to accomplish the task


Password Protect a Podcast Feed?

I've got a Wordpress account that I have multiple users on. I want to create a podcast feed that only those users have access to. Is there any method or plugin that could do this?


Removing admin javascript

I'm having some trouble adding jquery-week-calendar to WordPress' admin interface using `add_menu_page` and other API methods. What I found out is that the default `jquery-ui` and other JavaScript references are interfering in the rendered calendar behavior. How can I remove these extra scripts from the admin interface? `load- scripts.php` is called a couple of times, and I can't seem to deregister the scripts that the admin components like tinyMCE and others are calling.


Why does WordPress combine a term with the same name in the wp_terms table?

1. Add a term for a certain taxonomy with the name: Test   2. Add another term for a different taxonomy with the same name: Test   3. In the wp_terms table you find one record for both terms. In the wp_term_taxonomy table you find two records with the taxonomy and description and other information about the terms.   4. Now, if you edit one term and change the name from Test to Test2 then both terms are changed... Why is WordPress working that way? EDIT: The real question is not why WP uses a unique slug for a taxonomy. Thats obvious. It's why WP uses one record in wp_terms for the same term. But the meaning of 'Test' can be different in different taxonomies. If you edit one of the terms to be different. That isn't possible anymore. WordPress will edit both because they are both linked to the same term_id.


Getting Post Comments for post ID using WP_Query() and a Custom Loop?

_( **Moderator's note:** The original title was "Is there a way to get post comments by post ID on a custom loop using WP-Query()?")_ Hi! I'm running a custom loop **using WP_Query** , that only displays one post from a specific category on the **home.php** page, like so:               <?php $pr_q = "cat=11&posts_per_page=1"; $pregunta_q = new WP_Query($pr_q); ?>     <?php while ($pregunta_q->have_posts()) : $pregunta_q->the_post(); ?>         <!-- post stuff here -->     <?php endwhile; ?>      Is there any way to have it show comments for that specific post? I tried including the comments template inside the loop and nothing. Is there a function that loads the comments for a specific post that I can use inside home.php or anywhere else?


Customize Admin Section

I am custimizing WordPress in order to use it as CMS. This CMS system will have multiple user accounts at different levels of previlidges and autherization. Now, when it comes to using the admin section, I would like to make sure the users unaware that the system they are using is based on WordPress (there are many reasons for this decision, one of them is security by ambiguity). In any case, now, I need to customize the admin section. I have two solutions in my mind:   1. Customize the existing admin section.    2. Create new user admin pages, and write new admin functionality in those pages. Which solution is more accurate? Why? And more importantly, where can I find documentation to do this? I could not find much on the web to suppport either approach. Thanks.


Allow users to create and store data and retrieve it on login

I write a wedding blog and would like to allow the subscribers to login and be able to create and save their own wedding guest lists. The data they store, should be retrievable on future login to the site. I would like to know if this functionality would be possible and how it can be done.


Link to Authors blog posts

I am trying to create a link in my template that allows the user to see there own blog posts the code that i am using is `<li><a href="?author=<?php the_author_ID(); ?>">test</a></li>` but it is only taking me to `?author=`


What is the best way to setup Wordpress for version control and PhpStorm while allowing updates

Ok, so I have an active Wordpress website that I would like to put under version control. Since I do keep pretty up to date on core and plugin updates I would think that those items should be best kept out of version control. I really wish that Wordpress had a setup file like composer.json. That would make this immensely easier. I know that Drupal 8 is going that way, so good for them. But Wordpress will probably not head down that path anytime soon, if ever. Anyway, here is the deal. I have a custom theme for it and a couple of custom plugins. I would like to be able to maintain and deploy changes in a centralized way instead of having multiple repositories. And would like to use PhpStorm as my primary development tool while doing all of this. The complexity here comes from the fact that there would be hardly any files that would probably end up in version control (config, htaccess, custom theme, custom plugin). But I want PhpStorm to be able to recognize all of this and upload files accordingly as well as save them to the repo. Further, I would like PhpStorm to always fetch the latest files from the server that are not under version control. That would allow it to keep up to date on the latest versions of other plugins and core files. I intend to use Mercurial for the VCS. Does anyone have any suggestions? Any best practices for something like this?


Adding custom post status to visibility in publish meta box

We have two different custom user roles that have custom capabilities. What I'm trying to do is to add two custom visibility statuses that are visible from the publish meta box on the edit page. ![enter image description here](http://i.stack.imgur.com/g7vil.jpg) I've got the post statues registered but I saw on the codex wiki that there is no easy way to add it to the list but I figured I would turn here to see if anyone has done something similar?


Change Admin menu placement using hooks

I have been working in a wordpress multisite installation. Where I am using upPrev plugin that has an option page under Appearance ->> upPrev Now what I need is to move this menu under Settings ->> upPrev without editing the core plugin file. Here is the code used to register the menu in upPrev.php :                         add_action( 'admin_menu',                 'iworks_upprev_add_pages' );              function iworks_upprev_add_pages()         {         $dir = explode('/', dirname(__FILE__));         $dir = $dir[ count( $dir ) - 1 ];         if (current_user_can( 'manage_options' ) && function_exists('add_theme_page') ) {             add_theme_page(                 __('upPrev', 'upprev'),                 __('upPrev', 'upprev'),                 'manage_options',                 $dir.'/admin/index.php'             );         }     }      I've tried using the code below to update menu :                 add_action( 'admin_menu', 'my_remove_tp', 999 );          function my_remove_tp() {         remove_submenu_page( 'themes.php', 'upprev/admin/index.php' );     }               add_action('admin_menu', 'upprev_menu');     function upprev_menu(){             //add_options_page('upPrev Menu', 'upPrev', 'manage_options', 'upprev/admin/index.php', 'upprev');               if (current_user_can( 'manage_options' ) && function_exists('add_options_page') ) {         add_options_page(             __('upPrev', 'upprev'),             __('upPrev', 'upprev'),             'edit_page', 'options-general.php?page=upprev/admin/index.php');         }     }      Result : The menu is showing under settings but leads to an empty page... Any idea how it can be fixed ??


Notices on the front-end

I am reposting. As my last questions wasn't famous. My users are submitting custom post types (projects) from the frontend. How do I display notices (such as the one displayed on admin board) to the front end for when the user performs an action, example edit a post. I know there are hooks for update/submit (post_updated_messages...) but those do not display anything on the frontend. I tried putting the following but it doesn't work:               add_filter('post_updated','alert_user');          function alert_user()     {     add_action('display_message','prepare_text');     }          function prepare_text(){     return 'You did it!';     }      in my theme I have               do_action('display_message');      It doesn't work as prepare_text is never hooked to display_message! Any help? Thanks


Why wont this wp_query exclude certain pages?

I'm using the following wp_query snippet to show all pages on a single page while being able to select individual pages to exclude.               // This pulls a list of page ID's from a theme options multicheck field     $pages = of_get_option('exclude_pages' );     // This shows only those ID's that have been checked     $implode_pages = implode(', ',array_keys($pages, 1));     $args = array(         'post_type' => 'page',         'posts_per_page' => -1,         'orderby' => 'menu_order',         'order' => 'asc',         'post__not_in' => array($implode_pages)     );     $page_query = new WP_Query($args);     while ($page_query->have_posts()) : $page_query->the_post();      If I simply echo the `$implode_pages` bit in a page it displays like this `12, 31` where 12 and 31 are page ID's But when I try and include it in the `post__not_in` argument as shown above it only excludes the first ID even though if I hard code `12, 31` in there it excludes both... Am I doing something wrong?


Git Workflow for Large, Live Site?

The Wordpress site I am working on has thousands of posts, is updated hourly, and has dozens of plugins and hacks to get it to work in the way it does. Can someone explain a git workflow that would allow the following? Essentially, I want to take everything that is currently there — all Wordpress files, posts, plugins, etc. – and work on it locally. This would include, I presume, copying the database and running it locally. (I am aware of the Mark Jaquith solutions, but obviously can't start afresh with his Wordpress skeleton.) There are specific reasons why I want to work from the same database and post base, which is unfortunate, but necessary. I then want to make changes and test on a local environment, and then push it to the live server, along with the database that I will have been using in the local environment. I will have a team which can keep the development database up to date with the content that is being created on the live database (as I don't think there is any other way, right?). I presume also that I will have to manually keep the media uploaded to the live site in sync with the media folder on my local setup. As such, there will be a point where I want to push what I am working on locally to the live server. I presume everything that is in my git repository (that's different) should just overwrite what is on the live server, and I should upload the development/local database contents to my AWS account and then point the live wp-config file to that database. Am I thinking this through in the right way? How do large sites like the NY Times deal with conflicting databases with content management systems and other issues when pushing to the live server? Please also note that we are running Wordpress 3.5 and there is no prospect or possibility of us upgrading because of the specifics of the situation.


Custom menu - different submenu for first menu item

I created a custom menu with dropdowns. (just CSS no JavaScript).   I also added a custom CSS class for the first menu item. So far so good. The point were I get stuck is adding a custom dropdown only for the first menu item which is different from the other item dropdowns. Also I would like to set a different has-children style for the first item. Does anybody know how this can be done? Here is my custom walker:               class topmenu_walker_nav_menu extends Walker_Nav_Menu {              function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {             $id_field = $this->db_fields['id'];             if ( !empty( $children_elements[$element->$id_field] ) && ( depth == 0 ) ) {                 $element->classes[] = 'has-children'; // Use any classname you like             }             Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );         }          function start_lvl( &$output, $depth ) {         // depth dependent classes         $indent = ( $depth > 0  ? str_repeat( "\t", $depth ) : '' ); // code indent         $display_depth = ( $depth + 1); // because it counts the first submenu as 0         $classes = array(             'subnav',             ( $display_depth % 2  ? 'menu-odd' : 'menu-even' ),             ( $display_depth >=2 ? 'sub-sub-menu' : '' ),             'menu-depth-' . $display_depth             );         $class_names = implode( ' ', $classes );              // build html         $output .= "\n" . $indent . '
' . "\n";     }                function start_el( &$output, $item, $depth, $args ) {         global $wp_query;         $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent              // depth dependent classes         $depth_classes = array(             ( $depth == 0 ? 'main-menu-item' : 'sub-menu-item' ),             ( $depth >=2 ? 'sub-sub-menu-item' : '' ),             ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),             'menu-item-depth-' . $depth         );         $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );              $classes = empty( $item->classes ) ? array() : (array) $item->classes;         $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );              $output .= $indent . '
ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';              // link attributes         $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';         $attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';              $item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s',             $args->before,             $attributes,             $args->link_before,             apply_filters( 'the_title', $item->title, $item->ID ),             $args->link_after,             $args->after         );              // build html         $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }     }          add_filter( 'wp_nav_menu_objects', 'tgm_filter_menu_class', 10, 2 );     /**      * Filters the first and last nav menu objects in your menus      * to add custom classes.      *      * @since 1.0.0      *      * @param object $objects An array of nav menu objects      * @param object $args Nav menu object args      * @return object $objects Amended array of nav menu objects with new class      */     function tgm_filter_menu_class( $objects, $args ) {              // Only apply the classes to the primary navigation menu         if ( isset( $args->theme_location ) )             if ( 'main-menu' !== $args->theme_location )                 return $objects;              // Add "first-menu-item" class to the first menu object         $objects[1]->classes[] = 'settingsitem';              // Add "last-menu-item" class to the last menu object         $objects[count( $objects )]->classes[] = 'last-menu-item';              // Return the menu objects         return $objects;          }                   function output_top_menu() {              echo '

';         wp_nav_menu( array('depth' => 2, 'container_class' => 'nav', 'menu_id' => '', 'walker' => new topmenu_walker_nav_menu(), 'theme_location'=>'main-menu') );           echo '

';                   }      Here is my CSS:               .nav-container {         background: #232323;             width:100%;     margin-bottom: -5px;         height: 60px;         display: inline-block;     }          .nav {         background: #232323;         width:996px;     margin-bottom: -5px;         height: 60px;         display: inline-block;     }          .nav li {         float: left;         list-style-type: none;         position: relative;     }          .nav li a {         font-size: 16px;          color: white;         display: block;         line-height: 60px;         padding: 0 26px;         text-decoration: none;         border-left: 1px solid #2e2e2e;         font-family: Montserrat, sans-serif;         text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);     }     .nav li a:hover {         background-color: #2e2e2e;     }               #settings a {         padding: 18px;         height: 24px;         font-size: 10px;         line-height: 24px;          }                    .settingsitem a {         font-size: 16px;          color: white;         display: block;         line-height: 60px;         padding: 0 26px;         text-decoration: none;         border-left: 1px solid #2e2e2e;         font-family: Montserrat, sans-serif;         text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);               }     #options a{         border-left: 0 none;     }     #options>a {         background-image: url(triangle.png);         background-position: 85% center;         background-repeat: no-repeat;         padding-right: 42px;     }     .subnav {         visibility: hidden;         position: absolute;         top: 110%;         right: 0;         width: 200px;         height: auto;         opacity: 0;         transition: all 0.1s;         background: #232323;             z-index:1000;     }     .subnav li {         float: none;     }     .subnav li a {         border-bottom: 1px solid #2e2e2e;     }     #options:hover .subnav {         visibility: visible;         top: 100%;         opacity: 1;     }          .nav li.has-children a{         border-left: 1px solid #2e2e2e;     }     .nav li.has-children>a {         background-image: url(triangle.png);         background-position: 85% center;         background-repeat: no-repeat;         padding-right: 42px;     }          .nav li.has-children:hover .subnav {         visibility: visible;         top: 100%;         opacity: 1;     }


Content generator for development site

Does anybody knows good plugin which can generate dummy posts/tags/categories/users and write dummy comments? I want to generate some content on my development (localhost) site.


Redirect outside wordpress

I have a folder called **"stats"** on my server that I cannot access anymore because wordpress redirects it to the "Page not found". This folder has nothing to do with wordpress. I have searched for a solution but nothing seems to be working. I am using the theme elegant fusion. For clarification, the folder is on the same level directory wise as "wp- admin", "wp-content", "wp-includes". Does anyone know how I can access my folder without going through wordpress? Thank you in advance!


How To Display Selected Terms For Custom Taxonomy?

This may be a syntax problem but if so I can't see the problem. I want to select specific terms of a custom taxonomy and display their names. I'm having a problem with the selection process in the following code.               $taxonomy = 'chapters';     echo("Test Term Display ");     $args1=array(         'include'=> array(74,76             )         );     $chaptertitles=get_terms( 'chapters', $args1 );     $count1 = count($chaptertitles);     echo($count1);      if ( $count1 > 0 ){        echo "
";           foreach ( $chaptertitles as $chaptertitle ) {        echo "
 Chapter Title:" . $chaptertitle->name . "
";            }      echo "
";     }      This returns zero for $count1. However, if I remove the arguements so that the default conditions apply then I get all the terms returned. This suggests that my syntax is incorrect for $args1 but I can't see any errors. I'd appreciate any suggestions on how to get this working. Thx


How to create a custom field index page

I'm trying to create an index page for some custom fields, just like the taxonomy search pages. E.g. I have a custom field with slug=wpcf-delivery. I want an index page that lists all values where the meta value of wpcf-delivery is 1. I've tried creating a link like this: myblog.com/mkey=wpcf-delivery&mval=1 Then inserted the following code:               function eik_custom_fields_search( $query ) {         if ( !is_admin() && $_GET['mkey'] ) {             $query->meta_query = true;             $query->set('meta_query', array(                array(                     'key' => $_GET['mkey'],                     'value' => $_GET['mval'],                     'compare' => '=',                 )             ));         };     }     add_filter( 'pre_get_posts', 'eik_custom_fields_search');      But it returns no results. Any ideas? The results of print_r($query):               WP_Query Object (         [query_vars] => Array (             [error] =>             [m] => 0             [p] => 0             [post_parent] =>             [subpost] =>             [subpost_id] =>             [attachment] =>             [attachment_id] => 0             [name] =>             [static] =>             [pagename] =>             [page_id] => 2             [second] =>             [minute] =>             [hour] =>             [day] => 0             [monthnum] => 0             [year] => 0             [w] => 0             [category_name] =>             [tag] =>             [cat] =>             [tag_id] =>             [author_name] =>             [feed] =>             [tb] =>             [paged] => 0             [comments_popup] =>             [meta_key] =>             [meta_value] =>             [preview] =>             [s] =>             [sentence] =>             [fields] =>             [menu_order] =>             [category__in] => Array ( )             [category__not_in] => Array ( )             [category__and] => Array ( )             [post__in] => Array ( )             [post__not_in] => Array ( )             [tag__in] => Array ( )             [tag__not_in] => Array ( )             [tag__and] => Array ( )             [tag_slug__in] => Array ( )             [tag_slug__and] => Array ( )             [meta_query] => Array (                 [0] => Array (                     [key] => wpcf-service-speed                     [value] => 2                     [compare] => =                 )             )         )         [tax_query] => WP_Tax_Query Object (             [queries] => Array ( )         [relation] => AND         )         [meta_query] => 1         [post_count] => 0         [current_post] => -1         [in_the_loop] =>         [comment_count] => 0         [current_comment] => -1         [found_posts] => 0         [max_num_pages] => 0         [max_num_comment_pages] => 0         [is_single] =>         [is_preview] =>         [is_page] => 1         [is_archive] =>         [is_date] =>         [is_year] =>         [is_month] =>         [is_day] =>         [is_time] =>         [is_author] =>         [is_category] =>         [is_tag] =>         [is_tax] =>         [is_search] =>         [is_feed] =>         [is_comment_feed] =>         [is_trackback] =>         [is_home] =>         [is_404] =>         [is_comments_popup] =>         [is_paged] =>         [is_admin] =>         [is_attachment] =>         [is_singular] => 1         [is_robots] =>         [is_posts_page] =>         [is_post_type_archive] =>         [query_vars_hash] => 4e01d4a2ac7ac063e19e57f91931e95c         [query_vars_changed] =>         [thumbnails_cached] =>         [query] => Array ( )     )


Multisite theme control not working

Enabling and disabling themes from the network admin has no effect on the sites. All the sites continue to display their own themes. Even network- disabling all the themes has no effect. Installing new themes has no effect on the sites. They don't recognize a new theme has been added. The only effect the network admin can acheive is to delete a theme. Then all the sites stop working. How do I fix this?


Should we use get_template_part() in functions files instead of include_once?

I'm using the theme-check plugin to check my theme for errors and recommendations, I'm using get_template_part() in theme files like header.php and index.php but in functions.php I'm using include_once() theme-check is not pointing at these, it's pointing at include_once used in a widgets.php file which is included in functions.php my question is should we use get_template_part() instead of all include_once() and include() or just use it for getting frequently used markup only ? I know it's only recommended to use get_template_part() but I like to follow best practices and recommendations. thanks in advance.


Issue with enabling formatting in excerpts in Wordpress

This is what I added in my theme's functions.php file to enable formatting for excerpts in Wordpress (source of the tip):               remove_filter('get_the_excerpt', 'wp_trim_excerpt');     add_filter('get_the_excerpt', 'bwp_trim_excerpt');          function bwp_trim_excerpt($text)     {         $raw_excerpt = $text;         if ( '' == $text ) {             $text = get_the_content('');             $text = strip_shortcodes( $text );             $text = apply_filters('the_content', $text);             $text = str_replace(']]>', ']]>', $text);             $text = strip_tags($text, '');             $excerpt_length = apply_filters('excerpt_length', 55);             $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');             $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);             if ( count($words) > $excerpt_length ) {                 array_pop($words);                 $text = implode(' ', $words);                 $text = $text . $excerpt_more;             } else {                 $text = implode(' ', $words);             }         }         return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);     }      The problem with enabling formatting in post excerpts seems to be that, if the text that is formatted by a tag (be it `<b>`, `<strong>`, `<i>`, `<em>`, or any other for that matter) is cut off by the excerpt in between, your whole page's formatting will be overridden by that tag. Take a look at this screenshot for instance: ![Screenshot](http://i.stack.imgur.com/i3lXL.png) I believe that’s the reason why formatting for excerpts isn’t enabled by default. Is there anyway to fix this? Is something wrong with the code? Hope I can get some help here. Thanks!


Insert post in another database

I have developed a custom script that uses `wp_insert_post` to create new posts, however i'd like to use similar code to create the same data in another wp database. Could be this done on the fly before insertion? For example instruct wordpress to point another database and then insert data? Or should I do this "manually" using raw mySQL code?


How to get all taxonomies of a post type?

**How can i get taxonomies of a post type?** If I have a post type `event` and i need to find out the list of taxonomies that are attached to that post type. How do I find them?


Exclude current page in wp_list_pages

I'm using `wp_list_pages()` to display a menu of child pages. The structure is nice and simple. Looks like this: http://cl.ly/image/0w1Q1q2D3D18 The menu works perfectly when on a child page: http://cl.ly/image/3O310E0s2B3d But, alas, does not work when on the parent page: http://cl.ly/image/3w0T3Q2s4347 Seems so simple, but i just can't get to the bottom of it. Here's my `wp_list_pages()` code:               <?php                      $topmost_parent = $post->post_parent;                      $args = array(                     'post_type'    => 'guides',                      'sort_column' => 'menu_order',                     'title_li'     => __(''),                     'echo' => 0,                      'exclude' => $topmost_parent                     );                      $children = wp_list_pages( $args );                      if ($children) :             ?>                      <nav id="menu-context">                     <ul class="menu">                         <?php echo $children; ?>                     </ul>                 </nav>                  <?php endif;?>      Using that `$topmost_parent` trick works until I'm on the parent page. Anyone got a new trick? =)


404 Error with Custom Post Types and Taxonomy

I am creating a website for a real-estate agent and have encountered an issue which I assume is Custom Taxonomy and Post Types. Custom Post Type: Property Taxonomy: District Example URL: www.mywebsite.com/listing/[district]/[title], www.mywebsite.com/listings/kandy/house1 Current Situation: It works, but when I go to www.mywebsite.com/listings I get a 404 error. I expect to show all 'Property' type posts here. I then made a custom page name (slug) 'listings' hoping to give it a template that is similar to the blog that users can brows up and down. But still it shows 404 error. (WordPress.org and StackExchange got me up to here, but I am kind of lost at the moment, which I thought of asking the question.) Code is a mess, but here is what I got so far:               add_action( 'init', 'create_post_type' );          function create_post_type() {              register_post_type('post_mozeej_property',              array (                 'labels' => array (                     'name' => __('Properties'),                     'singular_name' => __('Property'),                     'add_new' => __('Add New'),                     'add_new_item' => __('Create New Property'),                     'edit' => __('Edit'),                     'edit_item' => __('Edit Property'),                     'new_item' => __('New Property'),                     'view' => __('View Properties'),                     'view_item' => __('View Property'),                     'search_items' => __('Search Properties'),                     'not_found' => __('No properties found'),                     'not_found_in_trash' => __('No properties found in trash')                 ),                 'description' => __('Add new real-estate property from here!'),                 'public' => TRUE,                 'show_ui' => TRUE,                 'capability_type' => 'post',                 //'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'),                 'publicly_queryable' => TRUE,                 'exclude_from_search' => FALSE,                 //'menu_icon' => get_stylesheet_directory() . '/images/property_icon.png',                 '_builtin' => false,                 'rewrite' => array( 'slug' => 'listings/%tx_mozeej_district%', 'with_front' => true ),                 'query_var' => true             )         );                   $labels = array(             'name' => _x( 'CR Districts', 'taxonomy general name' ),             'singular_name' => _x( 'CR District', 'taxonomy singular name' ),             'search_items' =>  __( 'Search CR Districts' ),             'all_items' => __( 'All CR Districts' ),             'parent_item' => __( 'Parent CR Districts' ),             'parent_item_colon' => __( 'Parent CR Districts:' ),             'edit_item' => __( 'Edit CR District' ),              'update_item' => __( 'Update CR District' ),             'add_new_item' => __( 'Add New CR District' ),             'new_item_name' => __( 'New CR District Name' ),             'menu_name' => __( 'CR District' ),         );                  register_taxonomy('tx_mozeej_district', array('post_mozeej_property'), array(             'hierarchical' => TRUE,             'labels' => $labels,             'show_ui' => TRUE,             'query_var' => TRUE,             //'rewrite' => true,             'rewrite' => array( 'slug' => '', 'with_front' => TRUE ),         ));              function filter_post_type_link($link, $post) {             if ($post->post_type != 'post_mozeej_property')                 return $link;                  if ($cats = get_the_terms($post->ID, 'tx_mozeej_district'))                 $link = str_replace('%tx_mozeej_district%', array_pop($cats)->slug, $link);                  return $link;         }              add_filter('post_type_link', 'filter_post_type_link', 10, 2);          }      Have I done any thing wrong? Will be great if some one can help me. Thanks in advance!


Wordpress function bloginfo not echoing output on parts of the pages

I'm having a bit of a problem with the `bloginfo()` function in Wordpress which I've never had before. Normally I use `<?php bloginfo('template_directory'); ?>/rest of image link here` but for some reason now it doesn't work. When I view source, it's not echoing out the link like it's supposed to and it just comes out as `"src="/images/pic name here"`    I've tried using `get_bloginfo('stylesheet_directory');`, etc. I saw a post on SO that tried to somehow concatenate `get_bloginfo()` with the link like this:               <img src="'.get_bloginfo('stylesheet_directory').'/link here etc...      This didn't work either. I'm sure I can probably hard-code it but that kind of defeats the purpose. No matter how I do it, it does not display the image, just the `alt` attribute text. The weird thing is that I define my external assets the same way, like this for example:               <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/scripts_n_css/css/default.css" type="text/css" media="screen" />      Any ideas as to what's going on? Thanks in advanced. **EDIT**   If you take a look at this site I'm working on, http://www.islandlivingpatio.com/?page_id=48, the images don't load up. When I inspect with FireBug, it says "failed to load given url" but it works on my localhost. This is what the code to produce the site's image and the URL it goes to looks like:               <a href="<?php echo bloginfo('url');?>/?page_id=775"><img src="<?php bloginfo("template_directory");?>/images/Lynx.gif" alt="castandtubular"/>      When you click that image's alt attribute (it's the only thing showing up) then the next page also fails to load the images. Any ideas as to what's going on?


404 or ugly page on IE, but Firefox, Chrome looks perfect

I have a variation of this issue. Was happening before and after new theme. I was getting 404 in IE, now sometimes get partial page that looks horrible. Contents can vary when I refresh. I have no idea why it's giving a 404 status. Is that the way WordPress handles domain/com/blogs? I have a page called Blogs, and my "Reading Settings" for "Posts Page:" is set to "Blogs". I use a plugin called "WP Code Highlight" but have tried deactivating it and other suspect plugins. Below are my Request/Response Headers:               Remote Address:97.79.239.229:80     Request URL:http://biztalk-training.com/blogs/     Request Method:GET     Status Code:404 Not Found     Request Headersview parsed     GET /blogs/ HTTP/1.1     Host: biztalk-training.com     Connection: keep-alive     Cache-Control: max-age=0     Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8     User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.132 Safari/537.36 OPR/21.0.1432.57 (Edition Campaign 48)     Accept-Encoding: gzip,deflate,lzma,sdch     Accept-Language: en-US,en;q=0.8     Cookie: __utma=194928574.1923935199.1399605602.1399605602.1399605602.1; __utmb=194928574.3.10.1399605602; __utmc=194928574; __utmz=194928574.1399605602.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)     Response Headersview source     Connection:close     Content-Type:text/html; charset=UTF-8     Date:Fri, 09 May 2014 03:22:26 GMT     Server:Apache     Transfer-Encoding:chunked     X-Pingback:http://biztalk-training.com/xmlrpc.php      I get similar results when I go to most any specific blog My .htaccess file contains just this one line: > ErrorDocument 404 / I tried removing it, then got some default page provided by my ISP.


How to call the_author_meta and make it work?

I am developing an author badge for my Wordpress site and I am learning how to call meta functions (needs to be within The Loop). The meta functions that I am calling are author bio related, like username, last name etc Here is a code example:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>              About <?php the_author(); ?>, the author of this blog         <?php userphoto_the_author_thumbnail() ?>         <?php get_the_author_meta( 'description' ); ?>          <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>      I added this example to my author.php file and it worked, however it displayed the same thing multiple times (hence the loop). How do I actually do this if I want to call meta functions in Wordpress and not have them echoed multiple times like this? I am certain that I am doing this incorrectly and there is a correct way of achieving it. If you choose to reply, please be detailed as my knowledge of PHP coding is to the extend that I learned what echo is _today_.


Incorrect redirection after commenting on custom type

I use custom post type, and when users make a comment on page   `www.mysite.com/custom-type/2013/01/20/post-name/`   they are redirected to   `www.mysite.com/2013/01/20/post-name/#comment-2231` [e.g. without `/custom- type/`]. So they get `404`.   In all other pages and posts (that is not custom type), the redirecting after commenting works well.   What is the problem?


WordPres multisite subdomain problems

Is anyone familiar with setting up a WordPress multi site network? I am attempting to do so on a Windows 2008 server with Plesk (and IIS). I followed the instructions from WP and everything is working ok on the main site. WP also allows me to create the subdomain sites. However, the subdomains are simply redirecting the the Plesk default page. I setup a subdomain wildcard CNAME in the DNS for the domain, but beyond that I am not sure why the subdomains are not working. Any suggestions?


Fixed layout for admin section

I would like to customize the layout of the admin section of WordPress. The thing is, whatever the layout I create, I'm very dependent of the default "fluid" layout of the admin. By fluid, I mean: when I resize the browser window, things tend to reorganize themselves in the admin section (in order to optimize space) and while it's a nice feature with the default look and feel of the admin section, it's a real pain in the neck when you try to create your own custom layout. Can someone tell me which css attributes of the admin need to be changed and what attributes parameters would disable that overall fluid behavior?


How can you preserve URLs when moving posts to a custom post type?

I am working on a site where they want to break up the content into custom post types (right now everything is broken up by post categories) but they want to be able to save their URLs to preserve inbound links and Facebook Likes. They currently have a date-based URL structure (`example.com/2013/01/11/the-post-name`) and they want to keep that but still use custom post types. I've seen plugins that will allow me to easily append the date before the post title in the URL, but nothing that removes the slug from the first URI segment. I tried to add a rewrite rule to remove the slug (`rewrite => array( 'slug' => '' )`) but that resulted in 404s. What's the best way to go about this? I know it's bad practice to remove the slug, but the client is pretty adamant about it.


Query all posts where a meta key does not exist

I am trying to get a query to retrieve all the posts where a specific `meta_key` does not exist and then create it. I am having problems finding those posts as the query I am testing does not seem to work. Here is the code I am using to try to get those posts:               $args = array(        'posts_per_page' => 18,        'cat'=>1955,        'post_status'=>'publish',        'meta_query' => array(                       array(                          'key' => 'colors',                          'compare' => 'NOT EXISTS'                       ),        ));                query_posts($args);      This returns nothing if there are no posts with the key `colors`, but returns they `ids` of the posts with the key `colors` whenever that key is present (the opposite of what I need). I tried with `EXIST` instead but no luck. If someone can tip me on the correct way of creating a query like the one I need I will appreciate it. Thanks!


Import rss-feed from subdomain to my tld and include it into the loop

Friends, community, i have a website with WP 3.X (MU) (www.paratodo.de) with several subdomains (for example imkerei.paratodo.de) and i want to import the articles. But i don't really want to import the hole content. I will explain that: I write articels on paratodo.de (my mainpage) and on imkerei.paratodo.de. When i publish an article on a subdomain, i want that this article is shown in the normal loop of the mainpage - but when i click on the article i want to have a redirect to the real place of the article (imkeri.paratodo.de/article/). Do you have an idea, a suggestion or a resolution for me? Thanks a lot and greetings from Paraguay!


Blocking adsense ad units for a particular country

So I have got one hater in India who bombarded on my adsense ad units. Luckily I didn't get banned from Google. I have blocked Indian visitors from my site using iq-blockcountry plugin (wordpress). Now I want to know if there's any procedure so that I can allow the Indian visitors but hide the adsense units from them? I don't want to block all visitors just because of one foolish person.


Widget page broken

**using WordPress 3.3.1** Im working on a wordpress site i did not build and i have registered a widget area. There was none before. Now when i go to the widget page it looks like this and i suspect there is something wrong with the WP installation? The functionality on the widget page does not work properly. For example the content of the widgets in a sidebar are displayed until you minimize the widget. After there is no way to open it again and you have to reload the page to see the content again. The content displays correctly on the front end though. Problem is still there after having deactivated all plugins. ![enter image description here](http://i.stack.imgur.com/NgvsP.jpg)


How to make method from plugin available in theme?

Let's say this was in my plugin:               class pluginslug_foo {         public function bar() {              //stuff         }     }      and I wanted to make the method bar available for use outside of the plugin, for instance in a theme file so it could be called with `pluginslug_bar();`. I tried:               function pluginslug_get_foo() {           $foo = new pluginslug_foo();           return $foo;     }     function pluginslug_bar() {           $bar = $foo->bar;     }      But I got an unknown variable error for $bar when I tried `pluginslug_bar();` in my theme:(


Get the product list of a given Category ID

I couldn't find the right way to get the list of all products for a given category ID (not category name). The code I am using to get the categories list is the following, it works fine:               $args = array(                'orderby'    => $orderby,                'order'      => $order,                'hide_empty' => 0,                'include'    => $ids,                'parent'    => 0,          );           $categories = get_terms( 'product_cat', $args );      However, now for a given category ID (say 47), I couldn't find the way to get its relevant products. I tried the following way:               $args = array(          'posts_per_page' => 5,         'offset'=> 1,         'category' => 47      );          $products = get_posts( $args );     echo var_dump($products);      Debugging the `$products` array returns always 0 which is wrong since I know there is some products under the category with ID 47. Any ideas how to fix my code?


java script error Uncaught SyntaxError: Unexpected token ILLEGAL

i had a website that was working fine on localhost without any errors but after i uploaded it on the domain the slider stoped working and i got this errors                Uncaught SyntaxError: Unexpected token ILLEGAL /js/jquery-ui.min.js:5        Uncaught TypeError: undefined is not a function custom.js:33        (anonymous function) custom.js:33 c jquery-latest.min.js:1069        p.fireWith jquery-latest.min.js:1113 x.extend.ready        jquery-latest.min.js:129 q jquery-latest.min.js:38      when i removed the custom.js page the error are removed but i need it so i could make the slider work but i i found that the (anonymous function) can be solved by adding ; after the function but i still give me the same error


Add video url directly into media library

Is there a way to add a video via URL directly into the Media Gallery? The only way I know how, is to do it via Post/Page 'add Media' button. Thanks


Importing posts via MySql (a csv file) need to be automatically published

I'm importing a csv file via the database, all the posts are unpublished when I look in the CMS, is there a way to make them automatically published on import? Doing a bulk publish via the CMS doesn't work as I need the dates I've put in the CSV file to be the publish date, not the date publish was clicked. In the post_status column, all the posts are set to publish. I'm trying to import hundreds of posts of news and the dates need to be in the past. Here's my csv file:               ID  post_author post_date   post_date_gmt   post_content    post_title  post_excerpt    post_status comment_status  ping_status post_password   post_name   to_ping pinged  post_modified   post_modified_gmt   post_content_filtered   post_parent guid    menu_order  post_type   post_mime_type  comment_count     6000    1   13/09/2010 00:00    13/09/2010 00:00    "Content here"  New Report Available - Taking Medical Sensing Technologies to Market        publish open    open        new-report-available-taking-medical-sensing-technologies-to-market          13/09/2010 00:00    13/09/2010 00:00        0   http://www.mediwales.com/v3/?post_type=news&p=6000 0   news        0      ![enter image description here](http://i.stack.imgur.com/lYs7s.png)


Float images in content

This is not a programming question. I have the problem to update the content in my WordPress blog. I'm very aware this problem can be solved by html modification. But my client doesn't know about html.So i need to give him relevant solution. My Problem :- I want to show my content as below screen. ![enter image description here](http://i.stack.imgur.com/yxc0F.png) But While i insert a post image content starts at the bottom of the image. This can be solved by html.But i need to know any other easy solution. ![enter image description here](http://i.stack.imgur.com/a3fCn.png) Thanks.


Get the most commented posts for the last x days

I want to get the most commented posts for the last x days,I have the following code:               <?php       global $wpdb;       $weekstart = date('Y-m-d', strtotime('-12 days'));       $query = $wpdb->prepare("       SELECT comment_post_id, count( comment_post_id ) AS c, SUBSTRING( comment_date,1,    5     ) AS d      FROM        $wpdb->comments      WHERE       (comment_date >= %s)      GROUP BY comment_post_id      ORDER BY c DESC, d DESC ",$weekstart);           $col_ids = $wpdb->get_col($query);      if ($col_ids) {      $postids = implode($col_ids,', ');      echo $postids;          function filter_orderby($orderby = '') {     global $postids;     $orderby = " FIELD(ID,$postids )";     echo $orderby;     return $orderby;     }          add_filter('posts_orderby', 'filter_orderby');       ?>      I want to filter the posts by id,the problem is that echoing $orderby (for testing) would return this: FIELD(ID, )   and not the actual order, the FIELD is not recognized and $postids is empty. What am i missing here ? How can I get this to work properly ? Thank you.


Whats worth using add_action when we can simply use add_filter?

I've just looked into wordpress code and found this definition of add_action:               function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {         return add_filter($tag, $function_to_add, $priority, $accepted_args);     }      Now why are we wasting one CPU cycle for just calling another function that we can simply do ourselves and then we won't have to remember two different function names for the same thing.


Why id in urls doesn't work and slug yes?

I'm lost, I don't understand why this works               http://website.com/?tag=my-cat-slug      and not this               http://website.com/?tag=15      It's really annoying because `wp_dropdown_categories()` only provides ids as values. I tried to change permalinks to default settings instead of rewriting:               http://website.com/?p=123      But it changed nothing


Displaying the type of post (Custom) in a single.php

How can I display the type of custom post type in a template? So: `<h3> [CUSTOM POST TYPE] </h3>`?


Pull Instagram images into an existing loop?

I am looking for a solution to pull Instagram images (from a single account) into a Wordpress loop and mix them chronologically with standard posts that will have been created within the Wordpress admin. So the archive page would be a mix of news items (full posts) and Instagram images, all in the same feed, appearing chronologically from whenever they were posted. Is that possible (with or without a plugin)? Thanks in advance for your response!


Dynamically generate meta tags and titles for a wordpress page

I have created a wordpress page that will output product details of a specific product from amazon: `wordpress/product?asin=123` I'm just using the product page as a template and it really contains nothing. I'm just adding a filter to the content to put some contents into it. I'm also using the wordpress seo plugin from yoast to take care of SEO stuff but it seems to be getting in the way. I currently have this code:               function ecom_title_filter($title){              if(is_singular()){             if(!empty($_GET['asin'])){                 if($title == 'Product Details Page'){                     $asin = $_GET['asin'];                     $titles = get_titles($asin);                     if(count($titles) == 1){                         $title = $titles[0];                     }else{                         $index = 1;                         $title = '';                         $title_count = count($titles);                         foreach($titles as $item_title){                                  if($title_count > $index){                                 $title .= $item_title . ', ';                             }else{                                 $title .= $item_title;                             }                                  $index++;                         }                     }                      }                  }              }              return $title;     }      Then I'm adding it into the `the_title` and `wp_title`:               add_filter('the_title', 'ecom_title_filter');     add_filter('wp_title', 'ecom_title_filter');      The problem is that the page still retains the old page title which is `Product Details Page` and not the title that I'm returning from the method above. The method returns what I expect it to return so the problem is not the method. Any ideas?


Pass $page_id to new WP_Query

Probably pretty simple and more PHP-related than pure WP, but how would one pass the `$page_id` generated in the first code snip into the `new WP_Query ()` in the second code snip? What I need to do - in a page template - is **dynamically** get the current page ID and pass that to the new WP_Query in order to display content for that current page. This is for a page template that will display different content according to the page_id, somewhat opposite of what a page template usually does with the loop. I don't need pagination or anything else; the new queries will display small amounts of content in a jQuery UI tab structure. **Global wp_query to get current page ID (and echo it for testing purposes):**               <?php global     $wp_query;     $page_id = $wp_query->get_queried_object_id();     echo $page_id; ?>      **Standard new WP_Query for the content:**               <?php $my_query = new WP_Query( **need $page_ID here** ); ?>     <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>     <?php the_content(); ?>     <?php endwhile; ?>


One button to change all settings in theme customizer?

I have been attempting to create a theme reset button for the theme customizer that automatically removes all of the theme_mod settings. I have tried multiple ways to do this and have never been able to get it to work.  As seen here. After multiple failed attempts using the remove_theme_mods approach I begin to wonder if that is my problem other than the ajax and javascript being faulty and not properly binding the button. Since I save all defaults into one big array so when my theme is installed it automatically has values populated on the theme customizer page, and the theme has a specific look... I was thinking I could try a different approach to instead remove the theme settings I just over ride them, maybe with a custom control? Possibly by somehow assigning these default values to all settings? I really hope someone can help me get this going. If you have any ideas I would appreciate it very very much. Here is an example of how I assign the default values for the theme:               function newtheme_get_theme_mods() {          $defaults = array(                  'newtheme_responsive'                 => true,                  'newtheme_hero_title'                 => 'Beautiful and Elegant',                  'newtheme_hero_description'           => 'The best theme in the world',                          'newtheme_header_logo'                => '/wp-content/themes/newtheme/img/logo.png',                          'newtheme_header_background_color'    => 'rgba(35,35,35, 0.9)'                   return $defaults;          }


Suggestions for i18n plugin

Could you please suggest me good plugins (that you have used) for translating a WordPress website? It should be wonderful if you can add as well a pros and cons list with your suggestion. Thanks in advance!


Return Page/Post ID's of Child WP_Nav_Menu items

Is it possible to return the Page ID of menu items? I specifically looking to get the IDs that appear in a rollover submenu.


Custom generated WordPress menu using get_pages renders the proper HTML but doesn't display all elements

I have created a menu with the hopes of listing all of the child and grandchild pages of a page (see link below) it works great except that it is cutting off the menu at about 15 children pages, most of the grandchild pages show up until the last few. The html all looks right. any ideas? http://www.simplycast.com/marketing-automation/


Multisite missing tmp folder error while uploading

I have a multisite setup on a server that requires me to upload to a stage server then send a "publishnow.txt" file over to send everything to the production server. This is a state agency hence the extra steps in getting core file changes made and live on the web. This is very new to me having always worked with hosts like Godaddy. I am having the hardest time configuring my tmp folder in order to upload any media to either of my 2 sites. I am getting the usual error of > “image.jpg” has failed to upload due to an error. Missing a temporary > folder. when I try to upload anything. My host has a public_html folder and a tmp folder in the root. I would love to tell Wordpress to use the tmp folder from the root, but I don't know if I need to write that in the wp-config.php file, the .htaccess file (which I cannot edit as the host says they do not parse that file) or something in the network settings within WP. I am lost and losing time and patience is dwindling with my client. Perhaps someone with a clearer head could imaging the situation and advise me what I should try. Thank you!


Admin user can't update WP

I have a site running WP 3.3.2. The backend shows a bar saying "WordPress 3.5 is available! Please notify the site administrator." Funny thing is that I'm logged in with an admin user, I double checked that. When trying to access the update page (at wp-admin/update-core.php) I get this error: "You do not have sufficient permissions to access this page." Any hints on what could be going on here? Thanks.


Understanding WordPress' post type support

I was hoping if someone could help me better understand WordPress' post type support.               remove_post_type_support( 'post', 'author' );      Above in example doesn't seem to actually remove the support, just hide things like (post) meta boxes and (edit) columns more globally compared to this example:               remove_meta_box( 'authordiv', 'post', 'normal' );     // unset( $columns['author'] );      Guessing because of this some modifications will be made to `add_post_type_support` sooner or later. For future compatibility, which out of the above would you suggest for simply hiding things? (removing the `author` post type support could really mess up your site if `remove_post_type_support` would _actually_ drop the support)


Trouble with parent and child conditional tag to show content

I am trying to conditionally change a link based on what page a user is on, but I am having trouble finding the correct code to perform the action. Here is what I want to do (In English to explain the code) If a user is not logged-in and on a page that is either keyword or a child of keyword (for example, domain.net/keyword/pricing or domain.net/keyword/about or simply domain.net/keyword) _Then Show X_ If user is not logged in and on any other page besides those mentioned above _Then Show Y_ If user is logged in _Then Don't do anything_ I've tried multiple conditionals and read the wordpress codex, but can't figure this one out. I am novice php user, so I wouldn't be surprised if the answer was quite simple. I appreciate the help in advance!


How do you create a re-useable HTML fragment in wordpress

Let's say you want all pages to have a common footer, and have that footer editable in WordPress; how would you accomplish this? My current solution is to create a page "footer" and include it using custom template function. But I am wondering if there is a better way to do it, without requiring custom coding. As an example, in the footer of this page you have the text statement > "WordPress is a trademark of the WordPress Foundation, registered in the US > and other countries. This site is not affiliated with the WordPress > Foundation in any way." How do you make them editable by normal wordpress user?


Can you echo PHP code from a variable?

Ok this is a stupid question, and I'm not sure I even asked it right, but this is what I'm trying to do. My wordpress theme supports ad placements and I want to use a advertising manager plugin. I know I can just go through the theme and replace the ad code that's currently there with code from the plugin. However, the theme does some other stuff with ad placement in between posts etc (that I'm not really sure whats involved to preserve). So I'm hoping there is an easier solution. If I put the php code from the plugin into the ad placement boxes from the theme, all it does is this in the source of the page (basically comments it out).               <!--?php if( function_exists( 'pro_ad_display_adzone' ) ) echo pro_ad_display_adzone( 1 ); ?-->      This is the code from the theme template file that displays the ad                <?php echo $con_single_ad_post; // ad ?>      Any ideas how I could get this to work?


How to migrate wordpress users from one blog to another

I have a client that has a single install outside of her network installation. I need to migrate the users with their passwords into the network installation. I've tried backupbuddy but it seems to skip the users. Any idea how I could pull this off manually?


Difference between $numpages & $max_page on archive pages

After taking a look at `global $max_page;` and `global $numpages;` on category-archive pages (`is_archive() || $GLOBALS['wp_query']->is_archive` returning `true`), I see the following return values:   * `$numpages`: 4   * `$max_page`: 7 What's going on here? Further Qs:   1. Where do they come from? After looking into /wp-includes/query.php I found `$numpages` in `setup_postdata()`, but beeing called as `global` on top and later counts the pages by the array that get's exploded through the `<!-- nextpage -->`-array.   2. `$multipage` get's set to `0` if the `$post->post_content` is already an array. Why is this in this case set to `0`, as the array indicates that it should be multipaged? Plus: Where could the array come from? post_content saves as string...   3. Why do I have `$numpages` on archive templates/pages as it is only meant to be set for paged content types?


Custom Taxonomy as checkbox or dropdown

I have registered a custom tax to my CPT. On the edit screen the tax meta box appears with an autocomplete field. Is it possible to display it as checkboxes or dropdown instead?


Post update RSS notification plugin

Whenever I update an older blog post with new information then it is visible to all readers that visit the site itself. Readers of the RSS feed don't get the update and miss the new information. I'm searching for a plugin which issues back the post to the RSS-feed as if it was a new post (with an `[Update]` put after the post title). However it should not be a new RSS post whenever I just did a minor change (like correcting spelling). It would be ideal if it asks me whether this was a minor change whenever I edit a post.


Adding "Interesting Tags" & "Ignored Tags" like StackOverflow.com in a WordPress Blog?

How to give "Interesting Tags" "Ignored Tags" selection option like stackoverflow.com in a WordPress blog? If a blog is about lots of topics and I want to give option to user to choose option like "Interesting Tags" and "Ignored Tags" option of stackoverflow.com. How to give that facility? Is there any plugin?


Plugin for Sending Email to Readers about New Posts? (besides "Subscribe2 ")

I wish to have a "subscribe to new posts" widget for my blog. I know I can use feedburner system, but I want a plugin based solution. The best I could find was Subscribe2, the downside of it is that you can't have it send full HTML e-mails for subscribers who are not registered users. Is there any alternative plugin, or solution that can do this (maybe a work around based on the GPL subscribe2 plugin?) p.s: the solution need to work with WP 3. So the plugin Subscribe2 for Social Privacy, that is supporting up to WP 2.6, is not a good answer.


Limit the Excerpt field in WP-Admin in words

Is it possible to limit the Excerpt field on the post page in words? Note that I am aware that it's possible to echo the excerpt and limit it in words, but I want the field itself to limit the amount of words, similar to how character limits on text-areas work. **Is such thing possible**? Maybe a Javascript solution? Maybe something similar to what this plugin does to the character bio field (although its limitation is based on amount of characters). The reason of this is that I run a multiple author platform where users often make the mistake to exceed the word limit that is being printed in the list of posts.


Basics of changing plugin output

There's a Mailchimp plugin I would like to alter it's output in order to match my needs. For example:   1. Order in which fields are loaded are not correct    2. Positioning of the plugin's response messages is not correct. I have already tried modifying everything using only CSS but I really need to modify the HTML of this plugin. Is there a way to do this without hacking the plugin itself? Thanks a lot!


Automatically enable custom theme, plugins and default content on installation?

I'm using wordpress for a large non-profit with many sites. I'd like to decrease the amount of installation steps for the people setting up their sites. Is it possible to make a WP install that automatically activates the plugins, themes and default content I choose?


Thumbnail informations (meta)

Does anyone know how can I display in the loop thumbnail's name, alternative text, title, caption, url? Thx for all advices and suggestions


Display category-specific comments in sidebar

I'm trying to display comments in the sidebar from only the current category. So far I've got this:               <?php         // Posts per page setting         $ppp = 8; //get_option('posts_per_page'); // either use the WordPress global Posts per page setting or set a custom one like $ppp = 10;         $custom_offset = 0; // If you are dealing with your custom pagination, then you can calculate the value of this offset using a formula              // category (can be a parent category)         $cat = get_query_var('cat');         $category_parent = $cat;              // lets fetch sub categories of this category and build an array         $categories = get_terms( 'category', array( 'child_of' => $category_parent, 'hide_empty' => false ) );         $category_list =  array( $category_parent );              foreach( $categories as $term ) {             $category_list[] = (int) $term->term_id;         }              // fetch posts in all those categories         $posts = get_objects_in_term( $category_list, 'category' );              $sql = "SELECT comment_ID, comment_date, comment_content, comment_post_ID, user_id, comment_author          FROM {$wpdb->comments} WHERE          comment_post_ID in (".implode(',', $posts).") AND comment_approved = 1          ORDER by comment_date DESC LIMIT $ppp OFFSET $custom_offset";              $comments_list = $wpdb->get_results( $sql );              if ( count( $comments_list ) > 0 ) {                  $date_format = get_option( 'date_format' );                  foreach ( $comments_list as $comment ) {     ?>
                     <a href="<?php echo ( get_permalink( $comment->comment_post_ID ) ); ?>#comment-<?php echo($comment->comment_ID); ?>"><?php echo get_avatar( $comment->user_id, 50 ); ?>                     <?php echo($comment->comment_author); ?> commented on
<a href="<?php echo ( get_permalink( $comment->comment_post_ID ) ); ?>"><?php echo get_the_title ( $comment->comment_post_ID ); ?>
                     <?php echo($comment->comment_date); ?>
"<?php comment_excerpt(); ?>" <a href="<?php echo ( get_permalink( $comment->comment_post_ID ) ); ?>#comment-<?php echo($comment->comment_ID); ?>">Read More

          <?php             }              } else {             echo '
No comments
';         }     ?>      This either displays 0 comments or all comments everywhere, so it doesn't work. I don't understand what I did wrong...


What program can I use to preview my wordpress site?

Apologies if this is the wrong site to be asking this, but I just downloaded a template for a website that I want to customise. On my Mac I have a program called Espresso which allows me to 'preview' any website that contains any mix of client-side and server-side files. Is there an equivalent on the PC? I essentially just want to preview my website offline.


Getting Error 301 Redirect error

I am getting following warning when I do Wordpress SEO by Yoast: "The keyword / phrase does not appear in the URL for this page. If you decide to rename the URL be sure to check the old URL 301 redirects to the new one!" This error comes for my home page. Can you please let me know what is the problem?


Two Domain pointing to the same Wordpress installation

Hi I've got an issue with domain pointing. I am using MultiDomain plugin to point two domains to the same Wordpress installation. The website is working properly on the first domain but on the second domain there is no menu and following error: > Warning: join(): Invalid arguments passed in > /homepages/40/d444244322/htdocs/wp-includes/post-template.php on line 389 > class=""> Could anyone please help me solve this issue?


How to edit php files in Child Theme?

I created a child theme and i want to edit a php file. So i copy and paste the php file into the child's theme folder and then i edit it. But it seems that nothing changed in the site preview! In the theme's folder there is a subfolder named "templates". There it is the "slider.php". Before creating the child theme, i tried to edit the parent theme and i made the same changes i made in the cherry and it was correct. I want to make some little changes in some php files but i can't! I think i find the start of my problem but i really can't understand it. In the WordPress documentation in the Child Theme section, in the "Other Files" paragraph it says: "if this file (slider.php) is not included by any of your template files or functions.php file then you can not override this file by your child theme." I first try creating the "functions.php" and then inserting this code:               <?php require_once( get_stylesheet_directory(). 'templates/slider.php' ); ?>      But after uploading the "functions.php" in the child theme an error occured. I am really confused about this! What is the way to edit a php file in a child theme?


gform_pre_render Dropdown populated with roles

I'm using gravity forms and trying to prepopulate a dropdown with a list of roles. This is what I have, but it's coming up with an error:               add_filter("gform_pre_render", "gform_prepopluate_populate_role");          //Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displayed when editing the entry.     add_filter("gform_admin_pre_render", "gform_prepopluate_populate_role");          function gform_prepopluate_populate_role($form){         global $wp_roles;         $posttype = 'em_companies';         $formid = '5';         $fieldid = '8';              //only populating drop down for form id 5         if($form["id"] != $formid)            return $form;              //Reading posts for "Business" category;         //$posts = query_posts(array('post_type' => array('post', 'movies')));        $roles = query_posts( array( $wp_roles->get_names() ) );        // if ( have_posts() ) : while ( have_posts() ) : the_post();              //Creating drop down item array.         $items = array();              //Adding initial blank value.         $items[] = array("text" => "", "value" => "");              //Adding post titles to the items array         foreach($roles as $role)             $items[] = array("value" => $role, "text" => $role );              //Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.         foreach($form["fields"] as &$field)             if($field["id"] == $fieldid ){                             $field["choices"] = $items;             }              return $form;     }      any ideas?