title: Get last post in category thumbnail

text: I want make a button to filter posts from a specific category, But also i would like this button to display the featured image of the latest post in that category. I'm completly new to php and wordpress, but i tought maybe using the `get_category` and `get_thumbnail`functions may be a good way to go. What do you guys think? I am sorry for the vagueness, but I am a little lost about this. Thanks for any hints in advance!


title: Confusion about arguments sent to add_image_size

text: Looking at the documentation for Cropping Thumbnails when adding new image- sizes makes me confused. > Set the image size by cropping the image and defining a crop position: > > add_image_size( 'custom-size', 220, 220, array( top, left ) ); // Hard crop > top left > > When setting a crop position, the first value in the array is the x axis > crop position, the second is the y axis crop position. > > x_crop_position accepts 'left' 'center', or 'right'. y_crop_position accepts > 'top', 'center', or 'bottom'. By this `array(top, left)` wouldn't be "allowed" because top is only allowed by y-crop position ?


title: Could Wordpress be used/extended as a medium-size ecommerce site?

text: Is wordpress reliable enough and could it be used with a proper plugin as a medium sized ecommerce site? We are talking around 1500 products here, estimates say around 5 to 10 costumers per day, usually returning ones. Some days none. I have a client who wants to sell online. We are situated in a country where people dont see web as something serious enough. Still, they literally have a budget of pretty much **none**. And 1500 products to sell online. Magento, or any other open source ecommerce platform are out of the question, there is just no resources for starting something like that. Or any time. Only way is something **free** , **small** , absolutely **not resource hungry** as Wordpress. I have to fight with making it work with only what i have at disposal. Also, if you can recommend any wordpress plugin for the job(WP-ecommerce?), i will be very thankful. I guess something paid, up to maximum 50$ would work too.


title: Allowing logged in users to comment without moderation across a multisite installation

text: I currently do web admin for an internet community based on BuddyPress and Multi Site, and use the `Comment author must have a previously approved comment` setting to make it easier for users to comment and not be moderated. All users are vetted before their accounts are created so I know we don't have spambots. However it does not quite behave as I wish it to and I wonder if there is a way to achieve what I want. Ideally what I'd like is for:   1. All logged in users to be able to comment anywhere on the multi-site without moderation that they have right to comment on, unless the owner of the subsite has ticked 'An administrator must always approve the comment'   2. For non-logged in comments to always be approved if they've ever been approved anywhere on the multi-site. (Currently it only works if the new comment is on a post by the same author on the same site they were previously approved on)  Is this possible using existing settings or plugins? If not can it be achieved another way and if so how?


title: Add a filter to a different custom plugin

text: Someone has built a custom plugin that adds a textarea on the admin/edit page, and a div on the pub page. I no longer have access to the person who built the custom plugin. I have created a filter for the main page content by doing something like this:               function getHappy($content) { //goofy example         str_replace(":)", "=^..^=", $content);         return (is_single()) ? $content : $content;     }          add_filter('the_content', 'getHappy');      Where `the_content` is the hook for the main page content. How can I go about finding out what the hook for a plugin is? If it doesn't have one, is there a way to add one? The problem is I am pulling live content with the filter, which means I cannot retrieve the data stored by the plugin, then alter it. It needs to be a 'live' filter. Am I looking at this the wrong way? In this case is `the_content` not even used, but `$content` is? If it is the latter, is it as simple as finding the variable that holds the custom content? These may be broad questions, but I hope the answer is fairly simple. I am trying to do this in a way that won't break every time I update WP. Cheers, Bo


title: What does this PHP function code mean?

text: Can someone please help me to understand each part of this code? Can you comment every line so I can understand and custom the code accordind to my purpose. Here is the link in pastebin:               class Towfiq_Person {         static function on_load() {             add_action('init',array(__CLASS__,'init'));             add_action('wp_insert_post',array(__CLASS__,'wp_insert_post'),10,2);             add_action('profile_update',array(__CLASS__,'profile_update'),10,2);             add_action('user_register',array(__CLASS__,'profile_update'));             add_filter('author_link',array(__CLASS__,'author_link'),10,2);             add_filter('get_the_author_url',array(__CLASS__,'author_link'),10,2);      }      The rest of the code at this link :pastebin.com/30GCNhLv many thanks **UPDATE 1 :** 1st part up understood, what about this part.what does each line does i mean in human language;                static function get_email_key() {          return apply_filters( 'person_email_key', '_email' );      }      static function profile_update($user_id,$old_user_data=false) {          global $wpdb;          $is_new_person = false;          $user = get_userdata($user_id);          $user_email = ($old_user_data ? $old_user_data->user_email : $user->user_email);          $email_key = self::get_email_key();          $person_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta}      WHERE     meta_key='%s' AND meta_value='%s'",$email_key,$user_email));          if (!is_numeric($person_id)) {              $person_id = $is_new_person = wp_insert_post(array(                 'post_type' => 'towfiq-person',                 'post_status' => 'publish',   // Maybe this should be pending or draft?                 'post_title' => $user->display_name,             ));         }         update_user_meta($user_id,'_person_id',$person_id);         update_post_meta($person_id,'_user_id',$user_id);         if ($is_new_person || ($old_user_data && $user->user_email!=$old_user_data-   >user_email)) {             update_post_meta($person_id,$email_key,$user->user_email);         }     }


title: Multisite Plugin - Access options (wp_options) on child sites

text: Is there a way I can access the `wp_options` table of all the child sites? I want to create a multisite plugin that can be setup at the network level and will populate the child site plugins with defaults that can then be overwritten by the each individual site. I'm aware that I could read/write from `wp_sitemeta` this way, but in my instance, it would make sense if I could access the other "local" tables. I could probably write a custom query using the WP query function, but I was wondering if there was a better way?


title: PHP library that can merge stylesheet with inline style

text:
I am working with html document generated from Micrsoft Word 2007/2010. Besides generating incredibly dirty html, word also has the tendency of using both block and inline style. I am looking for a php library would merge block into already existing inline style element. I have html converted from Word and will be sending them through XMLRPC. The php library will is need to merge stylesheet with in-line style so the format is preserved. I want to make the call to this library **after the request is received by XMLRPC** and before it reaches the kses filter so the style block is not stripped off. **Example** If the original html is:
         Lorem ipsum dolor sit amet, consectetur adipiscing elit.      In ut erat id dui mollis faucibus. Mauris eu neque et eros tempus placerat.      Nam in purus nisi, vitae dictum ligula.      Morbi mattis eros eget diam vulputate imperdiet.      Integer a metus eros.      Sed iaculis porta imperdiet.
                        Should become:
         Lorem ipsum dolor sit amet, consectetur adipiscing elit.          In ut erat id dui mollis faucibus. Mauris eu neque et eros tempus placerat.          Nam in purus nisi, vitae dictum ligula.          Morbi mattis eros eget diam vulputate imperdiet.          Integer a metus eros.          Sed iaculis porta imperdiet.
                        **Goal** The end goal is to be able to preserve all style and formatting from a Word generated HTML file and send it to wordpress, where it can be edit by TinyMCE. If there is an **alternative** to what I am describing (must be done on the server side), I am welling to accept it as the answer as well.


title: How do I find the first item in the post array?

text:
I left ????? where I need the answer.               <?php          global $post;          $the_post_ID = $post->ID;          $n = get_posts();     ?>               <?php foreach ( $n as $post ) : ?>
         <li<?php if (?????) echo ' class="current"'; ?>>             <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten`enter code here`' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

          <?php endforeach; ?>


title: Modifying a Loop to Show More

text:
This loop shows one featured post above 4 post titles from a certain category that is specified in the theme options. What I would like to do is show all 4 posts from the 4 titles, above the 4 titles. The 4 titles are from this snippet of code               <a class="listtitle" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpnewspaper' ), the_title_attribute( 'echo=0' ) ); ?>" ><?php the_title(); ?>      The full loop code is here.
     <?php gab_dynamic_sidebar('Subnews1');?>          <?php     $postnr = of_get_option('of_wn_nr8') + of_get_option('of_wn_nr8a');     if (intval($postnr) > 0 ) { ?>         <a href="<?php echo get_category_link(of_get_option('of_wn_cat8'));?>"><?php echo get_cat_name(of_get_option('of_wn_cat8')); ?>         <?php         $count = 1;         $args = array(          'post__not_in'=>$do_not_duplicate,           'posts_per_page' => $postnr,           'cat' => of_get_option('of_wn_cat8', 1)         );         $gab_query = new WP_Query();$gab_query->query($args);          while ($gab_query->have_posts()) : $gab_query->the_post(); if (of_get_option('of_dnd') == 1) { $do_not_duplicate[] = $post->ID; }         ?>         <div class="featuredpost<?php if($count == of_get_option('of_wn_nr8') or $count == $postnr) { echo ' lastpost'; } ?>">                       <?php if ($count <= of_get_option('of_wn_nr8')) { ?>
                     <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpnewspaper' ), the_title_attribute( 'echo=0' ) ); ?>" ><?php the_title(); ?>

                 <?php                     gab_media(array(   'imgtag' => 1,   'link' => 1,                         'name' => 'wn-subnews',                         'enable_video' => 0,                         'catch_image' => of_get_option('of_catch_img', 0),                         'enable_thumb' => 1,                         'resize_type' => 'c',                         'media_width' => 120,                          'media_height' => 103,                          'thumb_align' => 'alignleft',                         'enable_default' => 0                     ));                 ?>

<?php echo string_limit_words(get_the_excerpt(),27); ?>…
                      <?php gab_postmeta(); ?>             <?php } else { ?>                      <a class="listtitle" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'wpnewspaper' ), the_title_attribute( 'echo=0' ) ); ?>" ><?php the_title(); ?>                  <?php } ?>
         <?php $count++; endwhile; wp_reset_query(); ?>     <?php } ?>


title: How to Display Frontend CSS for Administrator only

text: I've been asked to restyle the css of a WordPress website frontend. The website can't be in maintenance mode while working on it as it must stay up and running all the time. I assume that if I can add a small and unobtrusive condition in the header allowing the administrator to see a different css file than the users, I could edit the css and test the result while the users still see the original version of the website. This way I could work on the design without anyone noticing. Can anyone tell me which WordPress function I should call on the header to switch the css file if and only if the user is an administrator? The best would be not to edit the "functions.php" file or activate any plugin as I really don't want to mess with the website as it is (few chances but chances anyway). I would rather edit the "header.php" file in the theme folder in order to be sure nothing bad happens. Thank you.


title: wordpress css file

text: i made a website by wordpress and i uploaded it to ftp file > public html my problem is that i made a css file that include all the other css files but when i tested the website i found that the wordpress didnt see the it saw only the first one what should i do to make the website see my files this is what is incuded in css file should i add url('wordpress/webcontent/....') or there is another way ?? > style.css               @import url('/styles/forms.css');     @import url('/styles/tables.css');     @import url('/styles/homepage.css');     @import url('/styles/reset.css');     @import url('/styles/stimenu.css');     @import url('/styles/layout.css');     @import url('/styles/demo.css');


title: add custom HTML css with js doesn't work

text: I am using latest Wordpress 3.6. I'd like to add some HTML code to the page using js. I put a               <script>               $('p.content').addClass('highlight');           </script>      in the head are, but it doesn't work. So I want to add the class highlight to a p element with calss=content. the reason I want to use it, is to change the_content output in wordpress. I just want the text inside of ... I would also love to understand how I could change this with e.g. the functions.php... thanks.


title: Hide certain pages / posts on wp-admin, show custom filter

text: I'm integrating a separate ecommerce CMS into a wordpress theme, using page templates for some pages such as the basket, search and checkout pages. This is working out pretty well so far. However, there are a couple of dynamic pages that I'd normally make a single-posttype.php template for, but can't as in this case I can't because Wordpress doesn't 'know' about them, as the data is coming from the ecommerce CMS. For example, the product details page or a product category search page. My solution was to create a template called product-details and make a page for it. In this template, the actual wordpress page data is ignored and the data is instead read from the ecommerce CMS. My gut feeling is that this is not best practice however short of writing a full wordpress plugin integration of the ecommerce system, it's the best I could come up with. **TL;DR** The problem this leaves me is that if an admin were to delete that page, or unassign the template, the shop would break. So, I'd like to hide these pages to help prevent accidental deletion or editing (page content doesn't matter for them). Is there a way to hide some pages from the 'All Pages' menu in wp-admin, unless a custom filter (e.g 'System Pages') is clicked?


title: How to stop direct HTTP POST to a PHP script?

text: I have a form on my site, created using Contact Form 7 with Captcha. Contents of the form when POSTed are being sent to a PHP script, the "action" attribute of the form is set to `themes/<themename>/<filename>.php` We have been receiving a lot of spam, it seems that someone can handcraft the form and use it to send spam. In the processing script I check the `HTTP_REFERRER`, `HTTP_SERVER` to see if the request came in via our site, but those headers can also be manually crafted in. What steps do I need to undertake to stop the spam coming in? Help is appreciated. **EDIT** : Some more clarity. CF7 will POST the form data to my script at http://www.example.com/wp-content/themes/themename/script.php , that script is accessible . Someone can go to the page where my form is and copy the HTML, re-create the form on their local machine and start submitting the form to my script. How do I stop that?


title: site_url is not honoring scheme

text: I'm using site_url() for my href for anchors. I want to control what when I send the user to a secure page or non secure page. I thought I could do that with site_url('/foo', 'http') and site_url('/bar', 'https') but the scheme is not changing. If I'm on a secure page and site_url('/foo', 'http') is set, the clicked page is still secure instead of non-secure.


title: Import post from Tumblr to Wordpress

text: > **Possible Duplicate:**   >  Moving the blogs from Tumblr to Wordpress Do know any way to import post from tubmlr to wordpress? I have tried this http://www.tumblr2wp.com/ but it only imported 1 post and I have about 20 plus posts. Need your help on this as soon as possible please Thanks


title: Where should I store global data for my multi-site WordPress plugin?

text: I wrote a plugin for WordPress which has a few user-configurable settings that are stored using WordPress's suggested method. I know they are saved in the wp_options table, but that is abstracted by the WordPress options API. Now I'm trying to add a "global override" of the settings that can be configured in the Network Admin section of a multi-site installation. I found the appropriate hooks to design my settings page, however I can't find any info about where to save the data. If I save it using the normal options API, then the settings get saved individually for each site. I'm looking for a place to save them globally for all sites, so the plugin can first look to see if the settings have been globally overridden by the server admin. I can just write some code to write directly to the wp_options table of one of the sites (for example site #1) or even create my own table. I know how to do all of these things, but I don't want to do that if there's a preferred way to write mult-site plugins. Thanks for any advice.


title: ID of parent Menu

text:
I'm trying to assign a different ID to each sub-menu wordpress generates using the wp_nav_menu function. As it is, wordpress assigns the same class (sub- menu) to every sub menu generated.

      I'd like to have it generate something like:

      I have a custom walker in my theme function file in order to modify the output, but I have no idea how to get, say the ID of the parent menu item and assign it to the UL output. Any help is appreciated! _edit_ Walker's below:               /**Custom walker**/     class description_walker extends Walker {     var $tree_type = array( 'post_type', 'taxonomy', 'custom' );     var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );     function start_lvl(&$output, $depth) {         $indent = str_repeat("\t", $depth);         $output .= "\n$indent
\n";     }     function end_lvl(&$output, $depth) {         $indent = str_repeat("\t", $depth);         $output .= "$indent
\n";     }     function start_el(&$output, $item, $depth, $args) {         global $wp_query;         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';              $class_names = $value = '';              $classes = empty( $item->classes ) ? array() : (array) $item->classes;         $classes[] = 'menu-item-' . $item->ID;              $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );         $class_names = ' class="' . esc_attr( $class_names ) . '"';              $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );         $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';              $output .= $indent . '
';              $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              $item_output = $args->before;         $item_output .= '';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;         $item_output .= '';         $item_output .= $args->after;              $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }          function end_el(&$output, $item, $depth) {         $output .= "
\n";     }     }


title: Sharing templates with the JSON API?

text: Is there any way to share 'templates' between JS and Wordpress? For instance, this sort of modest seat-of-the-pants templating feels ok:               var AJAXSuccessFunc = function(data){ // calling this on ajax.success          var title = data.page.title;         var content = data.page.content;         var string = '<h1>' + title + '</h1>' + content;         targetDiv.html(string).fadeIn();      }      But given that content might appear in this manner, or via conventional WordPress PHP templates, it's a bit worrying that I might have to maintain two basically identical templates for JS and PHP. Especially when there are more than a few HTML tags present. I want to standardise and centralise everything! What are my options?


title: Using WordPress as a Framework

text: I'm quite familiar with WordPress, but have just minimal experience with PHP frameworks such as Codeigniter. When building a custom application, say for example an invoicing system or time management app for my company, does it make sense to use WordPress as a framework, or would it be more advisable to use something like Codeigniter? What are the main differences in these two approaches?


title: Category archive by year with permalink support /category/YYYY

text: I am currently looking at creating a new type of site archive within WordPress that allows users to filter by category AND by year rather than the default category OR year. I am hoping to build a sidebar widget that creates the interface but I am looking for ideas and advice on creating the custom permalink setup. Ideally the archive will work with URLs along the lines of: /category/year/ /category-1/year/ etc. I have no requirement to filter any deeper than year. I have discovered this snippet of code but it does not work as expected. Thanks


title: why plugins are loaded prior to pluggables

text: ![WP URL call](http://i.stack.imgur.com/YmJTI.png) I got this image from one E-book for WP plugin development. Could you please clarify me why the Plugins are loaded before Pluggables.


title: Set template for custom post type?

text: Is there a way to add the template selection dropdown to the custom post type? Perhaps under Page Attributes?


title: wp_ajax handler with multiple class instances

text: Eight months ago I asked nearly the same question over there. But the Problem is still not solved so far. But I have an additional ideaa why it is failing. In the meantime my code advanced. I have multiple classes which all have the same structure:               <?php     class McCustomPost { ... }     $wpMcCustomPost = new McCustomPost();     ?>     ...     <?php     class McAdmin { ... }     $wpMcAdmin = new McAdmin();     ?>      and then I have my "starter" file which requires all files and has the plugin header:               <?php     /*     Plugin Name: MC 2.0     Plugin URI: ...     Description: ...     Version: 0.0.75     Author: ...     Author URI: ...     License: GPL2     */          define( 'MC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );          require_once( MC_PLUGIN_DIR . 'class.mc.php'               );     require_once( MC_PLUGIN_DIR . 'class.mc-admin.php'          );     ...     require_once( MC_PLUGIN_DIR . 'class.mc-custom-post.php' );          register_activation_hook( __FILE__, array( 'Mc', 'plugin_activation' ) );     register_deactivation_hook( __FILE__, array( 'Mc', 'plugin_deactivation' ) );          $wpMc = new Mc();     ?>      During the `require_once` the admin and custom post classes getting properly instantiated. But when I fire an ajax request from the admin class the request is newer returned. It reaches the JS file but after that the callback is not called, I guess it's not found.               <?php     class McAdmin {         protected $pluginPath;         private $dbHandler;                public function __construct()  {             $this->pluginPath = dirname(__FILE__);                  add_action( 'admin_enqueue_scripts', array( $this,'add_admin_scripts') );              add_action( 'wp_ajax_blubb', array( $this, 'add_vehicle' ) );           }              public function add_admin_scripts( ){             wp_enqueue_script( 'admin_scripts', plugins_url( 'js/functions.admin.js', __FILE__ ),   array('jquery') );                  // wp_localize_script('admin_scripts', 'ajax_var', array(               // 'nonce' => wp_create_nonce( 'ajax-nonce' )               // ) );         }              public function add_vehicle()           {               // $nonce = $_POST['nonce'];                    // if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )               //     die ( 'Busted!');                  $title = $_POST['id'];             wp_die("Post Id: " . $title);             exit;           }     ...     }     $wpMcAdmin = new McAdmin();     ?>      My JS file - the success callback is not executed...               $('.add-vehicle').click(function(){             var data = {                 action: "blubb",                 // nonce: ajax_var.nonce,                 id: 1             };                  $.post(                 ajaxurl,                 data,                 function( response ) { //on success                     alert('Server response from the AJAX URL ' + response);             });     });      I assume, that during the institution of `McAdmin()` class inside `Mc()` the callback don't know where to go back. How can I get my callback in the correct class instance (`McAdmin()`)? Thanks & BR, mybecks


title: how can I set the post author of a post I just created with php?

text: I'm using php to dynamically create a custom post, and I need the author to be someone other than the logged in user. I found this http://stackoverflow.com/questions/5759359/wordpress-manually-set-the-author- of-a-post-in-php but I'm wondering if there is a way to do it after the post is already inserted. I guess I could just do a db query...


title: How to display sticky post with custom html

text:
I'd like to display 9 posts and be able to insert a sticky post with its custom html template in between 4th & 5th post. Currently the sticky post gets displayed in both the "sticky container" and regular posts. have_posts()) : $my_query->the_post(); ?>               <?php if ($count <= 9 ){ ;?>
           <?php echo get_the_content(); ?>
              <?php if ($count == 3) {             $sticky = get_option('sticky_posts');             $args = array(                 'posts_per_page' => 1,                 'post__in'  => $sticky,                 'ignore_sticky_posts' => 1             );             query_posts($args);                  if ( have_posts() ) : while ( have_posts() ) : the_post();                      if($sticky[0]) { ?>

CUSTOM HTML
                     <?php echo get_the_content(); ?>
                 <?php                 }                  endwhile; else:             endif;             wp_reset_query();              }?>     <?php } $count++; ?>     <?php endwhile; ?>


title: Multisite installation on an existing single installation

text: How to create a blog in a sibling directory of an already installed WordPress directory? The domain is `example.com` and there is an existing installation in `blog` directory and the root directory at `example.com/` is free. Is it possible to create a blog at `example.com/anotherblog/` through multisite instead of `example.com/blog/anotherblog/`? On a new installation at the root this can be achieved by simply installing WordPress at the root and having two multisite blogs in two directories. However, that is total of 3 blogs(including the one at the root). Can the same be achieved without the 3rd blog and keep the root free?


title: Countdown Widget

text: Can someone recommend me a nice countdown widget plugin for Wordpress? I've been using the Countdown widget under Blogger and it's exactly what I need. A simple number from now until date or from date. I can't seem to find a very simple, easy countdown that does the same thing in Wordpress.


title: Prevent duplicate posts in wp_insert_post using custom fields

text: My source links are something linke this :               http://sample.com/entertainment/default.aspx?tabid=2305&conid=102950     http://sample.com/entertainment/default.aspx?tabid=2418&conid=104330     http://sample.com/entertainment/default.aspx?tabid=2429&conid=104264     http://sample.com/entertainment/default.aspx?tabid=2305&conid=102949     .     .     .      I cache content form links.I use wp_insert_post to post cached content from source site to wordpress:                $my_post = array(     'post_title' => "$title",     'post_content' => "$content",     'post_status' => 'draft',     'post_author' => 1,     'post_category' => array(1),     );      wp_insert_post( $my_post );      I want to put each link in custom fields and in the next cache , before post to WP , check new links with links in custom fields. If link is repeated , prevent insert content. Sorry for my bad description.


title: WP Page Navi Not Working in my Custom Query - Events Page Only

text:
I'm using the same custom wpquery format in my NEWS page. And my pagination uses `WP PAGE NAVI` plugin. It does work on my `NEWS PAGE` but doesn't work on my `EVENTS PAGE`. Plugins used:               1. WP PAGE NAVI     2. EVENTS MANAGER      **Problem:** When I click page 2 or next page. The page becomes `404`: Here's my code:               <?php      global $wp_query;      $old_query=$wp_query;      $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;      ?>           <?php $wp_query = new WP_Query(array( 'post_type' => 'event', 'posts_per_page' => 3, 'paged' => $paged ));  ?>           <?php while($wp_query->have_posts()) : $wp_query->the_post(); ?>           <?php $EM_Event = em_get_event($post->ID, 'post_id'); ?>

<?php echo get_the_date('d'); ?>

<?php echo get_the_date('M Y'); ?>

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

 Time: 10:AM to 12:00PM

 Location: <?php echo do_shortcode('[locations_list]'); ?>

           <?php endwhile; ?>           <?php wp_pagenavi(); ?>           <?php wp_reset_postdata(); wp_reset_query(); ?>           <?php $wp_query=$old_query;?>      Also I'm not sure if I have to post this as a separate question. I can't seem to pull out the start and end time of my event in my loop: As of now it has static start time and end time in there.


title: How do you modify CSS files via admin panel?

text: All theme styles are in style.css file. Let's say first line looks like:               body {         background-color: #fff;     }      Now, I've created an option in admin panel named body_bg. User types #000 there and I want the value in style.css to change. How do I achieve that? The easiest way to me looks like I have to rename style.css to .php, and just do:               <?php header("Content-type: text/css"); ?>          body {          background-color:  <?php echo get_option('body_bg');?>   ;         }      And then just link style.php in empty style.css file. It's perfectly valid and works, but I've never seen a theme with style.php file, so how do people modify their stylesheets dynamically?


title: Restrict CSS on one page

text: I have my site: http://theapkstore.com . On the homepage I've added a slider. And reduced the top margin of widget which says "Welcome to my site". The homepage looks fine but then when I open any one the link from the navbar then on that page I see that the top margin is acting on all the pages which causes the widget to devastate the design. Can you please tell how can I only put the top margin of that widget on the homepage?


title: Paging result of get_posts in function

text: I have created a function to use as a shortcode to allow me to display a specific post type on my page. The function works well, but I would like to the results to be paged, and the navigation only to appear if needed. her is my current code               extract(shortcode_atts(array("country" => '' ), $atts));     $country = preg_replace('~*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $country );       $argsq = array ('post_type' => 'quote',                         'country' => $country,                     'orderby' => 'meta_value'                    );               $testim= get_posts($argsq );     $output = '';     foreach ($testim as $testim_post){          $output .= "";     $output .= " **".$testim_post->post_content."**        ";     $output .= $testim_post->post_title;     $output .= "";              }        return $output;


title: Facebook is only displaying preview thumbnails that are 100px from my posts?

text:
I'm using Facebook and Digg Thumbnail generator and [FaceBook Share (New)], 2 As you can see if the image is 100px the thumbail is displayed when I press the share button: ![enter image description here](http://i.stack.imgur.com/mNxA8.png) But with an image with 300px of width: ![enter image description here](http://i.stack.imgur.com/Dkr1X.png) The thumb preview doesn't appear: ![enter image description here](http://i.stack.imgur.com/ERsY9.png) **front-page.php:**               <?php     /**      * Template Name: Front Page      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

                 <?php while ( have_posts() ) : the_post(); ?>
                         <?php the_content(); ?>
                 <?php endwhile; ?>                 <?php /* Display navigation to next/previous pages when applicable */ ?>                 <?php if (  $wp_query->max_num_pages > 1 ) : ?>
<?php next_posts_link( __( '← Older posts', 'twentyten' ) ); ?>

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

     <?php get_footer(); ?>      Any suggestion to solve this?


title: WP filter to alter admin CSS styles?

text: I want to change the CSS background definition for #wpadminbar in the new WordPress 3.8 admin themes. I can (and have) updated the /wp- admin/css/colors/theme/colors.min.css file but wonder if there is a cleaner way? Is there a filter that I could use in functions.php to update this specific style? I found this approach but it is a blunt instrument, replacing the entire CSS file: http://wp-snippets.com/custom-admin-css/ If it matters, I find the single color for the top bar and left column visually odd so I've manually updated #wpadminbar to use the medium color shade assigned to the background of #adminmenu.wp-submenu style. That makes the top bar slightly darker than the left column. Thanks for any ideas how I might do this more cleanly.


title: Page queried instead of a custom taxonomy

text:
When I try to get an archive for a custom taxonomy, WP searches for a page and doesn’t find anything. ## The Setup My code from the functions.php:               add_action( 'init', 'register_store_taxonomy' );          function register_store_taxonomy()     {         $args = array (             'hierarchical'      => TRUE         ,   'label'             => 'Store'         ,   'public'            => TRUE         ,   'query_var'         => 'store'         ,   'rewrite'           => TRUE         ,   'show_in_nav_menus' => TRUE         ,   'show_ui'           => TRUE         );         register_taxonomy(                 'store'             ,   array ( 'post', 'page' )             ,   $args             );     }      Now I have a post tagged with store **itunes**. Clicking on the link to `/store/mac-store/` should list all post in this taxonomy. And it does! On a local server (Win7).   On the staging server (Debian with mostly identical settings), however, I get the 404 page (and the 404 status header). There are no pages with similar names or slugs, not even in trash. I’ve refreshed the permalinks several times. No active plugins. I tried Google but couldn’t find anything useful. ## Debugging I added the following code to my functions.php to track the error:               add_action( 'wp_footer', 'dump_query' );     function dump_query()     {         if ( current_user_can( 'edit_posts' ) )         {             pre_dump( $GLOBALS['wp_query'] );         }     }          function pre_dump( $var, $print = TRUE )     {         $out = '
' . htmlspecialchars( var_export( $var, TRUE ) ) . '
';              if ( ! $print )             return $out;              print $out;     }      ### Output local, working query               WP_Query::__set_state(array(        'query_vars' =>        array (         'store' => 'itunes',         'error' => '',         'm' => 0,         'p' => 0,         'post_parent' => '',         'subpost' => '',         'subpost_id' => '',         'attachment' => '',         'attachment_id' => 0,         'name' => '',         'static' => '',         'pagename' => '',         'page_id' => 0,         'second' => '',         'minute' => '',         'hour' => '',         'day' => 0,         'monthnum' => 0,         'year' => 0,         'w' => 0,         'category_name' => '',         'tag' => '',         'cat' => '',         'tag_id' => '',         'author_name' => '',         'feed' => '',         'tb' => '',         'paged' => 0,         'comments_popup' => '',         'meta_key' => '',         'meta_value' => '',         'preview' => '',         's' => '',         'sentence' => '',         'fields' => '',         'category__in' =>          array (         ),         'category__not_in' =>          array (         ),         'category__and' =>          array (         ),         'post__in' =>          array (         ),         'post__not_in' =>          array (         ),         'tag__in' =>          array (         ),         'tag__not_in' =>          array (         ),         'tag__and' =>          array (         ),         'tag_slug__in' =>          array (         ),         'tag_slug__and' =>          array (         ),         'meta_query' =>          array (         ),         'ignore_sticky_posts' => false,         'suppress_filters' => false,         'cache_results' => true,         'update_post_term_cache' => true,         'update_post_meta_cache' => true,         'post_type' => '',         'posts_per_page' => 10,         'nopaging' => false,         'comments_per_page' => '50',         'no_found_rows' => false,         'taxonomy' => 'store',         'term' => 'itunes',         'order' => 'DESC',         'orderby' => 'wp_posts.post_date DESC',       ),        'tax_query' =>        WP_Tax_Query::__set_state(array(          'queries' =>          array (           0 =>            array (             'taxonomy' => 'store',             'terms' =>              array (               0 => 'itunes',             ),             'include_children' => true,             'field' => 'slug',             'operator' => 'IN',           ),         ),          'relation' => 'AND',       )),        'post_count' => 1,        'current_post' => -1,        'in_the_loop' => false,        'comment_count' => 0,        'current_comment' => -1,        'found_posts' => '1',        'max_num_pages' => 1,        'max_num_comment_pages' => 0,        'is_single' => false,        'is_preview' => false,        'is_page' => false,        'is_archive' => true,        'is_date' => false,        'is_year' => false,        'is_month' => false,        'is_day' => false,        'is_time' => false,        'is_author' => false,        'is_category' => false,        'is_tag' => false,        'is_tax' => true,        'is_search' => false,        'is_feed' => false,        'is_comment_feed' => false,        'is_trackback' => false,        'is_home' => false,        'is_404' => false,        'is_comments_popup' => false,        'is_paged' => false,        'is_admin' => false,        'is_attachment' => false,        'is_singular' => false,        'is_robots' => false,        'is_posts_page' => false,        'is_post_type_archive' => false,        'parsed_tax_query' => true,        'query' =>        array (         'store' => 'itunes',       ),        'request' => ' SELECT SQL_CALC_FOUND_ROWS  wp_posts.* FROM wp_posts  INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1  AND ( wp_term_relationships.term_taxonomy_id IN (135,134,133,132,131,130,129,128,125) ) AND wp_posts.post_type IN (\'post\', \'page\', \'attachment\') AND (wp_posts.post_status = \'publish\' OR wp_posts.post_author = 7 AND wp_posts.post_status = \'private\') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10',        'posts' =>        array ( /* cut out */),        'queried_object' =>        stdClass::__set_state(array(          'term_id' => '124',          'name' => 'iTunes',          'slug' => 'itunes',          'term_group' => '0',          'term_taxonomy_id' => '125',          'taxonomy' => 'store',          'description' => '',          'parent' => '0',          'count' => '1',       )),        'queried_object_id' => 124,     ))      ### Output staging server, broken query               WP_Query::__set_state(array(        'query_vars' =>        array (         'page' => 0,         'pagename' => 'itunes',         'error' => '',         'm' => 0,         'p' => 0,         'post_parent' => '',         'subpost' => '',         'subpost_id' => '',         'attachment' => '',         'attachment_id' => 0,         'name' => 'itunes',         'static' => '',         'page_id' => 0,         'second' => '',         'minute' => '',         'hour' => '',         'day' => 0,         'monthnum' => 0,         'year' => 0,         'w' => 0,         'category_name' => '',         'tag' => '',         'cat' => '',         'tag_id' => '',         'author_name' => '',         'feed' => '',         'tb' => '',         'paged' => 0,         'comments_popup' => '',         'meta_key' => '',         'meta_value' => '',         'preview' => '',         's' => '',         'sentence' => '',         'fields' => '',         'category__in' =>          array (         ),         'category__not_in' =>          array (         ),         'category__and' =>          array (         ),         'post__in' =>          array (         ),         'post__not_in' =>          array (         ),         'tag__in' =>          array (         ),         'tag__not_in' =>          array (         ),         'tag__and' =>          array (         ),         'tag_slug__in' =>          array (         ),         'tag_slug__and' =>          array (         ),         'ignore_sticky_posts' => false,         'suppress_filters' => false,         'cache_results' => true,         'update_post_term_cache' => true,         'update_post_meta_cache' => true,         'post_type' => '',         'posts_per_page' => 10,         'nopaging' => false,         'comments_per_page' => '50',         'no_found_rows' => false,         'order' => 'DESC',         'orderby' => 'wp_posts.post_date DESC',       ),        'tax_query' =>        WP_Tax_Query::__set_state(array(          'queries' =>          array (         ),          'relation' => 'AND',       )),        'post_count' => 0,        'current_post' => -1,        'in_the_loop' => false,        'comment_count' => 0,        'current_comment' => -1,        'found_posts' => 0,        'max_num_pages' => 0,        'max_num_comment_pages' => 0,        'is_single' => false,        'is_preview' => false,        'is_page' => false,        'is_archive' => false,        'is_date' => false,        'is_year' => false,        'is_month' => false,        'is_day' => false,        'is_time' => false,        'is_author' => false,        'is_category' => false,        'is_tag' => false,        'is_tax' => false,        'is_search' => false,        'is_feed' => false,        'is_comment_feed' => false,        'is_trackback' => false,        'is_home' => false,        'is_404' => true,        'is_comments_popup' => false,        'is_paged' => false,        'is_admin' => false,        'is_attachment' => false,        'is_singular' => false,        'is_robots' => false,        'is_posts_page' => false,        'is_post_type_archive' => false,        'parsed_tax_query' => true,        'query' =>        array (         'page' => '',         'pagename' => 'store/itunes',       ),        'request' => ' SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND (wp_posts.ID = \'0\') AND wp_posts.post_type = \'page\'  ORDER BY wp_posts.post_date DESC ',        'posts' =>        array (       ),        'queried_object' => NULL,        'queried_object_id' => 0,     ))      I feel that I miss something obvious, but I’m lost right now. So my questions are: How can I make WP search the taxonomy archive? Why does it work on one server, but not on the other? ## Update Permalinks are set to `/%year%/%postname%/` on both servers and I flushed the rewrite rules on `init` per:               $GLOBALS['wp_rewrite']->flush_rules();      ## Update 2 using the Rewrite Analyzer plugin from @ _Jan Fabry_ I compared the rules on my local installation and on the staging server. On the latter, the rules are absent. ### Rewrite rules local               store/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$            store: ([^/]+)                feed: (feed|rdf|rss|rss2|atom)     store/([^/]+)/(feed|rdf|rss|rss2|atom)/?$             store: ([^/]+)                feed: (feed|rdf|rss|rss2|atom)     store/([^/]+)/page/?([0-9]{1,})/?$            store: ([^/]+)               paged: ([0-9]{1,})     store/([^/]+)/?$              store: ([^/]+)      Do I really have to add the rules manually? Usually `register_taxonomy()` should do that, shouldn’t it? ## Workaround Bah! I used a workaround to add the missing rewrite rules per functions.php:               add_action( 'init', 'add_taxrules_manually' );     function add_taxrules_manually()     {         $tax           = 'store';         $rewrite_rules = get_option( 'rewrite_rules' );              if ( isset ( $rewrite_rules[ $tax . '/([^/]+)/?$' ] ) )         {             return;         }              $new_rules = array (             $tax . '/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?' . $tax . '=$matches[1]&feed=$matches[2]',             $tax . '/([^/]+)/(feed|rdf|rss|rss2|atom)/?$'      => 'index.php?' . $tax . '=$matches[1]&feed=$matches[2]',             $tax . '/([^/]+)/page/?([0-9]{1,})/?$'             => 'index.php?' . $tax . '=$matches[1]&paged=$matches[2]',             $tax . '/([^/]+)/?$'                               => 'index.php?' . $tax . '=$matches[1]',         );              $update = array_merge( $new_rules, $rewrite_rules );         update_option( 'rewrite_rules', $update );     }      **Important:** The new rules must come before the page rules. Changing the order of arguments in `array_merge()` will not fix it. The question is still open, because I just _have_ to understand what happens here.


title: Add Action Hook function to WP-User-Frontend in a custom post field

text: I'm using WP-User-Frontend plugin on my wordpress site to allow users to submit posts from the frontend. I only allow users to submit urls. So I created a new form in WP-User-Frontend and gave it 2 fields: title and URL. All I wanna do is grab the title, description and thumbnail of all submitted links. WP-User-Frontend allows you to add "action hooks" field into your forms to perform custom jobs. This is the documentation of WP-User-Frontend on how to add action hooks. http://docs.wedevs.com/wp-user-frontend-pro/#developer- documentation               add_action('HOOK_NAME', 'your_function_name', 10, 3 );     function your_function_name( $form_id, $post_id, $form_settings ) {     // do what ever you want     }      I have also found a function that scrapes external data from urls using cURL and OG tags. https://github.com/slv/PoOr.Scraper What I want to do is integrate the Scraper function into WP action hook and display the results in a wordpress post in a neat way. First I need to change the $_GET['id'] method into $_POST['link'] to be able to retrieve the data using a form. But don't really know how to do that. Or how to integrate the function in an action hook.


title: How do I map a subdomain in wordpress to the primary domain in a multisite setup?

text: We have a multisite setup, the primary domain needs to have domain.com, www.domain.com and secure.domain.com mapped in wordpress so the primary site's content loads on them. The problem we are facing is everything except secure.domain.com works. secure.domain.com always ends up at: http://www.domain.com/wp-signup.php?new=secure.domain.com The headers returned from the server are as follows: Status: HTTP/1.1 302 Moved Temporarily Date: Tue, 16 Oct 2012 19:55:53 GMT   Server: Apache   Location: http://www.domain.net/wp-signup.php?new=secure.domain.net   Content-Length: 0   Connection: close   Content-Type: text/html; charset=utf-8


title: How do I list the_tags() into HTML data-attribute

text: I'm new to wordpress and trying to make a theme. I'm using a jQuery filter script on a page of posts that filters the posts nested in an unordered list using the HTML data-attribute as a hook in the list items. I want to use each post's tags as the data attribute hook. I've looked up variations of the_tags() functions, but I can't seem to create one that will simply list the tags as separated by commas without the extra anchor tags, etc. This is the closest I can get to what I want:               <li class="griditemleft" data-="<?php     $posttags = get_the_tags();     if ($posttags) {     foreach($posttags as $tag) {     echo $sep . $tag->name; $sep = ', ';     }     }     ?>">      It looks right in the first list item, but the subsequent list items have an extra comma at the beginning of the data attribute string.


title: $.browser Undefined Seemingly Causing Faulty Page Display

text: At this site I have an error using the parent theme's `jquery.PrettyPhoto.js` This causes tabs not to load well nor gallery to work well it seems. The error states               TypeError: $.browser is undefined     http://www.domain.com/wp-content/themes/decondo/lib/scripts/pretty/jquery.prettyPhoto.js?ver=2.5     Line 59      I enqueued jQuery Migrate - v1.0.0 - 2013-01-14 with following code (whole function added): http://pastebin.com/EC3XrTiq to the parent theme's function.php as I thought it would be related to an outdated jQuery function - see http://stackoverflow.com/questions/14524289/browser-is-undefined-error -. I found another thread at SE that suggested adding the $.browser function mentioning this function was no longer used since 1.3. The version loaded on those pages is 1.8.3 so this could be the issue then. Odd I did not have the issue earlier, but anyways. ~~I realized that jQuery migrate was not being loaded checking these pages in Firebug. I is locatedhere for sure though and would say the path is correct.~~ Thanks to to some more research and a check in safari using the inspector I did realise the jQuery migrate scripts is already loaded by WordPress. Now the issue remains why the site's gallery (issues in Safari with layout), menu (dropdown broken in Firefox) and tabs (not loaded in Firefox) are not loading well and if the deprecated browser function is causing this or not.


title: Integrating Custom Database with Wordpress

text: I Have a Wordpress Site with few users who are my college students They Registered using their RollNumbers/HallTicket Numbers as their usernames in Wordpress site Now I Have Another Database with Their Personal Details like Marks, Rank etc Now I want to Integrate this Database to Wordpress so that when student/user logins , then he/her could see their respective marks and other details I Just want your suggestions/ideas to implement this, Not asking for a Complete solution Thankyou


title: Thumbnail gallery by date and taxonomy

text: I'm having problem to create something like image gallery. What I wanna do is, in the home page sidebar, there will be a box named photo gallery which will contain 2 or 4 images thumbnail (just like small icon). Then, if someone clicks on the photo gallery title link, that will show the image gallery page and the page will show image with a title . The title will be by date and from taxonomoy category , just like this


title: HTML Entities in Post Title

text: I'm inserting posts into wordpress using a script which is loaded through CRON. Before inserting each post I am checking whether the post with the same title exists or not. Below is the snippet I'm using:               if( is_null(get_page_by_title( $page_title, 'OBJECT', $post_type )) ) {         // Create post object         $my_post = array(             'post_title' => "Food & Wine",  // this is example and it actually inserts $page_title.             'post_content' => 'Dummy content',             'post_status' => 'draft',             'post_author' => 1,             'post_type' => $post_type,         );         // Insert the post into the database         wp_insert_post( $my_post );     } else {         echo 'Post already exists.';     }      Now this insertion part works pretty well, but it stores '&' as html entity (`&`) in the database. So in the database, the post title looks like "Food & Wine". In the list of posts admin screen, the title looks fine with '&' and once I go to the edit screen, it shows `&`. This causes the first 'if' condition to return TRUE and it inserts a duplicate post. My database collation type is "utf8_general_ci". Well this works on my local MAMP installation, but fails on my shared host. I would like to know what is wrong in the code and how should this situation be handled. Also is it suggested to escape html entities for the 'post_content'? Thanks.


title: Code snippet plugin not working correctly with Windows live writer and Wordpress

text: Downloaded the The Live Writer Source Code Plug-in For WordPress.com Blogs. The preview looks good but the published version looks really messed up. Could anybody let me know what could be the fix. In the preview in template of Code snippet plugin():- ![enter image description here](http://i.stack.imgur.com/vT9Zu.gif) After publish :- ![enter image description here](http://i.stack.imgur.com/RTZnu.gif)


title: exclude a post from wp_query loop

text: 0 down vote favorite I show my last post in a page with this code:               $query1 = new WP_Query();     $query1->the_post();      and it further with:               $id = $query->ID;      to retrieve last post ID so I wrote a new wp_query and I want to exclue that ID from the results: I wrote this but it don't work:               $query2-> new WP_Query('p=-$id');      what's the problem?


title: wordpress widgets screen disappeared

text: Im having a weird problem. The screen where you manage widgets (drag and drop them from left to right) suddenly disappeared. How can I access it? It should be accessible via admin>themes>widgets but I dont have that option in the sub menu. Only have "themes" "menus" "editor" Btw, Im using ithemes theme builder plugin. Since I have access to the editor and can edit php I assume I have admin rights.


title: CPT Meta Searching

text: I'm developing a WP plugin which uses custom post types and meta data. What I'm trying to achieve is having the meta data searchable. Here is some code that I found which searches the meta data fine, however I can't get it to display the search string on the CPT page. ![CPT Search Error](http://i.stack.imgur.com/5ZAs4.png)               add_filter( "pre_get_posts", "custom_search_query");     function custom_search_query( $query ) {         $custom_fields = array(             "pctracker_company",             "pctracker_customer",             "pctracker_phone1",             "pctracker_phone2",             "pctracker_mobile",             "pctracker_email"              );         $searchterm = $query->query_vars['s'];         $query->query_vars['s'] = "";         if ($searchterm != "") {             $meta_query = array('relation' => 'OR');             foreach($custom_fields as $cf){                 array_push($meta_query, array(                     'key' => $cf,                     'value' => $searchterm,                     'compare' => 'LIKE'                 ));             }             $query->set("meta_query", $meta_query);         };     }      I know that in the code its unsetting 'S', however if you don't unset it, it does not display any results. Can anyone point me in the right direction? Thanks very much, Jason EDIT: I've just been having a play around and I've got this working!               function my_search_results($query){         if(isset($_GET['s'])){             if($_GET['post_type'] == "pctracker_customers") {                 $mySearch = $_REQUEST['s'];                 $query = 'select * from wp_posts,wp_postmeta WHERE wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = "pctracker_phone1" AND wp_postmeta.meta_value LIKE "%'.$mySearch.'%" AND(wp_posts.post_status = "publish")';             }         }         return $query;     }     add_filter( 'posts_request', 'my_search_results');      EDIT 2: I've got multiple meta fields I need to search, pctracker_phone1 and pctracker_phone2 are just a couple. I've edited the SQL code so it searches for both. However the SQL code is going to be massive once all of the other metafields are added. Do you know how I could simplifier this:               $query = 'SELECT * FROM '. $wpdb->prefix .'posts,'. $wpdb->prefix .'postmeta WHERE '. $wpdb->prefix .'posts.ID = '. $wpdb->prefix .'postmeta.post_id AND '. $wpdb->prefix .'postmeta.meta_key = "pctracker_phone1" AND '. $wpdb->prefix .'postmeta.meta_value LIKE "%'.$mySearch.'%" OR '. $wpdb->prefix .'posts.ID = '. $wpdb->prefix .'postmeta.post_id AND '. $wpdb->prefix .'postmeta.meta_key = "pctracker_phone2" AND '. $wpdb->prefix .'postmeta.meta_value LIKE "%'.$mySearch.'%" AND('. $wpdb->prefix .'posts.post_status = "publish") ORDER BY '. $wpdb->prefix .'posts.post_date DESC';


title: Wordpress AJAX in header.php

text: I am currently studying Wordpress AJAX but keep getting error message (so the success function is not being executed) Currently I have changed the header.php (of twentythirteen theme) to include JavaScript that sends AJAX Request.               <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>     <![endif]-->     <?php wp_head(); ?>     <script type="text/javascript">              jQuery(document).ready(function($){              //AJAX         $.ajax({                  type: "GET",             dataType: "json",             url: "<?php echo admin_url('admin-ajax.php'); ?>;",             data: {                 action: 'xn_get_event'             },             success: function(response){                 alert("Yes");             },             error: function(response){                 alert("omg!");             }              }); //END OF AJAX (SEND REQUEST)     }); //END OF READY FUNCTION     </script>      And then in the theme folder, I have included another PHP file called json- feed.php inside functions folder (so theme_name/functions/json-feed.php) and here I included the following code:               header('Content-Type:application/json');               //Needs to include wp-load.php file!      if(file_exists('../../../../wp-load.php')):         include '../../../../wp-load.php';     else: //Double checking in case the path is wrong.         include '../../../../../wp-load.php';     endif;          //AJAX Handler     add_action('wp_ajax_nopriv_xn_get_event', 'xn_get_event');     add_action('wp_ajax_xn_get_event', 'xn_get_event');          function xn_get_event(){              echo "Wow!";          }      And then when I go to the website it keeps alerting "Omg!" to me and I do not know why it is keep returning error response!


title: Media uploader was overridden and uploaded php file

text: Sorry if this post already exist, But I am new in this area :) So I just deployed some wordpress application for a year. And when I found out that my server is sending Junk mail to unknown users I started tracing the uploaded files and found this php file https://gist.github.com/anonymous/efbdd9cff5fe631ef376 Please have a look at it and please reply if you are familiar.


title: Paginate custom taxonomy category with wp_custom_pagination

text:
I am trying to paginate taxonomy `cities`, with custom post type `city`, the categories that are displayed but failed to understand how can do it with the wp_custom_pagination function.               function wp_custom_pagination($before = '', $after = '') {             global $wpdb, $wp_query,$wp_rewrite;             $wp_rewrite->flush_rules();             $custom_pagination = array();             $custom_pagination['pages_text'] = ('');             $custom_pagination['current_text'] = '%PAGE_NUMBER%';             $custom_pagination['page_text'] = '%PAGE_NUMBER%';             $custom_pagination['first_text'] = ('First Page');             $custom_pagination['last_text'] = ('Last Page');             $custom_pagination['next_text'] = 'Next';             $custom_pagination['prev_text'] = 'Prev';             $custom_pagination['dotright_text'] = '...';             $custom_pagination['dotleft_text'] = '...';             $custom_pagination['num_pages'] = 3; //continuous block of page numbers             $custom_pagination['always_show'] = 0;             $custom_pagination['num_larger_page_numbers'] = 0;             $custom_pagination['larger_page_numbers_multiple'] = 1;                  //If NOT a single Post is being displayed             /*http://codex.wordpress.org/Function_Reference/is_single)*/             if (!is_single()) {                     $request = $wp_query->request;                     //intval � Get the integer value of a variable                     /*http://php.net/manual/en/function.intval.php*/                     $posts_per_page = intval(get_query_var('posts_per_page'));                     //$posts_per_page = 1;                     //Retrieve variable in the WP_Query class.                     /*http://codex.wordpress.org/Function_Reference/get_query_var*/                     $paged = intval(get_query_var('paged'));                     $numposts = $wp_query->found_posts;                     $max_page = $wp_query->max_num_pages;                               //empty � Determine whether a variable is empty                     /*http://php.net/manual/en/function.empty.php*/                     if(empty($paged) || $paged == 0) {                             $paged = 1;                     }                          $currently_showingfrom = ($paged-1)*$posts_per_page;                     $currently_showingto = $paged*$posts_per_page;                     if($currently_showingto >  $numposts) {                             $currently_showingto = $numposts;                     }                          $pages_to_show = intval($custom_pagination['num_pages']);                     $larger_page_to_show = intval($custom_pagination['num_larger_page_numbers']);                     $larger_page_multiple = intval($custom_pagination['larger_page_numbers_multiple']);                     $pages_to_show_minus_1 = $pages_to_show - 1;                     $half_page_start = floor($pages_to_show_minus_1/2);                     //ceil � Round fractions up (http://us2.php.net/manual/en/function.ceil.php)                     $half_page_end = ceil($pages_to_show_minus_1/2);                     $start_page = $paged - $half_page_start;                          if($start_page <= 0) {                             $start_page = 1;                     }                          $end_page = $paged + $half_page_end;                     if(($end_page - $start_page) != $pages_to_show_minus_1) {                             $end_page = $start_page + $pages_to_show_minus_1;                     }                     if($end_page > $max_page) {                             $start_page = $max_page - $pages_to_show_minus_1;                             $end_page = $max_page;                     }                     if($start_page <= 0) {                             $start_page = 1;                     }                          $larger_per_page = $larger_page_to_show*$larger_page_multiple;                     //round_num() custom function - Rounds To The Nearest Value.                     $larger_start_page_start = (round_num($start_page, 10) + $larger_page_multiple) - $larger_per_page;                     $larger_start_page_end = round_num($start_page, 10) + $larger_page_multiple;                     $larger_end_page_start = round_num($end_page, 10) + $larger_page_multiple;                     $larger_end_page_end = round_num($end_page, 10) + ($larger_per_page);                          if($larger_start_page_end - $larger_page_multiple == $start_page) {                             $larger_start_page_start = $larger_start_page_start - $larger_page_multiple;                             $larger_start_page_end = $larger_start_page_end - $larger_page_multiple;                     }                     if($larger_start_page_start <= 0) {                             $larger_start_page_start = $larger_page_multiple;                     }                     if($larger_start_page_end > $max_page) {                             $larger_start_page_end = $max_page;                     }                     if($larger_end_page_end > $max_page) {                             $larger_end_page_end = $max_page;                     }                     if($max_page > 1 || intval($custom_pagination['always_show']) == 1) {                             /*http://php.net/manual/en/function.str-replace.php */                             /*number_format_i18n(): Converts integer number to format based on locale (wp-includes/functions.php*/                             $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $custom_pagination['pages_text']);                             $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text);                             echo $before.'

'."\n";                                  if(!empty($pages_text)) {                                     echo '
'.$pages_text.'
';                             }                                  $ppl = explode('"',get_previous_posts_link());                             if (count($ppl) > 1) {                                     $ppl_url=$ppl[1];                             }                                  //Displays a link to the previous post which exists in chronological order from the current post.                             /*http://codex.wordpress.org/Function_Reference/previous_post_link*/                                            if( $paged > 1 )                             {?>                                     <a href="<?php echo $ppl_url ?>" class="prev" style='font-size:12px'> <img src="<?php bloginfo('template_directory'); ?>/images/previouspostslink.png" style="width:14px; height:13px;margin-bottom:-2px;">  Prev  |                                  <?php } ?>                                            <?php                                     //previous_posts_link($custom_pagination['prev_text']);                                       echo " $paged of $max_page ";                             if ($start_page >= 2 && $pages_to_show < $max_page) {                                     $first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $custom_pagination['first_text']);                                     //esc_url(): Encodes < > & " ' (less than, greater than, ampersand, double quote, single quote).                                     /*http://codex.wordpress.org/Data_Validation*/                                     //get_pagenum_link():(wp-includes/link-template.php)-Retrieve get links for page numbers.                                     //echo '
1
';                                     if(!empty($custom_pagination['dotleft_text'])) {                                     //  echo '
'.$custom_pagination['dotleft_text'].'
';                                     }                             }                                  if($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) {                                     for($i = $larger_start_page_start; $i < $larger_start_page_end; $i+=$larger_page_multiple) {                                             $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $custom_pagination['page_text']);                                             //echo '
'.$page_text.'
';                                     }                             }                                  for($i = $start_page; $i  <= $end_page; $i++) {                                     if($i == $paged) {                                             $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $custom_pagination['current_text']);                                     // echo '
'.$current_page_text.'
';                                     } else {                                             $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $custom_pagination['page_text']);                                     // echo '
'.$page_text.'
';                                     }                             }                                  if ($end_page < $max_page) {                                     if(!empty($custom_pagination['dotright_text'])) {                                             //echo '
'.$custom_pagination['dotright_text'].'
';                                     }                                     $last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $custom_pagination['last_text']);                                     //echo '
'.$max_page.'
';                             }          $npl=explode('"',get_next_posts_link());     if (count($npl) > 1) {     $npl_url=$npl[1];     } else {     $npl_url=$npl[0];     }                                            if( $max_page > $paged ) {                             //echo '
';                             ?>                                       <a href="<?php echo $npl_url ?>" style='font-size:12px'>|  Next <img src="<?php bloginfo('template_directory'); ?>/images/nextpostslink.png" style="width:14px; height:13px;margin-bottom:-2px;">                             <?php }?>                             <?php //next_posts_link($custom_pagination['next_text'], $max_page);                             if( $max_page < $paged );                                     echo '
';                             if($larger_page_to_show > 0 && $larger_end_page_start < $max_page) {                                     for($i = $larger_end_page_start; $i <= $larger_end_page_end; $i+=$larger_page_multiple) {                                             $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $custom_pagination['page_text']);                                             echo '
'.$page_text.'
';                                     }                             }                             echo '

'.$after."\n";                     }             }     }      I have tried with a for but did not managed to went ahead. Please help, I am a noob in wordpress. I researched about 10 stackoverflow posts, but did not managed to get it working. This is what I have:               <?php      global $wpdb;      $category_ids = get_categories('taxonomy=cities&orderby=order&hide_empty=0');      foreach($category_ids as $cat) {         $term_include = $wpdb->get_var($wpdb->prepare("SELECT term_include FROM $wpdb->terms WHERE term_id = %d ", $cat->term_id ));        $link = get_term_link( $cat->slug, 'cities' );        $image = z_taxonomy_image_url($cat->term_id, 'large');        $category_heading = $cat->name;        $excerpt = smart_excerpt(category_description($cat->term_id), 20);        $category_post = the_category(' / ');      }      wp_custom_pagination();     ?>


title: Display both standard posts in a specific category along with a custom post type in a single loop?

text: I'm building a content slider that needs to show posts from a custom post type called "Features," and also show standard blog posts that are assigned to a "Featured" category. I'd like to do this within a single loop. Can anyone help me put together the query that could handle this?


title: can't access some worpress function from my plugin

text:
I'm trying to write a relatively simple plugin. I have two php files, one is included within the other like this:               define( 'PLUGIN_DIR', dirname(__FILE__).'/' );     include_once(PLUGIN_DIR . '/included_file.php');      Things look fine. However I'm getting errors when I try to call some wordpress functions from within the included file: > Fatal error: Call to undefined function xxx() ... The odd this is, only on some functions but not others. For example, if I place this code at the top of the included file:               if (!function_exists('add_action')) echo "
add_action not found
";     if (!function_exists('check_admin_referer')) echo "
check_admin_referer not found
";     if (!function_exists('wp_verify_nonce')) echo "
wp_verify_nonce not found
";     if (!function_exists('wp_nonce_field')) echo "
wp_nonce_field not found
";      I get this output:               check_admin_referer not found     wp_verify_nonce not found      so only two out of these four functions are accessible in the included file... I'm probably missing something very basic, but I'm a bit stuck. UPDATE: I tried creating a very basic plugin:               <?php     /*         Plugin Name: Test this         Plugin URI: http://www.gingerlime.com         Description: test         Author: Yoav Aner         Version: 1.0         Requires at least: 3.1         Author URI: http://blog.gingerlime.com         License: GPL 2.0, @see http://www.gnu.org/licenses/gpl-2.0.html          */     if (!function_exists('add_action')) echo "
add_action not found
";     if (!function_exists('check_admin_referer')) echo "
check_admin_referer not found
";     if (!function_exists('wp_verify_nonce')) echo "
wp_verify_nonce not found
";     if (!function_exists('wp_nonce_field')) echo "
wp_nonce_field not found
";     if (function_exists('add_action')) echo "
add_action found
";     if (function_exists('check_admin_referer')) echo "
check_admin_referer found
";     if (function_exists('wp_verify_nonce')) echo "
wp_verify_nonce found
";     if (function_exists('wp_nonce_field')) echo "
wp_nonce_field found
";     ?>      as soon as the plugin is activated it prints > check_admin_referer not found > > wp_verify_nonce not found > > add_action found > > wp_nonce_field found I tried it on two wordpress installations. I might try a completely fresh wordpress and see what's going on. Strange.


title: vimeo/youtube video embed with thumbnails

text: Is there a way to get wordpress to embed Vimeo, YouTube videos like tumblr with a thumbnail and then to play without the player buttons? examples -   * http://ascender.tumblr.com/   * http://swell-theme.tumblr.com/


title: [Plugin: Posts 2 Posts] Changing display order of connections

text: Can I change the order in which connections are displayed ? If I create say three connections and then display them at the bottom of my article, I will get them in reverse order. How can I change that ? I tried to use 'orderby' and 'order' but it has no effect whatsoever :               $connected_titles = new WP_Query( array(     'post_type' => 'as_title',     'nopaging' => true,     'orderby' => 'title',     'order' => 'DESC',     'suppress_filters' => false,     'connected_from' => get_queried_object_id()     ));


title: Find most recent authors

text: What I'm looking to do it get the 16 latest posts from 16 different authors. In other words there would be the 16 latest posts, but no one single author would have more that 1 post on the page. The way I've thought about doing it, is looping through all the authors, removing the duplicates, then limited that to 16 and use that to generate the posts in a for each loop, but I'd imagine that would be heavy on the server. Any suggestions?


title: Permalink structure by Post Meta value

text: I have the following issue: Two Custom Post Types, lets call them **cpt1** and **cpt2**. In **cpt2** , I have a custom meta box in which you can select a post from **cpt1** , its `post ID` is stored in a meta value called `postid`. The permalink structure of **cpt2** is `/%post_type%/%post_name%/`. What i'm trying to accomplish is:   1. When `postid` has a `post ID` of **cpt1** (wich will always be the case since it is a required field), the permalink structure of that specific post will become `/selected_post_slug/%post_type%/%post_name%/`.   2. The **cpt2** archive page must be available by `/selected_post_slug/cpt2/`, so it looks like every **cpt1** page has its own **cpt2** archive. I managed to get point 1 to work by adding the following code in my `functions.php` file:               $wp_rewrite->add_rewrite_tag( '%selected_meta%', '([^&]+)', '?meta=' );          function extra_post_link( $permalink, $post, $leavename ) {         if ( stripos( $permalink, '%selected_meta%' ) == false )             return $permalink;              if ( is_object( $post ) && $post->post_type == 'ervaring' ) {             $_selected_post_slug = '';             $_selected_post_id = get_post_meta( $post->ID, 'rating-post', true );                  if ( $_selected_post_id )                 $_selected_post_slug = get_page_uri( $_selected_post_id );                  if ( ! $_selected_post_slug )                 return str_replace( '%selected_meta%', '', $permalink );                  return str_replace( '%selected_meta%', "$_selected_post_slug/", $permalink );         }              return $permalink;     }          add_filter( 'post_type_link', 'extra_post_link', 10, 3 );      I followed a quick tutorial about adding rewrite tags in the permalink structure wich showed me how to figure out the first thing. But, unfortunately, I'm still working on a solution for point 2. Could I get some thought about this issue to help me a bit further down the road? Help would be much appreciated.


title: Why my wp site always redirecting to the old website path..?

text: I am having problem on migrating my Wordpress site from the sub folder to the root directory. My current website URL is not working on uploading the project on root directory. It's get redirected to the existing path My current word press site is located on root directory > http://www.macil.com.au/ But it's always redirected to the old existing website path which is > http://www.macil.com.au/Welcome/Home.html I’ve checked the htaccess file, it is blank what can be the issue?


title: How to limit one IP to post only only comment per post?

text: I'm making a review website. How can I limit one IP address to be able to just post one comment on the same post?


title: Creating a theme option page?

text: I have a template page in Wordpress that I want the Admin to be able to change the text on that page. I'd love to learn how to make a plugin (I know how to make a plugin so that it shows up in WP, installs when the user sets it to activate, and then create the admin panel) that shows just one text field, and the data the person enters is passed to the template page. If I could have help finding a tutorial or simple advice on how to do this, it would be greatly appreciated.


title: Change RSS format for specific categories

text: Is there way to have, **in a single RSS feed** , different formats for different categories? For example, if a post is a very long and technical one I would like to have only an excerpt (or a custom text with a link) and if it is short I would like to put the whole thing on the feed.


title: How do I create a way for users to assign categories to a post from the frontend?

text: Basic idea is for any post on the site, I'd like users to be able to assign a category for it by selecting from a set of checkboxes on the frontend. This would be a kind of crowd-sourced categorization of content. Any ideas on the best way to approach this?


title: Custom post type and body_class: Remove "blog" class

text: I am using `body_class();` to style different sections of a wordpress site by their body class. Page styles descend from `.page-template`, blog styles descend from `.single-post` and/or `.blog` etc. I have created a custom post type "Products" for the products section of the site and want to style this section specifically using it's body class, but unfortunately `body_class();` is also giving the custom post type single pages the class `.blog` which is making many of the blog styles override the product styles- very frustrating. Is there a way to take the "blog" class away for my custom post type single pages? Thanks!


title: How to make page template with admin able to select NextGen Galleries to be part of the layout?

text: I'm trying to make a product page template, editable by client, which will have 3 different NextGen Galleries per page. In the product page admin area, I want the client to be able to select which 3 NextGen galleries to display, and in which order. What do I put in my template page, and (I'm assuming) functions.php? Here's a mockup of an individual product page how I want it to be, so you can see what I mean: https://dl.dropbox.com/u/10452828/LRG/a-project-page- mockup.jpg I'm customising a theme, in which all the 'About the Product' fields etc are in the page template already, I just want to add selectable NextGen Galleries. I've tried googling this but I'm not sure of exactly what terminology I should be searching for, so any advice would be appreciated. Thankyou!


title: Merge Multiple Sites/Networks (at least 2) into One Site/Network

text: What methods exist to merge at least two WordPress sites together that already live under one Multi Site instance? E.g. Sites wp_2 and wp_3 become either wp_4 or are merged together under wp_2. I suspect that this is no different than migrating or converting an existing WordPress site/data into a Network that has been outline here and includes all the caveats of 301 mappings, updating site options, and existing URLS found inside options and content.


title: Display posts styled exactly like default posts

text: What would the parameters be for the shortcode to display a category of posts exactly like they would appear on the main blog page? Seems pretty simple but I just don't see which parameter would do this? thanks,


title: How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?

text: Thanks for taking a look at this for me. You can see the current behavior at http://dev.citylightphilly.com/blog/ -- Here is my specific problem. We are using a category structure like this:               Events []       Meals and Mission []       Service []      Our problem is that our users are categorizing events like this:               Events []       Meals and Mission [x]       Service []      This results in the sidebar widget not reflecting the total number of events in the post count. For instance - we have 8 posts in "Meals and Mission" and 2 that are simply in the "Events" category. We'd like the sidebar to reflect the total post count like this               Events (10)       Meals and Mission (8)      However, the post count looks like this:               Events (2)       Meals and Mission (8)      **EDIT:** moved the quick fix to an 'answer' below. What I'd prefer to do is tweak the widget to reflect the total number of posts in that category, including all its child categories. Is this possible? I'm using the stock "categories" widget. Thanks!