Plugin error after installation

I'm running WP 3.1.2 on an Apche server with the latest PHP installed. My WP is setup for a subdirectory multisite. The themes for the sites are usually a modified TwentyTen theme. After installing a new plugin, I activate per site, not network, and I'm able to then click through to a few links in the admin UI before I'm prompted with an error starting with **Warning: require_once** It doesn't matter what plugin is installed or how it's activated (per site or network). I have verified that the "missing file" is where it should be. I am using the latest version, most of them have been updated with in the past month or so and as per the official WP forum for the plugins, other users claim them to work properly. It's becoming a real nuisance to have to go into every plugin and hard code the directory to each plugin file. I have tried reinstalling all the WP core files to no avail. Has anyone else seen this or know how to fix it? **Edit:** On a completely different domain with a brand new install of WP on a new database, I'm seeing hte same thing. Any new plugin install shows a missing file error. This is extremely annoying and I need to fix it. I suspect it's something within Apache but not sure.


What is the process for reimplementing a back up WordPress?

WordPress noob here. I'm helping a friend migrate her WordPress themes and change servers. I've already moved the WP across servers, but now I'm working on changing the theme on my localhost dev site through a child theme. After I'm done rebuilding the child theme, can I just make a backup of that database, activate the theme in the actual new WordPress and reimplement the backup? Is there anything else I should be aware of?


Shortcodes, HTML tables, and multiple rows

Im trying to build a shortcode which calls an HTML table with a fixed number of columns and a variable number of rows depending on the context. Its hard to manage -- or even build, multiple tables over and over through HTML. I've had no trouble creating fixed columns and rows through shortcodes. To illustrate through the usage of a trivial example: Lets assume i build a table with 4 columns and 1 row. The 4 columns will contain the following table headers:   1. Product name   2. Quantity   3. Price per item   4. Total price What if i wanted to create multiple rows (Product 1, Product 2 etc..), if at all possible, how can i build a shortcode that enables me to add more rows as i see fit -- without creating a separate shortcode for table rows (been there).


show if comment is in moderation

How to display a moderation-message with a comment after posting a comment. The workflow should be:   * post a comment   * wp thinks this one has to be moderated   * user sees his comment with a messe like "thx but you cannot see it since its in moderation"   * stretchgoal: this message should be visible every time the users visits (cookie?)   * the messages disapears when the comment gets deleted or approved Is there a way to do this? Thanks ps: this is a crosspost from http://getsatisfaction.com/wordpress_snippets/topics/show_if_comment_is_in_moderation


How to Reduce the Maximum Upload File Size?

In my website there are many authors who can publish posts but some of them are uploading images bigger than 1M , and I want to reduce the max upload size to 500 kb.


Replacing static code in a template file with a sidebar and widgets?

I am new to WordPress and need help. I am currently working on the site http://ecentriconline.com/surferbeachfront. On this page, I want to display the left hand side as a widget. Right now, the left hand side is coded in the `index.php` page. Please let me know the steps that I need to do to achive this.


add_meta_box() to Category Edit Screen?

I've got a plugin that attaches itself to both the post and page editors to read and write to the post_content object. I'd like to also attach my plugin to the category manager edit screen. In the code below, lines 1 and 2 attach it to the post and page editor, but line 3, a shot in the dark, is not yet doing the trick. Any ideas on the proper way to do it?               if ( function_exists('add_meta_box') ) {          add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'post', 'side', 'high');         add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'page', 'side', 'high');      //???   add_meta_box('My-plugin', __('My plugin'), 'My_plugin_callback', 'category', 'side', 'high');     }


Pagination 404s on custom query

The basic issue is that every paginated page for my blog is going to a 404 page. /page/2/, /page/3/, etc. It used to be working fine, but is not now. I think maybe the change to 3.9 did it. Here are some of the many things I have tried in an effort to fix this. The end result of all of these were the same. The paginated links 404'd.   * deactivated all plugins   * removed and reset permalinks multiple times   * tried permalinks as default rather than /postname   * Ensured my Reading Settings > Blog pages show at most was set to the same number as my loop. (as well as more and less to test)   * I tried two separate navigation plugins and the default wordpress pagination (older posts) and it 404s every time. tried using parse_query    * tried paginate_links  Here is my code (or links to my code): home.php                   <?php require dirname( __FILE__ ) . '/blog-page.php';      blog-page.php               <?php     /*     Template Name: Blog Page - Custom     */          get_header(); ?>          <---CUSTOM CODE--->          <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;        $args = array(            'posts_per_page' => 5,            'post_type' => 'post',            'paged' => $paged        );          $wp_query = new WP_Query($args);          if($wp_query->have_posts()) :              while($wp_query->have_posts()) : $wp_query->the_post(); ?>          <---CUSTOM CODE--->                  endwhile;          wp_reset_postdata();?>
<?php next_posts_link( 'Older posts' ); ?>

<?php previous_posts_link( 'Newer posts' ); ?>
     <?php  endif; wp_reset_query();      If it helps, here is a test site I've set up with the page in question. I've left it off with the default wordpress pagination. I've run out of things to try. Any suggestions would be appreciated.


Query between dates using Date Picker fields

I'm looking to replace an events plugin that i have on my website currently. We realize we don't need a full blown calendar and things like that, we just need to be able to enter in Events with a start and end date and also custom times. I made custom fields for start date and end date using the Advanced Custom Fields -> Date Picker fields. Naturally, it's possible that an event may span over multiple months. So if an event spans from May to July, when I am in June, I want this event to appear. We have a widget on our homepage that loads in the events by month and year. For example, it shows all of the events in may. What I am having problems getting it to do is in the case where an event starts in May and ends in July, i want that event to also show up in the month of June because that event is still going on. Maybe there is a Before/After comparison thing i can do. I've updated wordpress to the latest version as of today. I'm not quite sure how i should handle the date query using the custom fields. Is there a better way that I should do this? I wonder if you may have some suggestions or can help me out with the query I'm trying to write. Here is what I have so far:               $all_events = array (     'post_type' => 'events',         'posts_per_page' => 50,         'meta_query' => array(         array(             'key'       => 'event_start_date',             'compare'   => '>=',             'value'     => $startday,         ),          array(             'key'       => 'event_end_date',             'compare'   => '<=',             'value'     => $endday,         )         ),     );      This almost works. It will display the events if the start and end date are within the same month, but I don't see the events that end in another month or two months from now. I pass the month and year to the page to filter the list by month and year...I'm wondering if there is a better compare I should use for the end date so it sees those events that may have started in the month selected but also end at a much later time. Any suggestions would be greatly appreciated. UPDATE #1: After some experimenting, I might have gotten a solution. Take a look at this.               $all_events = array (         'post_type' => 'events',             'posts_per_page' => 50,             'status' => 'published',             'meta_key'      => 'event_start_date',             'orderby'       => 'meta_value_num',             'order'         => 'ASC',             'meta_query' => array(             array(                 'key'       => 'event_start_date',                 'compare'   => '>=',                 'value'     => $startday,             ),                 array(                 'key'       => 'event_start_date',                 'compare'   => 'BETWEEN',                 'value'     => array($startday, $endday),             ),                       array(                 'key'       => 'event_end_date',                 'compare'   => '>=',                 'value'     => $endday,             )         ),     );      This one doesnt work either. I'm able to get and display the events, but some of the events don't show up exactly. The most difficult part is that an event may span over several months. It might start on April 1 and go to July 15, for example. The problem I am having is getting these events to show in the months of May and June. I've tried another approach and that's writing a SQL query to grab the posts and display them. I am running into the same issue, but maybe some further tweaks of this query we can get this to work. The values of $startday and $endday are 20140601 and 20140630. I want to grab all of the events that may occur between those two dates. I see the way I have it written now if the end date is beyond 20140630 then it won't display. I also think the date values are stored as strings, so do i need to convert them or do something to those values to make behave like real date fields? Is there a way i can split this into two queries. The first query would query all of the events and then other query could get a subset of the initial query results?               $querystr = "         SELECT *         FROM $wpdb->posts wposts, $wpdb->postmeta metastart, $wpdb->postmeta metaend         WHERE (wposts.ID = metastart.post_id AND wposts.ID = metaend.post_id)             AND (metastart.meta_key = 'event_start_date' AND metastart.meta_value > $startday )             AND (metaend.meta_key = 'event_end_date' AND metaend.meta_value <= $endday )             AND wposts.post_type = 'events'         AND wposts.post_status = 'publish'         ORDER BY metastart.meta_value ASC      ";      **UPDATE #3** I've made a little progress and i think i am almost there to the finish line with this, but I need a little bit of help with this last bit. The solution we came up with seems a little whacky to me, but I think we can get this to work. Here's what I did. I made two fields, one for start date and one for end date. I made an additional custom field to hold the range of dates in. They go in a comma-delimited string. Then I query that field to see if any of the dates in the span of dates from the first of the month to the end of month match. That's the part I am stuck on now. Tell me if i have this setup correctly. First in my functions.php file, I setup two functions to handle creating the date range and then saving the range to the custom field (which will be hidden by default so the user won't even know its there). Make a Date Range Function - i found this somewhere on the internet, probably this website.               function makeDateRangeArray($startday,$endday)     {     $aryRange=array();          $iDateFrom=mktime(1,0,0,substr($startday,5,2), substr($startday,8,2),substr($startday,0,4));     $iDateTo=mktime(1,0,0,substr($endday,5,2), substr($endday,8,2),substr($endday,0,4));          if ($iDateTo>=$iDateFrom)     {         array_push($aryRange,date('Ymd',$iDateFrom)); // first entry         while ($iDateFrom<$iDateTo)         {             $iDateFrom+=86400; // add 24 hours             array_push($aryRange,date('Ymd',$iDateFrom));         }     }     return $aryRange;     }      Then I made a function to update the textarea field with the array converted to a string of date ranges. If my start date is jan 1 and end date is jan 15, I'll get 20140101 - 20140115 placed into this extra field. I'll later query this field instead of the two date picker fields.               function update_event_date_range( $post_id ) {              $slug = 'events';              // If this isn't an 'event' post, don't update it.       if ( $slug != $_POST['post_type'] ) {           return;       }              // Qry the post by ID         if ( isset( $post_id ) ) {                  // Get the date field values             $tempstartday = get_field( "event_start_date", $post_id);             $tempendday = get_field( "event_end_date", $post_id);                  // setup date vars             $startday = date('Y-m-d', strtotime($tempstartday)); // keep hyphens             $endday = date('Y-m-d', strtotime($tempendday)); // keep hyphens                  // Make the array             $DateRangeAry = makeDateRangeArray($startday, $endday);             $date_str = implode(', ', $DateRangeAry);              // Update the new post field with the date span         update_post_meta( $post_id, 'auto_event_date_span', $date_str );          }     }     add_action( 'save_post', 'update_event_date_range' );      So, all of this working, i see all of my event posts have the correct string of dates inserted into the new field. I create a new date range based on first of the month and end of the month because i only want to see the events that occur in May or June or July. And if an event span multiple months then it should show up in those months too.               $aryDates = createDateRangeArray($startday, $endday);     $date_str = implode(', ', $aryDates);      I setup my custom query:               $all_events = array (     'post_type' => 'events',         'posts_per_page' => 50,         'status' => 'published',         'meta_query' => array(         array(         'key' => 'auto_event_date_span',         'value' => $date_str,         'compare' => 'IN'       )      )     );      I've tried sending the "value" as an array and also as a string. I know I can send an array in the "value", but what I don't know is if the "field" I am comparing my array too can have multiple values in it as well? What am I missing here OR will this just not work? I do see that if there is a one day event, meaning in the "auto_event_date_span" field if there is only one date like 20140116 it will be able to match those types of events, but once i add a range of dates to the field, it kinda stops working. bummer. Question is can i send an array or string and compare using IN in a meta_query? Sorry if my posts are getting long winded, and ultimately, once done, I'll post a final well documented answer to this otherwise difficult question.


WP Insert Post If user refreshes override new post

WP Insert Post is a very simple and easy to use function. Currently I have it set up on event triggered by whether a user is logged in during a booking to ratify their booking in its own page. My concern is that if the user were to refresh or go back and submit again the page they would end up with 2 bookings. So I am looking to prevent that from happening. One idea that I have is to use a session that is created when the page with the new booking is created. That session then populates the field ID => in the insert post array. That way overiding the information in the existing post. For this to work it would rely on the default value of ID being a wordpress creation if the session had no value, ie. a booking had not been made yet. Would that work and if not does anyone know of a way it might. Marvellous


add_rewrite_rule is not fired

I need to rewrite some urls: I have a page (id = 61), with slug `anunciantes` on wich I use a custom template to generate a `wp_query` to list a custom post_type. I need to be able to filter by two different taxonomies, `area` and `category`               function rewrite_rules() {          /* Tried:             global $wp_rewrite;             $wp_rewrite->flush_rules();         */         add_rewrite_rule('^/?anunciantes/(.*)/(.*)/$',                     '/anunciantes/?area=$matches[1]&category=$matches[2]',                     'top');         /* Also tried:        add_rewrite_rule('^/?anunciantes/(.*)/(.*)/$',                     'index.php?page_id=61&area=$matches[1]&category=$matches[2]',                     'top');         */     }     add_action('init', 'rewrite_rules');      But I allways get 404 error if I try: `/anunciantes/one/two/` ( I did go to wp-admin -> permalinks -> save changes , I understand it flushes the rewrite rules? ) So, any idea what am I doing wrong?


add filter to wp_list_categories and query if used to list tax-terms?

this is probably a confusing title of my question, but it's exactly what's describing my problem best. I want to add the category-slug as classname to my wp_list_categories() output. I found a really simple function that does exactly that it works perfectly.               add_filter('wp_list_categories', 'add_slug_css_list_categories');          function add_slug_css_list_categories($list) {              $cats = get_categories();              foreach($cats as $cat) {             $find = 'cat-item-' . $cat->term_id . '"';             $replace = 'category-' . $cat->slug . '"';             $list = str_replace( $find, $replace, $list );             $find = 'cat-item-' . $cat->term_id . ' ';             $replace = 'category-' . $cat->slug . ' ';             $list = str_replace( $find, $replace, $list );*/         }              return $list;     }      So now I have `class-categoryslug` in my `li`s for `wp_list_categories()`` I have just one more little tweak to add to it. I wrote a function to use `wp_list_categories()` also to list my taxonomy terms for a hierarchical taxonomy and a custom-post-type … looks like this.               function wr_list_taxonomy($taxonomy, $orderby, $hierarchical) {         $show_count   = 0;         $pad_counts   = 0;         $title        = '';              $args = array(           'taxonomy'     => $taxonomy,           'orderby'      => $orderby,           'show_count'   => $show_count,           'pad_counts'   => $pad_counts,           'hierarchical' => $hierarchical,           'title_li'     => $title         );              return wp_list_categories( $args );     }      So I can use `wr_list_taxonomy()` and all my taxonomy terms are listed. I want to have the same thing for my taxonomy terms as well, so that the classnames have the slug of the taxonomy term associated with it. This would be easy because I only have to replace `$cats = get_categories();` with `$cats = get_terms('event_type');` … However I can only do either or. So either I choose to use `$cats = get_categories();` and all my normal categories for the normal blogposts have the category-slug as classname or I use `$cats = get_terms('event_type');` and all my taxonomy terms have the category-slug as classname. I have no idea how I can determine inside the function `add_slug_css_list_categories()` if the function is currently fired for normal categories or for my tax-terms. I thought of               add_filter('wp_list_categories', 'add_slug_css_list_categories');          function add_slug_css_list_categories($list) {              //$cats = get_terms('event_type');         $cats = get_categories();         //if ( empty( $cats ) )         //  $cats = get_categories();      But that doesn't work. Any ideas?


How to watermark wordpress images from wp-content/uploads folder with htaccess and php?

I have a Wordpress website, due to some limits i need to have originals of the photo at the serverside, but watermarked ones on a frontend and with direct opening of the photos. I'm using Frontend content creation plugin and (as i understand) not all the plugins will fork with custom file input fields (wp_handle_upload used). I've found good solution: php file + htaccess setting with RewriteRule. The problem is that it isn't work for me for some reason. The solution is: http://dolcepixel.com/how-to-watermark-all-your-uploaded- images/ When i opening file with: /watermark.php?p=br&q=90&src=wp-content/uploads/link/to/file.jpg everything is good, watermark is on the image, but when this image loads on the page or direct link in the browser - nothing happens. It loads original image without watermaks. There is two main settings: htaccess rule               RewriteRule ^wp-content/uploads/(.*\.(jpe?g|gif|png))$ watermark.php?p=br&q=90&src=wp-content/uploads/$1      And full block of mod_rewrite section:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     RewriteRule ^wp-content/uploads/(.*\.(jpe?g|gif|png))$ watermark.php?p=br&q=90&src=wp-content/uploads/$1     </IfModule>      the php file is bigger and it's works as i see, the problem is in something else, but you can find the .php at the link on top of the post. Whats the problem with me, or Apache, .htaccess or with Wordpress? If there is a way to deny any access to /uploads/ with possibility to open images throught php proxy – it is a solution also, but when i'm trying to use /wp- content/uploads/.htaccess with "deny from all" it wont work and the direct file is opens without any problems with browser. **UPDATE:** The rule is not working even after the RewriteBase rule


How to defeat "Blog pages show at most __ posts" setting in the loop?

I'm using this script on my archive.php in order to list a link list of all posts contained in the current category. However, its limiting the result count relative to the number assigned to "Settings > Reading > Blog Pages Show At Most ___ posts". In other words, there may be 10 posts that are in this category, but its only displaying up to the number assigned in that setting. How can I change my script to ignore this setting?               <?php if(is_category()) while (have_posts()) : the_post(); ?>         <li id="post-<?php the_ID(); ?>">             <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">             <?php the_title(); ?>                           <?php echo get_link_excerpt(); ?>
     <?php endwhile; } ?>


How to hook some Unicode texts into calendar widget safely?

I collected a good numerals replacing function for WordPress calendar:               function make_bangla_number($str)     {         $engNumber = array('0','1','2','3','4','5','6','7','8','9');         $bangNumber = array('০','১','২','৩','৪','৫','৬','৭','৮','৯');         $converted = str_replace($engNumber, $bangNumber, $str);              return $converted;     }      The function clearly stating that, it's taking English numerals and just replacing them with Bānglā numerals. But the problem is with a similar function I can replace all the Gregorian Months to Bānglā scripts, but using the numerals function, I'm messing the calendar widget. Because calling:               add_filter( 'get_calendar', 'make_bangla_number' );      replaces all the numerals, even in the HTML. Suppose the previous month link in HTML:                                  « Oct             	      getting...                                  « অক্টোবর             	      So there are two problems:   1. The anchor is getting wrong path so the archive URL is not isset (`?m=২০১৩১০`)   2. The structure of Widget archive is breaking, because the HTML is getting wrong value for HTML properties (`colspan="৩"`) And you all know that all the Unicode numerals can be equal in Numerical value, but not equal to their Binary value. So the Latin Numeral `1` is not equivalent to Bānglā Numeral `১` in compare to their Binary value. So,   HOW CAN WE PROCEED WITH SUCH A FILTER/HOOK IN A SAFE WAY?


Weird behaviour when adding terms/term_taxonomies programmatically

This certainly looks like a bug to me. I put together the following code for you to test it on a fresh install. Basically, the code will add two sub categories under the "uncategorized" to achieve the following effect               uncategorized        sub-uncategorized            sub-sub-uncategorized      No problems with adding them to the wp_terms and wp_term_taxonomies. Both Parent ID's are properly added. The problem is in the wp admin ui. You only see the uncategorized and the sub- uncategorized. The last one ( sub-sub ) is missing in action! But if you go to the parent dropdown selection on the very same "add categories" page, you will see that both the sub-uncat" and the "sub-sub-cat" appears there, properly indented - appearing exactly in the following correct hierarchy               uncategorized        sub-uncategorized            sub-sub-uncategorized      To bring the missing sub-sub-cat into the main view, you have to do one of the following steps; you either recycle the wp by stopping and starting. or simply add a dummy cat and then click on the "categories" link to list all cats. then wp remembers to display the subs properly. Anyone has any idea why this is happening? I'd appreciate any programmatic remedies so that I don't have to go thru the silly steps t just to get the cats into view. The code is below. Just adjust the wp-load.php path accordingly before you can test it on a fresh install and then check what I described above for yourself.               <?php          error_reporting (E_ALL);          //load the wp shebang into this page     include (" put the full path here to the wp-load.php");               define('WP_USE_THEMES', false);               //add a sub category under the "uncategorized" that fresh install comes with     $Term = "Sub-UnCategorized";     $args = array('parent' => 1 );     wp_insert_term($Term, "category", $args);               //add another sub under the recentyl created above.      $Term = "Sub-Sub-UnCategorized";     $args = array('parent' => 3 );     wp_insert_term($Term, "category", $args);          echo "<pre>          After running this code, you will notice that the Sub-Sub-UnCategorized is missing from the view.           But what's funny is the dropdown.      Check the dropdown for the *parent* selection, you will see that the missing     Sub-Sub-UnCategorized is there.           In order to get the missing sub-sub into the view, you will have to do two things.           1 - Add a dummy cat.     2 - Click on the categories link on the admin navigation.          With that, wp will sort this problem out and you will see everything you should have.          I cannot figure out what's causing this behavior and how to remedy this short adding the dummy cat and removing it later.           </pre>";          ?>


Change appearance based on category but post is in two main categories

I want to change header and menu based on what category a post is listed in. I could duplicate the post and assigned each of the two categories separately but this sounds messy and bleh. The post/s in this example belong in both "pirtek" and "btcc". http://www.talkativebroadcasting.co.uk/ but the posts with pirtek need to be styled with custom header etc. (and eventually custom menu...which makes me think perhaps I should just duplicate for easy implementation of a seperate menu?) What do you think? As it stands my standard header is prioritised every time                   <php     if ( has_category('pirtek') ) {       $header = 'http://www.talkativebroadcasting.co.uk/wp-content/uploads/2013/11/cropped-pirtekheader.png'     } else {       $header = 'http://talkativebroadcasting.co.uk/wp-content/uploads/2013/06/cropped-talkativeheader2.png'     }     ?>


Save/retrieve form data best practises for theme development

I'm building a theme and I have a custom page template with a `<form>` which is for the vistors to fill in and submit. I'm processing the data with help from hooks and this is all separated from the template file. I've come to the moment where I have to save the data to the database. What are the best practises when it comes to saving custom form data for a theme developer? I'm expecting at least a thousand of form submissions and about ten different field data to be saved. Should I   1. Create a separate db table and use $wpdb to save/retrieve data   2. Create a custom post and create an entry for every form submission   3. Something way smarter (up to you)


How to structure a plugin

This isn't a question about how to build a WordPress plugin. Rather, what, if any, guides could be applied to how to put together the file architecture of any plugin. Some other programming languages or libraries have very controlled ways of organizing directories and files. Sometimes this is annoying and highlights the freedom that PHP offers, but on the flip-side WordPress plugins are put together in any fashion as determined by their author. _There isn't a right answer_ , but my hope is to refine how I, and others, build plugins to make them more friendly for other developers to disect, easier to debug, easier to navigate, and possibly more efficient. The final question: **what do _you_ think is the best way to organize a plugin?** Below are a few sample structures, but in no way is an exhaustive list. Feel free to add your own recommendations. **Assumed Default Structure**   * `/wp-content`     * `/plugins`       * `/my-plugin`         * `my-plugin.php` **Model View Controller (MVC) method**   * `/wp-content`     * `/plugins`       * `/my-plugin`         * `/controller`           * `Controller.php`         * `/model`           * `Model.php`         * `/view`           * `view.php`         * `my-plugin.php` _MVC's three parts:_   * The **model** interacts with the database, querying and saving data, and contains logic.   * The **controller** would contain template tags and functions that the view would utilize.   * The **view** is responsible to display the data provided by the model as constructed by the controller. **Organized by type method**   * `/wp-content`     * `/plugins`       * `/my-plugin`         * `/admin`           * `admin.php`         * `/assets`           * `css/`           * `images/`         * `/classes`           * `my-class.php`         * `/lang`           * `my-es_ES.mo`         * `/templates`           * `my-template.php`         * `/widgets`           * `my-widget.php`         * `my-plugin.php` **Loosely organized method**   * `/wp-content`     * `/plugins`       * `/my-plugin`         * `css/`         * `images/`         * `js/`         * `my-admin.php`         * `my-class.php`         * `my-template.php`         * `my-widget.php`         * `my-plugin.php`


Why is admin ajax reloading my page

As far as I know I haven't used Ajax anywhere in my code. Yet, while debugging, I have breakpoints being hit with 'admin-ajax.php' at the root of the call stack. This second hit of my breakpoint occurs between 10 and 30 seconds after the original. The weird thing is, as of yet there is no HTML output, so no scripts are present in the browser. Any ideas why or where this is happening and why my php scripts are being called twice?


Load parent pages when there are no child pages

I use the following code to load subpages in a sidebar on all pages:               <?php                      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0&depth=1');                       if ($children) { ?>
                       <?php echo $children; ?>
                       <?php } ?>      It works well on all pages with sub pages or children. But what if I want this sidebar with children pages to load with parents]when there are no children? What code to add to another if or elseif? Basically I need to add a `No children? Then loads parent pages..` **Update:** At http://www.fldtrace.com/wordpress/how-to-display-parent-page-title-in- wordpress I found this code to load the parent page link:               <?php          $parent_title = get_the_title($post->post_parent);?>     <a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent_title;?>      Which is great, but I need to list all parent pages, which are sub pages of the grand parent...


titles in recent posts appear together in all languages with qtranslate

I´ve been dealing with a qtranslate problem (Im using the twentyten theme) and i hope you cna help me, I´ve been searching on forums and sites but to no vail (their solution is for other them called atahualpa). First of all the loading speed is too slow. The other problem is that I have a static page that for now uses the "Yet Another Related Posts Plugin" plugin because it is the only plugin I found that shows the recent posts list with a featured thumbnail (but I have the problem that it does not break lines for the expert texts) , and then in other pages I use the "NuRelm Get Posts" to get a list of recent post of a certain cathegory (like here http://eltemadehoy.net/?page_id=11 ). My problem is that in this "NuRelm Get Posts" (besides being unable to use thumbnails) all the titles of the posts that are translated with qtranslate are shown continous VG "Porque al mundo le importa la independencia de Escocia.Why The World Cares About Scotland´s Independence." So the titles appear in both languages one after the other. I have some content that is translated and some that isn´t but might be in the future. for now I simply leave blank the other untranslated language title, content and excerpt of a post. But those are are translated invariably get a duplicated title. Help please.


wp language changed after upgrading to centos 5.8

I have a spanish wordpress blog. after upgdaring centos 5.7 to 5.8 the language changed to english . how can I recover it to spanish ?


Bulk theme settings in wordpress multisite

I have a multisite with 500+ subsites. I would like to install the same theme in all 500+ sites. Most of them requires configuration like selecting sidebar(left/right), Selecting primary menu etc. Is there any plugin available to do this job? OR Can anyone give me some idea? Thanks


Generating add_settings_section() calls dynamically

I have some pieces of code within functions.php that I could easly replace with much shorter functions, like, for example:               function register_sections() {        add_settings_section('SOMETHING_settings', 'SOMETHING Settings', 'generate', 'SOMETHING_page' );        add_settings_section('SOMETHING2_settings', 'SOMETHING2 Settings', 'generate', 'SOMETHING2_page' );        add_settings_section('SOMETHING3_settings', 'SOMETHING3 Settings', 'generate', 'SOMETHING3_page' );        add_settings_section('SOMETHING4_settings', 'SOMETHING4 Settings', 'generate', 'SOMETHING4_page' );     (...)     }          add_action('admin_init', 'register_sections');      I guess function replacing the code above will look like:               function settings_sections() {     $array = ('SOMETHING','SOMETHING2','SOMETHING3', 'SOMETHING4');        foreach($array as $section) {            echo "add_settings_section('".$section."_settings','".$section." Settings','generate','".$section."_page' ) ;";         }      But I'm not sure how to initalize this dynamically generated content? Of course `add_action('admin_init', 'settings_sections');` echoes function's output on all admin pages instead of registering sections.


Migrating to Wordpress - but how will it do "structured" data?

Over the years we've looked after a few Wordpress sites but never anything more than a bit of maintenance. We've never started from scratch in Wordpress or converted an existing site over to Wordpress. But our occasional brush with Wordpress has always been positive. So now we _are_ thinking of converting an existing site to WP. One concern, as a relative beginner, is how will it do **structured** data? For example, we have a site where the site owner puts in her own product inventory, price, dimensions, description etc. Plus three images down the side. Simplified mockup:   ![enter image description here](http://i.stack.imgur.com/GWEqC.png)   I am sure WP can do this structured stuff but what is the way forward? I'm assuming the possibilities are:   1. Make each product a "post" and the site owner herself has to lay out the dimensions, price, images etc free style. _ie. Not structured at all. Not really what we are looking for._   2. Search for a "Inventory" or "Product Info" plug in. _I am sure such things exist but is it likely to do exactly what we want? e.g. will it force the user to put in 3 images exactly and then lay them out exactly per the existing site, down the side etc. Plus what if we have some very domain-specific product fields (not just colour, price). Will those be allowed?_   3. Get down and dirty with PHP and script a structured page in the theme. _Not sure if that's the right terminology, also this would be a not insignificant learning curve for a PHP novice_ Are those three ideas correct and which is the way forward?


get_term_children returns unknown int though term has no child

I am running get_term_children to check if a term has children. On a term which does not have have children wp returns an array containing a single int : 12 though that does not relate to any term. I did recently delete a child term though.                $hasChildren = get_term_children( $categories[$i]->term_id, 'my_tax' );      var_dump($hasChildren);      returns               array (size=1)     0 => int 12


get_post_meta fields don't show up on posts page

I'm new here, and to coding! I've been working hard (so, so hard...so hard) to create my website and with occasional help I've created a look and feel I like using some custom get_post_meta fields for my banner and background under header.php.               <div id="page" class="hfeed site">     <?php do_action( 'before' ); ?>     <?php     $banner = get_post_meta($post->ID, 'banner', true);     if (is_front_page() || $banner == '') { ?>         <header id="masthead" class="site-header" role="banner">     <?php     } else {     ?>         <header id="masthead" class="site-header" role="banner" style="background-image: url(<?=$banner?>); background-size:cover">     <?php } ?>       _But I'm really stumped on this problem_ --none of them show up on my /blog page, which is a pretty important page; it just shows the site's general header content, same as the front page. I've researched enough to understand that this is because I have the blog page set as the posts page (with a static homepage), so it's not referencing the same header.php content as the pages are but rather the "homepage template" which is a template that indexes the posts, so my /blog page no longer has a page ID and isn't included under `<div id="page">` that is being referenced for my custom fields. So how do I get this post index template to reference the same banner code as the _pages_ of my site? The solution on this page-- Custom fields won't display on my blog page --seems right for my problem too, but I can't figure out how and where to use the `get_option( 'page_for_posts' )` code in my own code!


How to add extra items in wp nav menu

I have a menu in wordpress where each menu item has an extra item. For example: I have a "Home" menu item where I have an extra item "come see us", I have an "About Us" menu item where I have an extra item "Know us". For example: I have an li menu item i.e: * HOME come see us How to get this span item seperately for each menu item. Just wondering how to do this in wp_nav_menu in wordpress. This is wordpress and this should be possible I think. Appreciate your help. Thanks.


404 Page Not Found for Only One Post

I have 40+ posts on my blog. Only one of them is going to a 404 page when I click the title (visit the permalink). To see it in action: http://thegrovestead.com/tag/strawberries/ Look for the post "Cure for the common slug" and click the title (permalink: http://thegrovestead.com/cure-for-the-common-slug/) You will get the 404 error. Note that all the other posts on that page will display the single post fine. My htaccess is clean:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      I've disabled all the plugins. I've tried deleting and recreating the post, still getting the 404 error. If I modify the slug by one letter, it works. But the specific permalink above does not work. There must be an explanation. Any advice?


Fix for empty post titles when using WP Yoast SEO plugin

I have a filter to fix visually empty post titles in WordPress, by replacing them with an excerpt of the content               add_filter( 'the_title', 'empty_title_fix' );     add_filter( 'single_post_title', 'empty_title_fix');     function empty_title_fix( $titles ) {     if ( strlen( trim( $titles ) ) < 1 ) {         $daa = get_post($idd);         $conten = $daa->post_content;         $contents = trim(strip_tags($conten));         if (strlen($contents) > 40) {             $titles = substr($contents, 0, 40) . '...';         } elseif (strlen($contents) == 0) {             $format = get_post_format();             if ( false === $format ) {                 $format = 'post';                  }             $titles = ucfirst($format);             } else {                 $titles = substr($contents, 0, 40);             }         }     return $titles;     }      When I'm using Yoast SEO plugin, the previous filters don't apply to the system Yoast uses to populate the `WP_Title()` tag with variables, and just show the post title empty. I have tried using a similar thing to the code posted using the `wpseo_title` filter, but it don't work as it ends replacing the whole title and ignoring the other variables (like %%sep%% and %%sitename%%).


Conditional loop based on current page

I'm trying to get the loop below to display only the post with the category that reflects the given condition but it doesn't seem to work. Any Ideas on how this can be achieved?                   <?php          if ( is_page('css-tutorial'));           global $x;          $x = 'css';              ?>         <?php              // assign the variable as current category            $category = $x;              // concatenate the query           $args = 'category_name=' . $category;                      // run the query           query_posts( $args );              $query = new WP_Query('category_name=$x');              if($query->have_posts()) : while($query->have_posts()) : $query->the_post();               ?>

             <?php the_post_thumbnail($size, $attr); ?>

               <?php the_title(); ?>
             <?php the_excerpt(); ?>             <a href="<?php echo get_permalink(); ?>">             <?php the_author(); ?>             |             <?php the_date(); ?>             | → Continue

                       <?php endwhile; ?>         <?php endif; ?>


Enabling user creation with " Active Directory Integration"

For our internal wordpress site, we have installed the plugin "Active Directory Integration" and we are able to have the users login using the domain password. How to have the users getting created automatically? Further I was not able to get a step-by-step guide that covers everything about this plug-in. Any suggestions would be greatly appreciated. Thanks, Kannan.


Create posts using markdown?

Can I replace the WYSIWYG editor with a markdown editor? If so, what plugin can I use?


Implementing the twentythirteen responsive menu in twentytwelve

I've made plenty of 2012 child-themes in the past as the theme really suits my overall needs, but having it be responsive never was that important. Now however I'm creating a site that really needs a good responsive menu. And in all honesty, I think the 2012 one is terrible. So I'm looking for a way to implement the 2013 menu (or another responsive type menu like: http://demos.cyberchimps.com/responsivepro/) in the 2012 theme. No idea as to where to start, so I was hoping someone here could point me in the right direction. Thanks.


SSH Upgrade Problem

![alt text](http://i.stack.imgur.com/tjqez.png) I keep getting the same error, any ideas?   1. I have generated a key without a password using `ssh-keygen`   2. I set permissions on the keys to 600   3. I have successfully logged in using `ssh -i /root/.ssh/id_rsa 1**.**.*8.128`   4. I have tried changing hostname to `localhost` and `127.0.0.1` The server is running CentOS 5.4.


Add term list as class

I am trying to add a list of terms as a class for custom post types.               <?php while($portfolio->have_posts()) : $portfolio->the_post(); ?>                              <?php $categories = get_the_terms($post->ID, 'project_type');                             foreach($categories as $category){                                      return $category->name;                             }                         ?>                                    <div class='portfolio-tile <?php echo $category ;?>'>                             <?php the_post_thumbnail('medium' ); ?>                              </div>                          <?php endwhile; ?>                          </div>                  <?php wp_reset_query(); ?>


Is the 404 page the same as "well this is embarrasing" page?

I'm not sure if wordpress 3 upgraded itself from displaying 404 pages to having a "well, this is embarrassing" text in pages that aren't there, but I would like to know whether the tutorials that say "fix your 404 pages" would fix my "well this is embarrassing" page as well. Thanks EDIT: Let's say it's the latest twenty-eleven theme.


Is it possible to retrieve a post and its metadata at the same time?

I usually use two steps to retreive a list of posts and the associated metadata: call get_posts(or a custom WP_Query), and then loop through each post returned and retrieve each posts metadata one by one. Is there any way to combine this into a single query? I guess I'm looking for something like a get_posts_with_meta() function?


Get the post_id of a new post

There are several ways to get the id of a post after it has been saved (auto, etc.), but is there a way to get the post id immediately after you create a new post? I am trying to create a directory using the post id, but I cannot seem to get a static post id. the code below seems to work but I get an auto incremented id back every time the new post auto saves the draft, I continually get a new number.               function myfunction( $id ) {             if (!file_exists("/www/foo/blog/wp-content/uploads/" . $id)) {                 mkdir("/www/foo/blog/wp-content/uploads/" . $id, 0777);             }     }     add_action('save_post', 'myfunction');      I would like to get the post id that it will be saved as. Surely WP has a method for determining this correct? Or does the draft auto save every minute incrementing the id by one until the actual 'publish' button is clicked? thoughts? cheers! bo


Undefined Index. But isset not working?

I have social icons that are being set via my theme options in WP. Of course if they are not entered I am getting an Undefined Index error. I tried wrapping isset around which removes the error, but when my options panel is saved it shows all the icons? Even if they have not been set? Confused on how to do the isset correctly?
     <?php if ( $theme_global['social-twitter'] ) { ?>
<a class="social-twitter" href="<?php echo $theme_global['social-twitter']; ?>" title="<?php _e( 'View Twitter Profile', 'lang' ); ?>" target="_blank">
Twitter

     <?php } if ( $theme_global['social-facebook'] ) { ?>
<a class="social-facebook" href="<?php echo $theme_global['social-facebook']; ?>" title="<?php _e( 'View Facebook Profile', 'lang' ); ?>" target="_blank">
Facebook

     <?php } if ( $theme_global['social-linkedin'] ) { ?>
<a class="social-linkedin" href="<?php echo $theme_global['social-linkedin']; ?>" title="<?php _e( 'View Linkedin Profile', 'lang' ); ?>" target="_blank">
Linkedin

     <?php } if ( $theme_global['social-pinterest'] ) { ?>
<a class="social-pinterest" href="<?php echo $theme_global['social-pinterest']; ?>" title="<?php _e( 'View Pinterest Profile', 'lang' ); ?>" target="_blank">
Pinterest

     <?php } ?>
      Many thanks


How to modify a class in load-scripts.js ?

I need to semplify the image edit interface and I need to override a couple of function defined in load-scripts.js in the class imageEdit. There is a way to override it?   And there is an unminified version of the wp backoffice javascript? Thank you ^^


How to Change my website language from English to Danish?

I have developed a website in Wordpress in english language. Now I want to change the language to Danish. Please help me how to change it.. I want to change by easiest and very less time consuming process... Please help me....


Some posts from custom post type to subdomains

I have custom post type where all posts associated with some persons. **Like:** `mysite.com/masters/master-name/` And i need to have redirection from `master-name.mysite.com`. This redirection will be created automatically.


Which wordpress function is the caption shortcode linked to?

I have used this code in my page content to try and output an image + caption with a custom caption class and id... `[caption id="my-caption-id" class="my-caption-class" align="alignnone" width="399"]<img src="whatever.jpg" alt="whatever" width="399" height="600" /> My caption text[/caption]` ...but the caption's id and class names are not being output. After some digging around, I found the `img_caption_shortcode` function in wp- includes/media.php which handles the id and class attributes of the `[caption]` shortcode but, after some experimenting, it seems this function is not executed with the `[caption]` shortcode... So does anyone know which function the `[caption]` shortcode is linked to? (and / or how to get the class and id attributes to be output on a caption?) I'm using WordPress 3.9.2 .


Include Category With Tax Query

I'm using The Events Calendar plugin but I thought I'd post it here as I believe this particular function works the same as `get_posts()`. I'm trying to use the function to display only posts from one particular category ('Lead Event'):               <?php              $args = array( 'posts_per_page' => 5,                        'eventDisplay' => 'all',                        'tax_query', array(                             array(                                 'taxonomy' => 'event-type',                                 'field' => 'slug',                                 'terms' => 'lead-event'                            )                        ),         );              $events = tribe_get_events( $args );          ?>      But it's just returning 5 posts, regardless of which category they're in I've also tried with the `IN` operator but still no luck:               <?php         $args = array( 'posts_per_page' => 5,                        'eventDisplay' => 'all',                        'tax_query', array(                             array(                                 'taxonomy' => 'event-type',                                 'field' => 'slug',                                 'terms' => 'lead-event',                                 'operator' => 'IN'                            )                        ),         );              $events = tribe_get_events( $args );          ?>      Can anyone see what I'm doing wrong?


Cherry framework adding custom post type

Looking for some information as developer docs for the cherry framework seem to be non existent. I am trying to add a custom post-type with the following code in my theme-init file: (this code works fine in a standard installation used with a theme with the cherry framework it does not display i just get a 404 error)                   <?php          add_action( 'after_setup_theme', 'my_setup' );          if ( ! function_exists( 'my_setup' ) ):          function my_setup() {              // This theme styles the visual editor with editor-style.css to match the theme style.         add_editor_style();              // This theme uses post thumbnails         if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9             add_theme_support( 'post-thumbnails' );             set_post_thumbnail_size( 299, 190, true ); // Normal post thumbnails             add_image_size( 'slider-post-thumbnail', 1386, 563, true ); // Slider Thumbnail             add_image_size( 'slider-thumb', 96, 41, true ); // Slider Small Thumbnail         }              // Add default posts and comments RSS feed links to head         add_theme_support( 'automatic-feed-links' );              // custom menu support         add_theme_support( 'menus' );         if ( function_exists( 'register_nav_menus' ) ) {             register_nav_menus(                 array(                   'top_header_menu' => 'Top Header Menu',                   'header_menu' => 'Header Menu',                   'footer_menu' => 'Footer Menu'                 )             );         }     }     endif;               /* Slider */     function my_post_type_slider() {         register_post_type( 'slider',                     array(                      'label' => __('Slides', CURRENT_THEME),                      'singular_label' => __('Slide', CURRENT_THEME),                     '_builtin' => false,                     'exclude_from_search' => true, // Exclude from Search Results                     'capability_type' => 'page',                     'public' => true,                      'show_ui' => true,                     'show_in_nav_menus' => false,                     'rewrite' => array(                         'slug' => 'slide-view',                         'with_front' => FALSE,                     ),                     'query_var' => "slide", // This goes to the WP_Query schema                     'menu_icon' => get_template_directory_uri() . '/includes/images/icon_slides.png',                     'supports' => array(                             'title',                             'custom-fields',                 'thumbnail')                         )                      );     }          add_action('init', 'my_post_type_slider');                    /* Portfolio */     function my_post_type_portfolio() {         register_post_type( 'portfolio',                     array(                      'label' => __('Projects', CURRENT_THEME),                     'singular_label' => __('Project', CURRENT_THEME),                     '_builtin' => false,                     'public' => true,                      'show_ui' => true,                     'show_in_nav_menus' => true,                     'hierarchical' => true,                     'capability_type' => 'page',                     'menu_icon' => get_template_directory_uri() . '/includes/images/icon_portfolio.png',                     'rewrite' => array(                         'slug' => 'portfolio-view',                         'with_front' => FALSE,                     ),                     'supports' => array(                             'title',                             'editor',                             'thumbnail',                             'excerpt',                             'custom-fields',                             'comments')                         )                      );         register_taxonomy('portfolio_category', 'portfolio', array('hierarchical' => true, 'label' => 'Categories', 'singular_name' => 'Category', "rewrite" => true, "query_var" => true));         register_taxonomy('portfolio_tag', 'portfolio', array('hierarchical' => false, 'label' => 'Tags', 'singular_name' => 'Tag', 'rewrite' => true, 'query_var' => true));     }          add_action('init', 'my_post_type_portfolio');               /* Testimonial */     function my_post_type_testi() {         register_post_type( 'testi',                     array(                      'label' => __('Testimonial', CURRENT_THEME),                      'public' => true,                      'show_ui' => true,                     'show_in_nav_menus' => false,                     'menu_position' => 5,                     'rewrite' => array(                         'slug' => 'testimonial-view',                         'with_front' => FALSE,                     ),                     'supports' => array(                             'title',                             'custom-fields',                             'thumbnail',                             'editor')                         )                      );     }          add_action('init', 'my_post_type_testi');               /* Services */     function my_post_type_services() {         register_post_type( 'services',                     array(                      'label' => __('Services', CURRENT_THEME),                      'public' => true,                      'show_ui' => true,                     'show_in_nav_menus' => false,                     'menu_position' => 5,                     'rewrite' => array(                         'slug' => 'services-view',                         'with_front' => FALSE,                     ),                     'supports' => array(                             'title',                             'thumbnail',                             'editor')                         )                      );     }          add_action('init', 'my_post_type_services');                    /* FAQs */     function phi_post_type_faq() {         register_post_type('faq',                      array(                     'label' => __('FAQs', CURRENT_THEME),                     'singular_label' => __('FAQ', CURRENT_THEME),                     'public' => false,                     'show_ui' => true,                     '_builtin' => false, // It's a custom post type, not built in                     '_edit_link' => 'post.php?post=%d',                     'capability_type' => 'post',                     'hierarchical' => false,                     'rewrite' => array("slug" => "faq"), // Permalinks                     'query_var' => "faq", // This goes to the WP_Query schema                     'supports' => array('title','author','editor'),                     'menu_position' => 5,                     'publicly_queryable' => true,                     'exclude_from_search' => false,                     ));     }     add_action('init', 'phi_post_type_faq');               /* Our Team */     function my_post_type_team() {         register_post_type( 'team',                     array(                      'label' => __('Our Team', CURRENT_THEME),                      'singular_label' => __('Person', CURRENT_THEME),                     '_builtin' => false,                     'exclude_from_search' => true, // Exclude from Search Results                     'capability_type' => 'page',                     'public' => true,                      'show_ui' => true,                     'show_in_nav_menus' => false,                     'menu_position' => 5,                     'rewrite' => array(                         'slug' => 'team-view',                         'with_front' => FALSE,                     ),                     'supports' => array(                             'title',                             'custom-fields',                             'editor',                 'thumbnail')                         )                      );     }          add_action('init', 'my_post_type_team');          function products_post_type() {              $labels = array(             'name'                => _x( 'Products', 'Post Type General Name', 'text_domain' ),             'singular_name'       => _x( 'Product', 'Post Type Singular Name', 'text_domain' ),             'menu_name'           => __( 'Products', 'text_domain' ),             'parent_item_colon'   => __( 'Parent Product:', 'text_domain' ),             'all_items'           => __( 'All Products', 'text_domain' ),             'view_item'           => __( 'View Product', 'text_domain' ),             'add_new_item'        => __( 'Add New Product', 'text_domain' ),             'add_new'             => __( 'New Product', 'text_domain' ),             'edit_item'           => __( 'Edit Product', 'text_domain' ),             'update_item'         => __( 'Update Product', 'text_domain' ),             'search_items'        => __( 'Search products', 'text_domain' ),             'not_found'           => __( 'No products found', 'text_domain' ),             'not_found_in_trash'  => __( 'No products found in Trash', 'text_domain' ),         );         $args = array(             'label'               => __( 'product', 'text_domain' ),             'description'         => __( 'Product information pages', 'text_domain' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ),             'taxonomies'          => array( 'category', 'post_tag' ),             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'capability_type'     => 'page',         );         register_post_type( 'product', $args );          }                    // Hook into the 'init' action     add_action( 'init', 'products_post_type');                    function my_connection_types() {         p2p_register_connection_type(              array(                 'name' => 'testi_to_product',                 'from' => 'testi',                 'to' => 'product',                 'admin_box' =>                  array(                     'show' => 'any',                     'context' => 'advanced'                 )             )         );     }     add_action( 'p2p_init', 'my_connection_types' );     ?>      after creating new products i am unable to get the post to display, i just get a 404 error, for the category and the single page. has anyone managed to add a new post-type to the cherry framework and can point me in the right direction for integrating it properly?


Advanced wp_query - custom date and postname

I'm trying to write a query and sort by:   1. **custom date**   2. **postname (in reverse order)** because my postnames have a version string at the end and the latest entry should stay on the top of each other. That's why **the posts should display in the following order** :   1. PostnameA Version 10 (newest date)   2. PostnameA Version 09 (older date)   3. PostnameA Version 08 (oldest date)   4. PostnameB Version 05 (newest date)   5. PostnameB Version 04 (older date) and so on... **The following code already displays the posts considering the custom date like so** :   1. PostnameA Version 10 (newest date)   2. PostnameB Version 05 (newest date)   3. PostnameA Version 09 (older date)   4. PostnameA Version 08 (oldest date)   5. PostnameB Version 04 (older date) and so on... **but how can I also sort the posts by name after that?**               <?php      $today = date('Y-m-d');          $args = array(       'post_type' => 'product',       //'posts_per_page' => 50,       'product_cat' => $catTerm->slug,       'post_status' => 'publish',       //'orderby' => 'name',       //'order' => 'ASC',       'meta_query' => array(                  array(              'key' => 'PUBLICATIONS_date', // yy-mm-dd              'value'   => $today,  // value for comparison              'compare' => '<=',    // method of comparison              'type' => 'CHAR',              //'paged' => $paged               //'type'    => 'DATE'             )              )     );     ?>      Any help would be greatly appreciated.


User field and access post

I’ve create two custom post type (all'code here). I use the ACF Plugin to create custom post and 've create a relationship user field with the field name "sleziona_cliente". I create a cpt post and i've assign every post to every different user (usign the relationship user field of ACF). On function.php i've creat a function to make an automatic redirect. If the user logged have a post assigned (with user acf field), the script redirect the visitor to their post, if there aren’t any post redirect to a specific page.               function login_redirect     ( $redirect_to, $request, $user ){     global $wpdb;$results = $wpdb->get_var     ( "select post_id from az_postmeta where meta_key = 'seleziona_cliente' and meta_value= '".$user->id."'" );     if($results){$permalink = get_permalink( $results );         return $permalink;} else    return $redirect_to;}     add_filter( 'login_redirect', 'login_redirect', 10, 3 );      This scirpt function but i have a problem. Every visitor can see on frontend every CPT post and this is not ok. How can i do to restrict the access to only user slect on user field acf? I think to set every CPT ad private post and create a new function to assign the read private cpt to ACF user select. I try some code but i have not a good result. I try to set this on single_cpt.php               <?php get_header(); ?>     <?php if (is_user_logged_in()) { ?>
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <h2 class="title" id="post-<?php the_ID(); ?>"><?php the_title(); ?>
     <?php the_content(__('Read the rest of this page »')); ?>     <?php endwhile; endif; ?>
     <?php comments_template(); ?>          <?php } else {     // they aren't logged in, so show them the login form            ?>

I'm sorry, but you must be a logged in member to view this page. Please either login below or <a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register">Register today.p>
       <?php     // !!! IMPORTANT !!! If you are using permalinks to rewrite the urls     // of your site, you will need to adjust the action of the form below.     // The form will look for the wp-login.php file based on the action.     // If the rewritten url of your page is     // http://www.yourdomain.com/your_page_name/,     // you will need to change the action in the form to     // action='../wp-login.php'     // so it will look in the 'directory' above /your_page_name/     // for the wp-login file.     // Depending on your url structure, you may have to go up several directories.     // For instance, if your page is located at     // http://www.yourdomain.com/some_section/your_page_name/     // you will need to change the action to     // action='../../wp-login.php'     ?>     <form name='loginform' id='loginform' action='<?php bloginfo('wpurl'); ?>/wp-login.php' method='post'>
           Username
           <input type='text' name='log' id='log' value='' size='20' tabindex='1' />

           Password
           <input type='password' name='pwd' id='pwd' value='' size='20' tabindex='2' />

                      <input name='rememberme' type='checkbox' id='rememberme' value='forever' tabindex='3' />           Remember Me

           <input type='submit' name='submit' id='submit' value='Login »' tabindex='4' />           <?php //use a hidden field to return them to the page they came from ?>           <input type="hidden" name="redirect_to" value="<?php echo $_SERVER["REQUEST_URI"]; ?>" />
       </form>       <?php } ?>          <?php get_sidebar(); ?>     <?php get_footer(); ?>      And function...so if the user is not logged can't see the post. But how can i do to set that only $user->id that i've select on ACF relationship user field can see his post? Thanks


wp_nav_menu, walker class, categories as classes of li

OK I'm trying to show my principal menu so I use the following code:               <?php $defaults = array(         'theme_location'  => '',         'menu'            => '',          'container'       => false,         'container_id'    => '',         'menu_class'      => 'menu',          'menu_id'         => '',         'echo'            => true,         'fallback_cb'     => 'wp_page_menu',         'before'          => '',         'after'           => '',         'link_before'     => '',         'link_after'      => '',         'items_wrap'      => '
%3$s
',         'depth'           => 0,         'walker'          => new description_walker()     ); ?>     <?php wp_nav_menu( $defaults ); ?>      The menu is filled with the category names (not pages) and it outputs the following:

menu

menu

menu

menu

menu

menu

menu

menu

menu

      I would to replace all these li classes with the category name so I try to use a walker class in functions.php: https://gist.github.com/1053467 So I have minimal stuff but I don't know how to add the classes. class="category-categoryname" (i.e. class="category-photography"). Many thanks for your time and help.


Noob Loop Question

I come with a basic question but I can not solve, I think that will be easy for you. I would like, if I have 2 or more post on loop, show the entire loop. I tried the following:               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $portfolio = new WP_Query(array('post_type' => 'project', 'posts_per_page' => 12, 'paged' => $paged));     $count = 0; ?>          <?php if ($portfolio < 2) : ?>                  [CONTENT LOOP]         <?php if ($portfolio) :  while ($portfolio->have_posts()) : $portfolio->the_post();             [/CONTENT LOOP]                  <?php endwhile; ?>         <?php endif; ?>     <?php endif; ?>      However, that didnt work, the single post still appearing. Like I said, if i have one post in the loop, will show nothing of the loop. Sorry for the question, is that I'm not very familiar with wordpress yet. Thank you!


Understanding the use of wp_reset_query();

I am not able to understand why we need to use `wp_reset_query();` could anybody explain me?               global $more;     $more = 0;     query_posts('cat=3');     if(have_posts()) :          while(have_posts()) :the_post();          ?>
<a href="<?php the_permalink(); ?>"><?php the_title();?>

<?php the_content('Read More') ?>
          <?php          endwhile;     endif;     wp_reset_query();?>


Apply cropping to custom size from media library

I want to be able to apply a specific crop to the medium size or any other custom image size i define. I want to control the crop as it is controlled in the media library for the thumbnail. I want to have an option added into the "Apply changes to:" medium/anything i want. Is this something possible? the apply changes section


How to parse date format using JSON API plugin 1.0.7?

I'm using the JSON API plugin to display my blog posts on my mobile website. I've got everything working as I'd like, however the the date displays in this format:                2012-03-21 20:03:30      However, I'd like it to display like so. Or something similar.:                March 21, 2012      This is the Javascript I'm using to display the blog posts:                var MYBLOG_LIMIT = 7;         var MYWRAPPER_CLASS = 'homeblog';              var WP={open:function(b){var a={posts:function(){var d=MYBLOG_LIMIT;var e=0;var c={all:function(g){var f=b+"/api/get_recent_posts/";f+="?count="+d+"&page="+e+"&callback=?";jQuery.getJSON(f,function(l){var k=l.posts;for(var j=0;j<k.length;j++){var h=k[j];h.createComment=function(i,m){i.postId=h.id;a.comments().create(i,m)}}g(k)})},findBySlug:function(f,h){var g=b+"/api/get_post/";g+="?slug="+f+"&callback=?";jQuery.getJSON(g,function(i){h(i.post)})},limit:function(f){d=f;return c},page:function(f){e=f;return c}};return c},pages:function(){var c={findBySlug:function(d,f){var e=b+"/api/get_page/";e+="?slug="+d+"&callback=?";jQuery.getJSON(e,function(g){f(g.page)})}};return c},categories:function(){var c={all:function(e){var d=b+"/api/get_category_index/";d+="?callback=?";jQuery.getJSON(d,function(f){e(f.categories)})}};return c},tags:function(){var c={all:function(e){var d=b+"/api/get_tag_index/";d+="?callback=?";jQuery.getJSON(d,function(f){e(f.tags)})}};return c},comments:function(){var c={create:function(f,e){var d=b+"/api/submit_comment/";d+="?post_id="+f.postId+"&name="+f.name+"&email="+f.email+"&content="+f.content+"&callback=?";jQuery.getJSON(d,function(g){e(g)})}};return c}};return a}};          var blog = WP.open('http://www.endofphotography.com/');              blog.posts().all(function(posts){             for(var i = 0; i < posts.length; i++){                 jQuery('.'+MYWRAPPER_CLASS).append(function(){             return (posts[i].content) ? '

'+posts[i].title+'

'+posts[i].content+'
'+posts[i].date+'

' : '

'+posts[i].date+'

';          });        }      });      I've scoured the web for an answer and Stack Overflow as well, but I believe the solution is going to be 'hacking' the plugin somehow. Thanks in advance!


showing custom taxonomies w/custom post type

we have set up a custom post type under the heading of custom post type along w/two custom taxonomies. (the following code has been added to our functions.php page:) add_action('init', 'create_seminar_post_type'); function create_seminar_post_type(){ register_post_type('seminars',                       array(                     'labels'=> array(                             'name' => 'Seminars',                             'singular_name' => 'Seminar',                             'add_new' => 'Add New Seminar',                             'add_new_item' => 'Add New Seminar',                             'edit' => 'Edit Seminars',                             'edit_item' => 'Edit Seminar',                             'new_item' => 'New Seminar',                             'view' => 'View Seminar',                             'view_item' => 'View Seminar',                             'search_items' => 'Search Seminars',                             'not_found' => 'No Seminars found',                             'not_found_in_trash' => 'No Seminars found in Trash',                             'parent' => 'Parent Seminar',                     ),                     'supports' => array('title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'thumbnail', 'author', 'page-attributes'),                     'public' =>true,                     'taxonomies' => array('post_tag', 'category')                     )         );         register_taxonomy ('trt', 'seminars', array(         'labels' =>array(                     'name' =>'Total Running Time',                     'singular_name' => 'Total Running Time',                     'search_items' => 'Search Total Running Time',                     'popular_items' => 'Popular Total Running Times',                     'all_items' => 'All Running Times',                     'parent_item' => 'Parent Running Time',                     'edit_item' => 'Edit Running Time',                     'update_item' => 'Update Running Time',                     'add_new_item' => 'Add New Running Time',                     'new_item_name' => 'New Running Time Name'         ),                     'hierarchical' => true, 'label' => 'Total Running Time'));         register_taxonomy ('discs-in-set', 'seminars', array(         'labels' =>array(                     'name' =>'# of Discs in Set',                     'singular_name' => 'Total Discs in Set',                     'search_items' => 'Search Discs in Set',                     'popular_items' => 'Popular Discs in Set',                     'all_items' => 'All Discs in Set',                     'parent_item' => 'Parent Discs in Set',                     'edit_item' => 'Edit Discs in Set',                     'update_item' => 'Update Discs in Set',                     'add_new_item' => 'Add New Discs in Set',                     'new_item_name' => 'New Discs in Set'         ),         'hierarchical' => false,         'public' => true,         'show_ui' => true,         'query_var' => 'discs-in-set',         'show_tagcloud' => true,         ));      } and here's the code added w/the loop in our single-seminar page (derived from the single.php page):               <?php $loop = new WP_Query( array( 'post_type' => 'seminars', 'posts_per_page' => 10 ) ); ?>             <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>             <?php the_title( '
', '
' ); ?>      what we'd like to have shown for each individual seminar is the seminar info, along w/the custom taxonomy info of running time and discs in set. But all that shows is the seminar post and its accompanying categories & tags. what should I do to make this work? on a similar note, when viewing the seminars listing in the dashboard, it shows all the listings , with columns for title, author, categories, tags, comments and date. It would be nice to incorporate the custom taxonomies into this listing for the sake of simplicity. Can this be done w/custom taxonomies? Or is there a more direct mode in doing this? any help/insights are greatly appreciated..   * don


Search doesn't find tags or categories in custom post types

I've added tags and categories to a custom post, but the search bar doesn't find them when I use it. It does find the 'uncategorized' category (default category) that's inherent in wordpress though. The Categories I've entered show up in the sidebar, as well as w/the custom post type (as do the tags I've entered). What am I missing?


How do I get next_posts_link to work with private posts?

next_posts_link and previous_posts_link don't show pages or posts that are private. This question has been asked many times on Wordpress forums with no solution. How do I get this navigation to show my privately published posts?


Managing large CSS files

I am creating a theme but find the CSS file too long, would it be acceptable to split the CSS file into several so a typograhy.css buttons.css table.css or would that reduce performance and cause other problems? or are there better ways of managing CSS files.


wp_reset_postdata() or wp_reset_query() after a custom loop?

Reading som stuff about query_reset_postdata and query_reset_query makes me confused... For example: > > 1) Is there any need to use both wp_reset_postdata and wp_reset_query > together? >> >> 2) http://www.poststat.us/properly-reset-wordpress-query/ Above states that you should only use `query_reset_postdata()` when using "separate queries". In example2 there's a comment:               WP_Query( $args ) = wp_reset_postdata();      AND               query_posts ( $args ) = wp_reset_query();      And really you should never use wp_reset_query because you shouldn't use query_posts!? In the WP Codex it states that you should use wp_reset_query() afte a custom loop (first example) http://codex.wordpress.org/Function_Reference/wp_reset_query Is the codex wrong then?


if && problems with transition_post_status

I'm attempting to get this function to work and it seems to not work when put together. When I just have                $new_status == 'publish'       it works, when I use just the second it also works. When I attempt to && them together there seems to be a hiccup. Also it should be noted that I attempted just to use the               add_action ('publish_tweet', 'twitter_run_when_published');      but that also didn't work. Here is the full function that I'm attempting to use, it is from a codex example               function intercept_all_status_changes( $new_status, $old_status, $post ) {       if ( $new_status == 'publish' && $_POST['post_type'] == 'tweet' ) {         // Post status changed            twitter_run_when_published ();            }     }       add_action( 'transition_post_status', 'intercept_all_status_changes', 10, 3 );      The twitter_run_when_published works. I know this because individually the if/condition works. Some quirks: The function will work if I publish immediately. It does not work when I schedule a future post. Additional info that might help I attempted these in the code, they did not work.               add_action('publish_tweet', 'twitter_run_when_published');     //possible alts to make it happen only once and not double down          add_action('new_to_publish_tweet', 'twitter_run_when_published');     add_action('draft_to_publish_tweet', 'twitter_run_when_published');     add_action('pending_to_publish_tweet', 'twitter_run_when_published');     add_action('future_to_publish_tweet', 'twitter_run_when_published');     add_action('auto-draft_to_publish_tweet', 'twitter_run_when_published');     add_action('private_to_publish_tweet', 'twitter_run_when_published');     add_action('inherit_to_publish_tweet', 'twitter_run_when_published');     add_action('trash_to_publish_tweet', 'twitter_run_when_published');      Only publishing immediately performs the function mentioned above. The classic example works.               function intercept_all_status_changes( $new_status, $old_status, $post ) {       if ( $new_status != $old_status) {         // Post status changed              twitter_run_when_published ();           }     }     add_action( 'transition_post_status', 'intercept_all_status_changes', 10, 3 );      But this will fire off the function multiple times. It doesn't work in the plugin but will work for sure in the theme. What am I missing? I'd like to have it so that when an article is published and it meets the custom post type tweet that it performs a function. EDIT: I was rambling a bit and attempted to clear up a few poorly phrased sentences.


Creating Category Specific menus

I have a question.. I am trying for this since many days.. but didn't get success. My requirement is say I have 5 categories: cat1, cat2 cat3 cat4 cat5 Now each of category has 'N' number of posts.. What I want is on the Category page i.e. say I visited cat1 . So now archive page for Cat1 opens. I want to generate a dynamic menu now which has "All the Posts belonging to Cat1 hyperlinked." Live example say if you visit w3schools whenever you change category you see that category specific menu! Is it possible to do so? are there any plugins available? Thanks in advance :)


How to let custom post type posts show in standard post archive (like in homepage)?

If I, for example, create a custom post type named 'tutorial', how do I get it to also show up in places like "Recent posts" , etc?


Where do custom menus get constructed?

I've created a simple menu in wp-admin>appearance>menus called main-nav. Works fine. However, I'd like to add a custom element to the end of the menu... a search box like the search box in the apple.com menu bar. I can't work out where the menus get constructed in code. where can I can add this... any ideas? (I'm using the starkers theme) EDIT Thanks to tnorthcutt and hakre for pointing me in the right direction. The solution was to put this code in with the other 'add_filter' stuff in my theme's functions.php               add_filter('wp_nav_menu_items','search_box_function');     function search_box_function ($nav){     return $nav."
<form action='http://example.com/' id='searchform' method='get'><input type='text' name='s' id='s' placeholder='Search'></form>
";     }      **UPDATE** @tnorthcutt's solution is great for when you have just one menu on your screen, but if you add second menu it appends the search box to that menu too. How would you target just one menu? i've registered my menu's like so:               register_nav_menus( array(       'primary' => __( 'Primary Navigation', 'twentyten' ),       'secondary'=>__('Secondary Menu', 'twentyten' ),           ) );      ..and the secondary one gets shown like this:               wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'secondary' ) );


Restricting Users to View Only Media Library Items They Have Uploaded?

I want users to be able to upload photos using `add_cap('upload_files')` but in their profile page, the Media Library shows every image that's been uploaded. How can I filter that so that they can only view the images _they_ uploaded? Here's my solution for the moment… I'm doing a simple WP query, then a Loop on the user's "Profile" page               $querystr = " SELECT wposts.post_date,wposts.post_content,wposts.post_title, guid      FROM $wpdb->posts wposts     WHERE wposts.post_author = $author      AND wposts.post_type = 'attachment'      ORDER BY wposts.post_date DESC";          $pageposts = $wpdb->get_results($querystr, OBJECT);


How do I get my wp_nav_menu single category page to highlight the parent?

With the new wp_nav_menu system, it is possible to add a category as a menu item, so in my example I have a 'news' category, which is a submenu item of 'About'. `About (page)   \--news (category)   \--history (page)   \--contact us (page)` The menu highlighting CSS picks up from current-menu-parent and current-menu- ancestor, so that when I'm in a submenu section, the top level menu item (e.g. 'About') is highlighted when I visit 'news'. This works fine, apart from when I visit a post in the 'news' category, which matches is_single() and in_category('news'). As far as I can see in Firebug, the 'current-menu-parent' and 'current-menu- ancestor' is applied to the 'news' menu item, however it's not applied to the 'About' top level menu item. Is there something I'm missing in setting up my menu? I've tried using a custom walker, however it seems that the initial menu ancestors are not being set up properly? It seems my only solution (without resorting to a nasty JQuery hack) is to create a 'news' page which queries the news posts, rather than pointing to the news 'category'. Any ideas? Thanks, Dan _Update with code sample 09/09/2010_ The way it is currently, viewing a single page in the News category http://www.example.com/2010/09/top-news-did-you-know/: `
About Us

Events

News & views

Contact Us

 ` So you see that "About Us" doesn't have any CSS class to indicate it is a parent of the currently viewed page. How I think it should work (and to be honest, if it doesn't do this, then it's a bug due to lack of implementation): `
About Us

Events

News & views

Contact Us

 ` This has the `current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor` CSS classes attached to the Top level menu item. It works this way for every other page, or even when viewing the category itself, just not a single page in a category.


How to make Wordpress use authentication from Parent Site

I have a site already, I am adding wordpress to it. THe current site already has user authentication. I want to continue using that authentication and I want my user to be able to seamlessly move to the blog, be recognized as a logged in user and be able to comment and or contribute to the blog. I'm hoping someone call tell me how or point me in the direction I should be going. For more information on the current systemm I am using HybridAuth which allows my users to sign in with Facebook or Google (among others) it also easily lets me get the users friend or contact lists. Any help is much appreciated!


Individual css class for each tag in wp_tag_cloud

Help, this is probably the best way to have control over the styling of the wp_tag_cloud ... I was looking for a way to add size based classes to my tags within the tag cloud widget. The problem here is that this solution only works when hard coded into for example a template file, but not for the tag cloud widget. I also found this snippet to add slug classes and they beautifully work right out of the box. I simply had to place them inside the function.php file. I was trying to get solution one to work in the same way solution number two works, but with the size based class names instead of slug names or even both. However, I can't figure it out and need help. Thanks in advance.


How to Set Post Status to Draft if older than today

In a previous question I needed to set a future dated post (custom post type) as published on save instead of scheduling it. On the date it's 'scheduled' for I'd like to set it as a draft again. I've been trying to hook into init and wrap it in an if checking for post type. I figured it would compare to server time and then set status to draft if it was older than server time. As a rough outline:               if custom post type       get_the_time of post       get the server time       if post time is older than server time set status to draft     endif      Here and update with some code I'm working with.               function sfn_show_expire(){         global $wpdb;         $server_time = date('mdy');         $result = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type = 'show' AND post_status = 'publish'");         if( !empty($result)) foreach ($result as $a){             $show_time = get_the_time('mdy', $a->ID );             if ( $server_time > $show_time){                 $my_post = array();                 $my_post['ID'] = $a->ID;                 $my_post['post_status'] = 'draft';                 wp_update_post( $my_post );             }         } // end foreach     }     add_action( 'init', 'sfn_show_expire' );      It's getting the posts I need and is giving me the server time but isn't doing anything past that as far as I can tell.


Multiple post types in archives (filter?)

I'm trying to get all custom post types to appear in my archive sections on a site, including monthly, tagged, author archives. At the moment, I've thought of something like:               add_filter('pre_get_posts', 'sw_custom_post_type_includes');          function sw_custom_post_type_includes($query) {                  $post_type = array('post','custom1','custom2','custom3');                  $query->set('post_type',$post_type);                  return $query;          }      But I don't want to use pre_get_posts, as this messes with all queries. Is there a filter for, in effect, pre_get_archives? Can't seem to find a solution on Google.


Is there a hook that runs after a user logs in?

I am writing a plugin that fetches some extended user info from a remote service and I need it to execute its function each time a user logs in. Is there a hook that gets fired after login that I can add an action to?


Query custom post types

I'm having some trouble feeding a custom post-type I created (events) on my homepage. I am trying to allow this particular post-type to display under the query which looks for category 8 (Featured). I have managed to enable to ability to add categories to my custom post type, but for some reason none of the posts from my custom post-type actually display within the feed, only my standard posts. I currently have the post-type as POSTS but I have tried changing this to PAGES and no luck. I have a feeling that this could be a problem with the loop rather than the code within my functions.php, because I actually have another loop on the same homepage which seems to be feeding my events custom post-type. Here is the loop I'm using which doesn't work:               <?php                         $featuredPosts = new WP_Query();                         $featuredPosts->query('showposts=5&cat=8');                         for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides                             while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts                         ?>                         <li id="slide-<?php echo $i++; ?>" class="clearfix">
                                 <?php if (has_post_thumbnail( $post->ID )): ?>                                     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>                                     <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=150&h=150&zc=1" alt="<?php the_title(); ?>" />                                 <?php endif; ?>

<a href="<?php the_permalink(); ?>"><?php echo substr($post->post_title,0,30); // short title ?>...
                                     <?php the_excerpt(); ?>

                              <?php endwhile;                         } // end for() loop number 2                     ?>      Here is the PHP snippet I have found and used in my functions.php:                   add_filter( 'pre_get_posts', 'my_get_posts' );          function my_get_posts( $query ) {              if ( ( is_home() || is_tag() ) && empty( $query->query_vars['suppress_filters'] ) )             $query->set( 'post_type', array( 'post', 'events' ) );              return $query;     }      Any help would be great, thanks guys!


jQuery child error message

I'm trying to do the following. with jQuery if any/multiple children hasClass e.g '.notvalid' display a single error message e.g 'please double check all fields'


Display Parent Category of a Post belonging only to Subcategory

So basically, I have posts assigned to only subcategories and not to categories (this is so both of them get displayed in the premalink) and in the post page only the subcategory is displayed. I want to to display the parent category somewhere on the post page also. I need something like this:               Sample Post belongs to SubcategoryName a part of Category     Buttercake belongs to Cakes a part of Desserts      I've tried this code:               <?php     foreach((get_the_category()) as $category) {     echo get_category_parents($cat, TRUE, ' » ');     echo $category->cat_name . ' ';     }     ?>      But I keep getting this error:               Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wamp\www\wp-content\themes\yoko\content.php on line 22      Does anybody know how to achieve this?


wp_link_pages output appears twice

I believe this is completely different than the question asked here. I'm adding pagination to my theme using a filter hook. The output appears at the beginning and end of my content, rather than just the end. My function, in the template's functions.php file:               add_filter('the_content','pagination_after_post',1);     /**      * Adds pagination after the post      *      * @uses is_single()      */          function pagination_after_post($content){         if( is_single() ){             $content .= '
' . wp_link_pages('before=&after=&next_or_number=next&nextpagelink=Next&previouspagelink=Previous') . '
';             return $content;         } // if     } // pagination_after_post      Here is my single.php:               <?php get_header(); ?>
                  <?php if (have_posts()) : ?>                      <?php while (have_posts()) : the_post(); ?>                                    <div class="post" id="post-<?php the_ID(); ?>">
<a title="<?php _e('Permanent Link to',woothemes); ?> <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>

<?php the_time('l, M j, Y \a\t g:i a'); ?> by <a href="<?= get_author_posts_url( get_the_author_meta( 'ID' ) ) ?>" rel="author"><?= get_the_author() ?>

<?php the_category(', ') ?>

                             <?php echo woo_get_embed('embed','500','360','video-post'); ?>                             <?php the_content(__('Continue Reading',woothemes)); ?>
                              <?php the_tags('
Tags: ', ', ', '
'); ?>

                         <?php comments_template(); ?>
                  <?php endwhile; ?>

<?php previous_post_link(); ?>

<?php next_post_link(); ?>

                    <?php endif; ?>
          <?php get_sidebar(); ?>          <?php get_footer(); ?>      And a screenshot of the issue: ![enter image description here](http://i.stack.imgur.com/PilRL.png)


Slow meta_query with about 4 milion record on wp_postmeta

Although optimized wordpress all the way but still very slow as follows : I have converted from LONGTEXT meta_value field to TEXT Then create INDEX for this field               ALTER TABLE wp_postmeta ADD INDEX idx_metavalue ( meta_value ( 255 ) ) ;      I continue to create FULL - TEXT search               ALTER TABLE wp_postmeta ADD fulltext ( meta_value ) ;      AND my database is **Innodb** type Initially when the number of posts is around 150,000 posts , the query speed is relatively fast But when the number of posts is 200,000 articles , the query speed is very slow . Each post has about 20 custom fields , so there are about 4 million records in the table postmeta . With the amount of 4 million records that I have used INDEX and fulltext search is not supposed to speed very slow . But the current query very slow speed ( approximately 20 seconds ) **query:**               SELECT post_id FROM wp_postmeta WHERE meta_key='_title' AND MATCH('meta_value') AGIANST('$title') LIMIT 10;      So how to increase the speed of queries when the query execution meta_query ( ) speed you can check in http://fixapk.com/apps or http://fixapk.com/games Thank you !


Tax Query With Meta Query

I'm tring to using `tax_query` and `meta_query` in `taxonomy-term.php` I want to sort list by date custom field. Taxonomy name is `sektorler`, Meta Key is `bs_fuarlar_baslangic` My Code is;               <?php         $todaysDate = date('d.m.Y');         $queried_object = get_queried_object();         $term_id = $queried_object->term_id;         $args = array(             'post_type'=>'fuarlar',             'tax_query' => array(                 array(                     'taxonomy' => 'sektorler',                     'field' => 'id',                     'terms' => $term_id,                 )             ),                           'meta_query' => array(                 array(                     'key' => 'bs_fuar_baslangic',                     'value' => $todaysDate,                     'compare' => =,                 )             ),             'orderby'=>'meta_value',             'order'=>'ASC'         );         query_posts($args);     ?>      It doesn't work. What is the matter?


Why is save_post triggered even when I havent saved the post

I created a meta box I notice that `save_post` seems to be triggered when I land on the page, thus giving me errors like `Undefined index: xxx in /data/www/ae/wp-content/themes/xx/functions.php on line 121`               add_action('save_post', function($id) {         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return;         }         if (!isset($_POST) || !is_array($_POST)) {             return;         }         update_post_meta($id, 'xxx', sprintf('%f', $_POST['xxx']));         ...     });