title: High CPU usage after running WP-Optimize for the first time

text: I installed WP-Optimize and ran it one time. It found and removed over 1500 post revisions and some spam comments. Before this, 4 CPUs were very idle, below 10%. After running the scan, all 4 CPUs went up to 50-70%, sometimes even more. It has been like that ever since (almost 12 hours now). Traffic on the site is very low. The site itself is up, with no DB issues; load time is normal. I can't seem to figure what's causing the high CPU usage. I removed the plugin by manually deleting the files, but this didn't work. Could the be configurations left over in the DB that cause this? These are my installed and activated plugins:   * AddThis Social Bookmarking Widget   * Autoptimize   * Custom Author Byline   * Disqus Comment System   * Feed Statistics   * PuSHPress   * Q2W3 Fixed Widget   * List item   * Redirection   * Tab Override   * UpdraftPlus - Backup/Restore    * WordPress Pop Up Plugin   * WordPress SEO   * WP Code Prettify   * WP Super Cache   * WP User Avatar   * Yet Another Related Posts Plugin Installed but deactivated:   * Disqus Author Notify   * Regenerate Thumbnails


title: Remove specific published page when theme deactivated

text: I am working on developing a theme which automatically creates a page on theme ativation. But the problem if when the theme is switched and activated again, it recreates the page.   is it possible to put a check if page is already available/publish, don't create or perhaps delete the page on theme switching/deativating?   Here is the code i am using for creating new page on theme activation :               if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {          global $wpdb;              $the_page_title = 'Homepage Template';         $the_page_name = 'homepage-1';     //$page_check = get_page_by_title('Page Title');     $page_check_id = $page_check->ID;        $the_page = get_page_by_title( $the_page_title );                  // Create post object         $new_page = array(     'post_type' => 'page',     'post_title' => 'Homepage Template',     'post_status' => 'publish',     'post_author' => 1,          );     if(!isset($page_check_id)){     wp_insert_post($new_page);     $new_page_data = get_page_by_title($the_page_title);     $new_page_id = $new_page_data->ID;     update_post_meta($new_page_id, '_wp_page_template','homepage-1.php');     }     }      My Main goal is offering users multiple homepage templates/layouts they can switch from theme admin panel or settings -> reading . So if there is a better option please do suggest!


title: What is the advantage of separating wp_users and wp_usermeta table?

text: I want to know why Wordpress designed their database with two tables separating users and meta from each other. Wouldn't it be better if first_name, last_name, nickname, description, and capabilities are in the wp_users table? SO what's the advantage for doing this separation?


title: Highlight only current on single pages

text: Goodmorning, I tried to highlight the childs also in the navigation. I came up with this code. It works, but it will highlight all menu items in a row. What do I wrong or forget to add:               function add_custom_class($classes=array(), $menu_item=false) {         if ( !is_page() == $menu_item->title &&                  !in_array( 'current-menu-item', $classes ) ) {             $classes[] = 'current-menu-item';                 }                             return $classes;     }     add_filter('nav_menu_css_class', 'add_custom_class', 100, 2);


title: Any way to make posts inherit properties/taxonomies through a single assigned taxonomy

text: I want to have a central "data" sheet that is regularly drawn upon for types of posts that are submitted. Lets say I had a movie review site, but also want to let people post other info, like Trivia or some such. So I would have 2 custom posts types (or perhaps one if I let Reviews just be handled in Posts). I want both the review and the trivia to be search for by the movie title, the production company, the category the movie is in, etc. I've been creating Taxonomies for each of these properties outside of the category. What I've run into though is that every time a new review or piece of trivia is created for that movie, one would have to re-enter all that data. I rather just have them choose the Movie title, and have the rest of that data inherited. So if they chose "Scream 4" for their review, it automatically inherits the "Horror" Category, "Wes Craven" as the director, and "Dimension Films" as the Studio without someone have to individually assign those taxonomies each time something is created. Is there any way to do such a thing?


title: How to print the output of the get_num_queries function from frontend to backend?

text: I'm trying to develop a simple plugin and figure out how to display the number of queries executed in frontend, to an admin page (plugin options page), using get_num_queries() function. I've added the following code to my plugin's function file and works well showing (in my footer) the number of queries processed to create the frontend page:               function get_queries() {     $get_queries ='';     $get_queries .= get_num_queries();     $get_queries .= ' queries';     echo $get_queries;     }     add_action('wp_footer', 'get_queries', 999);      If I use `echo get_queries();` in the place where I want to display the value in my plugin page, it display the number of queries processed in the plugin options page, not from frontend. My question is: how to print the number of queries processed to create the frontend page in my plugin options page?


title: Hide Twenty Eleven Theme From Themes Page

text: Is there a way to hide the Twenty Eleven theme from the "Themes" page in wordpress? I have 10 themes for clients to choose from and i don't want them to be able to see the Twenty Eleven theme or be able to accidentally activate it. All of the other themes are children themes of twenty eleven, so deleting it isn't an option. Any ideas? Thanks!


title: Slugs Disappeared Leaving 404s - Quick way to repopulate?

text: I've got roughly 3000 pages in WordPress w/ permalinks on. I recently cleaned up the database which appears to have deleted a fair amount of slugs for many of the pages. Obviously, with no slug, WordPress can't reference the page, therefore I or anyone else can't get to it. Rather than go in, one at a time and fix the missing slugs - Does anyone know a quick way to repopulate them?


title: Give a function a unique ID

text: I'm developing a theme that uses a Twitter Tweets custom widget (Not coded by me). There are several widget areas within the theme and if I try and include the Twitter widget in say the sidebar and the footer at the same time I get this error;               Fatal error: Cannot redeclare echo_tweets_js() (previously declared in..... on line.....       This is the section of offending code;               function echo_tweets_js() {             global $pt_twitter_username, $pt_twitter_postcount;             echo pt_twitter_js($pt_twitter_username, $pt_twitter_postcount);         }              add_action('wp_footer', 'echo_tweets_js', 9999);      Is there a way I can make it work if a user decides they want it in 2 places at the same time?


title: Custom Taxonomy template not showing

text: I've spend the better part of a day trying to figure this out. My custom taxonomy shows up in the WordPress admin, I can add it to a nav and display it with wp_nav_menu, but when I click on any of the terms I get a 404 even though I have a taxonomy.php in the theme. Any ideas?               /** Product custom post type **/     add_action( 'init', 'product_post_type' );     function product_post_type() {       register_post_type( 'product',         array(           'labels' => array(             'name' => __( 'Products' ),             'singular_name' => __( 'Product' ),             'add_new_item' => __( 'Add New Product' ),             'new_item' => __('New Product'),             'all_items' => __( 'All Products' ),             'view_item' => __('View Products' ),             'search_items' => __('Search Products'),             'not_found' =>  __('No Products found'),             'not_found_in_trash' => __('No Products found in Trash'),              'parent_item_colon' => '',             'menu_name' => __('Products')           ),         'menu_position' => 5,         'public' => true,         'taxonomies' => array('product')         )       );     }          /** product Taxonomy **/          add_action( 'init', 'create_product_taxonomy' );          function create_product_taxonomy()      {       $labels = array(         'name' => __( 'Product Categories' ),         'singular_name' => __( 'Product Category' ),         'search_items' =>  __( 'Search Product Categories' ),         'all_items' => __( 'All Product Categories' ),         'parent_item' => __( 'Parent Product Category' ),         'parent_item_colon' => __( 'Parent Product Category:' ),         'edit_item' => __( 'Edit Product Category' ),          'update_item' => __( 'Update Product Category' ),         'add_new_item' => __( 'Add Product Category' ),         'new_item_name' => __( 'New Product Category' ),         'menu_name' => __( 'Product Categories' ),       );                register_taxonomy('product', array('product'), array(         'public' => true,         'hierarchical' => true,         'labels' => $labels,         'query_var' => true       ));     }


title: Order by value in serialized custom field

text: Quite a pesky problem here. I've taken over a site that contains multiple information, serialised, within a custom field. For example:               if ($new_query->have_posts()) :                       while ($new_query->have_posts()) : $new_query->the_post();                           $ids[] = get_post_custom( get_the_ID() );                     print_r($product_custom_fields['item_data']);                      endwhile;                  endif;      Would return something along the lines of:               {i:0;s:0:"";s:13:"regular_price";s:4:"1000";s:10:"sale_price";s:0:"";s:6:"weight";s:0:"";s:10:"tax_status";s:7:"taxable";s:9:"tax_class";s:0:"";s:12:"stock_status";s:7:"instock";s:12:"manage_stock";s:3:"yes";s:10:"backorders";s:2:"no";}       I'd like to be able to run a query that orders all of these items by 'regular_price' but cannot determine the best way to achieve this. I currently have decided to run a preliminary query:               $new_query = new WP_Query( $args );                  if ($new_query->have_posts()) :                       while ($new_query->have_posts()) : $new_query->the_post();                           $ids[] =  get_the_ID();                      endwhile;                  endif;      This gets all the correct items into the array $ids. I can then run a function which will sort these IDs into the order I want, by mucking about with the serialized data. I can then run:                query_posts(array('post__in' => $ids) );      Which will filter my main results by the ids and order I have set up. The trouble being, this queries the posts twice, and potentially is a bit longwinded. If anyone can suggest a more succinct method, maybe with direct SQL injection into the query, it would be much appreciated.


title: Install wordpress as a development site in a subdirectory on live server

text: I am trying to set up a development environment for a friend. I have never had a problem before until now. Basically on the home directory of the server there is a WordPress installation. My friend wants a new folder on the server called development. So the Dev url would be mysite.com/development/ But when I try to install WordPress by going to the url /development/wp- admin/install.php I get a 404 with the live wordpress theme. I cannot for the life in me figure out why it is doing this. There is only the main WP info in the htaccess file and there are no plugins activated to prevent the install in the development folder. I can visit html and txt files in the development folder but not php files. (readme/liecense etc) Does anyone have any ideas why this might be happening?


title: hatom-feed entry-title error in the rich snippets tool

text:
I am using wordpresss cms. I am trying to get things right with Google's rich snippets tool. Though, I have able to set `updated`, `author` and 'entry- title' correctly I am still having trouble setting my title in a correct way. In the rich snippets testing tool I am having this `Error: Missing required field “entry-title”.` I tried a solution that was suggested here but it did not work. Below is the code that I tried.
<? php the_title();?>
      FYI, I also use wordpress seo plugin by yoast. I thought about asking this at webmasters-stackexchange but thought I will ask here first as it might be related to wordpress. The other reason I need to get this sorted is, coz I am getting errors in my search results as displayed within google webmasters tools. ![enter image description here](http://i.stack.imgur.com/5FoWN.png) * * * ![enter image description here](http://i.stack.imgur.com/eKp7W.png)


title: Search tag within category

text: How do I search a tag within a category? like if a user is viewing a post that belongs to category "Romance" and the user clicks on one of the tags like for example "blonde" it should list all posts tagged "blonde" within category "Romance". How can I do this?


title: How to change style a menu item in plugin?

text: I want to assign specific style to a specific item in navigate menu like "Home" but in plugin not in theme. I think I must write something like this in my plugin:               function change_home(..){     if($item == "home")     //get a css to the item     else     return $className;         }     add_filter('a properly hook', 'change_home', 10,2);      is there a way to do this?


title: Hook into create_initial_post_types to add capabilities array?

text: Is it possible to do this? I don't want "create_posts" to be mapped to "edit_posts" -- would like to add to the capability array for when posts are registered to add "create_posts". Does anyone know if this is possible or if there is a better solution?


title: Scripts are not called until I login from wordpress backend

text: I am enqueuing custom scripts for slider in header.php but it is not working until I login from backend. I am working on localhost. The code is               <head>          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />          <title><?php bloginfo('title');?> | <?php bloginfo('url'); ?></title>     <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />          <?php wp_enqueue_script('bjqs-1.3', get_template_directory_uri().'/js/bjqs-1.3.js'); ?>     <?php wp_enqueue_script('bjqs-1.3.min', get_template_directory_uri().'/js/bjqs-           1.3.min.js'); ?>     <?php wp_enqueue_style('bjqs', get_template_directory_uri().'/bjqs.css'); ?>     <?php //wp_enqueue_style('demo', get_template_directory_uri().'/demo.css'); ?>     <?php wp_enqueue_script('jquery.secret-source.min',     get_template_directory_uri().'/jquery.secret-source.min.js'); ?>     <?php wp_head(); ?>      </head>


title: Best practice for show data to one specific user?

text: I'm attempting to build a locked page on wordpress (through a plugin) that shows differant data, depending on who signs-in. Essentially it has three screens, as follows:   1. If you sign-in as the admin (or someone with admin privileges granted) it shows a screen that has info and functionallity for the admin only;    2. If you sign-in as a default user (created by admin) you're taken to a private registration page;   3. If you sign-in with a registered account you're presented with a file uploader. The way I'm doing this is with a `if elseif else` statement; like so `if (current_user_can( 'manage_options' )): 1, elseif ( 2 == $current_user->ID ): 2, else: 3, endif;`. What I'm wondering is if the way I'm calling the second function is best practice, or if there is a better/saver way of doing this? Thanks for any help! ;)


title: How do I add Widgets to my theme and activate them on my site?

text:
I registered the widget area in my functions.php and they appear in my admin area but when I drag it over to the right hand panel to make changes none of them seem to do anything. Anyone know what I can do to find a solution to this problem? The widget in question is WP YouTube Lyte Edit:               add_action( 'widgets_init', array(&$this,'arphabet_widgets_init'));     function arphabet_widgets_init() {              register_sidebar( array(             'name' => 'Home right sidebar',             'id' => 'home_right_1',             'before_widget' => '
',             'after_widget' => '
',             'before_title' => '
',             'after_title' => '
',         ) );     }


title: Form Shortcode not saving data to WP database

text:
I'm developing a plugin that creates a custom table upon plugin activation. The plugin allows users to add a form shortcode to collect data for leads. I've got to the point where either the data saves but I can't create a new post (I'll get the "headers already sent" when the publish button is cliked in the WP editor) or, I'm able to create a new post, the form does display via shortcode BUT the data does not save to the database. I've been pulling my hair out trying to figure out what I'm doing wrong. Any help in the right direction would be much appreciated. Here is the form process code.                   //Process form data     function el_process_form(){          if (isset($_POST['everlead'])) {              if( $_SERVER['REQUEST_METHOD'] == 'POST' && !empty( $_POST['post_type'] ) &&  $_POST['post_type'] == "everlead"){                       $name = stripcslashes($_POST["name"]);                  $email = stripcslashes($_POST["email"]);                  $phone = stripcslashes($_POST["phone"]);                  $website = stripcslashes($_POST["website"]);                  // Do some minor form validation to make sure there is content             if (trim($name) == "" ) {                      echo 'Please enter your name.
';                  }             if (trim($email) == "" ) {                      echo 'Please enter a valid email address.
';             }             if (trim($phone) == "" ) {                      echo 'Please enter a contact number.
';             }             if (trim($website) == "" ) {                      echo 'Please enter your website url.
';             }              global $wpdb;         //Set time         $formtime = date('m-d-Y h:i:a');         $ipaddress = $_SERVER['REMOTE_ADDR'];              //Table data         $data = array(             'name'      => $name,             'email'     => $email,             'phone'     => $phone,             'website'   => $website,             'date'      => $formtime,             'ipaddress' => $ipaddress         );              //set lead data         $table = $wpdb->prefix . 'el_leads';              $wpdb->insert( $table, $data, array('%s', '%s', '%s', '%s', '%s') );              }     }     }          add_action( 'init', 'el_process_form' );      One weird thing with the code above ^^^. Everything works fine if on a local server (xampp) you remove `if (isset($_POST['everlead'])) {` but I get the "headers already sent" error when on a live site.' Also, If I add this if statement before the form process, I'm not able to save the data to the database.                   function el_process_form(){     if(isset($_POST['post_type'])){     ...process form data     }     }     add_action('init', 'el_process_form' );      The code above allows me to create a new post (as stated in previous paragraph) but the data does not save.


title: Custom Post Fields at the beginning of a Custom Permalink

text: Is there any way to have a permalink begin with a custom post field? For example, the follow works:   * $wp_rewrite->add_permastruct('solicitors', '/anything/%custom_field%/%custom_field_2%', false); But this doesn't:   * $wp_rewrite->add_permastruct('solicitors', '/%custom_field%/%custom_field_2%/', false); It seems that every page aside from city pages get redirected to the homepage when the custom field placeholder is placed first. When a manual text item (such as 'anything) is placed first, it works, but that is not what our structure needs to be. Any ideas?


title: Pre-selecting category from drop-down list or convertingdrop down list to links

text: I'm using this plugin called buddypress links and in it's link directory page the user can sort through the links by category from a drop down list(screenshot).What I need is seperate links for each category not a drop down list and after some searching I tried to follow a tutorial to pre-select an item from a drop down list using JavaScript.BUT NOTHING HAPPENS. Here's the code from the directory page which generates the category select drop down list `<?php bp_links_dtheme_link_category_filter_options_list() ?>` which i traced to               function bp_links_dtheme_link_category_filter_options_list() { ?>         <li id="links-category-select" class="last">             <?php _e( 'Category:', 'buddypress-links' ) ?>             <select id="links-category-filter">                 <option value="-1"><?php _e( 'All', 'buddypress' ) ?></option>                 <?php bp_links_category_select_options() ?>                 <?php do_action( 'bp_links_category_filter_options' ) ?>             </select>             <?php wp_register_script( 'myjavapage', 'newser.js' ); ?>             <?php wp_enqueue_script( 'myjavapage', 'newser.js' ); ?>             <?php     function my_scripts_loader() {     wp_enqueue_script( 'myjavapage', 'newser.js', false );     }     add_action( 'wp_enqueue_scripts', 'my_scripts_loader' );     ?>         </li> <?php     }      And the javascipt file               <script>     function setSelectedIndex(s, v) {     for ( var i = 0; i < s.options.length; i++ ) {     if ( s.options[i].text == v ) {     s.options[i].selected = true;     return;     }     }     }     setSelectedIndex(document.getElementById('links-category-filter'),"News");     </script>      As you've probably figured out by now, I'm 70% stupid and 30% dumb and this code is from tutorials that I barely understand.So please help me out before I start loosing my hair. BTW, any other solution that will result in being able to create separate links to each category will work perfectly fine.


title: Job Manager plugin help?

text: I've installed the Job Manager plugin on my website. I would like for the job listings to display on my jobs page, eg. `example.com/jobs/` instead of `example.com/jobs/jobs/`... How can I go about this? Thanks!


title: What's wrong with my usage of add_filter

text:
I wanted to override the wordpress default search with my custom search, however when i put the following code in the plugin file it doesn't appear replace the default searchbox(no error, nothing) and when i put the code in functions.php it works fine and replaces the default searchbox. Can anyone tell me why is it not working in plugin file? Thanks!               function DynamiteSearch($form) {         $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
' . __('Search for:') . '         <input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />         <input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
         </form>';         return $form;     }          add_filter('get_search_form', 'DynamiteSearch');


title: Making a client area in WordPress - Any good tutorials or plugins?

text: I'd like to make a client area in WordPress from my freelance design business. I'm capable of making it myself but I was wondering if there are any good tutorials and plugins that other people are already using. A Basecamp style project management system would be the ideal.


title: attachment page template? only show attachments for current post?

text:
hey guys, didn't know that, but the attachement page (i'm using attachment.php as template) is actually looping through ALL ever uploaded attachments to my blog! I just want to use it in order to view the images of a gallery etc. So I just want to loop through the images that are specific to the current post. Any idea how to solve that? attachment.php
                 <?php get_template_part( 'loop', 'attachment' ); ?>
       loop-attachment.php               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>                          <article <?php post_class() ?> id="post-<?php the_ID(); ?>">

          <?php if ( wp_attachment_is_image() ) :         $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );         foreach ( $attachments as $k => $attachment ) {             if ( $attachment->ID == $post->ID )                 break;         }         $k++;         // If there is more than 1 image attachment in a gallery         if ( count( $attachments ) > 1 ) {             if ( isset( $attachments[ $k ] ) )                 // get the URL of the next image attachment                 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );             else                 // or get the URL of the first image attachment                 $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );         } else {             // or, if there's only 1 image attachment, get the URL of the image             $next_attachment_url = wp_get_attachment_url();         }     ?>
                                                                       <?php                                 $attachment_width  = apply_filters( 'attachment_width', 1068 );                                 $attachment_height = apply_filters( 'attachment_height', 1068 );                                 echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height.                             ?>
                                     <?php previous_image_link( false, ' ' ); ?>

                                     <?php next_image_link( false, ' ' ); ?>

          <?php endif; ?>

                                  <?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?>

          <?php //comments_template(); ?>          <?php endwhile; // end of the loop. ?>


title: Plugin to list active plugins across networked sites

text: I guess the title of this question is not clear. I'm asking for a plugin, which only superadmins can use, that shows which (or, at least, how many) blogs use each plugin installed on the network. I've searched a lot for this, but found nothing. Is anybody who knows any such plugin?


title: Why is my category post repeating twice

text:
Im trying to output category with its post on a single page, but for some reason the post from all category are repeating in each category, what am i doing wrong here Here the code:               <?php             #Template Name: food             get_header();      ?>          <?php             $taxonomy = 'category';             $param_type = 'category__in';                  $term_args = array(                     'orderby' => 'name',                     'order' => 'ASC',                     'exclude' => 1             );             $terms = get_terms($taxonomy, $term_args);     ?>
             <?php if($terms) : ?>                          <?php $counter = 0; foreach($terms as $term) : $counter++; ?>                                  <?php                                     $args = array(                                             '$param_type' => array($term->term_id),                                             'post_type' => 'food',                                             'post_status' => 'publish',                                             'posts_per_page' => -1                                     );                                          $my_query = null;                                     $my_query =  new Wp_Query($args);                             ?>                                  <?php if($my_query->have_posts()) : ?>                                                  <?php if($counter == 2): ?>
                                             <?php $counter = 0; else: ?>
                                             <?php endif; ?>
<?php echo $term->name; ?>
                                                     <?php                                                             while($my_query->have_posts()): $my_query->the_post();                                                             $post_meta_data = get_post_custom($post->ID);                                                             $price = $post_meta_data['fangshsu_price'][0];                                                      ?>
                                                                     <?php the_title(); ?>                                                                     <?php if($price) {echo '£' . $price;} ?>                                                                     <?php the_content();?>
                                                          <?php wp_reset_query(); endwhile; ?>
                                  <?php endif; ?>                          <?php endforeach; ?>                  <?php endif; ?>
     <?php get_footer(); ?>


title: Use WP 3.1 Internal Linking 'widget' as a meta_box

text: There is lots of information out there on how to customize meta boxes added with add_meta_box(), such as enabling WYSIWYG editors on textareas and uploading images. What I have yet to find is a way to reuse WordPress 3.1 Internal Linking feature. Many of my custom fields contain urls to other pages on the site. The new Internal Linking feature would make it a lot easier for my users to find a page URL rather than having to remember it of cut & paste it. Is the new Internal Linking feature reusable in conjunction with add_meta_box()?


title: How do I determine if a category exists by ID?

text: I know I can get a categories ID by calling get_cat_ID('category-slug'), however, what is the method to call to determine if a category exists by ID when you don't know the slug? In other words, I need to determine if category id 1 exists. What's the function for this? Can I just use if(get_category(1)) {//do something?}


title: QTranslate for Custom Post Type

text: How to add qtranslate-support for custom post type? Just saving text with tags OR add flag switcher. My Custom Post Type field:               add_meta_box('project_rolesid', 'Roles box', 'project_roles', 'portfolio', 'normal');     <textarea id="portfolio_project_roles" cols="80" rows="7" name="portfolio_project_roles">'.$roles.'</textarea>      Trying to add suport by adding line               add_action('portfolio_project_roles','qtrans_useCurrentLanguageIfNotFoundShowAvailable', 0);      in `qtranslate_hooks.php`, but no effect.


title: Disable author profile in post

text: I am managing a WP 3.0.4 site where every post has the profile of the author appended. Where is the setting to disable this?


title: How do I filter the excerpt metabox description in admin?

text: I want to change the default "Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts." help text below the Excerpt input area to something more meaningful for my Custom Post Type. I've done something similar with Post Title, using a "translation" filter, but how would I do this with the post excerpt? Here is my current code:   ` add_filter('gettext', 'custom_rewrites', 10, 4);   function custom_rewrites($translation, $text, $domain) {`                   global $post;              $translations = &get_translations_for_domain($domain);         $translation_array = array();              switch ($post->post_type) {             case 'model':                 $translation_array = array(                     'Enter title here' => 'Enter model name here',                     'Excerpt' => "Byline",                     'Excerpts are optional hand-crafted summaries of your content that can be used in your theme.' => "Foobar"                 );                 break;         }              if (array_key_exists($text, $translation_array)) {             return $translations->translate($translation_array[$text]);         }              return $translation;     }      The third translation isn't working?


title: Subscribe to email

text: I am looking for a way where, the users of my website will subscribe to a post, and when my post will be edited or updated they will be emailed by my posts contents, My post contains, article, Twitter Updates, a Video How will the users get notification when my posts get updated and also when someone comments on posts


title: How to modify wp-includes without messing my wordpress installation?

text: I'm using a Twenty Twelve theme with a child theme. When the screen is shrunk to less than a certain width a responsive menu is toggled. The problem is that this menu's top level pages look the same as nested ones so I want to modify the menu's template. I thought this would be a matter of copying the menu's template to my child- theme but the template file is located in wp-includes (it's nav-menu- template.php I belive). How should I modify it so my changes are not erased when I update wordpress? And also with minimum risk of breaking something


title: function_exists call in function.php

text: In the function.php file of the twentyeleven the setup function checks to see whether it exists before running it:               if (!function_exists('twentyelevent_setup')):     function twentyelevent_setup() {     ... Setup code ...     }          add_action( 'after_setup_theme', 'twentyeleven_setup' );      However, in twentytwelve, it is not set up like this (it does not check if the function exists). My question is: what is the point of this design pattern? Does function_exists just check whether the function has been defined (which it is on the next line?) or does it do something else? Why does the new theme not include it?


title: Failed Media Import (importing from LIVE to local)

text: When I try to import some content to my local site so I can work on the theme w/ relevant data, my import hangs forever.... and if it finishes then the media/images fail. based on some suggestions at Failed media import i checked my uploads folder... which was for some reason marked read-only. i unset that. i unset the read only attribute from the entire wp-content folder. i've also tried giving myself total control over that folder, but i'm not convinced it is 'sticking'... as every time i look at the properties it is back to read-only. i have tried putting this in my htaccess               php_value post_max_size 7M     php_value upload_max_filesize 7M     php_value max_execution_time 600     php_value max_input_time 600     php_value memory_limit 300M     php_value output_buffering on     php_value Timeout 300     php_value KeepAlive On     php_value MaxKeepAliveRequests 100     php_value KeepAliveTimeout 15      i've tried upping the memory in wp_config.php. i have used WXRsplit to split large XML files into smaller <2mb chunks. so i'm sort of at a loss here at what else to do. i can't even work until i get this sorted out.


title: Control Category of each user can post

text: i need to know if has some plugin to control category of each user can post. Exemple: USER A - Only can post on the category A USER B - Only can post on the category B Thanks for TIPS!!!


title: Does having multiple random posts add up to server load and page load times?

text:
I have 8 post types in wordpress and have the following query in `functions.php` file 8 times So will it put load on mysql and decrease load times?               // random jokes      function randJokes($rJokes){       $RandJokesQuery = new WP_Query(array('post_type'=>'jokes','posts_per_page'=>$rJokes,'orderby'=>'rand')); ?>
Random Jokes

         <?php while ($RandJokesQuery->have_posts()) : $RandJokesQuery->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php if(function_exists('short_title')) { short_title(90); } ?>
         <?php endwhile; ?>
<?php       wp_reset_postdata();     }


title: Removing Dashboard Menu Items Through The Database

text: I'm dealing with a previous developer that's being difficult. He's removed the Plugin & Settings menus through the database (I'm assuming) as I can't find it anywhere in the functions.php file and can't access any plugin that might be used. Can someone point me to a link on how this can be done in the database? Is it the users-meta table? I'm really not sure what was done, and the developer stated: > "he should easily know how to go into the cpanel with the username/password > you already provided him, pull up the phpmyadmin interface and edit user(s) > as necessary to provide any permissions."


title: Leveraging Wordpress Comments on Custom Plugin Object page

text: I have written a plugin that creates it's own tables to house the necessary schema for client's product. Then I created a single page that retrieves the custom object via passed in query string like so:               http://localhost/wordpress/my_object/?id=7      Where it would retrieve the item with ID 7 in it's custom table. However the client would like to have commenting enabled on their custom object's page, with those comments obviously being related to the item with id 7. Seeings how I don't create a page, or post for this object. **Is there any way to tie Wordpress Built In Commenting to this custom object ?**


title: Child_of not displaying all children posts.. via get_posts

text:
I have put together this loop to display all children posts of the desired cat, but i am not getting any of the posts from one of the children cats..   Not sure if i am using the best method to accomplish what I am trying to do..                <?php             $posts = array();              $categories = get_categories('child_of=5');              foreach($categories as $category) {                $args=array(                 'post_per_page' => 5,                 'orderby' => 'post_date',                 'numberposts' => 45,                 'category__in' => array($category->term_id)                             );              $posts = $posts + get_posts($args);             } // Close your foreach here                  shuffle($posts);                   if ($posts) {                     foreach($posts as $post) {                       setup_postdata($post);                        ?>                         <div <?php post_class('boxy');?>>

                            <?php                            if ( has_post_thumbnail()) {                           $full_image_url =    wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');                           echo '';                           the_post_thumbnail('thumbnail');                           echo '';                         }                        ?>                              <?php the_content(''); ?>
                       <?php }                 }                   ?>      I am using the results in a tiled mosaic of sorts with Isotope, and I am shuffling the results, thats also a must.. Any guidance would be appreciated I have spend the last couple weeks getting as far as I am now.


title: How to get tags and categories?

text: I used the following code to get tags from the post and then simply echo them:               $posttags = get_the_tags($post->ID);     if ($posttags) {       foreach($posttags as $tag) {          echo $tag->name . ', ';}     }      Now I need to get the categories as well. My first idea was to simply duplicate the function but isn't there a way to create one single function that'll retrieve both the tags and categories and then have it echo?


title: What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?

text: Edit: Thanks for your replies, guys. This is exactly what I was after. You each brought up some good points. I think I'll stick with using constants. This is really a best practices/performance question. I'm mainly concerned with the following functions:               get_template_directory_uri()     get_template_directory()     get_stylesheet_directory_uri()     get_stylesheet_directory()      I've been under the impression that it is bad practice to repeatedly call a function over and over in certain situations. So, this would be considered bad practice:               // Pattern 1     wp_enqueue_script( 'test-1', get_template_directory_uri() . '/js/test-1.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-2', get_template_directory_uri() . '/js/test-2.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-3', get_template_directory_uri() . '/js/test-3.js', 'jquery', '20120206', true );      And this would be better:               // Pattern 2     $template_directory_uri = get_template_directory_uri();     wp_enqueue_script( 'test-1', $template_directory_uri . '/js/test-1.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-2', $template_directory_uri . '/js/test-2.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-3', $template_directory_uri . '/js/test-3.js', 'jquery', '20120206', true );      I've seen some themes initialize constants:               // Pattern 3     define( 'THEME_URI', get_template_directory_uri() );     define( 'THEME_JS', trailingslashit( BASETHEME_THEME_URI ) . 'js/' );     // Then, later on...     wp_enqueue_script( 'test-1', THEME_JS . 'test-1.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-2', THEME_JS . 'test-2.js', 'jquery', '20120206', true );     wp_enqueue_script( 'test-3', THEME_JS . 'test-3.js', 'jquery', '20120206', true );      I'm getting the impression that using constants is not such a good idea, even if they are initialized using `get_template_directory_uri()` et al., because they can be inflexible. Here's a ticket in WP trac where the constant approach got the boot. Taking a look at _s, (sample below), they are (potentially) calling `get_template_directory_uri()` multiple times. I know this isn't a huge deal, but I run into this question all the time, and see it done differently in themes and plugins. Can you guys help me to set the record straight?               // ...sample code from _s using the multiple calls to get_template_directory_uri()     /**      * Enqueue scripts and styles      */     function _s_scripts() {         global $post;              wp_enqueue_style( 'style', get_stylesheet_uri() );              wp_enqueue_script( 'jquery' );              wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', 'jquery', '20120206', true );              if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {             wp_enqueue_script( 'comment-reply' );         }              if ( is_singular() && wp_attachment_is_image( $post->ID ) ) {             wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );         }     }     add_action( 'wp_enqueue_scripts', '_s_scripts' );


title: Cannot redeclare wp_update_core()

text: I think it's right after the WordPress update, we can't access the wp-admin to log in anymore. > **Fatal error:** Cannot redeclare `wp_update_core()` (previously declared in > C:\DWASFiles\Sites\pyromaitre\VirtualDirectory0\site\wwwroot\wp- > admin\includes\update.php:288) in > C:\DWASFiles\Sites\pyromaitre\VirtualDirectory0\site\wwwroot\wp- > admin\includes\deprecated.php on line 1076 What cause this? How can I resolve it?


title: How to change theme programmatically from a external application?

text: I have a one-click Wordpress install as part of my services. After install I want to show my clients a set of themes so they can choose one and their pages will start working without any configuration needed. The problem is I need to know how to change the theme from an external (PHP) application, perhaps accessing directly to the database or to one of the installation files.


title: How to get Images included in Post

text: is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the rest of imgs only render into hidden img tags (will be visible through lightbox slideshow). So is there any function like `get_post_attachments('type'=>'image')` whose output I would be able to iterate over a loop? Thanks for your help


title: Thumbnails Not Generating

text: Ok, So this is a weird issue...WordPress doesn't generate thumbnails, I have my image sizes set and everything...I'm pretty sure it's related to my custom posts type code (see below) because when I remove it the thumbnails generate properly.               // Tells WP to add a slides and marquee sections     add_action( 'init', 'create_my_post_types' );          // WP slides section attributes     function create_my_post_types() {         // Add Slide Section         register_post_type( 'slides',             array(                 'exclude_from_search' => true,                 'labels' => array(                     'name' => __( 'Slides' ),                     'singular_name' => __( 'Slides' ),                     'search_items' => __('Search Slides'),                 ),                         'public' => true,                         'publicly_queryable' => true,                         'show_ui' => true,                         'query_var' => true,                         'rewrite' => true,                         'capability_type' => 'post',                         'hierarchical' => false,                         'menu_position' => 5,                         'supports' => array('title','editor','thumbnail')             )         );         // Add Marquee Section         register_post_type( 'marquee',             array(                 'exclude_from_search' => true,                 'labels' => array(                     'name' => __( 'Marquee' ),                     'singular_name' => __( 'Marquee' ),                     'search_items' => __('Search Marquee'),                 ),                         'public' => true,                         'publicly_queryable' => true,                         'show_ui' => true,                         'query_var' => true,                         'rewrite' => true,                         'capability_type' => 'post',                         'hierarchical' => false,                         'menu_position' => 6,                         'supports' => array('title','editor')             )         );     }      Anyone see what's wrong with the code or know why this code would interfere with normal thumbnail generation? Thanks,   Josh


title: Headers already sent error with CSV export plugin

text:
I have built a Wordpress plugin that allows the user to export all pages, with their levels and urls, to a csv file. The problem I have is that I keep getting error messages when trying to export the csv file: > Warning: Cannot modify header information - headers already sent I have checked the config & functions files for spaces, as well as trying on different installations, but still can't get this to work!!! Does anybody know how to fix this please? Plugin code:               /*     Plugin Name: Your Site's Functionality Plugin     Description: All of the important functionality of your site belongs in this.     Version: 0.1     License: GPL     Author: Your Name     Author URI: yoururl     */     add_action('admin_menu', 'my_page_export_menu');          function my_page_export_menu() {        add_submenu_page('edit-pages.php', __("Wordpress Export Pages to CSV", "my-page-export"), __("Export Page List", "my_page_export_menu"), 'edit_pages', __FILE__,'my_page_export_menu_options');     }          function my_page_export_menu_options() {          echo '
         <form method="post" id="download_form" action=""><input type="submit" name="download_csv" class="button-primary" value="Export" /></form>
';          if ( isset($_POST['download_csv']) ) {              $text = wp_list_pages("echo=0&title_li=");         $html = preg_replace('/class=".*?"/', '', $text);         $html = strip_tags($html, '
,
, ');         $html = '
'.$html.'
';              function get_depth(DOMElement $element)         {             $depth = -1;             while (                 $element->parentNode->tagName === 'li' ||                  $element->parentNode->tagName === 'ul'             ) {                 if ($element->parentNode->tagName === 'ul') {                     $depth++;                 }                 $element = $element->parentNode;             }             return $depth;         }              $dom = new DOMDocument;         $dom->preserveWhiteSpace = false;         $dom->loadHTML($html);         echo '
';         $fp = fopen("php://output", "w");              $file = 'test_export';         $filename = $file."_".date("Y-m-d_H-i",time());         header("Content-type: text/csv");         header("Content-disposition: csv" . date("Y-m-d") . ".csv");         header( "Content-disposition: filename=".$filename.".csv");         header("Pragma: no-cache");         header("Expires: 0");              foreach ($dom->getElementsByTagName('a') as $li) {          printf(               '%s%s%s',                str_repeat(',', get_depth($li)),               trim($li->childNodes->item(0)->nodeValue),               ',,,,=HYPERLINK("'.$li->getAttribute( 'href' ).'")'.PHP_EOL           );         }                    echo '
';          } else {         echo '
';         wp_list_pages("&title_li=");         echo '
';     }      }


title: Query to get last posts from authors of blog

text: Firstly I get user with role "author".               $author_args = array(     'role' => 'author'     );     $authors_list = get_users($author_args);      Nextly I reform array               $author_list = array();     foreach((array)$authors_list as $author) $author_list[] = $author->user_nicename;      And then finally query args               $author_posts_args = array(             'author_name' => $author_list,             'post_type' => 'post',             'cat'  => $colecti_id,             'posts_per_page' => '4',     );     $author_posts_query = new WP_Query($author_posts_args);      Why it doesn't works?


title: get_avatar() returns false, use with JSON-API

text: I have JSON-API installed and I'm using a custom controller to get all users with the role 'editor'. I also have WP-User-Avatar installed so the editors can upload their own images instead of using Gravatar. I have two installations, one test server where the api returns the images and the production server, where I get 'false' for images. Here is the code from the controller:               public function get_editors_with_image() {          global $json_api, $wp_query;          $args = array('role' => 'editor');     $user_query = new WP_User_Query( $args );     $user_results = $user_query->results;          $editors = array();          foreach ($user_results as $key => $value) {       $current_id = $value->data->ID;       $editors[$key]['id'] = $current_id;       $editors[$key]['url'] = $value->data->user_url;       $editors[$key]['display_name'] = $value->data->display_name;       $editors[$key]['description'] = get_the_author_meta('description', $current_id);            $editors[$key]['image'] = get_avatar($current_id, 400);     }          return array(       "editors" => $editors     );          }      This is the outcome on the testserver:               {       "status": "ok",       "editors": [         {           "id": "2",           "url": "http:\/\/example.de",           "display_name": "Example",           "description": "Hello, is it me you're looking for?",           "image": ""         },         {           "id": "3",           "url": "",           "display_name": "HEllo World",           "description": "",           "image": ""         }       ]     }      But on the production server, I get this:               {       "status": "ok",       "editors": [         {           "id": "16",           "url": "",           "display_name": "foo bar",           "description": "",           "image": false         },         {           "id": "21",           "url": "",           "display_name": "bar foo",           "description": "",           "image": false         }       ]     }      What could cause this? Could it be some setting on the production server I haven't thought about?


title: Dashicons and Pseudo :before

text: I am generating a custom post type that uses the dashicons and allows users to select one to associate with the post. The idea being the user can select an icon from a drop down list and it is displayed to the right. I have run into an issue though as javascript can't change the `:before { content: '\f188';}` value directly so I had planned on using a data-attr (data-icon) on the element then using `:before { content: attr(data-icon);}`. This works and replaces the content with the necessary icon code but for some reason renders it as text rather than an icon. Switching back to just using the text (rather than the data attr) in the css works. HTML:               <select name="_mo_content_menu_ico" id="_mo_content_menu_ico">         <option value="\f118">Education</option>         <option value="\f130">Status</option>...         ...<option value="\f161">Gallery</option>     </select>           CSS:               #content_icon:before {     content: attr(data-icon);     font: 400 20px/1 dashicons!important;     speak: none;     color: #333;     padding: 8px 0;     height: 36px;     width: 20px;     display: inline-block;     -webkit-font-smoothing: antialiased;     -moz-osx-font-smoothing: grayscale;     -moz-transition: all .1s ease-in-out;     -webkit-transition: all .1s ease-in-out;     transition: all .1s ease-in-out;     }      JS:               var $j = jQuery;     $j(document).ready(function(){         $j('#_mo_content_menu_ico').change(function(){             var icon = $j('#_mo_content_menu_ico').val();             $j('#content_icon').attr('data-icon',icon);         });     });      Any idea how to get round this? Or even why it's happening? Thanks,


title: Adding an admin menu page showing the link twice - how to solve this?

text: I'm newbie and I'm trying to create a plugin to add a menu to left menu in admin section. i have create the page but it is working fine. but i find the left menu being displayed twice. how can I resolve the issue. Find below my code:               add_action('admin_menu','user_data');         function user_data(){           add_menu_page('User Data','User data','manage_options','user-page','user_data_options');         }         function user_data_options(){             include('user-page.php');         }


title: if is_bbPress register jquery

text: i use this code to deregister jquery from wp_head():               <?php if ( !is_admin() ) wp_deregister_script('jquery'); wp_head(); ?>      i want jquery just added when user on bbpress page, but it's not working:               <?php         if (is_bbPress()) {wp_register_script('jquery'); wp_head();}         else (!is_admin()) {wp_deregister_script('jquery'); wp_head();}     ?>      can somebody help me fix this please


title: Storing/querying custom date data

text: I'm currently building a site where I need to filter/order/query a custom post type by date data. I can't use the post published date for this, but can't decide what would be the most efficient way to attach this to a post for further querying/filtering on the front-end of the site. As far as I can see my options are either: **1 - Store as custom field (probably in UNIX timestamp format)** I can see that this would work, but I have concerns about scalability with this as the number of posts grows (into thousands potentially) - as all posts would have to be queried to search/filter by custom field... this doesn't seem like it would be too efficient. **2 - Store as a taxonomy (Year->month->day)** I have a custom plugin I've written to pre-populate terms of a taxonomy, so have no problems modifying this a-little to setup the terms ready for Year (parent) -> month (child) -> day (grand-child) for a few years to come! In my mind this seems like it would build more efficient queries in the future? At face-value this feels a-little strange to do it like this, but I think it would produce much more efficient queires and filtering of posts on the front-end of the site, as it would be the taxonomy tables that are queried rather than custom fields in ALL of the posts. Is this overkill? I'd very much appreciate opinions on what would work best. I should mention that from an admin point of view I have a custom post creation/editing process, so this doesn't effect my decision. I'm really just trying to figure out the best way to attach custom date data to custom post type and query against it (with certainly hundreds, if not thousands of posts!!)


title: Able to go to WordPress admin even after deleting auth cookies from request headers

text: I discovered that if I remove my auth cookies from my browser's request header, I am still able to view a page. Steps:   1. Log into my WordPress installation   2. Go to the wp-admin page   3. In Chrome, use the developer Network tab and copy the headers for accessing a page   4. Paste the cookie into Dev HTTP Client   5. Remove all the cookies   6. Press SEND   7. The output reveals that I am still able to access the admin page Is this a vulnerability? If I have removed the auth cookies, shouldn't WordPress be able to retrieve the logged in user?


title: How do I modify the url of uploaded media content?

text: I have just moved hosts, and with the move I've also changed the setup that I have for media uploads. I used to host my media on a subdomain called media.detailsofmylife.net, but now that I have switched over, I want to go back to the traditional detailsofmylife.net/wp-content/uploads/ style. I have already backed up and relocated the content so it should be ready to go. For example, yesterday, an image used to located here: http://media.detailsofmylife.net/uploads/2013/06/Cyril-Hahn-Perfect-Form.jpg but now it is located here: http://www.detailsofmylife.net/wp-content/uploads/2013/06/Cyril-Hahn-Perfect- Form.jpg Could someone please help me with the necessary SQL statement to correct all of the old url references to the new format?


title: 404 errors after plugin options update and category base change

text: I'm calling the function below after each "save changes" on my plugin's settings file via the sanitization callback. The plugin allows the end user to change their category base, and needs to completely rewrite the permalinks in order to avoid 404 errors. However, I'm still getting 404s. The only way I can resolve them is to go to the "Settings > Permalinks" manager and clicking "Save Changes". What am I missing in this function to get rid of the 404s?               function myplugin_refresh() {         wp_cache_flush();         global $wp_rewrite;         $my_permalinks = get_option('permalink_structure');         $wp_rewrite->set_permalink_structure($my_permalinks);         $wp_rewrite->flush_rules();         }


title: Adding rel="next" & rel="prev" for paginated archives

text: Does someone perhaps know a plugin or snippet (besides Yoast's WordPress SEO) to accomplish this perhaps? Pagination with rel=“next” and rel=“prev” The only thing I've come across seems to be an 3-month old Trac ticket.


title: How do I remove twentyten without ruining what I did?

text:
I created a blog with the twenty ten theme. I understand there are issues with upgrading WP with this default theme. It overwrites what you did. Is there a way to fix this with starting over. How would I change something like this? Ex.               <?php else : ?>             <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

                 <?php twentyten_posted_on(); ?>


title: Can WP Customizer work with single pages or posts?

text: Theme Customization API has been added in WP 3.4 and is described here: https://codex.wordpress.org/Theme_Customization_API It makes it easy to add options such as "change background color" for themes. Such options will be stored in the database (in `wp_options`) with a name of your choice. You can then retrieve your value with `get_option( 'field-name' );`. I'm wondering though if this works also with single posts or pages? So, is it possible to set different custom background color for each page with this tool and retrieve values using `get_post_meta($id_of_the_current_post, 'field- name');`?


title: How Could I sanitize the receive data from this code

text: <form id="tellastory" method="post" action="">         <label for="fullname">Full Name </label>         <input id="fullname" name="fullname" type="text" maxlength="255" value=""/>          <label for="title">Title </label>         <input id="title" name="title" type="text" maxlength="255" value=""/>         <label for="title">Message </label>         <textarea id="editor" name="editor" rows="20" cols="50"></textarea>         <input type="hidden" name="form_id" value="123456" />                <input id="saveForm" type="submit" name="submit" value="submit" />     </form>     <?php     $storyteller_user_id = "3";  //your guest user id here     //$stories_category = "3";  //your stories category id here     $key = "storyteller";          if ($_POST['form_id']=="123456") {         $my_post = array();          $my_post['post_title'] =$_POST['title'];         $my_post['post_content'] = $_POST['editor'];         $my_post['post_status'] = 'publish';         $my_post['post_author'] = $storyteller_user_id;         $my_post['post_category'] = array($stories_category);         $post_Num = wp_insert_post( $my_post );         add_post_meta($post_Num, $key, $_POST['fullname']);     }     ?>


title: How can we take into account post types when constructing permalinks?

text: When I'm working with Wordpress's permalink system, I can create plenty of options for creating permalinks, like so: `/blog/%year%/%monthnum%/%day%/%postname%/` But if I add introduce a new kind of content type, say portfolio pieces, so I can have a url like: `/portfolio/postname/` The permalink options I do have (and have been using for the last 3-4 year's worth of posts), means that end up with ugly urls like: /blog/portfolio/usual_path I want all the existing links to work for posts that have already been at: `blog/YYYY/MM/post-name` But I also want to make custom posts available at: `portfolio/post-name` ### How I'd normally do it The approach I've normally do would be:   * remove the hard coded blog slug, from the permalinks to that the new permalink structure was `/%year%/%monthnum%/%day%/%postname%/`   * Add a rule in apache to 301 all requests for domain.com/blog/YYYY/MM/DD/old-post to domain.com/YYYY/MM/old-post, for SEO and suchlike. As far as I know, this would mean that any existing links to `http://domain.com/blog/YYYY/MM/DD/old-post` would still work, although browsers would end up at: `http://domain.com/YYYY/MM/DD/old-post` I'd still have the decent urls for custom post types too, at `http://domain.com/portfolio/post-name` ### Is this how you'd do it? I feel fairly comfortable about this approach - I could improve the naming structure for SEO while maintaining performance, by removing the days or even years and have something like this: `/%year%/%postname%/` I'm not sure how I'd allow for custom permalink structure here, but is there anything else I should bear in mind here when fixing links like this?


title: Create a homepage like Wordpress.com?

text: How can I create a homepage like Wordpress.com. I am currently using wordpress MS and would like to display the latest posts across the network on the homepage. How is this possible?


title: What template is used for a custom taxonomy page?

text: When I create a custom taxonomy, what template file is being used to display the page? How might I create a custom listing page for my custom taxonomy. eg. I have a custom taxonomy skills. In it are values like: PHP, MySQL, HTML/CSS/JS ... When users goto say `/skills/php` they will see all posts containing PHP in skills. What template is used by default for this page and how might I create a custom page template for this?


title: Whats the way to format a date after using get_posts()

text: I see that theres no way to get a formatted date from a function like               echo get_the_date($post->ID, 'd M Y');      `get_the_date` only works with the current `$post`. If I used `get_posts()` how can I format the date. With pure PHP I can do something like ...               echo DateTime::createFromFormat('Y-m-d h:i:s', $cp->post_date)->format('d M Y');      but its abit long, and I don't know if there's a need to actually create a `DateTime` object, perhaps its a waste of resources?


title: When are tags counted? Can it be trigered manually?

text: I'm using a feed aggregator combined with an auto-tagger for tracking words in a stream. I'm using WP-Cumulus to generate a pretty tag cloud based on these. However, I want to keep the tag cloud "fresh", at the moment it's showing "all-time" tag use. I want it to show tag use for, for example, the 100 newest entries. To do this, I think I might do the following:   1. Write a bit of php that deletes all entries except the 100 newest entries, when there are more than 100 entries.   2. Trigger re-count of tags. Will this work? How can I trigger a re-count? Does it happen with every new post? Or am I doing it all wrong? Thanks in advance for your advice.


title: Order by & include array by specific post ids

text:
I have the following:               <?php $num_cols = 2; // set the number of columns here                           $args = array(                         'post_type' => 'testimonials',                         'posts_per_page' => 4,                         'orderby' => 'ID',                          'include' => '883, 563, 568, 106',                                                           'order' => ''                                         );                  query_posts($args);                 if (have_posts()) :                 for ( $i=1 ; $i <= $num_cols; $i++ ) :                 echo '
';                 $counter = $num_cols + 1 - $i;                 while (have_posts()) : the_post();                      if( $counter%$num_cols == 0 ) : ?>
                          <?php the_post_thumbnail('post-thumbnail', array('title' => '', 'alt' => '')); ?>                                    <?php the_excerpt();?>
                     <?php endif; $counter++;                       endwhile;                       echo '
';                        endfor;                       endif;                      wp_reset_query();                      ?>      I thought that simply putting the post Ids, I could have the specific posts appear, and only those posts. Unfortunately, that doesn't seem to be the case. So I was wondering if anyone knew how I can accomplish this. Thanks in advance!


title: How can I add an incremental class identifier to my sidebar widgets?

text:
My sidebar widget code in functions.php looks like this...               if ( function_exists('register_sidebar') )     register_sidebar(array(         'name' => 'Home Sidebar',         'id' => 'home-sidebar-widget',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
',     ));      Which creates this markup on the site...

widget 1 title

Lorem ipsum dolor sit amet

widget 2 title

Lorem ipsum dolor sit amet

      Here's what I need (just adding a number to the class collection)...

widget 1 title

Lorem ipsum dolor sit amet

widget 2 title

Lorem ipsum dolor sit amet

      I would like to add a count variable so that each sidebar gets a number that I can then use for css targeting. How?


title: Tiny MCE doesn't look anything like my blog

text: I'd like my blog to actually look like what I type in WYSIWYG mode but it's not even close. How do I fix it? www.halseyschools.com


title: Too many nested wp_query loops in this hypothetical query?

text: I'm attempting something more complex than I've ever done before with WordPress, so please forgive me if this question doesn't make sense. I have a Books archive page and want it to display excerpts from my custom post type "Books", sorted first by Genre, then by Series, then by Reading Order. So it would look like this: Historical GENRE --- My First Historical SERIES; SERIES description; ------BOOK 1, BOOK 2, BOOK 3 --- My Second Historical SERIES; SERIES description; ------BOOK 1, BOOK 2, BOOK 3 Contemporary GENRE ... ETC I have gone back and forth on how to set up my data. Right now, I'm set up like this: "Series" is a Custom Post Type with custom fields "Genre" and "Description"; "Books" is a Custom Post Type with custom fields for "Series" (dropdown list populated by currently published Series) and Reading Order (a number). So conceptually, this is the code I think I need to do to display my Books Archive page:   1. WP_Query to select all custom-post-type-SERIES sorted by custom field GENRE;   2. For each GENRE, display Genre name if not different from previous Genre name;   3. Display SERIES name and description;   4. NEW query to select all custom-post-type-BOOKS with parent ID of current custom-post-type-SERIES, sorted by custom field READING ORDER;   5. When that query is done, display next SERIES name/description and repeat from 4;   6. When there are no more SERIES with current custom-field GENRE, display next GENRE name and repeat from 2. This seems like a ton of queries though. Before I go write all the code, can you tell me if there's a better way to either think about this or organize my content? Thank you so much!! Michelle


title: How to catch/what to do with a WP Error Object

text: I am running some of the WP functions directly inside a plugin, including wp_insert_post(), if something goes wrong, this returns a WP Error object, what is the correct method to catch this error? Either using built in WP functions or PHP exceptions or whatnot..


title: htaccess disable Wordpress rewrite rules for folder and its contents

text: I have another PHP application in a folder named `app` inside my Wordpress installation, and I need to disable all Wordpress rewrite rules for that folder and it's content. So that when I go to `www.domain.com/app` I get my application page, instead of the standard Wordpress 404 page. I know this is pretty basic apache rewrite rules, and i searched for this, tried some things and didn't work well. Almost forgot, i need to do this only by editing Wordpress htaccess file. And the app has it's own htaccess file. Thanks. **EDIT: htaccess content**               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      **EDIT: Application htaccess**               DirectoryIndex index.php     <FilesMatch "\.(php|inc)$">     Order allow,deny     deny from all     </FilesMatch>     <FilesMatch "(index.php|download.php)$">     Order allow,deny     allow from all     </FilesMatch>      These rules don't do much, they basically deny access to all `PHP` and `INC` file types, except `index.php` and `download.php`. Which are the ones the user needs to access, the rest of them are classes used internally by `PHP`. **EDIT 3: Resolution:** As it turns out, there was nothing wrong with the Wordpress `htaccess` or the application, after turning error reporting on remote hosting server, PHP reported a corrupted file, once replaced, all started to work well. My thanks to Wietse Venema for the suggestion.


title: upload files dynamically to user folders

text:
we have several users on our site. we have created a separate folder for each user. Admin have a select box to select users on the site. we have to give ability to upload files to that particular user on selection. I have created a hook to upload_dir. its working fine with the logged in user. but how to make it dynamic on admin panel. How make this work when admin selected an user in drop down menu and upload files to that user he selected.                   function custom_upload_directory( $args ) {             global $current_user;             get_currentuserinfo();             $base_directory = ABSPATH."user_documents/".$current_user->user_login;             $base_url = home_url()."/user_documents/".$current_user->user_login;             $args['path'] = $base_directory;             $args['url']  = $base_url;             $args['subdir'] = $current_user->user_login;             $args['basedir'] = $base_directory;             $args['baseurl'] = $base_url;return $args;         }         add_filter( 'upload_dir', 'custom_upload_directory' );      ![admin screen](http://i.stack.imgur.com/ldSLN.png) upon selecting a user from drop down i have to upload a file to his folder. dropdown code
         <form method="post" action="">
<?php echo "users: " ?>
             <select id="userselection" name="userselection">             <?php                 $blogusers = get_users('blog_id=1&orderby=login&role=subscriber');                 echo '<option value="" selected="selected"></option>';                 foreach ($blogusers as $user) {                     echo '<option>' . $user->user_login . '</option>';                 }             ?>             </select>             <INPUT TYPE="submit" name="submit" />         </form>


title: Caching-Plugins and Ajax-Page-Parts

text: I'd love to use »W3 Total Cache« for my Wordpress page. Caching the full page is really fasten up the site. But there is a lot of current community activity and most pages including some "latest comments" or "new notifications" parts (self made boxes in template, not sidebar widgets) How can i be sure that only these parts of the page are up to date while the rest can stay in cache as long as i don't empty it? Whats a good workaround? Building thoses Boxes with AJAX? Hope i could explain myself... thanks a lot.


title: Thousands of 404 errors on old posts due to embedded links

text: The number of 404 errors on the server has gone up drastically in the last 45 days (from 2000 to 9000). this is after I have made no changes to my permalink structure or .htaccess. the 404 pages are pointed to the older pages on the website - 2010/11 Several of these (majority) are - 1) the external links that are embedded into the wordpress posts are resulting in a 404 ex -               2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/www.whufc.com/      the above link is generated from the page www.thehardtackle.com/2010/premiership-forecast-title-race-hots-up-gunners- prepare-for-adebayor 2) Few pages on the website were published with special characters in the url ex-               ...thehardtackle.com/2012/arsenal-rewind-tactical-evolution-–-from-w-m-to-4-2-3-1-part-iv/      google webmaster shows 404 on the following -               /2012/arsenal-rewind-tactical-evolution-%25E2%2580%2593-from-w-m-to-4-2-3-1-part-iv/      but the link is resolved into this by chrome and firefox -               /2012/arsenal-rewind-tactical-evolution-%E2%80%93-from-w-m-to-4-2-3-1-part-iv/      I think something is resolving the url with special characters with a different code than it used to previously, which is why the older links result in a 404. 3) Google webmaster shows 404 on this -               http://www.thehardtackle.com/index.php/thehardtackle-exclusive-interview-%E2%80%93-carlton-chapman/      it resolves into ...hardtackle.../ **index.php** /thehardtackle-exclusive-interview----carlton- chapman which return a 404 it should ideally return ...hardtackle.../ **2011** /thehardtackle-exclusive... The problem here is that if the url does not have special characters index.php is correctly replaced by year name, but if the url has special characters index.php does not resolve into year name. Please help, I do not know how to fix this.


title: Exclude a specific category link from archive / front page

text: I create posts that are used just to create an index item to show an existing post has been updated. The post I create 301 redirects to the updated post. I add these index posts to the category 'Update' and this excludes the posts from the previous and next post links via a plugin (I couldn't find any other way). Problem is on the front page and archive pages the category each post is included in is displayed. I would like to exclude 'Update' category from these links as it is just for admin purposes. Can I add something to my functions.php file which will prevent all links to the 'Update' category archive page being displayed? Appreciate any guidance and apologies if this is covered already under a different term / search. I have looked.


title: Hide image if taxonomy term is empty

text:
So I have a Country taxonomy with the country names as terms. The country names are represented by clickable flags (png images) on a map. Now I only want to show flags for terms that have countries in them, so what I need is simply to hide the flags representing empty terms. I'm not a php developer, but here's an excerpt from the map's css:
     <img class="mapAdjust" src="<?php bloginfo('template_url'); ?>/img/map-adjust.gif" />         <img class="map" src="<?php bloginfo('template_url'); ?>/img/map.jpg" />
                 <a href="<?php echo home_url();?>/country/sweden" alt="Sweden" title="Sweden">                 <img class="flag" src="<?php bloginfo('template_url'); ?>/img/flags/sweden-flag.png" />

                 <a href="<?php echo home_url();?>/country/china" alt="China" title="China">                 <img class="flag" src="<?php bloginfo('template_url'); ?>/img/flags/china-flag.png" />

                 <a href="<?php echo home_url();?>/country/brazil" alt="Brazil" title="Brazil">                 <img class="flag" src="<?php bloginfo('template_url'); ?>/img/flags/brazil-flag.png" />       etc... Any ideas? Thank you!


title: Adding Custom JQuery Menu Fresh Slide Out

text:
TBH this is my first time doing as adding a custom `jquery` in a `wordpress` and i read like about 10-20 articles about it already and more i guess but there still something missing, so i did it like this, and please mention what Im doing wrong, and the jquery im adding is found here. Here is the snippet of what i want,

                                                                                About                             Learn about us and our services

      And here is the code I added into `function.php` in the `wordpress` theme, function my_custom_function() { wp_enqueue_script( 'jquery' );               wp_enqueue_style( 'style', get_template_directory_uri() . '/javascript/css/style.css' );          wp_register_script( 'jquery', get_template_directory_uri() .  '/javascript/jquery-1.4.2.min.js', array( 'jquery' ), false, true );      wp_enqueue_script('jquery'); } add_action( 'wp_enqueue_scripts', 'my_custom_function' ); I added this too in the `header.php` as I saw in the sample index.php of the slider its on the head so i assume it is needed,                     And this `php` snippet is where im getting my menu's,               <?php wp_nav_menu('menu=header_menu&container=false'); ?>      from all of this, i just wanted to know if what im doing wrong and now what i needed to do next, pretty much a newbie here in this jquery integration, just did this today. And in my mind the thing im missing too is in the last `php` code where i need to include the `id="menu"` but thats the thing too, how do i add it. And BTW has anyone successfully implemented the `Fresh Slide Out` please help me, even though im just learning I still need to successfully implement it to go to other jquery and try them out.


title: All Users > User List > Update User Meta Field Inline

text:
I am asking user few questions at the time of registration with checkboxes like In Registration form               [] I am blah blah     [] I am blan blah     [] I am blah blah      Now user will come for approval in admin panel, in pending state. I want to add above (Checkbox) in the listing user table. So Admin can change the data if he wants inline and as soon as click on approve data get saved in the database for that user. This is what i have tried.               function X_member_user_table( $columns ) {         $columns['dbem_X_member_f'] = 'Member';         $columns['dbem_X_delegate_f'] = 'Delegate';         $columns['dbem_X_sponsor_f'] = 'Sponsor';         return $columns;     }     add_filter( 'manage_users_columns', 'X_member_user_table' );          function X_modify_user_table_row( $val, $column_name, $user_id ) {         $column_value = get_the_author_meta($column_name,$user_id );         //return "<input type='checkbox' name='".$column_name_.$user_id."' value='".$column_value."' id='".$column_name_.$user_id."'/>";         //return "<input onclick='$(form).serialize();' type='checkbox' name='{$column_name}[]' id='{$column_name}_{$user_id}' class='$role'    value='{$user_id}' />";         $checkbox = '' . ''                         . "<input type='checkbox' name='{$column_name}[]' id='user_{$column_name}_{$user_id}' class='$role' value='{$column_value}' />";         return $checkbox;     }     add_filter( 'manage_users_custom_column', 'X_modify_user_table_row', 10, 3 );      I am able to get checkbox in the user table. Now the question is how to get the in `$GET` or `$POST` when user clicks on Approve link. This link is just redirecting the page and not submitting the page so i do not think it will come in post. I have created below method to get data in `GET` attributes. Do I need to use jQuery to build data in it?               function X_user_row_actions($actions, $user_object){         $current_user = wp_get_current_user();         $u = $user_object->ID;         if ( $current_user->ID != $user_object->ID ) {             /*if ( in_array( 'pending', (array) $user_object->roles ) ) {                 switch ( get_option( 'type' ) ) {                     case 'admin' :*/                         // Add "Approve" link                         $actions['approve-X-user'] = sprintf( '%2$s',                             add_query_arg( 'wp_http_referer',                                 urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),                                 wp_nonce_url( "users.php?action=approve&user=$user_object->ID&dbem_X_member_f=1", 'approve-X-user' )                              ),                             __( 'Approve with changes', 'theme-my-login' )                         );                         //break;                 //}             //}         }         return $actions;         echo "
";         print "X row";         print_r($actions);         print_r($user_object);         echo "
";         return $actions;         //exit;     }     add_filter( 'user_row_actions', 'X_user_row_actions' , 10, 2 );      However it is not working. Is there any hook to use when Approve is clicked, or change its status?


title: how to make a plugin call a class

text: i want to make a plugin that call a class when send a new post & publish it. my code is :               add_action('publish_post', 'send_post');     add_filter('publish_post', 'send_post');     function send_post($post_ID)     {         $meta_values = get_post_meta($post_ID, 'is_notified', true);         if ($meta_values != 'yes') {             $pub_post = get_post($post_ID);             global $wpdb;             $post_title = $pub_post->post_title;             if ($pub_post->post_status == 'publish') {                 if ($pub_post->post_type == "post") {                     $pluginName = 'bitly/bitly.php';                     if (is_plugin_active($pluginName)) {                         remove_all_filters('post_link');                     }                     if ($post_thumbnail_id != "") {                         $first_img = wp_get_attachment_url(get_post_thumbnail_id($post_ID));                     } else {                         $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postpp->post_content, $matches);                         $first_img = $matches [1] [0];                     }                     $content = $postpp->post_content;                     $title = $postpp->post_title;                     $content = preg_replace("/(<)([img])(\w+)([^>]*>)/", "", $content);                     $content = apply_filters('the_content', $content);                     $content = str_replace(']]>', ']]>', $content);                     $content = strip_tags($content);                     $content = html_entity_decode($content, "UTF-8");                     $title = preg_replace("/(<)([img])(\w+)([^>]*>)/", "", $title);                     $title = apply_filters('the_content', $title);                     $title = str_replace(']]>', ']]>', $title);                     $title = strip_tags($title);                     $title = html_entity_decode($title, "UTF-8");                     $title = substr($title, 0, 50);                     $des = substr($content, 0, 100);                     //publish post                      $my_var = new Myclass();                     $my_var->Setcontent($title, $des, $content, $first_img);                     if ($my_var->Send()) {                         $response = "ok";                     } else {                         $response = "Your server";                     }                     $time = time();                     $post_options = array(                         'postid' => $post_ID,                         'publishtime' => $time,                         'status' => $response . "TEXT"                     );                     update_option('post_logs', $post_options);                 }             }             if ($Rreturns) {                 add_post_meta($post_ID, 'is_notified', 'yes');             }         }     }      but my plugin never call my class.whay ? how to solve it?


title: How do I initiate imagesLoaded with Masonry in Wordpress 3.9?

text:
Im trying to style a grid using the built in Masonry in Wordpress 3.9. It works great, except that the grid fails to display correct at first pageload, but adjust on the second. I guess this is because I don't call in ImagesLoaded, and the grid calculates before the images are loaded. This is the site: http://www.skateflix.se To iniate Masonry I use this in Functions:               function my_masonry(){     wp_enqueue_script('masonry');     }     add_action('wp_enqueue_scripts', 'my_masonry');      I tried this to make ImagesLoaded to work, placed in the header:                     My HTML looks like this:               <div class="js-masonry"     <div class="feed-item"     <div class="feed-item"     <div class="feed-item"     <div class="feed-item"
      What am I doing wrong here?


title: Wordpress wp-ffpc + memcached + nginx

text: Seem to be having issues with the centmin build, nginx + memcached with wordpress and wp-ffpc plugin. When I have the plugin active. The site doesn't load, just get a white screen, memcached is running and it is able to connect. Site loads fine without the plugin active. While checking the php-fpm logs I can see the below               26-Jul-2014 01:04:42 UTC] PHP Warning:  Invalid argument supplied for foreach() in     /home/nginx/domains/blog.example.com/public/wp-content/themes/jeffsrowe/Flavour/class-flavour-helpers.php on line 14     26-Jul-2014 01:04:42 UTC] PHP Fatal error:  Call to a member function get() on a non-object in /home/nginx/domains/blog.example.com/public/wp-includes/cache.php on line 113      Thanks in advance


title: Is there a Wordpress Plugin like Imsanity that keeps high resolution originals?

text: I'd like to show lower resolution photos on blog posts and their previews on the main page, but when clicked upon, they should still link to the full resolution version. Is there a plugin to do that automatically?


title: Add custom column to Users admin panel

text: There is default 5 columns named Username Name Email Role Posts in USERS. Now I want to add one more column with his contact number. How can I achieve this?? ![Here where black box is shown](http://i.stack.imgur.com/rA75R.png)


title: What does this number represent in JetPack stats?

text: ![enter image description here](http://i.stack.imgur.com/UQv0a.png) When signed into my blog, this graphic is up on top. I know it shows visitor pattern over 48 hours, but does anyone know what the number represents? I searched on the WP site, and am not finding this.


title: BbPress Register Page in Breadcrumbs

text: For some reason, the Forums Register page in bbpress plugin is appearing in the breadcrumb, take a look: http://putonthestand.com/forums/topic/let-the- dead-bury-the-dead/


title: Sortable custom field values from all posts on a page template

text:
I was looking for a way to display a list of custom field from across all the posts on a custom made page template and I got the solution in this thread,. As all the custom field values are strings only, I need the list to **display in an alphabetical order**. Is it possible ? Given is the code I am using currently that fetches me a nice unordered list, that gets the work done. If this is possible, Please suggest the change in code.               <?php     function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {         global $wpdb;         if( empty( $key ) )             return;         $r = $wpdb->get_col( $wpdb->prepare( "             SELECT pm.meta_value FROM {$wpdb->postmeta} pm             LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id             WHERE pm.meta_key = '%s'              AND p.post_status = '%s'              AND p.post_type = '%s'             ", $key, $status, $type ) );              return $r;     }     ?>     <?php $my_list_items = get_meta_values( 'full_name' ); ?>
Display a list of custom values :

             <?php foreach($my_list_items as $my_list_item) {                 echo '
' .$my_list_item. '
';                 } ?>


title: Insert Array in Plugin Database

text: trying to create one plugin, getting some issue to submit the array data in wordpress database. $formDATA gets the array value now issue is when                   $sql = "INSERT INTO `".$table_name ."` (`paid_arr`) VALUES '".$formDATA."'";             $result  = $wpdb->insert($table_name,$formDATA);      getting strange warnings and errors not able to insert data in wp DB.                 Warning: array_keys() expects parameter 1 to be array, string given in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1316           Warning: Invalid argument supplied for foreach() in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1318            Warning: implode() [function.implode]: Invalid arguments passed in /home3/mahesh/public_html/project/lal/wp-includes/wp-db.php on line 1327      here is php code;               $formDATA = array(         'fname'     => $fname,         'lname'     => $lname,         'email'     => $paidemail,         'Phone'     => $paidphone,         'gender'    => $gender,         'hobbies'   => $interest,         'hear'      => $city,         'message'   => $message_field,         'time'      => $curtime      );          formsubmitpaid($formDATA);                 function formsubmitpaid( $formDATA ) {          global $wpdb;     $formDATA = json_encode($formDATA);     $table_name = $wpdb->prefix . "padi_forms";     $sql = "INSERT INTO `".$table_name ."` (`paid_arr`) VALUES '".$formDATA."'";     $result  = $wpdb->insert($table_name,$formDATA);          if( !$result ){         echo '<script>alert("dfdf")</script>';     } else {         echo '<script>alert("No")</script>';      }     print_r($sql);     print_r($result);          }


title: How can an author be subscribed to the posts of another author and receive notifications of the new posts?

text: What I'm trying to achieve is to implement a function that will enable an author, when registered and browsing the front-end, to have the option of following other authors of the site and receiving notifications via a front end message when the followed authors post. Is this something that can be achieved with WordPress?


title: How do I create my own nested meta_query using posts_where / posts_join?

text: Some of my posts (not all) have a price as a meta key/value. Today I use the `pre_get_posts` action so that my users can search for prices that are between a certain value. This is the code that I'm using today, and it's working.               add_action('pre_get_posts', 'my_search_price');     function my_search_price( $query ) {         if ($query->get('maxprice') != "" && $query->get('minprice') != "" && $query->is_main_query()) {                  $maxprice = intval($query->get('maxprice'));             $minprice = intval($query->get('minprice'));                  $meta = array();             $meta[] =              array (                 'key' => 'price',                 'value' => $maxprice,                 'compare' => '<=',                 'type' => 'numeric'             );                  $meta[] =              array (                 'key' => 'price',                 'value' => $minprice,                 'compare' => '>=',                 'type' => 'numeric'             );                  $meta[] =              array (                 'key' => 'price_updated',                 'value' => time()-(60*60*24*14),                 'compare' => '>',                 'type' => 'numeric'             );                  $query->set('meta_query', $meta);         }     }      My problem is that some of the posts now have a second price, also stored as a meta key/value. The name of the new price is "price_used" and this price has its own updated key/value named "price_used_updated". I would like to modify the function `my_search_price()` so that it also handles the new price. The result should be posts where "price" OR "price_used" is between minprice and maxprice. "price_updated"/"price_used_updated" should be max 14 days old. As I understand from reading some other posts, meta_query cannot be nested. So I need to modify the SQL instead using the posts_join or/and posts_where filter. Can someone please point me in the right direction to the solution please? I'm guessing I'm not the first one that needs a more advanced meta_query. But I have never modified the SQL-query before. What I have done is reading these these pages:   * Nested Meta Query with Multiple Relation Keys - WPSE Thread   * **WordPress Codex:** Custom Queries UPDATE: The result query should look like this:               SELECT SQL_CALC_FOUND_ROWS wp_posts.*, mtGP2.meta_value, mtAM2.meta_value     FROM wp_posts          INNER JOIN wp_postmeta AS mtGP1 ON (wp_posts.ID = mtGP1.post_id)     INNER JOIN wp_postmeta AS mtGP2 ON (wp_posts.ID = mtGP2.post_id)          INNER JOIN wp_postmeta AS mtAM1 ON (wp_posts.ID = mtAM1.post_id)     INNER JOIN wp_postmeta AS mtAM2 ON (wp_posts.ID = mtAM2.post_id)          WHERE 1=1          AND wp_posts.post_type = 'post'     AND wp_posts.post_status = 'publish'          AND     (     (mtGP1.meta_key = 'price' AND CAST(mtGP1.meta_value AS SIGNED) BETWEEN 1 AND 10     AND mtGP2.meta_key = 'price_updated' AND CAST(mtGP2.meta_value AS SIGNED) > NOW()-60*60*24*14)     OR     (mtAM1.meta_key = 'price_used' AND CAST(mtAM1.meta_value AS SIGNED) BETWEEN 1 AND 10     AND mtAM2.meta_key = 'price_used_updated' AND CAST(mtAM2.meta_value AS SIGNED) > NOW()-60*60*24*14)     )     GROUP BY wp_posts.ID      But this query has two problems. 1) It is very slow 2) I still have a problem, because I don't know how implement the query in wordpress. I think I need to use the post_where and posts_join filters, but I'm not sure how. UPDATE 2. I've rewritten the query so it is no longer slow. But I still don't know how to use filters or actions (like in my original my_search_price() function) to implement the query in wordpress.               SELECT SQL_CALC_FOUND_ROWS *       FROM     (     SELECT wp_posts.*     FROM wp_posts     INNER JOIN wp_postmeta AS mtGP1 ON (wp_posts.ID = mtGP1.post_id)     INNER JOIN wp_postmeta AS mtGP2 ON (wp_posts.ID = mtGP2.post_id)     WHERE 1=1     AND wp_posts.post_type = 'post'     AND wp_posts.post_status = 'publish'     AND mtGP1.meta_key = 'price'     AND CAST(mtGP1.meta_value AS SIGNED) BETWEEN 1 AND 10     AND mtGP2.meta_key = 'app_updated'     AND CAST(mtGP2.meta_value AS SIGNED) > UNIX_TIMESTAMP()-60*60*24*14     GROUP BY wp_posts.ID          UNION          SELECT wp_posts.*     FROM wp_posts     INNER JOIN wp_postmeta AS mtGP1 ON (wp_posts.ID = mtGP1.post_id)     INNER JOIN wp_postmeta AS mtGP2 ON (wp_posts.ID = mtGP2.post_id)     WHERE 1=1     AND wp_posts.post_type = 'post'     AND wp_posts.post_status = 'publish'     AND mtGP1.meta_key = 'price_used'     AND CAST(mtGP1.meta_value AS SIGNED) BETWEEN 1 AND 10     AND mtGP2.meta_key = 'price_used_updated'     AND CAST(mtGP2.meta_value AS SIGNED) > UNIX_TIMESTAMP()-60*60*24*14     GROUP BY wp_posts.ID     ) AS t


title: Issues with Post 2 Post Plugin

text: I am trying to create connections between some of my posts. I have pairs of posts that need to go together (post with a quiz). I found the Post 2 Post plugin, which seems perfect for what I need. I have installed the plugin, but whenever I add the following code to my theme's functions.php file I get a white screen whenever I try to save a page on the admin side (it still saves, but I get a white screen).               <?php     function my_connection_types() {       p2p_register_connection_type( array(         'name' => 'posts_to_quiz',         'from' => 'post',         'to' => 'quiz'       ) );     }     add_action( 'p2p_init', 'my_connection_types', 100 );     ?>      I switched themes and it corrects itself, so I know it is an issue with the theme, but not sure where to start debugging. I am using the Bones framework, but have made some changes (not much to the functions.php file though). Any ideas would be much appreciated.