How to implement default comment section in theme template?

My home.php is associated with my blog page, as opposed to rest of site which is just a cms. I want my blog page to render the comments ability, an archive of older posts, tags, blogroll, etc. Right now, this is what I have in my home.php:               <?php     /*     Template Name: Home     */     ?>     <?php get_header(); ?>     <?php         $blog_query = new WP_Query;         $blog_query->query( 'post_type=post' );     ?>
          <?php echo "Blog updated daily" ?>          <?php if( $blog_query->have_posts() ) : ?>              <?php while( $blog_query->have_posts() ) : $blog_query->the_post(); ?>
             <h2 id="post-<?php the_ID(); ?>"><?php the_title();?>
             <?php the_content(); ?>
              <?php endwhile; ?>          <?php endif; ?>          <?php wp_reset_query(); ?>
     <?php get_footer(); ?>      Problem is obviously, this just rendering the posts, but not the comment section or anything else. How can I inherit the wordpress defaults so that it will display the comment section and so forth? Right now If i was to remove that code above, the page would be blank.


Changing wp-content to other name? Multisite set up

Is there an easy way to change the words `wp-content` that show in the source code to `xyz-content` without breaking my site?   I want to do it for branding purposes. I tried:   1. Url rewriting but the original `wp-content` still shows in the source code.   2. Doing a site download, find and replace and then re-upload but it takes over 24 hours with my server.    3. The plugin Real-Time Find and Replace changes the words from `wp-content` to `xyz-content` quickly, but the css etc does not load.  Is there another way to do this?


Redirect home resets (qtranslate) language

I'm developing a website for a product (audio speaker) I'm launching and I'm experiencing an issue I can't resolve (on my own ;) ). I've added this code to `functions.php` to disable dashboard access for subscribers.               add_action('admin_init', 'no_mo_dashboard');     function no_mo_dashboard() {         if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {             wp_redirect(home_url()); exit;         }     }           It works like a charm except for the fact that it resets language. i.e.: a user is logging in from page `www.example.com/en/new-user` the code above redirects him to `www.example.com` instead of `www.example.com/en`. Is there a way to implement this?


is_home doesn't affect content

I have a bunch of html i need to show only if it is a homepage. My theme pulls content from AJAX and then changes the URL to reflect the new content change. in the meantime, the homepage content (the entirety of which is contained in the footer) still remains below, what i need to happen is the footer content should still be there but the content under   `<?php if ( is_home() ) { ?>` disappears. there is a close button included on each page, when it's clicked the AJAX content is removed and the page returns to the homepage, i need the is_home content to come back at this point. What happens right now is that the content does not go away when the url chnages, and when the ajax content is removed and the page scrolls back to the homepage area and the url goes back to home, i simply get the background no content. My entire footer file can be found here: http://pastebin.com/Xpjc0vrG (the issue begins at line 46. ). The actual site is HERE: http://onthemouse.com/. the content i need gone when not in home is the grey stuff under the carousel you can see the custom.js file here http://pastebin.com/i4cQRS27, this file handles all the ajax requests, but i'm not sure which part actually pulls the page content. i added code on limnes 261 and 594 to try and make this work, hasnt so far. I think the url chnage and ajax content starts at LINE 236.


Remove link on full-size images

Is there a way to remove the link on full size images in posts/pages? I still would like to have it for the other smaller sizes. Since the full size image is already full size, it seems unnecessary to link to itself.


How can I implement a location based (zip code) search in WordPress?

I am working on a local business directory site that will use custom post types for the business entries. One of the fields will be "Zip Code." How can I set up a location based search? I'd like visitors to be able to enter their zip code and choose a category and show all the businesses withing a certain radius, or all the businesses ordered by distance. I saw a couple plugins that claim to do this but they don't support wordpress 3.0. Any suggestions?


Why doesn't a custom post type permalink ever hit index.php

So, I've got an entirely custom theme which has a number of custom post-types. I've also got a custom taxonomy which I can visit on the front end with URLs such as:               www.mysite.local/custom-tax/custom-term      Which runs a query giving me results of posts that match the term 'custom- term' in the tax 'custom-tax'. Also paginates, etc. When it comes to the custom post type pages, e.g. I've got a CPT of 'submissions' with the permalink slug set to 'your-reviews', the backend suggests the permalink will be:               www.mysite.local/your-reviews/my-new-awesome-post/      Which 404's. I've checked out the WP template hierarchy and everything falls back to index.php which routes to the various custom templates that need to be used depending on the part of the site the user is visiting etc. So if I change the first line in **index.php** to a               die or               wp_die I'd expect no matter which page I visit, I'd always get the message in the die statement even for the 404'ing custom post type page. It's worth noting that I get a 404 whether I visit the 'archive' page at:               www.mysite.local/your-reviews/      Or the individual page (some of which are 'hierarchical' and produce a permalink such as (the non-hierarchical pages also 404).               www.mysite.local/your-reviews/my-parent/my-new-awesome-post/      **Updated** So, the code that generates this specific CPT (alongside a few others) is:               define( 'LL_POSTTYPE_ONELINER', 'll_submissions' );          $args = array(         'label' => __('Submissions'),         'labels' => $labels,         'public' => true,         'can_export' => true,         'show_ui' => true,         '_builtin' => false,         '_edit_link' => 'post.php?post=%d', // ?         'capability_type' => 'post',         'menu_icon' => get_bloginfo('template_url').'/images/thumb_up.png',         'hierarchical' => true,         'rewrite' => array( "slug" => "submissions" ),         'supports'=> array('title', 'thumbnail','page-attributes' ) ,         'show_in_nav_menus' => true,         'query_var' => true,         'taxonomies' => array()          );          register_post_type( LL_POSTTYPE_ONELINER, $args);      Note, whilst this one's marked as 'hierarchical' => 'true', others that aren't hierarchical also 404 in the same way. And to follow up, from the reply I've had so far, out of the template hierarchy (single.php, etc...) I only have `index.php` which it never hits.


Does wordpress insert automatic google analytic?

I just noticed there was this script in my source code:               <script src='/google_analytics_auto.js'></script>      I did not insert this script and I have no plugins, so I don't know why it's there? Does someone know how to remove that?


Get the latest tags in a cloud?

Is there something that allows us to get a list of the latest tags used in post. I want to get the 10 latest tags and align them side by side How Can I make this happen?


Remove Parents From Permalink of Hierarchical Taxonomy

I have a custom hierarchical taxonomy called "places" set up with categories like so: Services > Financial Services > Financial Advisors. The permalink for this category listing page is currently mysite.com/places/services/financial-services/financial-advisors. Does anyone know how I can remove the parents from my permalinks so it would simply become mysite.com/places/financial-advisors/ ? I've searched quite a lot and cannot find an answer. There's a plugin out there called "no category parents" that achieves this for regular blog posts, but it doesn't work for custom taxonomies. Any help would be much appreciated!


How to add a custom URL placeholder to author archives?

I am working with a client who has a directory site that allows users to create accounts, then lists of items from the directory. Right now, whenever a user creates an account, she gets a profile URL like:               domain.com/member/%author%      Which is accomplished with a simple:               $wp_rewrite->author_base = 'member';      Now, I need to allow those users the ability to create a list, which should result in this kind of a URL structure:               domain.com/member/%author%/%list%      So far, I'm creating these lists as custom post types. All of the articles and Stack Exchange posts I see on WP_Rewrite don't cover a URL rewrite like this. Is this possible? Do you have any pointers on how this could be done?


Using strpos with WordPress

I have a navigation bar that uses strpos to highlight the tab of the current page the user is on. This method works fine as:               <a <?php if (strpos($_SERVER['PHP_SELF'], 'current-journal')) echo 'class="current-st"';?> href="current-journal">
3Elements
      The problem arises when I try to use this method with a few WordPress pages that I have incorporated into my static website. For some reason, trying to find the occurence (the page the user is on) does not work with the WordPress pages. Any insight would be great


hook into completed image upload filter

I'm trying to run a little function to determine the luminance of an image and store that in the postmeta for that image.. I have the function working, but id like it to fire when an image has finished uploading.. does anyone know the function/filter/action i should hook into for this? ive looked at   * image_attachment_fields_to_save   * attachment_fields_to_save   * wp_handle_upload   * media_upload_form_handler   * wp_generate_attachment_metadata and i just cant seem to make any of them simply run an addition to the postmeta table for the image currently my code looks something like:               function insert_luminance_data($post, $attachment) {         if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {             $lum = 'TEST';             add_post_meta( $post['ID'], 'image_lum', $lum, true ) || update_post_meta( $post['ID'], 'image_lum', $lum );         }         return $post;     }          add_filter('image_attachment_fields_to_save', 'insert_luminance_data', 10, 2);      but this isnt working. Thanks in advance for any assistance * * * **SOLUTION** Thanks to s_ha_dum               function get_avg_luminance($filename, $num_samples=10) {         $img = imagecreatefromjpeg($filename);              $width = imagesx($img);         $height = imagesy($img);              $x_step = intval($width/$num_samples);         $y_step = intval($height/$num_samples);              $total_lum = 0;              $sample_no = 1;              for ($x=0; $x<$width; $x+=$x_step) {             for ($y=0; $y<$height; $y+=$y_step) {                      $rgb = imagecolorat($img, $x, $y);                 $r = ($rgb >> 16) & 0xFF;                 $g = ($rgb >> 8) & 0xFF;                 $b = $rgb & 0xFF;                      // choose a simple luminance formula from here                 // http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color                 $lum = ($r+$r+$b+$g+$g+$g)/6;                      $total_lum += $lum;                      $sample_no++;             }         }              // work out the average         $avg_lum  = $total_lum/$sample_no;         return $avg_lum;         // assume a medium gray is the threshold, #acacac or RGB(172, 172, 172)         // this equates to a luminance of 170     }          function insert_luminance_data($post_ID) {         $src = wp_get_attachment_image_src( $post_ID, 'large' )[0];         $lum = get_avg_luminance($src, 10, true);         add_post_meta( $post_ID, 'image_lum', $lum, true ) || update_post_meta( $post_ID, 'image_lum', $lum );         return $post_ID;     }          add_filter('add_attachment', 'insert_luminance_data', 10, 2);      this creates a number between 0 and 255 that represents the luminance of the image.. this is particularly useful if you are layering text over a background image and wish to know if the image is mostly light or mostly dark.


I have an elderly WordPress theme that I am trying to bring back up to date. I am stuck on the following snippet...               if ( function_exists('register_sidebar_widget') )         register_sidebar_widget(__('Pages'), 'widget_nav');      This is giving me the following message... register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead I realise that reigster_sidebar_widget has now been replaced by wp_register_sidebar_widget() but I can't work out whats changed with the syntax.


Allow Permalinks to Work with and without Hyphens

Is there a way that I can change my .htaccess file to allow the user to go to a permalink with or without the hyphen? For example: I have a page: `http://example.com/parent/two-words` To get to that page, I'd like to be able to type in any of the following:               example.com/parent/two-words     example.com/parent/twowords     example.com/two-words     example.com/twowords      Is that possible? Thanks!


Custom section (e.g. Demos or Downloads)

On my website, I want to display a page where I will store all my demos, which should function just like a blog (so I can add new records, edit them and specify custom meta data and list all of them on a public page), but it should independent for easier management. I have searched the web for answers or tutorials, but haven't any. Example can be found here: http://css-tricks.com/downloads/ As you can see there there is a separate blog and the demos page function as an independent group of records, with their special metadata and I'm pretty sure there is a way of creating something like this.


Changing from localhost:8888 to localhost

I have just changed ports on MAMP from :8888 to :80 for localhost in order to setup a WordPress multisite for local development. However I have several sites with separate installations that are in my htdocs folder and previously used localhost:8888 as a root. I did the following things in order :   1. Opened wp-config and changed the Mysql hostname to `define('DB_HOST', 'localhost');`   2. Went to the options table of the database and changed the siteurl and home.    3. I cleared my .htaccess file   4. Cleared my browser cache.  Still, when I am at the index for localhost I am still being redirected to localhost:8888. I'm sure other people have had this problem and yet I can't seem to find the same question. Interestingly enough I have access to admin just not to the front end.


Get fields of a widget

I have a widget that has fields, so how can I get these fields in my Metabox. I have tried with this variable `$wp_registered_widgets`, but I can't get the fields. Is there any solution for my problem and thanks. [Update] here is the code of metabox               <?php                    add_action('add_meta_boxes','dar_meta_create');          function dar_meta_create()     {         add_meta_box(               'dar_meta', // $id               'metabox dardar', // $title                'dar_meta_function', // $callback               'page', // $page               'normal', // $context               'high');     }          // callback          function dar_meta_function($post)     {         wp_nonce_field(basename(__FILE__), 'dar_nonce');                   // my form              $nbr1 = get_post_meta($post->ID,'nombre1',true);         $nbr2 = get_post_meta($post->ID,'nombre2',true);              echo          '<input type="text" value="'.wp_kses_post($nbr1).'" id="nombre1" name="nombre1">          <input type="text" value="'.wp_kses_post($nbr2).'" id="nombre2" name="nombre2">';               //******************************************************//                   //  I want get and display fields of a specific widget                       //*****************************************************//               }          // save meta box          function dar_meta_save($id,$post)     {          // check the autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)               return $id;               if (             'page' == $post->post_type             && current_user_can('edit_page', $id)             && wp_verify_nonce($_POST['dar_nonce'], basename(__FILE__))             && isset($_POST['nombre1']) && isset($_POST['nombre2'])         )          {         update_post_meta($id, 'nombre1', strip_tags($_POST['nombre1']));         update_post_meta($id, 'nombre2', strip_tags($_POST['nombre2']));         }          }     add_action('save_post','dar_meta_save',1,2);


Advanced custom field - posted fields from custom post type

I'm using the Advanced Custom Fields - plugin and I have custom post type called 'course' where some fields from the ACF are related to. I have this code below:               function update_course($course_id) {              //Check conditions and tell user if certain values are incorrect/inconsitence         $nr_available = intval(get_field('nr_available'));         $nr_registered = intval(get_field('nr_registered'));              echo 'nr avail=' . $nr_available;         echo 'nr registered=' . $nr_registered;          }          add_action( 'edit_post' , 'update_course');      The thing I want to do is to check for instance if available spots are less then register = incorrect. Then I want to indicate that the user has done this incorrectly. But anyway, my real issue is that I don't know how (I don't get it) to get values from ACF of the custom post type posted (course). Above would only return the actual values in the database (for the current course - I think), **I want the posted values**. If I look at the $_POST - variable it shows something like:               [field_524bceba787b8] => 800 [field_524bcf0a787b9] => 40 [field_524bcf58787ba] => 50 [field_524bcfdb787bb] => [field_524bd005787bc] => [field_5253d4b31053b] => 0      **UPDATE:** Whole array looks like:               Array ( [_wpnonce] => 8fce853ce2 [_wp_http_referer] => /wp-admin/post.php?post=1911&action=edit&message=1 [user_ID] => 1 [action] => editpost [originalaction] => editpost [post_author] => 1 [post_type] => course [original_post_status] => publish [referredby] => http://{host}/wp-admin/post.php?post=1911&action=edit&message=1 [_wp_original_http_referer] => http://{host}/wp-admin/post.php?post=1911&action=edit&message=1 [post_ID] => 1911 [autosavenonce] => 0995694d61 [meta-box-order-nonce] => 1da8897fe1 [closedpostboxesnonce] => c92ea6dd81 [post_title] => Balett 8-9 Ã¥r [samplepermalinknonce] => 31966e47cc [content] => coolt222 [wp-preview] => [hidden_post_status] => publish [post_status] => publish [hidden_post_password] => [hidden_post_visibility] => public [visibility] => public [post_password] => [mm] => 10 [jj] => 02 [aa] => 2013 [hh] => 07 [mn] => 52 [ss] => 46 [hidden_mm] => 10 [cur_mm] => 10 [hidden_jj] => 02 [cur_jj] => 08 [hidden_aa] => 2013 [cur_aa] => 2013 [hidden_hh] => 07 [cur_hh] => 20 [hidden_mn] => 52 [cur_mn] => 55 [original_publish] => Uppdatera [save] => Uppdatera [tax_input] => Array ( [categorycourses] => Array ( [0] => 0 [1] => 29 [2] => 27 ) ) [newcategorycourses] => Namn fÃ¶r ny kategori [newcategorycourses_parent] => -1 [_ajax_nonce-add-categorycourses] => 2a26873ebd [acf_nonce] => 52e8f939a6 [fields] => Array ( [field_524bcd27ed097] => [field_524bcde2787b4] => o [field_524bce12787b5] => 433 [field_524bce5f787b6] => 1/:00 [field_524bce98787b7] => [field_524bceba787b8] => 1000 [field_524bcf0a787b9] => 10000 [field_524bcf58787ba] => 5 [field_524bcfdb787bb] => [field_524bd005787bc] => [field_5253d4b31053b] => 0 ) [advanced_view] => 1 [add_comment_nonce] => 82940723b5 [_ajax_fetch_list_nonce] => 83bc001ed1 [post_name] => balett-8-9-ar [post_author_override] => 1 [post_mime_type] => [ID] => 1911 [post_content] => coolt222 [comment_status] => closed [ping_status] => closed )


Regarding Wordpress Post, reply tree view

I want to make post/reply tree view in my admin panel so anybody can guide me which is best way to do that. I am using custom post type, custom post category and also added meta values to added post as per requirement on fronted. Just thinking will using walker class would be good solution for this although i don't have much information/knowledge about wordpress walker class so i need to study it in deep to use it. Thanks for your guidance in advance.


Display First posts without the default featured image

How can i display in loop (paged) the posts without the default featured image ? Here is my query of my custom taxonomy template page :                        <?php                  $term_region = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );                 $secteur_id = $_GET["secteur_id"];     if($secteur_id == ""){                 $args = array(                     'post_type' => 'visite',                     'paged' => $paged,                     'tax_query' => array(                         array(                             'taxonomy' => 'regions',                             'field' => 'slug',                             'terms' => $term_region->slug,                             )                         )                     );                   $wp_query = new WP_Query($args);              ?>      I know this kind of query to display only posts with not the default "thumbnail" :               <?php          $args = array(             'post_type' => 'visite',             'posts_per_page' => 5,             'meta_query' => array(                 array(                     'key' => '_thumbnail_id',                     'value' => '556',                     'compare' => 'NOT LIKE',                 )             )             );                     $wp_query = new WP_Query($args);     ?>      Any idea ? Thank you


Errors with paginating custom table

I have this code for a custom table with pagination. But my error is that it is not redirecting to paged_numbers. And additionally, it produces a 404 error. My code is:               add_filter( 'the_content', 'get_scrapy_scraped' );          function get_scrapy_scraped( $content )     {     include_once('paginator.class.php');              global $wpdb;              if ( ! is_page( 'jobs' ) ) //when jobs is read             return $content;             $query = "SELECT COUNT(*) FROM wp_careers";     $result = mysql_query($query) or die(mysql_error());     $num_rows = mysql_fetch_row($result);          $pages = new Paginator;     $pages->items_total = $num_rows[0];     $pages->mid_range = 9; // Number of pages to display. Must be odd and > 3     $pages->paginate();          echo $pages->display_pages();     echo "".$pages->display_jump_menu().$pages->display_items_per_page()."";          $query = "SELECT * FROM wp_careers ORDER BY Job_Name ASC $pages->limit";     $result = mysql_query($query) or die(mysql_error());          echo "
";     echo "
Job Name	Department/Location	Information	Apply Links
";     while($row = mysql_fetch_row($result))     {         echo "
$row[3]	$row[1]	$row[0]	$row[2]
\n";          }     echo "
";          echo $pages->display_pages();     echo "
Page: $pages->current_page of $pages->num_pages
\n";     echo "
SELECT * FROM table $pages->limit (retrieve records $pages->low-$pages->high from table - $pages->items_total item total / $pages->items_per_page items per page)";     }      and paginator.class.php is:               class Paginator{         var $items_per_page;         var $items_total;         var $current_page;         var $num_pages;         var $mid_range;         var $low;         var $limit;         var $return;         var $default_ipp;         var $querystring;         var $ipp_array;              function Paginator()         {             $this->current_page = 1;             $this->mid_range = 7;             $this->ipp_array = array(10,25,50,100,'All');             $this->items_per_page = (!empty($_GET['ipp'])) ? $_GET['ipp']:$this->default_ipp;         }              function paginate()         {             if(!isset($this->default_ipp)) $this->default_ipp=25;             if($_GET['ipp'] == 'All')             {                 $this->num_pages = 1;     //          $this->items_per_page = $this->default_ipp;             }             else             {                 if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;                 $this->num_pages = ceil($this->items_total/$this->items_per_page);             }             $this->current_page = (isset($_GET['pg'])) ? (int) $_GET['pg'] : 1 ; // must be numeric > 0             $prev_page = $this->current_page-1;             $next_page = $this->current_page+1;             if($_GET)             {                 $args = explode("&",$_SERVER['QUERY_STRING']);                 foreach($args as $arg)                 {                     $keyval = explode("=",$arg);                     if($keyval[0] != "pg" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;                 }             }                  if($_POST)             {                 foreach($_POST as $key=>$val)                 {                     if($key != "pg" And $key != "ipp") $this->querystring .= "&$key=$val";                 }             }             if($this->num_pages > 10)             {                 $this->return = ($this->current_page > 1 And $this->items_total >= 10) ? "items_per_page$this->querystring\">« Previous ":"« Previous ";                      $this->start_range = $this->current_page - floor($this->mid_range/2);                 $this->end_range = $this->current_page + floor($this->mid_range/2);                      if($this->start_range <= 0)                 {                     $this->end_range += abs($this->start_range)+1;                     $this->start_range = 1;                 }                 if($this->end_range > $this->num_pages)                 {                     $this->start_range -= $this->end_range-$this->num_pages;                     $this->end_range = $this->num_pages;                 }                 $this->range = range($this->start_range,$this->end_range);                      for($i=1;$i<=$this->num_pages;$i++)                 {                     if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";                     // loop through all pages. if first, last, or in range, display                     if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))                     {                         $this->return .= ($i == $this->current_page And $_GET['pg'] != 'All') ? "num_pages\" class=\"current\" href=\"#\">$i ":"num_pages\" href=\"jobs?page=$i&ipp=$this->items_per_page$this->querystring\">$i ";                     }                     if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";                 }                 $this->return .= (($this->current_page < $this->num_pages And $this->items_total >= 10) And ($_GET['pg'] != 'All') And $this->current_page > 0) ? "items_per_page$this->querystring\">Next »\n":"» Next\n";                 $this->return .= ($_GET['pg'] == 'All') ? "All \n":"querystring\">All \n";             }             else             {                 for($i=1;$i<=$this->num_pages;$i++)                 {                     $this->return .= ($i == $this->current_page) ? "$i ":"items_per_page$this->querystring\">$i ";                 }                 $this->return .= "querystring\">All \n";             }             $this->low = ($this->current_page <= 0) ? 0:($this->current_page-1) * $this->items_per_page;             if($this->current_page <= 0) $this->items_per_page = 0;             $this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";         }         function display_items_per_page()         {             $items = '';             if(!isset($_GET[ipp])) $this->items_per_page = $this->default_ipp;             foreach($this->ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n";             return "Items per page:<select class=\"paginate\" onchange=\"window.location='jobs?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n";         }         function display_jump_menu()         {             for($i=1;$i<=$this->num_pages;$i++)             {                 $option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n";             }             return "Page:<select class=\"paginate\" onchange=\"window.location='jobs?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n";         }         function display_pages()         {             return $this->return;         }     }      which is from this article. How to solve this?


Different template for second page result for Ajax-loading new pages

Everytime I enter a posts page, index.php is called. Now on the site I load next pages (page2, page3...) with Ajax and insert the posts (just the posts) from the Ajax result inside my page. This works perfect but I was wondering if it is possible to have a different page template for second-pages so I would just load the articles in those (no scripts or styles or parent-innecesary divs). This way the Ajax call would be faster. A thing to consider is that if it would be possible, it wount just be for the page number different to one, as the user might enter directly in the fourth page (this one should have all the styles and divs) and then load the fifth, sixth by this second-Ajax template. **EDIT2:** I realized about http://stackoverflow.com/questions/3124636/detect-ajax- calling-url               if (strcasecmp('XMLHttpRequest', $_SERVER['HTTP_X_REQUESTED_WITH']) === 0)      **EDIT:**               <?php get_header(); ?>
              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                  <article id="post-<?php the_ID(); ?>">                  ...
              <?php endif; ?>
          <?php get_footer(); ?>      And then I load via javascript Ajax next pages:               $.ajax({              url : page_to_load,              success : function (data) {                  $('#main').append($('#main>article', data));              }          });      If Im right, every time an Ajax page is called all the page is actually downloaded (scripts,etc.) I was sondering if it would be possible to have a different page template for this second page, something like:                   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                  <article id="post-<?php the_ID(); ?>">                  ...
              <?php endif; ?>      So ONLY articles are loaded, no header,scripts,styles or anything extra. Thanks.


custom image dimensions (for gallery)

when uploading an image into the mediapool, wordpress will auto-resize it in several dimensions. unfortunately i'm requiring a special format which is kinda between thumbnail + medium. any ideas if it's possible to do that? thanks


Wordpress Rewrite Rules

I created the page template which needs to take some GET variables, currently URL's looks like that: http://example.com/coupons/?cat_id=25 I need to make that way: http://example.com/coupons/25 I checked the WP_Rewrite documentation and playing a bit with that stuff, but can't make things work as except. Regards, Chris


Why is my mod_rewrite not working?

Ok I have a WP site using the permalink structure of `/%category%/%postname%/` I have built it in the way of page templates, using category queries inside, i.e. **page-help.php**               <?php $my_query = new WP_Query('category_name=help');     while ($my_query->have_posts()) : $my_query->the_post(); ?>          <!--content-->     <?php endwhile; wp_reset_query(); ?>        **page-about.php**               <?php $my_query = new WP_Query('category_name=about');     while ($my_query->have_posts()) : $my_query->the_post(); ?>          <!--content-->     <?php endwhile; wp_reset_query(); ?>         Pretty simple. The problem I have is, I need an archive by year for the news section. I did this by just making the **archive.php** have the same layout as **page-news.php** and just query the posts in the news category. *-this is fine in my case because news is, and will only ever be the content to be archived. My news category (latest-news) is a child of the about category (about), so when I go to the news section, the url is: > www.example.com/about/latest-news/ On the news page is use the following code to list the archives;               <!-- Gets archive for news-->        <?php $my_query = new WP_Query('category_name=news_article');     while ($my_query->have_posts()) : $my_query->the_post(); ?>          <?php wp_get_archives('type=yearly'); ?>      <!--Ends archive for news-->     <?php endwhile; wp_reset_query(); ?>         The links it generates naturally lead me to > www.example.com/2000 > > www.example.com/2001 etc. I want the rewrite to change them to > www.example.com/about/latest-news/2000 > > www.example.com/about/latest-news/2001 I have modified the .htaccess in the WP route to this:               # BEGIN WordPress       <IfModule mod_rewrite.c>          RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]         RewriteRule  /([0-9]+/?)$  /about/latest-news/$1     [NC,L]  #Added this line     </IfModule>       But I am having no luck, the url remains as > www.example.com/2000 I have the issue of not knowing wether my re-write is wrong, wether I should be putting this line of re-write in a different htaccess elsewhere, or if WordPress is overwriting it. Any help would be really appreciated.


wp_query display posts based on day

I am trying to get all posts to be displayed on a certain date. For example today Tuesday I want all posts to be displayed. It doesn't matter that the posts were created today (Tuesday) or last week or last year - I just want a loop that will display all post of the current day. Tomorrow (Wednesday) I want all post to be displayed. I have created this code but it isn't working for me and I am getting a little frustrated. Here is my code.               <?php     $day = date('j');     query_posts( 'day='.$current_day);     query_posts('cat=9&posts_per_page=2' );          if (have_posts()) :         while (have_posts()) :             the_post(); ?>
                                      <?php the_field('time'); ?>                                  <a href="<?php the_permalink() ?>" class="eventFeed">                     <?php the_title(); ?>
             <?php         endwhile;     endif;     wp_reset_query();     ?>      Thank you for any help in advance :)


Shortcode displays always first. Once again

OK, I've had a problem with echoes in my last shortcodem, but everything works fine now. But I have another one:               function myWidget_shortcode( $atts ) {             extract( shortcode_atts( array(             'title' => 'My Widget',             'value' => '5',             ), $atts ) );                  return the_widget(myWidget,'title='.$title.'&value='.$value);     }          add_shortcode('myWidget', 'myWidget_shortcode');       Can you tell me wy this shortcode always displays first on pages? There's no echo etc., all the data is being returned... [found the answer - edit] **This resolves the problem:**               ob_start();         the_widget(popularPosts,'title='.$title.'&number='.$number);     return ob_get_clean();      Anyways I don't understand why it's always first in this case. Because the_widget is a function itself and echoes something? :>


Insert data in custom table during new post creation

I want to in insert data in my custom db table when creating a post. Suppose there are three categories (php, wordpress & jquery). When i create a post in wordpress, i want to insert post id and category id in my custom database table. How can i do this job?


Trouble with Transient API when W3TC is activated

I'm using W3 Total Cache 0.9.2.11 on Wordpress 3.5.2. I've got a problem with transient API and w3tc's object cache setting. When I activate 'object cache' with memcached (other settings are default), transient APIs stop working. The behavior is: when I call get_transient() within the expiration time after set_transient(), I get null. The behavior is consistent when 'object cache' is activated, and it works flawlessly when it's deactivated. The documentation mentioned no scenario where a `set_transient` call might fail. I tried the debugging mode w3tc object cache. And the page displayed some 1000 to 2000 object cache entries. I don't quite understand the name of each entry, but my transient values aren't there. I'm wondering if there are any settings I have overlooked? What's the cause of this? **Update:** I also noticed that refreshing the page will make `get_transient` return the desired output. It goes like this:   1. first `set_transient`, `get_transient` returns null   2. second `set_transient`, `get_transient` returns the first value   3. third `set_transient`, `get_transient` returns the second value So it looks like `set_transient` is taking longer to finish, is there any reference on whether w3tc have made this call asynchronous? And if so, how do I workaround it?


Random Alphanumeric Key URLs

I need random (and unique) alphanumeric permalinks. I've looked at several plugins but they all seem to do some form of redirection to a longer URL. That's not what I want, I want the permalink to be changed. Basically, I'm wanting URLs like bit.ly or 9gag.com. I've looked, but came up empty in my searches - does a plugin exist that does this? If not, could someone point me into the right direction as to how I might accomplish it? I'm pretty self sufficient in PHP but I'm not very familiar with WordPress yet. The easiest way I could think of is something like `add_filter("post_slug", md5(rand()))` (if that were actually valid code). Obviously, I'd have to check for duplicate slugs and what not... Honestly, what I'd much rather prefer is something like: `example.com/prefix/hf434g5ay/postname` In that the `/prefix/alphanumeric-key` is required but postname is used for SEO.


WordPress updates

How does WordPress know that a plugin is belong to WordPress plugin repository and it need to pull the updates from the WordPress SVN? And on the other end how does it know that another plugin does not belong to repository?


How to use get_post_custom function on the blog page?

First, I have a static page for homepage and for blog page too. I created a custom box for pages to setup unique background image for the pages. My idea is working on all page templates, but on blog page something wrong. **header.php is same on all page**               <head>     {...}     <?php $values = get_post_custom( $post->ID );  ?>     <style type="text/css">         body { background-image:url("<?php echo $values['background_image_meta'][0]; ?>"); }     </style>     {...}     </head>


A plugin for having rel="nofollow" in posts?

I'd like to make all the links in posts on one of my sites to be with rel="nofollow" on links inside posts. I wasn't able to find a plugin that did the job except for WP-NoExternalLinks. It also didn't work, unless I used it's dooms day option: > "Mask ALL links in document (can slow down your blog and conflict with some > cache and other plugins. Please use it on your own risk." But when I use it, it also puts nofollow on my blogroll links (which I would have preferred to keep alive.) Any suggestion what might be causing this? or how to resolve it? Thanks.


How organize uploaded media in WP?

I am new in WordPress and I came from Joomla. I am having some problem to understand how can I (if I can do it...) organize the uploaded media into folders and subfolders using WordPress. If I go in my backend administration panel I have the **Media** sub panel in which I can add a file (for example a jpg image). The problem is that all files are added in the same library. I want to organize my library having subcategory\subfolder in which the uploaded files are stored. For example I want have category image for: "Spring articles images" and "project management articles image", etc. How can do it?


Custom text box containing post titles

I added two text boxes to my home page on a wordpress site and I need to display recent posts titles only. What line of code should i add to do that ? Here is the code I used to create the boxes:

Latest News

Our Clients


wp3 custom post types rss

From what I've found online, getting an rss feed for a custom post type is as simple as:               http://mywebsite.com/feed/?post_type=custom_type      Well I have tried it with no success as it just returns the default feed. However I can get this to work on the website just fine with               http://mywebsite.com/?post_type=custom_type      So why does it work for the html but not the rss feed? Please advise. ** EDIT ** I ended up adding this to my theme's functions.php:               function myfeed_request($qv) {         if (isset($qv['feed']) && isset($_GET['post_type'])) {             //$qv['post_type'] = get_post_types();             $qv['post_type'] = explode(',', $_GET['post_type']);         }              return $qv;     }     add_filter('request', 'myfeed_request');


Add $more_link_text parameter to the_excerpt()

this `filter` is on the Wordpress Codex …               add_filter('excerpt_more', 'new_excerpt_more');          function new_excerpt_more($more) {         global $post;         return '<a class="moretag" href="'. get_permalink($post->ID) . '"> … </a>';     }      This works perfect, however I wonder if it is also possible to create a filter that extends `the_excerpt()` with the same parameter like `the_content()` where it is possible to set the "more-link-text" as parameter? So I wonder how I can achieve this … `the_excerpt('custom more link')`` This would be especially useful for me because I have multiple custom-post- types where I always use `the_excerpt()` as teasers. Since those custom-post- types have various contexts and meanings it would be nice to have different "more-links" at the end … Is this somehow possible? Thank you in advance!


Removing duplicate values between two wordpress queries

I'm addressing a well known issue in Wordpress, in which I want to display "featured" posts, and under it the rest of the posts.   I have a `$query1` which holds 2 featured posts, and my `query_posts` which holds all of the posts on the site (including those two from `$query1`).   I now wish to remove from `query_posts` those two posts so I can display it using regular Wordpress loop in the form of:                 while (have_posts ()) : the_post();     the_title();     the_content();     endwhile;         I have the solution for removing these duplicate posts inside the above loop, but because of the paging, I want to have the query without duplicates before that, so the `query_posts` array will be paged **without** those two featured posts.


List author's posts with SQL

I want display authors'posts with the code below but authors' name aren't showing. What is wrong?               <? // query test     $qry = $wpdb->get_results( $wpdb->prepare("     SELECT *     FROM $wpdb->posts     WHERE post_type ='post'     AND post_status='publish'     order by 'ID' DESC     LIMIT 5     "));          echo "
";          foreach ( $qry AS $k => $v ){          $qry_name = $wpdb->get_results( $wpdb->prepare("     SELECT user_nicename AS USER_NAME     FROM 'wp-users' AS a     LEFT JOIN 'wp-posts' AS b     ON a.ID = b.post_author     WHERE b.post_author = a.ID     "));          $ID = $v->ID;     $title = stripslashes(mb_substr($v->post_title, 0,20,"utf-8"));     $ddate = $v->post_modified;     $name = $v->user_nicename;     $link = '';     $list = "
".$ID."	".$link.$target.$title."	 on ".$ddate."	".$qry_name[0]->USER_NAME."
";     echo $list;     }          echo "
";     ?>


See output of a sql query while plugin installation in wordpress

Doing wordpress plugin development, I am creating a table (while installing the plugin) with the following string:               $sql = "CREATE TABLE (query skipped)..."; /*someting*/      For example: I have this               register_activation_hook( __FILE__, 'my_plugin_install' );     function my_plugin_install(){          $sql = "CREATE TABLE (query skipped)..."; /*someting*/     echo $sql;     }      The problem is there is some error with this query and and I want to see the output of $sql using php. But the above code doesn't echo anything when plugin is installed. Any way to see the ouput?               Details:      function my_plugin_install(){             global $wpdb, $current_user;;             //getting the musician/user rating keys         global $k11, $k12, $k13, $k14, $k21, $k22, $k23, $k24;             $fabprofile_table_name=$wpdb->prefix."fabulous_profile";             $fabulous_profile_version = "2.0";             //mid= music user id        //uid = general user id        //creating the ratings table        $sql = "CREATE TABLE $fabprofile_table_name (            mid tinyint(9) NOT NULL,            uid tinyint(9) NOT NULL,            $k11 tinyint(1) NOT NULL, $k12 tinyint(1) NOT NULL,$k13 tinyint(1) NOT NULL, $k14 tinyint(1) NOT NULL,            $k21 tinyint(1) NOT NULL, $k22 tinyint(1) NOT NULL, $k23 tinyint(1) NOT NULL, $k24 tinyint(1) NOT NULL          );";                       require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             dbDelta( $sql );        $wpdb->show_errors();          echo $sql;         }


wordpress plugin to create subdomain from registered user

I have created Network enabled (Multisite) site in Wordpress installation. I can able to create multiple site as many as i want.It will create the separate table to maintain the site data respectively. I have parent domain which is like `www.site.com`. I have created the subdomain `s1` like `www.site.com/s1` and `www.site.com/s1/wp-admin`. Separate admin to maintain the data respectively. Wordpress has all its features by default. Is it possible to create subdomain dynamically from parent site for registered user? How do I programmatically do user registration to create subdomain for multisite enable wordpress setup?


How to permanent redirect old domain to new one. in case amazon store

How do I permanently redirect this url using .htaccess, so that if anyone views old web page, it redirects to the new one. For example:               http://olddomain.com/folder/AmazonASIN.html       --> http://newdomain.com/AmazonASIN.html          http://oldexample.com/detail/B007OZNZG0.html        --> http://newexample.com/B007OZNZG0.html


Why adding Categories does not auto refresh in Backend while using my custom theme?

If I am using my own created custom theme, the Post Categories Page in admin panel is not getting updated automatically when I add a new Category. **To see the new category I have to reload the page Manually**. When I change to default themes it works as perfectly. So the problem is in my theme. I think I must have missed something in my functions file. Any idea what it can be??


Use get_term_children to get the sub category of a parent category for the current post

In my WooCommerce theme I've created a root category: 'Brands' then for each product I've added it's brand as a sub category to the 'Brands' parent category. On the product page I want to display the brand of the current product.               global $post;          // Get the brands ID from slug     $brands_id = get_term_by('slug', 'brands', 'product_cat');          // Get the children of that term     $termchildren = get_term_children( $brands_id, 'product_cat' );          // Loop through the children of 'brand' term to echo the name of the brand     foreach ( $termchildren as $child ) {         $term = get_term_by( 'id', $child, 'product_cat' );         echo '' . $term->name . '';     }      This always echoes _all_ the brands. How do I take this information and filter out the brands not associated with the current product?


Is wp_nonce_field vulnerable if you know the action name? I am actually adding a hidden field with name = the name of the action name in my form so that my plugin can identify it. I want to know if there's security issues if I am making my action name "visible"? edit: I am actually automating my form submission workflow; so if displaying the action name is a concern, i can encrypt it. ex. I call `MyFormPlugin::generateAction( 'submitQuestion' );` in my form to generate the nonce and my hidden "form_action" action field.               class MyFormPlugin{              public static function generateAction( $action, $referer = true ){             $nonce_field = wp_nonce_field( self::secured_action( $action ), "mfp_nonce" , $referer , FALSE );             return $nonce_field.'<input type="hidden" name="form_action" value="'.$action.'"/>';         }              public static function secured_action( $action ){             return md5( $action.'randomsalt');         }              public function verify_nonce( $action ){             $nonce = $_POST[ 'mfp_nonce' ];             return wp_verify_nonce( $nonce, self::secured_action( $action ) );         }     }      does this look secured?


$wpdb->prepare with ON DUPLICATE KEY UPDATE

I just took this code from $wpdb Codex page, and modified my existing Insert query:               $table = $wpdb->prefix . 'user_req';          $post_id = explode('_', $_POST['post_id']);     $user_id = $_POST['user_id'];     $wpdb->insert(              $table,             array(                 'user_id' => $user_id,                 'post_id' => $post_id[1]             ),             array(                  '%d',                 '%d'             )         );      into:               $wpdb->query( $wpdb->prepare(                  "                     INSERT INTO {$wpdb->prefix}user_req                     ( user_id, post_id )                     VALUES ( %d, %d )                     ON DUPLICATE KEY UPDATE                     user_id = VALUES(user_id), post_id = VALUES(post_id)                 ",                  $user_id,                  $post_id[1]             ) );      Because I need to **prevent the duplicate entries** entering into the database. But still the duplicate entries are entering into the db while the insert query is functioning properly. To add the `ON DUPLICATE KEY UPDATE` portion, I followed the s_ha_dum's Answer on another thread. What am I doing wrong?


I change all options except for General Settings

I can change all the settings on the site except for the Wordpress General Settings section. This includes both Wordpress options and plugin related options. I get a this error code: ** ## 403 Forbidden Access to this resource on the server is denied! ** I have tried switching off all the plugins to no avail along with trying the the htaccess modification I found recommended by a similar problem.               # BEGIN WordPress     <IfModule mod_rewrite.so>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      I have eventually changed the site name by manually changing it via phpMyAdmin but I cant ship this site to my clients with this type of problem.


Rewrite for page with a possible unknown parent page

I am trying to add a wp rewrite for my plugin that allows users to include a shortcode on a page that will then display a calendar. This calendar then requires url params in order to navigate the dates. All this is working fine without issues...it is now getting it to work if a user includes the shortcode on a page that has a parent page or pages. So another words if the page with the shortcode is on is called 'class-calendar' and the user puts it as a subpage to a parent page called 'yoga' then the url may look like mysite.com/yoga/class-calendar/ and if you navigate the schedule then it will look like mysite.com/yoga/class-calendar/7/4/2014. I have it working fine if it is like mysite.com/class-calendar/7/4/2014 but I need to able to make so it works for an unknown parent page or pages. I can make it work like the code sample below $newrules = array();                       $newrules['([^/]*)/([^/]*)/' . $this->schedule_page_slug . '/([^/]*)/([^/]*)/([^/]*)/?$'] = 'index.php?pagename=$matches[1]/$matches[2]/' . $this->schedule_page_slug . '&month=$matches[3]&days=$matches[4]&years=$matches[5]';                  $newrules['([^/]*)/' . $this->schedule_page_slug . '/([^/]*)/([^/]*)/([^/]*)/?$'] = 'index.php?pagename=$matches[1]/' . $this->schedule_page_slug . '&month=$matches[2]&days=$matches[3]&years=$matches[4]';                  $newrules[$this->schedule_page_slug . '/([^/]*)/([^/]*)/([^/]*)/?$'] = 'index.php?pagename=' . $this->schedule_page_slug . '&month=$matches[1]&days=$matches[2]&years=$matches[3]';                  return $newrules + $rules;      However, even though this works I know it is not right and it only handles the page with the shortcode to be 2 pages deep ( not that it really should go any deeper, but just the same I know how I have it is not right) Any help getting me pointed in the right direction would be much appreciated. I have been trying to mess with a wild card parent, but can't get it to work. Thanks


Use Advance Custom Fields to fill text widget

I have a custom WYSIWYG field setup in Advance Custom Fields Plugin and I want to show that content in a text widget on the sidebar / widgets. I've tired the shortcode and the php code but no luck.


Extend the wp_users table

I'd like to to extend the `wp_users` table in my WordPress' database.   Why? I want people to add more information about themselves when they sing up at my website. I know how to extend it, but I'm afraid that when WordPress needs an update the `wp_users` table, i.e. the columns I added, will be deleted. I there anyone here who has some experience with extending the `wp_users` table?   Will this table be updated when the WordPress version is updated?


Images in sub-pages fail to load

I added a .htaccess file to a wordpress website I'm working on, to show nice urls instead of page ids. The content of the .htaccess is this:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      It's working fine, but in every subpage I have it doesn't show images. Using Firebug I see that the path to the image is correct (for example: for the logo is the same path as in other pages), but it gives the error "Failed to load the given URL". The src for the images is this: wp-content/themes/.../file.jpg. I noticed that putting an absolute url, such as http://mysite.com/wp-content/.../file.jpg does solve the problem. Shall I just use absolute URLs or is there something I can do in the htaccess?


problem with add_size_image

why if im add size like :               add_image_size( 'featured1', 466, 316, false);     add_image_size( 'featured2', 466, 260, false);      the seconde size Does not generated What is the problem ?


how to get the post id in the option tag

$term_id .= $_POST['main_brand_id'];             $term = get_term( $term_id, 'state' );             $slug = $term->slug;             global $post;             $args = array( 'post_type' =>'dealers','taxonomy'=>'state', 'term' => $slug );             $myposts = get_posts( $args );             foreach( $myposts as $post ) :  setup_postdata($post);                 echo '<option>';                     $options .= '<option value="'.$post->id.'">';                     $options .=  the_title();                 echo '</option>';             endforeach;      I have to pass the **post id** to get the output as below               <option value="24">Andhra Pradesh</option>     <option value="29">Bangalore</option>     <option value="44">Delhi</option>      This piece of code is not working........               $options .= '<option value="'.$post->id.'">';      This is the output im getting               <option>Andhra Pradesh</option>     <option>Bangalore</option>     <option>Delhi</option>      can anyone help me....


How to control display of page lists on sidebar that doesn't have childrens

I am using the following code to list the child pages of current page on my sidebar. It is working very well.               $titlenamer = get_the_title($post->post_parent);     $output = wp_list_pages('echo=0&depth=1&title_li=
'.$titlenamer.'
' );     if (is_page( )) {       $page = $post->ID;       if ($post->post_parent) {         $page = $post->post_parent;       }       $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );       if ($children) {         $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=
'.$titlenamer.'
');       }     }     echo $output;      But If a parent menu has no childs, this code will list all the parent pages on my sidebar. How can I control this? If the parent menu doesn't have any childs, then I wants to display certains pages I define. If this is not possible, I don't want to display anything for page that doesn't have childs.


Adding pages to the Admin panel

Instead of going to Pages on the Admin panel nav bar on the left to see all the pages that are created. I would Like the pages to show up on the Admin panel nav bar it self. Like a custom post type. How can I do this. Any help would be greatful.


Optimizing wp_get_attachment_image_src

I'm working on WordPress gallery. I display images with wp_get_attachment_image_src function:               foreach($slideshow_data['attachment_ids'] as $attachment_id) {         $img_data = wp_get_attachment_image_src( $attachment_id, 'full' );         echo "<img src=\"{$img_data[0]}\" width=\"{$img_data[1]}\" height=\"{$img_data[2]}\">";     }      Which results in over 140 database queries per page for large galleries. Of course this can be cached, but I feel that this is not correct way. My question is, am I doing something wrong? Thank you.


Eliminate MultiSite Network Splogs

Are there any plugins that can delete splogs from a MultiSite Network? I have been looking for quite a while but can not find any plugins that can delete splogs from a MultiSite Network. Although I have been able to find plugins to prevent spam, that is not what I want here. Thanks Guys.


wordpress - load a template based on the URI

I have a number of custom of post types - i.e. `'windows'`, `'doors'`, `'garages'` and I want to load a custom template (`special.php`) whenever my wordpress site has a url that looks like this:               www.mysite.com/windows/     www.mysite.com/doors/     www.mysite.com/garages/      I don't want to use pages, as it is not appropriate in this case (I have given a scaled down example in the above example) **How can I achieve this?** Currently, as no pages exist with those names, I am getting an 404 (index.php)


How can I rename the element <dc:creator> to <author> in my RSS?

I need to change the author element of the feed from dc:creator to author. How does this is possible?


Search ONLY by meta key / meta values

I'm almost there on this one. On functions.php i have this:               function base_home_product_post_type( $query ) {              if($query->is_search() && $_POST['box'] == 'sku') {             $query->query_vars['post_type'] = 'product';             $query->query_vars['meta_key'] = 'sku';             $query->query_vars['meta_value'] = $query->query_vars['s'];             return;         }          }     add_action('pre_get_posts', 'base_home_product_post_type', 1);      And it does what it's told. Searches for the search string on the meta_key 'sku'. Problem here is that by default, the query object returned from WordPress also contains this and queries `post_title` and `post_content` by default:               SELECT SQL_CALC_FOUND_ROWS  whirl_2_posts.ID FROM whirl_2_posts  INNER JOIN whirl_2_postmeta ON (whirl_2_posts.ID = whirl_2_postmeta.post_id) WHERE 1=1  AND (((whirl_2_posts.post_title LIKE '%__SEARCH_STRING__%')  OR (whirl_2_posts.post_content LIKE '%__SEARCH_STRING__%')))      I really don't want that when i'm searching only for the "sku" value, so I've tried removing it using `posts_where` and some pretty ugly REGEX like this (warning, hacky and buggy):               function get_rid_of_titles($search) {         if(is_search() && $_POST['box'] == 'sku') {         $search = preg_filter('|AND\s\({3}\w*\.post_title\sLIKE\s\'\%[^%]*\%\'\) OR \(\w*\.post_content\sLIKE\s\'\%[^%]*\%\'\){3}\s|', '', $search);         }         return $search;     }     add_filter('posts_where','get_rid_of_titles');      But to no luck. Can anyone point me the how-to's to search onlu for the custom value in this case? **SOLUTION** Thanks to @kaiser below, I got this working:               function get_rid_of_titles($search) {              if(is_search() && $_POST['box'] == 'sku') {                    $sku = $_POST['s'];          // get search string               $needle = "LIKE '%$sku%'";   // search only for LIKE '%_SEARCH_STRING_%'. This is a multisite environment, so involving table names directly is a bad idea               $replace = "LIKE '%'";       // replace it with SQL Wildcard so any title and any content are welcome               $count = 2;                  // only the first 2 occurrencies which happen to be post_title and post_content               return str_replace($needle,$replace,$search, $count);              }     }     add_filter('posts_where','get_rid_of_titles');


How to make sure a wp-cron job runs

I am using a plugin to send emails to a relatively large email list. Because we have a low per-hour email threshold from our host we have to use a setting in the plugin to throttle the emails down to only a certain number every hour. I am assuming that the plugin uses wp-cron to accomplish this. I have tried finding documentation on wp-cron but the only substantial information I have been able to find is that it requires a page view to run. Questions:   1. Is an RSS feed being pinged enough to trigger a "page view" and therefore wp-cron?   2. How long after a page view will wp-cron run? (e.g. if last page view is at 6:59p.m. will cron scheduled for 7pm run?)   3. What happens if a cron job is missed?(No one visits website all day until 7:03 p.m. Is 7p.m. cron job run?)


Custom fields: In what order are they saved into the DB?

If I insert multiple custom fields to my article, they get sorted in _"I don't know what"_ way. So when I insert some multiple fields in an article and call those via               $cf = get_post_custom();     foreach ($cf['ISSUU-configID'] as $key => $value) {       echo "<h4>" . $cf['ISSUU-configID'][$key] . "</h4>\n";     }      their order is mixed up and neither logically ordered nor in the way I inserted them. Seems weird to me. To make it a little clearer:   I insert these numbers, each one in an own custom field (in specifically that order):   12345, 23456, 34567, 45678 And the output will be something like (in fact this is always different):   45678, 23456, 12345, 34567


How to configure apache to create files with correct group owner

I've got WP site on a self-hosted server. Any files I create are owned by me/me and any files created by WP are owned by apache/apache. I've created a group, wp, that both me and apache are members of and that works ok. But how can I set this up so when either me or apache creates or edits a file or directory that it gets the wp group owner (as well as group write access)? Thanks for the assistance.


Getting Year & Date inside wpdb

I am creating a shortcode to display data based on some options.               function dot_irt_top_posts ( $atts, $content = null ) {              // get our variable from $atts         extract(shortcode_atts(array(             'before' => '
',             'after' => '
',             'number' => '10',             'post_type' => 'post',             'year' => '',             'monthnum' => '',             'show_count' => '1',         ), $atts));              global $wpdb;              $request = "SELECT * FROM $wpdb->posts, $wpdb->postmeta";         $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";              if ($year != '') {             $request .= " AND year=$year";         }              if ($year != '' && $monthnum != '') {             $request .= " AND &monthnum='$monthnum'";         } elseif ($monthnum != '') {             $request .= " AND monthnum='$monthnum'";         }              $request .= " AND post_status='publish' AND post_type='$post_type' AND meta_key='_recommended'";         $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $number";         $posts = $wpdb->get_results($request);              $return = '';                   foreach ($posts as $item) {             $post_title = stripslashes($item->post_title);             $permalink = get_permalink($item->ID);             $post_count = $item->meta_value;             $return .= $before.'' . $post_title . ' ';                  if ( $show_count == '1') {                 $return .= '' . $post_count . ' ';             }                  //$return .= get_the_post_thumbnail($item->ID, 'showcase-thumbnail');             $return .= $after;              }         return $return;          }     add_shortcode('irt_top_posts','dot_irt_top_posts');      And then the shortcode would be like:               <?php echo do_shortcode("[irt_top_posts post_type='showcase' number='10' monthnum='9']"); ?>      **UPDATED QUESTION's**   1. There seems to be some issue with my query. The Codex http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters has an example for using the date to retrive results when using WP_Query. I want to know what changes I need to make to my code to have YEAR or MONTH in the query when getting results   2. I noticed most shortcodes when communicating with database use wpdb class and not wp_query. Is there a reason behind this?


Get the Page Content,without generating HTML

I want to get the page content (so i can parse the tags/short-codes in it), but i don't want to output the result itself to the browser (i.e. echo=0). I tried get_the_content(); but its the same deal.


Enabling users to replace site title (text) with a image logo (but keeping the text if there isn't any image)?

I would like to know if there's a way of giving an option (in the admin panel) to the user to change the text of the site title for an uploaded logo image. So basically it would go like this: If there's an uploaded image for the site title, don't show the text otherwise just display the site title text. Does anyone know any tutorial or how to do it? Thanks in advance!


How to programmatically add a user to a role?

I want to programmatically add the current user to a role and also remove the current user from a role in a php page i created . am really stuck. thanks in advance


If I rename a plugin (in its main php file) do I still get update notifications?

I've recently been forced to edit the core files of a plugin. I've updated the title of said plugin to indicate that its been edited. My question is will the plugin still get update notifications? If so, I'll likely disable the updates for this plugin, to prevent someone forgetting about my updates and overwriting. Ideally, I would like to see if the plugin gets updates, but not allow them to happen just by clicking update. (it would have to be uninstalled and reinstalled, or similar).


Creating Multiple Menus when using the TwentyTen Theme?

How to get multiple menus in TwentyTen theme?


Slug is redirecting to 404

I had a page called Recipes. I changed it to Recipes_old and changed the slug so I could create a new Recipes page. When I created the new Recipes page the slug was properly defined as /recipes/ but I can't get to the page, WordPress is redirecting all requests to /recipes_old/ How do I remove the redirect? I have at this point deleted Recipes_old and Recipes. Still the slug is being redirected.


convert from single site to multisite (network) with existing subdomains

We currently use wordpress to manage our website under our main domain. We also have a few subdomain under which different applications run.               www.example.com // our main website, running wordpress     extranet.example.com // a custom-made LAMP application     forum.example.com // another LAMP application     *.example.com // anything can happen in there.      We would like to use the Network feature to create subdomains in which each team can have its own communication tool based on wordpress + buddypress. Question: can i convert our main wordpress installation to Network with subdomain, without removing access to extranet.* and forum.* ? I read the manual, but it doesn't address the specific case where subdomains already exist and i'm afraid to break things up.


How can I use a separate domain for URL shortening?

I have a hosted Wordpress blog running on my own domain. I've recently considered trying to build a custom URL shortener (a la bit.ly) that I manage and control using a very short domain. I'm wondering how I can achieve this. For example: I want this: http://nerdgap.com/some-made-up-post-here/ To shorten to this: http://g4p.it/23 (where 23 is the Worpress post ID). Is this possible? How can I go about it? Thanks!


How are plugins in the WordPress plugin directory ranked?

When searching the plugin directory on `wordpress.org` how are the results ranked? It seems the main components are number of downloads and rating, or is there actually a full blown algorithm behind it taking many different statistics into account? I have searched Google, but all I get are WordPress plugins for SEO instead of information about the way plugins are ranked within the WordPress search. Finally, what are my options for SEO if I want my plugin to rank highly in `wordpress.org`?


Creating a new div onclick wordpress+ajax

I have a link in worpress page               Trend      and i am calling an ajax function onclick.               function show_trend() {              // This does the ajax request         $.ajax({             url: ajaxurl,             data: {                 'action':'render_admin_charts_page',                  },             success:function(data) {                 // This outputs the result of the ajax request                 console.log(data);             },             error: function(errorThrown){                 console.log(errorThrown);             }         });     }      what i want to do when calling this function is display a div section .for that ,this is my function               function render_admin_charts_page() {         ?>

<?php esc_html_e('Event Booking Report','dbem'); ?>
                         <?php em_bookings_events_table(); ?>

         <?php     }      ajax function is calling but not rendering to div


"Folding" links in the blogroll

I've got a site (this one) with too many links in the blogroll. I want to keep them there, but to maybe have them "fold" in the menu (after some of them showing without the unfolding of the menu) Any solutions for that? Update: When I wrote "folding" I meant that, for (a rough) example, there would be a shuffling of the links showing and that at some point there would be a "press here for more links" button - that will poll down more of the links.


Getting the Next and Previous Posts Titles in the Sidebar?

Let's assume that I have the following posts with the following titles:   * PostA (is assigned to the 'category 1')   * PostX ( **category 2** )   * PostB (category 1)   * PostC ( _category 1_ )   * PostD (category 1)   * PostY ( **category 2** )   * PostE (category 1)   ... When a visitor will read the PostC, how can I display in the sidebar: * * * _Previous Posts:_   'PostA' (these are links here, of course)   'PostB' _Next Posts:_   'PostD'   'PostE' * * * IOW the previous and the next 2 posts from the same category. (If a post has more categories we will choose the 1st one or the last one - it doesn't matter very much). Also, if it is impossible to display the prev & next two posts it is acceptable also only one previous and next post. (I know that there are some WP functions for this but we prefer if it's possible two posts). Also, of course, we want to display the first _'n'_ characters from the title (let's say 22). We don't want to display a static text like 'Next Post' or similar. TIA


Custom Post Types — $args vs. labels array

I registered a new post type, and I was wondering what the difference was between the $args and labels array. Read more about it in the codex (can't have more than two links, sorry). For example, labels (code from this CPT tutorial)               'labels' => array(         'name' => __( 'Super Dupers' ),         'singular_name' => __( 'Super Duper' ),         'add_new' => __( 'Add New' ),         'add_new_item' => __( 'Add New Super Duper' ),         'edit' => __( 'Edit' ),         'edit_item' => __( 'Edit Super Duper' ),         'new_item' => __( 'New Super Duper' ),         'view' => __( 'View Super Duper' ),         'view_item' => __( 'View Super Duper' ),         'search_items' => __( 'Search Super Dupers' ),         'not_found' => __( 'No super dupers found' ),         'not_found_in_trash' => __( 'No super dupers found in Trash' ),         'parent' => __( 'Parent Super Duper' ),     ),      VS $args (code from this portfolio tutorial)               $args = array(               'label' => __('Portfolio'),               'singular_label' => __('Project'),               'public' => true,               'show_ui' => true,               'capability_type' => 'post',               'hierarchical' => false,               'rewrite' => true,               'supports' => array('title', 'editor', 'thumbnail')              );       What are the advantages of each? I noticed that if I tried to use some of the labels in the $args array, nothing happened or didn't happen as expected. For example, `'add_new_item' => __( 'Add New Super Duper' ),` doesn't work if I include it in the $args array. I would like for those labels to work as well as all existing code in the $args array (i don't want anything to break).


how to enable different number of revisions for different blogs when using WPMU?

for example i would like blog1 to have at most **3 revisions** for each post but i want blog2 can have at most **10 revisions** since this blog may have more than one editors that i want to enable this blog to have more revision than blog1, how to do this? wp-config.php only support for global revision, and can not be customize for each blogs, so should i implement this function by myself?


automatic title through filter

the template of my customer looks bad if the user doesn't add an title at the top of every page. I want to write a function to add an H1 tag automatially if H1 tags are not present. **This doesn't work!**                   function auto_dummy_titles($content) {         if (strpos($content,'
') == false) {             echo '
PLEASE ADD H1 TITLE TO THE PAGE
';         }         return $content;     }     add_filter( 'the_content', 'auto_dummy_titles');      **It does work just if I write 'h1' instead of ''** Why?


How to delete file uploaded by Plupload

I follow the steps from here to integrate the plupload in metabox. Everything is working fine. But I do found one disadvantages of this guide. When I click 'Remove' link from the uploaded images, it only removed it from the post, not actually delete it in the directory. Another example of using plupload in metabox is RW Metabox plugin. This plugin does delete the file entirely when the "Delete" link is click. But I just can't figure it how he did in their code. Can somebody here tell me how can I apply the 'Delete' feature in plupload with jquery?


Custom Blog Post Listing in Genesis Sample Child Theme

I want to add several images and divs and also customize the look of my Blog post listing... But i can't find the way to do it. Here's the Blog Template code               <?php     /*      WARNING: This file is part of the core Genesis framework. DO NOT edit      this file under any circumstances. Please do all modifications      in the form of a child theme.      */          /**      * Template Name: Blog      * This file handles blog post listings within a page.      *      * This file is a core Genesis file and should not be edited.      *      * The blog page loop logic is located in lib/structure/loops.php      *      * @category Genesis      * @package  Templates      * @author   StudioPress      * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)      * @link     http://www.studiopress.com/themes/genesis      */     genesis();      and just above the `genesis();` code.. i tried to put some divs and images there.. But i guess that's not the way it works. .. I also tried to make my own Blog listing template using a normal wordpress code theme..               <?php /*      Template Name: List Post Pages     */      ?>     <?php get_header(); ?>     <?php if ( has_post_thumbnail() ) { ?>
       <?php the_post_thumbnail(); ?>
     <?php } ?>

       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>       <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>">           <?php the_title(); ?>

           <?php the_content(); ?>

           <?php the_tags('Tags: ', ', ', '
'); ?>           Posted in           <?php the_category(', ') ?>           |           <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

       <?php endwhile; ?>       <?php else : ?>
Not Found
       <?php endif; ?>       <?php genesis_after_loop(); ?>
     <?php get_footer(); ?>      But no luck, what's the right way to do this? ***Update -code below is the one i want.. but instead of having the Content of the page. I want the list of Post with excerpts ....How can i do that????               <?php /*     Template Name: Page Template     */ ?>     <?php get_header(); ?>     <?php if ( has_post_thumbnail() ) { ?>
       <?php the_post_thumbnail(); ?>
     <?php } ?>

     <?php genesis_before_content_sidebar_wrap(); ?>
       <?php genesis_before_content(); ?>
         <?php genesis_before_loop(); ?>         <?php genesis_loop(); ?>         <?php genesis_after_loop(); ?>
              <?php genesis_after_content(); ?>
          <?php genesis_after_content_sidebar_wrap(); ?>     <?php get_footer(); ?>


Update post date of page when Visitor access that page?

How to update post date of page to real time when Visitor access that page? Example: I write a post on May 28, 2013. And now, when I visit that post, it will change may 28 to June 8. How to do this?


Way of getting queried loop before the query with a filter hook?

Is there a way to get the results of a loop with a filter before the code for the loop is performed in the structure of your code? My markup is something like this:               <body>       <div>        /* can I use a function to get the results from a loop performed after this point with a filter or hook of some sort */       </div>       <div>         /* a loop/foreach etc. with results I would also like information for above */       </div>     </body>      or would I need to duplicate the loop/foreach or restructure the page to achieve this?


Fatal error: Out of memory

i have a memory issue while NextgenGallery try to create the thumbnails. Wp-Version is 3.4.1 Fatal error: Out of memory (allocated 29884416) (tried to allocate 2000 bytes) in /xxx/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 179 But my memory is not exceeded: **PHP Version : 5.2.17 / 32Bit OS Memory limit : 128 MByte Memory usage : 27.75 MByte** I am getting desperate trying to solve this issue. Many thanks in advance for any help, Joe


"regular" pages not found after changing permalink

My regular pages with the default theme can not be found, but my frontpage that is a page but it has an other theme works, even my custom post type pages work. In my permalinks settings I have `/%postname%/` My `.htaccess` file has this:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>


Add Post As a menu Item

When I write a post, I want to put it under one of the menu categories so it shows up. How can I do that? Please Help


wpdb custom tables without plugin

I am using custom tables, with $wpdb, trying to perform basic queries at the moment. I can't find anything on manually creating tables then using them with $wpdb, everything is plugin related. I really do not want to use a plugin. My tables are named Wp_customtable and wp_customtable_meta. custom table has a foreign key to wp_user, and wp_customtable is connected to wp_customtable_meta. I run queries in the SQL, my tables work flawlessly with WP default tables. I run the $wpdb queries with custom tables in my app, I get undefined errors in wp-db.php. assuming I have to make my tables known in that file? Is there a way to do this without adding a plugin? What should I include/change inside wp-db.php, so WordPress $wpdb class can find my custom tables?


wp_link_pages appearing after post content and not at bottom of page

This code worked perfectly! But my issues is that it removes text on pages. I just need the page numbering to appear immediately after the post and not at the bottom of the page. Any suggestions?               add_filter ('the_content', 'pagination_after_post',1);     function pagination_after_post($content) {        if(is_single()) {           $content.= '
' . wp_link_pages('before=&after=&next_or_number=next&nextpagelink=Next&previouspagelink=Previous') . '
';        }        return $content;     }


Calculate and save an average in a meta

I'm asking for your help to develop a system average. I have a website video games and I created a function that automatically calculates the average for each review. It works very well. The problem is that I would like to display in my sidebar Rated 5 games. Unfortunately, I can not ask WP to calculate and compare each mean. It will take a lot of time. So I'd like to do is calculated at the publication of the review in the admin to save automatically mean a meta. I do not know anything about the possibility in the administration. Is it possible? If yes, how? thank you               /* RATE */          function get_rate_overall($rate=bool){              $graphics = get_field('graphics');         $gameplay = get_field('game-play');         $life = get_field('life');         $sound = get_field('sound');              $overall = $graphics + $gameplay + $life + $sound;         $overall = $overall / 4;         if (is_float($overall)) { $overall = number_format($overall,1); }         if ($rate == true) { echo $overall.'/10'; }         if ($rate == false) { echo $overall; }       }


Wrap text around shortcode

I use a shortcode handler in my plugin. The shortcode can have different (optional) parameters. And it should be possible to use for example 2 shortcodes on a static WordPress page with text before, between and after the shortcodes. An example could be:                   Lorem ipsum dolor sit amet, consetetur sadipscing elitr

             [shortcode option="1"]	             [shortcode option="2"]

              invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.         Sticky Posts:         [shortcode option="3"]     m et justo duo dolores et      My coding for the shortcode handler is this:               function show_posts_handler( $atts, $content=null, $code="" ) {         //code 4 displaying              extract( shortcode_atts( array(                 'sticky' => 'false',                 'latest' => 'false',                 'missions' => 'false',                 'count' => '0',             ), $atts ) );                  if($sticky != 'false')             {                 show_sticky_posts();             } else if($latest != 'false'){                 show_lastest_posts($count);             }else if($missions != 'false'){                 show_lastest_missions($count);             }else{                 show_all_posts_from_categories();             }     }          add_shortcode( 'show_posts', 'show_posts_handler' );      The shortcodes should be used in the WYSIWYG editor of pages and not programatically in the template. **The problem is "The shortcodes are always displayed before the text".**


Two Search pages, One search form

I have a search form that I want to place in multiple pages (it will be in different header types) I do this by using the 'get search form' function. On my Search form I have radio sections listing two custom post types 'poster' and 'house'. I have two different search pages for each post type. I want them to be separate because I want to add the search separate search pages on my Navigation e.g. "search for a poster", "search for a house". Is there a way how I can get the search form to redirect the user to either the "search for a house" page or the "search for a poster" depending on the radio button selected before the entry was submitted?. Preferably I would like to keep all the necessary coding within the Searcform.php file if possible.


How do you alter the default WordPress thumbnail?

I have selected 'thumbnail' under 'Apply changes to:', however, nothing seems to happen in either the media library or on the site. I've also tried regenerating the images after making changes, but the result shows the changes being added to the full-size image, not the thumbnail.


Capture Webcam Video within Buddypress (and BuddyPress Media)

Has anyone had experience capturing video from a webcam and adding it to a users album inside of BuddyPress and BuddyPress Media? BuddyPress Media isn't necessary if there's a better solution BP Media has a premium FFMPEG add-on for converting video which I think will be needed if this is possible; but I have no real experience with hosting, recording, and converting video on a custom site i.e. not within Vimeo or YouTube


If meta key exists in get posts function otherwise create it

The following code fetches posts with the meta key home telephone numbers.               $metas = '';          $args = array(         'numberposts' => 1,         'post_type' => 'electors',         'orderby' => 'post_date',         'order' => 'ASC',         'meta_query' => array(             array(                 'key' => 'wpcf-home_telephone_number',                 'value' => '0',                 'compare' => '>'             )          )          );               $canvassing = get_posts( $args );      I want to add another meta to look for. The problem is that this meta may not exist on all posts. I want to get posts that either don't have the meta key or don't have a value for it.               array(                 'key' => 'wpcf-success',                      'value' => ''             )      This code will only get posts that have the key without a value. I also want posts that do not have this key at all. I tired this `add_post_meta($post->ID, 'wpcf-success', '', true);` but since we have not fetched the posts there is no post ID yet.


How to include a plugin's php file to another plugin functions file

I need to customize the output of the shortcode of plugin A by using a function of plugin B. So I alter the shortcode function of plugin A by inserting a condition to check the value of the function of plugin B but I need to include the php file that supports this function. I tried all require_once, require and include but I get the following errors: When using `require_once('../../pluginname/pluginfunctions.php');` Error Warning: require_once(): open_basedir restriction in effect. File(../../magicmembers/core/libs/functions/mgm_misc_functions.php) is not within the allowed path(s) When using `include(WP_PLUGIN_URL . '/pluginname/pluginfunctions.php');` Error Warning: include(): URL file-access is disabled in the server configuration What is the correct way?


Delete posts from a post type automatically via Cron

how can I use Cron to delete posts of a certain post type once they reach a certain limit, like keep maximum 50 posts? The reason is that these posts are being imported automatically periodically, so I want to prevent the DB getting too large, apart from the fact that the older posts won't be needed.


Facebook Like Button On Individual Comments

Has anyone added this kind of functionality to a WP site before? I'm looking to add Facebook Like button to individual comments. This can be a Theme function or a plugin


plugin to search entire posts, blogs, forum, users

hi can anyone recommend a good search engine plugin that allows the users to search for posts, blogs, forums, users, etc and shows the results as a combined result and not divided into categories? we need a good plugin in our site that will not override the normal wordpress search. we're using wordpress and buddypress. thanks


wp_pagination not displaying at top of page

I've installed the wp_pagination plugin and it appears to be working fine _at the bottom of the page_ , however, the pagination is not displaying at the top of the page. Below is the template code:               <?php     /*     Template Name: Press     */     get_header(); ?>

<?php wp_title(); ?>
                                  <?php if(function_exists('wp_paginate')) {                     wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous');                 } ?>                 <?php                  query_posts( array( 'posts_per_page' => 6, 'cat' => 16, 'paged' => get_query_var('paged') ) );                  while (have_posts()) : the_post();                  ?>

<a href="<?php echo get_permalink(); ?>"><?php the_title();?>
                         <?php                          global $more;    // Declare global $more (before the loop).                         $more = 0;       // Set (inside the loop) to display content above the more tag.                         the_content("More...");                         ?>
                 <?                 endwhile;                 ?>                      <?php if(function_exists('wp_paginate')) {                     wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous');                 } ?>

      Why isn't it working at the top? MTIA!


Can't Get Metabox Data Saved Assistance Needed

I'm trying to create meta box on a post create/edit page. I faced the problem:      1\. When I create a post from scratch the data from my meta box is saved as expected   2\. When I try to update an existing post with a new meta box data the data is not saved. I experimented with a couple of action hooks which I got from wordpress docs and none of them seem to work. Please check the code below:               <?         add_action('save_post','callback');       // works when a post is created from scratch         add_action('update_post','callback');     // doesn't work         add_action('pre_post_update','callback'); // doesn't work         add_action('publish_post','callback');    // doesn't work              function callback( $post_ID ) {             echo "THE POST IS SAVED";                  // Code for saving metabox here             ...         };      Don't see any reason why this thing is not working as expected. If anyone faced the same issues please help! I'm desperate      Have a nice day!


wp_editor returns the shortcode and not render the output

I built a plugin, and I would like to use shortcodes in the integrated wp_editor. I'm using echo to display the content of the wp_editor, so I think that's the problem why I can't use the shortcode. What's the method to do that? I'm using the following code for shortcode:               add_shortcode('facebook', 'facebook');          function facebook($atts) {         $options = get_option( 'social_options' );         return 'Facebook';     }      ..and the following code to get the content of the wp_editor:               <?php         $footer = get_option('footer_options');         $footer_content = array($footer['footer_content_1'], $footer['footer_content_2']);         foreach($footer_content as $content) {             echo'                 '.$content.'             ';         }     ?>


Create new custom post and post category of same name

I have a custom post type "Product" and want to create a post category "A Product Name" automatically on creation of a new Product so that the post category (not custom post category) would have the same name as the new Product and so that all relevant posts could be linked to the custom post type. I was trying to hook into the wp_publish_post but apparently it has been renamed to `{$new_status}_{$post->post_type}` so I imagine the tag would be publish_product?                   // adds category with name of product automatically     add_filter( 'publish_product', 'my_publish_product' );          function my_publish_product( $post ) {         global $wpdb;         $post_type = 'product';               if ( ! $post = get_post( $post ) )             return;              if ( 'publish' == $post->post_status )             return;              $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );              clean_post_cache( $post->ID );              $old_status = $post->post_status;         $post->post_status = 'publish';         wp_transition_post_status( 'publish', $old_status, $post );              /** This action is documented in wp-includes/post.php */         do_action( 'edit_post', $post->ID, $post );         /** This action is documented in wp-includes/post.php */         do_action( "save_post_{$post->post_type}", $post->ID, $post, true );         /** This action is documented in wp-includes/post.php */         do_action( 'save_post', $post->ID, $post, true );         /** This action is documented in wp-includes/post.php */         do_action( 'wp_insert_post', $post->ID, $post, true );              if ( 'post' != $post_type ) {             return;         } else {             add_action( 'wp_insert_post', 'my_wp_insert_post($post->post_name)' );             return;         }     }     function my_wp_insert_post( $post_name )     {         $my_cat = array(       'cat_ID' => 0,       'cat_name' => $post_name,        'category_parent' => 'products',       'taxonomy' => 'category'        );              wp_insert_category($my_cat);     }      I'm not terribly adept at using hooks and filters so apologies if this is all wrong or makes no sense.


Hard code a domain into Yoast SEO canonical URLs

For various reasons, I've been asked to duplicate a wordpress blog across multiple subdomains. Obviously, this will cause duplicate content issues, which I hope to mitigate with the use of a canonical tag, pointing back to a single sub-domain (www). I'm using Yoast SEO on the site however. This auto generates the canonical tag - and appears to use whichever sub-domain I'm on at the time. Presumably it's picking this up from the WP_SITEURL setting or similar, but I've had to modify this to allow the multiple sub-domains in the first place. Is there any way that I can force Yoast SEO to use a single sub-domain for all canonical URLs? I still need all links on the site and general functionality to make use of the other sub-domains - whichever it's currently on - but the canonical should always point back to a single sub-domain. Please note: redirection is not an option. I figure the best way to do this is with the Yoast SEO API, but I'm unfamiliar with it. I think I need to adjust the following to include my desired sub- domain, but I'm unsure as to the syntax to get the rest of the generated URL in there.               add_filter( 'wpseo_canonical', 'http://www.' );


MySQL Rank & $wpdb

I need a rank column in my MySQL statement, for example:               SET @rank=0;     SELECT @rank:=@rank +1 as rank, player, points      FROM my_table      Is there a way to use the above with $wpdb? WordPress doesn't like having 2 lines, the ';' causes it to blow up.               $mydata = $wpdb->get_results($wpdb->prepare(" --MySQL SELECT Statement-- "));      Thank you.


delete duplicate meta_value with same post_id

I've trying to cut down on the time to query a custom post type. After looking at the database and the wp_postmeta table, for some reason, there is some duplicate meta values for the same post_id and meta_key. The only difference is the meta_id. Nacin talks about this here http://wordpress- hackers.1065353.n5.nabble.com/How-to-get-the-meta-ID-td572.html Some of these duplicates are pretty large. I bet if I were to get rid of them, I would cut the size of the wp_postmeta table down to 1/3 of the size which hopefully will make my query faster. Anyone have any suggestions on how to get rid of duplicates and why they may exists? It's only happening on a some specific meta data. Thanks!


How can I assign a specific id to the last comment of a post

I am fairly new to Wordpress and I am currently designing a template for a client of our company. However, I need to assign a specific id to the last comment of a post. Basically I have my own function that is called on the callback of `wp_list_comments()`. this is due to the fact that I have a very customised comment layout. Now, in the functions.php I would like to assign simply with an if statement such as               if ( is_last_comment() ) : print "last-comment" endif;       I have looked here and in the codex and on other pages and I cannot find anything. I appreciate anykind of help. Thank you very much in advance.