Securing my WordPress Files and Directories

I am new to WordPress and securely hosting it on Amazon EC2. My question is, how do I secure my WordPress files and directories properly? My file permissions are set to 644 and my directories are set to 755.               [ec2-user@ip-xx-xxx-xxx-xx my_sub_directory]$ ls -l     total 160     -rw-r--r-- 1 ftpuser 65534   395 Jan  8  2012 index.php     -rw-r--r-- 1 ftpuser 65534 19929 May  6  2012 license.txt     -rw-r--r-- 1 ftpuser 65534  9177 Jun 21 17:26 readme.html     -rw-r--r-- 1 ftpuser 65534  4663 Nov 17  2012 wp-activate.php     drwxr-xr-x 9 ftpuser 65534  4096 Jul 23 23:12 wp-admin     -rw-r--r-- 1 ftpuser 65534   271 Jan  8  2012 wp-blog-header.php     -rw-r--r-- 1 ftpuser 65534  3522 Apr 10  2012 wp-comments-post.php     -rw-r--r-- 1 ftpuser root   3596 Jul 23 20:27 wp-config.php     drwxr-xr-x 5 ftpuser 65534  4096 Jul 23 17:44 wp-content     -rw-r--r-- 1 ftpuser 65534  2718 Sep 23  2012 wp-cron.php     drwxr-xr-x 9 ftpuser 65534  4096 Jun 21 19:39 wp-includes     -rw-r--r-- 1 ftpuser 65534  1997 Oct 23  2010 wp-links-opml.php     -rw-r--r-- 1 ftpuser 65534  2408 Oct 26  2012 wp-load.php     -rw-r--r-- 1 ftpuser 65534 29217 Jun 21 03:02 wp-login.php     -rw-r--r-- 1 ftpuser 65534  7723 Sep 25  2012 wp-mail.php     -rw-r--r-- 1 ftpuser 65534  9899 Nov 22  2012 wp-settings.php     -rw-r--r-- 1 ftpuser 65534 18219 Sep 11  2012 wp-signup.php     -rw-r--r-- 1 ftpuser 65534  3700 Jan  8  2012 wp-trackback.php     -rw-r--r-- 1 ftpuser 65534  2719 Sep 11  2012 xmlrpc.php      And my `.htaccess` file attempts to further protect the `wp-config.php` file               # PROTECT WP-CONFIG     <Files wp-config.php>     Order Allow,Deny     Deny from all     </Files>      When I try to access my wp-config.php file from the browser like this:               http://ec2-xx-xx-xxx-xx.compute-1.amazonaws.com/my_sub_directory/wp-config.php      I get this error: > Forbidden > > You don't have permission to access /my_sub_directory/wp-config.php on this > server. But when I access another file in my directory, for example, `wp-cron.php` like this:               http://ec2-xx-xx-xxx-xx.compute-1.amazonaws.com/my_sub_directory/wp-cron.php      I get a blank white page. I'm thinking, this can't be secure. **So my question is, how do I properly secure the following files?**               [ec2-user@ip-xx-xxx-xxx-xx my_sub_directory]$ ls -a     .            wp-activate.php       wp-cron.php        wp-settings.php     ..           wp-admin              wp-includes        wp-signup.php     .htaccess    wp-blog-header.php    wp-links-opml.php  wp-trackback.php     index.php    wp-comments-post.php  wp-load.php        xmlrpc.php     license.txt  wp-config.php         wp-login.php     readme.html  wp-content            wp-mail.php


SKU Customization jigoshop plugin

When a product is published, SKU is randomly created but what I need is, the SKU value should be category-name.defaultskuvalue. All this is done automatically while product is created. How can I modify the way the sku values are created?


Taxonomy Archive: Display only one post per term from separate custom taxonomy

I am having trouble coming up with a solution for product catalog I am building using custom post types and 4 custom taxonomies. The product catalog is separated by "model", but each "model" can have up to 15 "product" variations. Each "product" has different attributes and I need to be able to filter a list of products based on these attributes. Structurally, I have things organized like so:   * Product (Custom Post Type)   * Model (Taxonomy)   * Size (Taxonomy)   * Color (Taxonomy)   * Features (Taxonomy) With the exception of "Model", each taxonomy is used as a way to filter the products shown. I am using the Query Multiple Taxonomies plugin to help me filter the attributes for each product. This works great. It allows me to use the default Wordpress template hierarchy and make all my changes to a taxonomy.php file. Now here is where I get lost. I would like to limit the results that are shown so only 1 of each model is shown, even though the filtering may return multiple products per model. I am currently using The Loop and get_the_terms() to create an array, and then using the array_unique() function to save only one instance of each model name to an array. Here is the code I have for that portion:               $modelSlugs = array();          while (have_posts()) : the_post();          // Gather the model names assigned to each product     $terms = get_the_terms( $post->ID, 'models' );     if ( $terms && ! is_wp_error( $terms ) ) :          $term = array_pop($terms);         $modelSlugs[] = $term->slug;     endif;                                         endwhile;              $modelList = array_unique($modelSlugs);      This will give me only one of each model slug (or name), which is good, but I also need to show a product thumbnail and use the permalink to link to the single product page. I know I can generate additional queries based on each slug, but that sounds like it is a performance nightmare. The more I think about it, I can't help think this is the wrong way to go about this. I know the returned $wp_query object has everything I could possibly need, I am just not sure what tricks to use to ensure I only show one post for each model. Is there a way to prepare or manipulate the returned WP_Query object before running the loop, or is there something I can do inside of the loop to limit how many products are displayed?


How can I redirect all wordpress tag subdirectory (subfolder) to another one (archives/tag)

I changed my permalinks and it working fine but I need to redirect old **tag** folder to **archives/tag** to not lose links which google indexed below is my .htaccess file in the root of my recipes site http://foodonia.com               # Use PHP5.4 as default     AddHandler application/x-httpd-php54 .php          # 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>      Example: http://foodonia.com/tag/fudge/ should redirect to http://foodonia.com/archives/tag/fudge I tried to add each one of blow codes but redirect not working `#RewriteRule tag/(.*) archives/tag/$1 [NC,L]` `#RewriteRule tag/$ /archives/tag/$1 [NC,L]` `#RewriteRule tag/ /archives/tag [L]` I try to search for solution but can't find similar post


is_taxonomy() is not working

<?php        if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly             get_header();             $term = is_taxonomy('special-offers');        if ($term) {          echo "New template";        }             else{     ?>      New template. I want to set taxonomy by template. Any help?


Randomly placed sticky custom posts complemented by blog posts

On my index.php file I am showing the most recent posts using the standard index.php file. However, I'd like to include a custom post type (named products) in this standard loop. Have about 6 products posts in total and would like to show them in a random order on the first 12 'slots' of the loop. So a scenario could be:               1. Product     2. Post (most recent)     3. Post (most recent - 1)     4. Product     5. Post     ...     12. Product/Post     13. Only posts from here on     ... Post (oldest)      I have merged the products and posts in the loop as follow:               global $query_string;     parse_str( $query_string, $args );     $args['post_type'] = array( 'post', 'products' );     query_posts( $args );     if (have_posts()) : while (have_posts()) : the_post();      ...      Hope this makes sense. Have no clue on how to approach it. Appreciate ideas!


Theme information in style.css being corrupted

I am customising someone else's theme to allow the website owner to edit more regions than she could previously. I copied the theme into a new folder, with a different folder name to the original. I edited style.css, and replaced the theme information with:               /*     Theme Name: Customisable SuperBaby & Ted     Author: Steve Doig     Author URI: http://tech.doig.com.au     Description: Modified version of SuperBaby & Ted to allow edits to the home page and footer navigation.     Version: 2.0     */      Yet when I upload style.css to the theme's folder, I see this in Appearance > Themes: ![enter image description here](http://i.stack.imgur.com/1Wsz3.png) I've added a blank line between each line, with no difference. I've copied this info into a new Notepad, copied from that Notepad, and pasted back into the original Notepad with no difference. Can you see what is going on here?


Supporting older WordPress versions in a Plugin/Theme?

The practice of only supporting latest WP version seems popular in WP development circles, yet there is massive percentage of blogs running outdated versions. Not supporting those plugins seems it can lead to significantly less usage than if _(some)_ older versions are supported. Support of older version comes with major issues, especially:   * Complicated testing for multiple versions _(unit tests?);_   * No access to latest functionality or having to backport it;   * Incompatibilities of your code between WP versions _(works in one, breaks another);_   * Wider hosting requirements range _(older PHP and MySQL versions, dropped by WP)._ -   1. In your experienced had you ever had to support older WP versions in your code?    2. Which organizational and technical practices had produced good results?   3. What type of code do you use to manage the multiple version support.


How to add an option to admin to add image that could be used as header?

I want to add an option to add/change an Image in admin dashboard in a way that I can call it through code. For example lets call it header_2 Image and then want to use it in an header template. So that users later on can change this image without editing header template.


If/elseif statement within wp_mail function

I need to know what is wrong with my if statement here:               //EMAIL ADMIN BASED ON PROBLEM_TYPE     function new_post_creation_email() {         global $post;         $postid = $post->ID;         $problem_type = get_post_meta($postid, 'problem_type', true);         $description = the_content();         if ($problem_type = 'phones') {             $to = '1st email here';         }         elseif ($problem_type = 'computers') {             $to = '2nd email here';         }         else {             $to = '3rd email here';         }         $subject = "New Ticket in " . get_post_meta($postid, 'problem_type', true);         $message = "A new ticket has been added.  Please login to view and print.";              wp_mail($to, $subject, $message);     }      **Emails are correct in actual code** Currently, the message sends but the same email arrives multiple times in my 1st email address, not the correct one.


Delete an attachment in the WP media modal window

I'm trying to create an option in the WP modal media window to detect duplicate files and delete a newer file if an older duplicate is found. I have the following code working (in conjunction with the 'attachment_fields_to_edit' filter) to deselect a duplicate file and select the original file in the media modal. What I'd like to do is, when a user clicks the button, delete the original file (or at least hide it in the media library window so I can delete it later).               ( function( $ ) {              var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;         wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({             render: function() {                 _AttachmentDisplay.prototype.render.apply(this, arguments);                 currentselection = this.controller.state().get('selection').first().toJSON();                 selection = this.controller.state().get('selection');                      $('button.dmc').on('click', function(e){                          e.preventDefault();                          var id = $(e.currentTarget).data("id");                     if(currentselection.id == id) {                              currentattachment = wp.media.attachment(id);                         selection.remove(currentattachment);                              console.dir(wp.media.view.Attachment);                              newattachment = wp.media.attachment($(e.currentTarget).data("original"));                         selection.add(newattachment);                          }                 });             }         });          } )( jQuery );      The interface looks like the attached image. ![screenshot of duplicate media check](http://i.stack.imgur.com/Xbymq.jpg) I can see in media-views.js at line 5873 that there's a deleteAttachment function bound to 'click .delete-attachment'. How can I access this, given my current setup, by passing in an image ID or attachment object?


Set if condition with wp_nav_menu

I have created one new menu and add bellow code in footer.php to display my menu               wp_nav_menu( array('menu' => 'footer-cn', 'menu_id' => 'nav', 'menu_class' => 'ft-nav' ));      Currently I did not add any pages inside this menu so I want to set some condition if any pages available inside `footer-cn` then display menu. I want to set condition something this:               <?php         if(){ // Some condition             wp_nav_menu( array('menu' => 'footer-cn', 'menu_id' => 'nav', 'menu_class' => 'ft-nav' ));         }     ?>      Is it possible? Thanks. ![enter image description here](http://i.stack.imgur.com/oUSFJ.png)


Conditions for single post

I want to add `current-page-anchestor` when a single post is browsed. I was looking for that function code and tried many, but with not success yet. Now I am thinking I can do it that way, then it would work. Like **if ... the post from this category ... then add`current-page-anchestor`** etc, something like that. So then, when I visit my single post, my menu will be highlight too . You can also see details what I am looking for here My current nav code is below               add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);     add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);     add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);          function my_css_attributes_filter($var) {       return is_array($var) ? array_intersect($var, array('current-menu-item', 'current-menu-ancestor')) : '';          }


Prepared statements used incorrectly in ACF?

I've just updated to WP 3.9 and it returns a warning when using placeholders incorrectly. I've found some prepared statements written incorrectly, but I really got worried when I saw this in the ACF-plugin (because it's so widely used): (Take a look at the export.php in the core files of the plugin)               // create SQL with %d placeholders     $where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')';          // now prepare the SQL based on the %d + $_POST data     $posts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->posts} $where", $my_options['acf_posts']));      This seems to be a vulneribility in the plugin? (because the abscence of actual placeholders in the actual prepare-statement (they're using `$where` instead ) or am I totally incorrect in my assumtpion? Please guide me :-)


How to make pages slug have priority over any other taxonomies like custom-post, post or category

I use WordPress as a CMS. I need to show page instead of category when they have same slug.   * I have category called "vertical machining centers" with the slug "vertical-machining-centers" This category is ranking in the second page in google and I want to optimize more. So I create a page.. So as you see the page and the category have the same slug. When I write www.xx.com/vertical-machining-centers , the category page is opening, I also check with it monkeyman-rewrite-analyzer it shows that category slug is higher rank. I need to make wordpress to show the page instead of category when they have the same slug. Is there any plugin or any way to do that without writing code. Thanks....


How to customize tag and category post listings to show introductory content?

In wordpress, we allow google to index our category and tag pages. We don't use no-index for tag or categories, which results very high ranking in a lots of keywords and we are receiving very high traffic from google. We also use Wordpress SEO for SEO. We don't have so many control on the content of category or tag because the content is creating by underlying posts. So, I need to find a plug-in to create specific content in tag or category like following http://www.youtube.com/watch?v=Hi3PZSDfRfQ http://www.tizish.com/how-to-add- html-in-your-wordpress-category-introductory-content/ Thanks


which template does wp_ tag_ cloud point to?

This is very embarassing. If I add `wp_tag_cloud` to my navigation in list form, it shows as I need it (like a sub nav). If you then click a tag what template is then used? I've tried adding **taxonomy.php** , **archive.php** and **tag.php** but it doesn't seem to use those and i'm now at a loss! Any guidance is much appreciated Thanks


How was my WP site hacked

My site, http://www.cancer-study.com, has been hacked, and I can't login to wp-admin. Can you say how it has been hacked and what can I do to undo the damage? I have access to the host.


Share common libraries across multiple themes/plugins

What is the best way to integrate a common library (like a framework) across multiple WordPress themes and plugins? Try to answer this from the library developer point of view. Keep in mind that this library is intended to be used by many users and for many plugins and themes.   1. **As an external plugin** \- Create a plugin that will be loaded before all other plugins to initiate the common library. Create a WordPress plugin repository and update it occasionally.     * **Pros** \- The library is more likely to stay updated.     * **Cons** \- Requires the user to install another plugin just to use the theme/plugin that depends on that common library.    2. **As a part of the depending theme/plugin** \- Include the library files inside the plugin/theme files.      * **Pros** \- No additional plugin installation is required.     * **Cons** \- Requires the depending plugin/theme to issue an update every time the library is updated. Ma create a conflict if different versions of the library exists within the same WordPress installation. Are there any other ways? How would you do it?


Where did the "WP-Custom" plugin go?

There used to be a plugin called "WP-Custom" in Wordpress plugin base. Does anyone know what its new name or where I can get it? Wordpress shows no sign left of it.


How to make that all permalinks would open in a new window?

Where should I amend to make this happen? I should add somewhere target="blank_" Regards,


How to display different styles on index posts in wordpress pages?

I want to add a new div on wordpress index.php thumbnails. When hovered a new div should cover the thumbnail. The problem is that whatever I add to index.php it will affect all posts, so if a user hovers one thumbnail the effect will hit all posts thumbnails. Any ideas on how to fix it? You can have a glimpse of what I am building at techgeek.lt/naudinga/


why there is a large file named core in wpmu's directory?

why the file named core is here? can i delete it?               ls -lh     total 37M     -rw-rw-r--  1 hugemeow pg   16 2012-03-04 04:22 a.php     -rw-------  1 hugemeow pg  30M 2012-10-16 10:41 core   // this is the large file     -rw-r--r--  1 hugemeow pg  397 2012-01-26 07:53 index.php     -rw-r--r--  1 hugemeow pg  17K 2012-01-26 07:53 license.txt     -rw-r--r--  1 hugemeow pg 9.0K 2012-01-26 07:53 readme.html     -rw-rw-r--  1 hugemeow pg 7.4M 2012-09-22 02:27 tags     -rw-r--r--  1 hugemeow pg 4.2K 2012-01-26 07:53 wp-activate.php     drwxr-xr-x 10 hugemeow pg 4.0K 2012-10-11 08:37 wp-admin     -rw-r--r--  1 hugemeow pg  40K 2012-01-26 07:53 wp-app.php     -rw-r--r--  1 hugemeow pg  274 2012-01-26 07:53 wp-blog-header.php     -rw-r--r--  1 hugemeow pg 3.9K 2012-01-26 07:53 wp-comments-post.php     -rw-r--r--  1 hugemeow pg 3.2K 2012-01-26 07:53 wp-config-sample.php     -rw-r--r--  1 hugemeow pg 3.6K 2012-10-11 08:37 wp-config.php     -rw-r--r--  1 hugemeow pg 3.5K 2012-03-14 17:08 wp-config.php_bak0     drwxr-xr-x  8 hugemeow pg 4.0K 2012-12-01 04:12 wp-content     -rw-r--r--  1 hugemeow pg 2.7K 2012-01-26 07:53 wp-cron.php     drwxr-xr-x  8 hugemeow pg 4.0K 2012-09-22 02:35 wp-includes     -rw-r--r--  1 hugemeow pg 2.0K 2012-01-26 07:53 wp-links-opml.php     -rw-r--r--  1 hugemeow pg 2.5K 2012-01-26 07:52 wp-load.php     -rw-r--r--  1 hugemeow pg  28K 2012-01-26 07:53 wp-login.php     -rw-r--r--  1 hugemeow pg 7.6K 2012-01-26 07:53 wp-mail.php     -rw-r--r--  1 hugemeow pg  413 2012-01-26 07:53 wp-pass.php     -rw-r--r--  1 hugemeow pg  334 2012-01-26 07:53 wp-register.php     -rw-r--r--  1 hugemeow pg 9.7K 2012-01-26 07:53 wp-settings.php     -rw-r--r--  1 hugemeow pg  19K 2012-01-26 07:53 wp-signup.php     -rw-r--r--  1 hugemeow pg 3.7K 2012-01-26 07:52 wp-trackback.php     -rw-r--r--  1 hugemeow pg 3.2K 2012-01-26 07:53 xmlrpc.php               file core     core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from 'php5.cgi'


1- Enable Link Manger in Wordpress 3.9 with this plugin: http://wordpress.org/plugins/link-manager/ 2- I have about 1200 Links in my Link Manger! all links are displayed on one page by default, And It's not good. 3- I want to add Page number in wordpress Link Manager Admin panel. How? Thanks. P.s: this solution only work with Wordpress 3.1: Replace `/wp- admin/includes/class-wp-links-list-table.php`file with https://dl.dropboxusercontent.com/u/403487/class-wp-links-list-table.php.zip Source: katz.co/paginate-links-wordpress-link-manager/


Custom navigation menu with awsAccordion

I'm making a custom template for my client. Well i'm strangling for hours, for making the vertical accordion menu dynamic so my client can change the nav links etc. The structure of the navigation is this

Menu title

Menu Title

Menu Title with submenu

                 Submenu Title                 Submenu title

      Its my first template in wordpress and I read the documentation i tried to experiment with the code which is in wordpress codex but I couldnt achieve it. I tried this and many experiments with that code but none of them worked. I want it to render the same way on the first example of code i gave you.                wp_nav_menu(array(           'container'       => 'ul',           'container_id'    => '',           'menu_class'      => 'menu',           'menu_id'         => '',       'before'          => '',       'after'           => '',       'link_before'     => '',       'link_after'      => '',       'items_wrap'      => '
%3$s
', ));      Can you help me a little? Thank you :)


Dynamically add / duplicate custom meta in custom post types

I am using Custom post types in one of my themes I have one custom post type called "accommodation" with meta boxes to add details such as type of rooms (single, twin, double...); each room has a price according to different season (high season, low season, peak season - each could be ). However the room types could differ among individual "accommodation" post entries (suppose one has a room called "de luxe", another has a room type "budget", not just single, twin double), and not all entries have the same rooms (ie some could not have a "dorm" type), therefore the admin should be able to manually insert different types of rooms. Each room should have a price too. And each room could have price variation according to season. Season period should be defined with a range date picker. Additionally, there could be multiple high/low season within the year. How would you arrange this? thanks a lot for any help!


View homepage in a preview mode

Is there any way to view your homepage in a preview mode, so that I can check how my posts will look on the homepage before publishing them (i.e. to make sure the featured image looks right etc).


WP Video media player not loading correct CSS after AJAX load

I have a post which uses WP `[video]` shortcode to display my video file. It's supposed to look like this: ![enter image description here](http://i.stack.imgur.com/5ROO1.png) But it looks like this: ![enter image description here](http://i.stack.imgur.com/sf1Ko.png) After I click "Load More Posts" AJAX call. The video player will look like the way I want after I click the post. It's only when the post is loaded with AJAX that it appears like this. Can anyone tell me what's wrong? Thanks.


Why does preg_replace_callback never fire in this function?

In the function below, the save_content function runs, but the doReplace does not (echo "This is the doReplace" never shows. Any ideas why?               add_action('content_save_pre', 'save_content');           function save_content($content){       global $post;       $mykeyword = rseo_getKeyword($post);       $mykeyword = preg_quote($mykeyword, '/');       $content = preg_replace_callback("/\b($mykeyword)\b/i","doReplace", $content);      return $content;      }           function doReplace($matches)      {       echo "This is the doReplace";       die;       }


301 Redirects for posts, category, pages from original domain to sub-domain of multisite

I want to move my blog from its original domain ( _site1.com_ ) to become a sub-domain on another domain which is a multisite installation ( _sub1.site2.com_ ). I also want to change the permalink structure on the new site based on some SEO suggestions I read online. Original used `/%year%/%monthnum%/%category%/%postname%/` as its permalink structure. I want to switch to `posts/%category%/%postname%/`as the new permalink structure on _sub1.site2.com_ . I am changing the permalinks because I rightfully agree with some SEO suggestions that articles may feel dated if the year is prominent in the URL when actually the content is mostly not time dependent. How do I use either `.htaccess` or a plugin or even PHP (as in this thread) to ensure links from the old site (posts, category and other archives) do not break especially because of the the change in permalink structure. I tried following a few previously answered questions but got confused becasue of the nature of their specific queries. Also Regex syntax is relatively new to me so I want to defer to people who know what they are doing fully.


Category Descriptions - HTML?

Is it possible to allow HTML to be rendered in Category descriptions? My theme uses them quite a lot, and I'd like to style them better with images and links. This seems to be do-able from what I read elsewhere, but I wondered if there is a best practice to get it to work (I'd prefer not to use a barely supported plugin). Many thanks, R


Import / Export Settings API fields values?

I've been storing all my theme options using Settings API for some time now and it's lacking one functionality. I have multiple pages (different servers) using my custom themes and I would love to move settings between them, I mean I'd like to export all the Settings API fields values from theme 1 and import them to theme 2. Are there any plugins out there / any ideas how to achieve that?


Custom WP plugin installation permission problem

I've developed a custom plugin for WP. When I install it manually on my server, using FTP transfer, all is perfectly working. I tried to make a zip file and uploading it through WP admin panel. All seems to go well, but when I try to use it I get many 500 errors, due to the permissions given to my plugin's files by WP. Folders have 755 permission and files have 644 permission. I read that these are the correct permissions for WP, but in this way when a file situated in a subfolder is called via ajax, I get a 500 error as this file hasn't execute permission (644). Giving to my file manually 755 permission makes it work. What can I do to make WP give the execute permissions to my files when installing the plugin using the zip file? Thank you.


Custom Loop for custom post type. Compare by meta_value?

I'm a bit confused. I have a custom-post-type named `wr_event`. I'm using the code underneath to loop through all "upcoming" events (defined by the meta_key `event_date). The problem I have now is that I want not only to show all upcoming posts, but all posts of the current year.               if ( have_posts() ): the_post();              $current_year = mktime(0, 0, 0, 1, 1, date('Y'));         //$last_year = mktime(0, 0, 0, 1, 1, date('Y') - 1);              // Show all upcoming events of the current year         /*$args = array(             'post_type' => 'wr_event',             'posts_per_page' => -1,             'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => 'DSC',             'meta_value' => $current_year,             'meta_compare' => '>',             'taxonomy' => 'event_type',             'term' => get_queried_object()->slug         );*/              // Show all upcoming and taken place events of the current year         $args = array(             'post_type' => 'wr_event',             'posts_per_page' => -1,             /*'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => 'DSC',             'meta_value' => $last_year,             'meta_compare' => '>',*/             'taxonomy' => 'event_type',             'term' => get_queried_object()->slug         );              $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post();             get_template_part( 'inc/event', 'item' );         endwhile;         wp_reset_postdata();              else: ?>              <p class="wrapper no-items">                 There are no posts found             </p>      Any idea how to do so? I simply want to list all events filterd by the current taxonomy-term of the current_year. And I can't seem to find out how to do so? **UPDATE** Thank you … but how would this look?                $args = array(                     'post_type' => 'wr_event',                     'posts_per_page' => -1,                     'meta_query' => array( array(                         'key' => 'event_date',                         'value' => $current_year,                         'compare' => '>=',                         'type' => 'numeric'                     ) ),                     'taxonomy' => 'event_type',                     'term' => get_queried_object()->slug                 );


How to filter $post->post_content prior to save

I have a function inside my plugin that attaches to save_post, and inside that function, I'm seeking to filter the post_content prior to it being saved. However, the content never actually gets changed once its saved. See below where I'm setting $post->post_content = "test";               add_action('save_post', 'save_post_filter',10,2);          function save_post_filter($postID, $post){         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return $postID;         }         else         {             if($parent_id = wp_is_post_revision($postID))             {             $postID = $parent_id;             $post = get_post($postID);             }             $post->post_content = "test";         }     }


Wordpress Gallery not being output correctly/consistently

Using WP 3.5.0, Wordpress galleries have been working fine. I use the Cleaner Gallery plugin and Lightbox to display galleries in lightbox mode. Now I am using WP 3.5.1, a gallery I created on this page is output with inconsistant hyperlinks on the thumbnails. Some point to a URL with format: http://test.incredibleconcepts.com.au/?attachment_id=2593 Some point to a URL with format: http://test.incredibleconcepts.com.au/exhibitions/inflatable_archway_06/ Both fail to load larger images in the lightbox, producing message "image cannot be loaded, please check the image filename and path and try again". To me, the hyperlinks on the thumbnails are not correct, but I can't see why Wordpress would be producing this.


De-registering a CSS file leaves it in the queue

I'm trying to de-register a CSS file that it is systematically add from a plugin. The CSS file it is useless in all pages. So I have added a simple `wp_deregister_style` passing the name of the CSS class used for the registration purpose. As a matter of fact, the CSS file is no longer print, but looking at the `$wp_styles` variable I can still see the "item" in the queue array. Any idea on how to remove it?


Execute PHP function inside the admin area

I want to ask if there is a hook for executing php inside the admin area, my problem is I'm trying to do the get_posts wordpress function inside a popup frame using the thickbox jQuery plugin, using an anchor, and I linked this anchor to a page contains my code I do the main function in the functions.php file which is               function fetch_all_companies() {     $companies_args = array(         'numberposts' => -1,         'orderby' => 'post_date',         'order' => 'DESC',         'post_type' => 'company',         'post_status' => 'publish'     );     $companies = get_posts($companies_args);     return $companies;}      when executing this function inside the admin panel I got this error               Fatal error: Call to undefined function fetch_all_companies()      any ideas ???


How to Display Custom Meta Box only on Specific Page IDs

I am using Magic Fields 2 for custom meta boxes and custom fields, but this situation pertains to any meta box. I have a custom meta box that I want to display on only 3 specific page IDs.               function mf_1_remove_meta_boxes() {              if( !in_array($_GET['post'], array('194','185','2') ) ):             remove_meta_box( 'mf_1', 'page', 'normal' );     }      ## UPDATE Using Bainternet's solution, the code works. That being said, a new issue became apparent. When a new page is created, the meta box is visible immediately, then disappears once the page is saved, since the ID does not match an ID that has been specified. ## UPDATE 2 The code above has been modified to correct the issue with the meta box appearing on a new (unsaved) page. It has also been modified to a complete and working code. The meta box will be removed for all users. To remove the meta box for everyone except admins:               function mf_1_remove_meta_boxes() {              if( !is_admin())             return;              if( !in_array($_GET['post'], array('194','185','2') ) ):             remove_meta_box( 'mf_1', 'page', 'normal' );     }


Order by category titles

I have a category page called 'features' this is all fine, but the posts in the features category also belong to a certain genre of film, and it's this what I want to order the posts by on the actual features category template. eg features cat template brings in all features posts. then what I want to do is display in alpha order by whatever genre it also belongs to               features           action              post              post              post           comedy              post              post            sci-fi              post              post      etc. this is what I have at the moment ( the cat numbers relate to the genres = action=10 etc)               query_posts('cat=10,11,12,13,14,15,16,17,18&orderby=title&order=DESC' );                                  while (have_posts()) : the_post(); ?>      How can I list all the posts (group them) by genre ? when I use title here i guess it's using the posts title. Playing around if I stick this in the post loop               <?php                             foreach((get_the_category()) as $childcat) {                             if (cat_is_ancestor_of(4, $childcat)) {                             echo $childcat->cat_name;                             }}      this returns the actual genre cat for each post while in the loop, but I'm not sure how to stick it together so I can state the ordering of the posts by groups of genre, I was hoping I could do this in the query_posts? Any help in the right direction would be greatly appreciated Thanks MRO


How do I get the next page of posts link?

Functions such as get_next_posts_link allow you to get the HTML link to the next page, with few parameters for change (label and max pages). I want to get the URL to the next page so I can add custom classes to the link.


How to reference same column name but different table in custom db query

I use `wpdb` to connect to a custom db, then I use the following query: `$my_row = $wpdb_c->get_results("SELECT Employee.Name, Area.Name, Area.Region FROM Area INNER JOIN Employee ON Area.ID = Employee.Area_ID WHERE Employee.ID = " . get_the_ID());` How do i refer to each of the `Name` columns from the `Employee` and `Area` tables? I tried `$my_row[0]->Area.Name` but it only returned the string `'Name'`.


HTML code in Custom field

I'm using a custom field to display images in a slider on each post, but when I update the post after having entered the HTML code in the custom field, the code disappears. I'm assuming that there is some kind of filter that removes HTML code from custom fields when a post is saved. Is there a way to circumvent that without using a plugin? Thanks! Edit: The information is saved using the following code:               function save_details(){         global $post;              update_post_meta($post->ID, "ptime", $_POST["ptime"]);         update_post_meta($post->ID, "services", $_POST["services"]);         update_post_meta($post->ID, "tools", $_POST["tools"]);         update_post_meta($post->ID, "url", $_POST["url"]);         update_post_meta($post->ID, "images", $_POST["images"]);     }      You can find the complete functions.php code here (Pastebin).


Allow authors to edit pending posts

I am using the WP User Frontend plugin so that frontend user can create posts. The users creates a post, the admin has to review/publish it. Then if needed, the author can edit his posts, they are set again to pending, and the admin again has to review etc.. What I need to add is, that the author can edit hist post which is pending. But he only sees post that are published, not the pending ones. Any ideas?


How to always show pictures on my blog post

On my WordPress blog I'd like to show pictures in every view (e.g. category- view, tag-view, comment-view, single-view) but in the most of this views, I can't see them, and if so, only the main-picture. This is my blog. Images should be shown in most of the posts on the second, third and fourth page, and also if you click on "weiterlesen", it will let you enter into the full-view. I'm using WordPress 3.6.1 with the theme "attitude-free", so all of my page- template.php's looks like these:               <?php     /**      * Template Name: Blog Full Content Display      *      * Displays the Blog with Full Content Display.      *      * @package Theme Horse      * @subpackage Attitude      * @since Attitude 1.0      */     ?>          <?php get_header(); ?>          <?php     /**       * attitude_before_main_container hook      */     do_action( 'attitude_before_main_container' );     ?>          <div id="container">     <?php     /**       * attitude_main_container hook      *      * HOOKED_FUNCTION_NAME PRIORITY      *      * attitude_content 10      */     do_action( 'attitude_main_container' );     ?>     </div><!-- #container -->          <?php     /**       * attitude_after_main_container hook      */     do_action( 'attitude_after_main_container' );     ?>          <?php get_footer(); ?>      in /site/wwwroot/wp-content/themes/attitude/libary/structure/ i found the content-extensions.php which seems to me, be the file i need to manipulate, may these be possible? i replaced all the_excerpt with the_content, now the all kind of pictures are shown in category-view, wich is great. but still in comment-view there are no images, where do i need to change this? and not even this, the article is shown in full size an also embeded youtube- videos are shown.


Hide Parent if No Children

The codex provides a way to display the children and parent page for use as a sub-menu. However, this code displays the parent page in the list even when the parent has no children. How can I modify this code so it only displays if the parent has pages? Functions.php               if(!function_exists('get_post_top_ancestor_id')){     /**      * Gets the id of the topmost ancestor of the current page. Returns the current      * page's id if there is no parent.      *       * @uses object $post      * @return int       */     function get_post_top_ancestor_id(){         global $post;              if($post->post_parent){             $ancestors = array_reverse(get_post_ancestors($post->ID));             return $ancestors[0];         }              return $post->ID;     }}      Calling it:               <?php wp_list_pages( array('title_li'=>'','include'=>get_post_top_ancestor_id()) ); ?>     <?php wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>get_post_top_ancestor_id()) ); ?>


Reposition WooCommerce breadcrumb outside of wrapper content

I currently have this code in my functions file for the WooCommerce plugin..               function my_theme_wrapper_start()     {       echo the_breadcrumb();       echo '

';     }          function my_theme_wrapper_end()     {       echo '

';     }          function mytheme_prepare_woocommerce_wrappers()     {       remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );       remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);            add_action( 'woocommerce_before_main_content', 'my_theme_wrapper_start', 10 );       add_action( 'woocommerce_after_main_content', 'my_theme_wrapper_end', 10 );     }          add_action( 'wp_head', 'mytheme_prepare_woocommerce_wrappers' );          add_theme_support( 'woocommerce' );      Now I would like to reposition the WooCommerce breadcrumb outside of the section.main class, yet I cannot see how to do this. Is there a way to do this? This is the code I have for the WooCommerce breadcrumb...               function woocommerce_breadcrumb( $args = array() ) {              $defaults = apply_filters( 'woocommerce_breadcrumb_defaults', array(             'delimiter'   => ' / ',             'wrap_before' => '',             'wrap_after'  => '',             'before'      => '',             'after'       => '',             'home'        => _x( 'Home', 'breadcrumb', 'woocommerce' ),         ) );              $args = wp_parse_args( $args, $defaults );              woocommerce_get_template( 'shop/breadcrumb.php', $args );     }      I have tried putting the section.main tag in the 'before' line, but this only adds a section tag in the breadcrumb, it does not reposition the breadcrumb.


How to create a custom template for a custom taxonomy?

I have the following below which I have used to create a custom post type and a custom taxonomy. Within the products section I've created the categories "monitors" & "consumables". I have then created the template taxonomy-monitors.php, is that correctly named for the monitors category? Also what is the url I need to visit to see only the monitors category using that template?               add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'products',             array(                 'labels' => array(                     'name' => __( 'Products' ),                     'singular_name' => __( 'Product' )                 ),             'capability_type' => 'post',             'supports' => array('title','editor','comments'),                'public' => true,             'has_archive' => true,             'rewrite' => array( 'slug' => 'products' ),             )         );     }          function news_init() {         // create a new taxonomy         register_taxonomy(             'products',             'products',             array(                 'label' => __( 'Product Categories' ),                 'sort' => true,                 'hierarchical' => true,                 'args' => array( 'orderby' => 'term_order' ),                 'rewrite' => array( 'slug' => 'products-category' )             )         );           }     add_action( 'init', 'news_init' );      UPDATE ![enter image description here](http://i.stack.imgur.com/FBW3p.png)


Use PHP code in shortcode

Sorry I am not a coder and my English is bad, but I want do this: I have shortcodes:   `[tabs][tab title="Title1"]Content1[/tab]`   `[tab title="Title2"]Content2[/tab][/tabs]` How can I use PHP in this like the code in my `single.php` theme file:   `[tabs][tab title="Title1"]echo (get_post_meta($post->ID, 'distance', true));[/tab]`


Custom attachment permalink structure

I have 10 images attached to each of a custom post type. My permalink structure for the custom post type is: example.com/post-type/post-title I am using the Wordpress Attachments plugin. My attachment permalinks look like this example.com/?attachment_id=55 What I would like to do for the attachment permalinks is: example.com/post- type/post-title/1 How could I go about doing this?


Adding media upload button to User Profile page (following a tutorial)

I am currently following a tutorial by Steven Slack on s2webpress.com on how to add an Author Image upload field to a user Profile page. I've managed to get most of it working, except for the part that allows me to use the WP 3.5 media manager system. The jQuery snippet that I'm trying to add is inside this code:               /**      * Adds additional user fields      * more info: http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields      */          function bck_authorimagefield( $user ) { ?>
<?php _e( 'Author Image', 'textdomain' ); ?>

                 <?php _e( 'The author profile picture', 'textdomain' ); ?>	                                                           <img src="<?php echo esc_url( get_the_author_meta( 'user_meta_image', $user->ID ) ); ?>" style="width:150px;">
                                          <input type="text" name="user_meta_image" id="user_meta_image" value="<?php echo esc_url_raw( get_the_author_meta( 'user_meta_image', $user->ID ) ); ?>" class="regular-text" />                                          <input type='button' class="additional-user-image button-primary" value="<?php _e( 'Upload Image', 'textdomain' ); ?>" id="uploadimage"/>
                     <?php _e( 'Upload an additional image for your user profile.', 'textdomain' ); ?>

     <?php } // bck_authorimagefield          add_action( 'show_user_profile', 'bck_authorimagefield' );     add_action( 'edit_user_profile', 'bck_authorimagefield' );          /**     * Saves additional user fields to the database     */     function bck_saveauthorimagefield( $user_id ) {              // only saves if the current user can edit user profiles         if ( !current_user_can( 'edit_user', $user_id ) )             return false;              update_usermeta( $user_id, 'user_meta_image', $_POST['user_meta_image'] );     }          add_action( 'personal_options_update', 'bck_saveauthorimagefield' );     add_action( 'edit_user_profile_update', 'bck_saveauthorimagefield' );               /*      * Adapted from: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/      */     jQuery(document).ready(function($){     // Uploading files     var file_frame;            $('.additional-user-image').on('click', function( event ){              event.preventDefault();              // If the media frame already exists, reopen it.         if ( file_frame ) {           file_frame.open();           return;         }              // Create the media frame.         file_frame = wp.media.frames.file_frame = wp.media({           title: $( this ).data( 'uploader_title' ),           button: {             text: $( this ).data( 'uploader_button_text' ),           },           multiple: false  // Set to true to allow multiple files to be selected         });              // When an image is selected, run a callback.         file_frame.on( 'select', function() {           // We set multiple to false so only get one image from the uploader           attachment = file_frame.state().get('selection').first().toJSON();                // Do something with attachment.id and/or attachment.url here         });              // Finally, open the modal         file_frame.open();       });          });     /**      * Return an ID of an attachment by searching the database with the file URL.      *      * First checks to see if the $url is pointing to a file that exists in      * the wp-content directory. If so, then we search the database for a      * partial match consisting of the remaining path AFTER the wp-content      * directory. Finally, if a match is found the attachment ID will be      * returned.      *      * http://frankiejarrett.com/get-an-attachment-id-by-url-in-wordpress/      *      * @return {int} $attachment      */     function bck_getattachmentimagebyurl( $url ) {              // Split the $url into two parts with the wp-content directory as the separator.         $parse_url  = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url );              // Get the host of the current site and the host of the $url, ignoring www.         $this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );         $file_host = str_ireplace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );              // Return nothing if there aren't any $url parts or if the current host and $url host do not match.         if ( !isset( $parse_url[1] ) || empty( $parse_url[1] ) || ( $this_host != $file_host ) ) {             return;         }              // Now we're going to quickly search the DB for any attachment GUID with a partial path match.         // Example: /uploads/2013/05/test-image.jpg         global $wpdb;              $prefix     = $wpdb->prefix;         $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM " . $prefix . "posts WHERE guid RLIKE %s;", $parse_url[1] ) );              // Returns null if no attachment is found.         return $attachment[0];     }          /*      * Retrieve the appropriate image size      */     function bck_getadditionalusermetathumb() {              $attachment_url = esc_url( get_the_author_meta( 'user_meta_image', $post->post_author ) );              // grabs the id from the URL using Frankie Jarretts function         $attachment_id = bck_getattachmentimagebyurl( $attachment_url );              // retrieve the thumbnail size of our image         $image_thumb = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );              // return the image thumbnail         return $image_thumb[0];          }          function bck_displayauthorimage() {     // retrieve our additional author meta info     $user_meta_image = esc_attr( get_the_author_meta( 'user_meta_image', $post->post_author ) );              // make sure the field is set         if ( isset( $user_meta_image ) && $user_meta_image ) {                  // only display if function exists             if ( function_exists( 'bck_getadditionalusermetathumb' ) ) ?>                 <img alt="author photo" src="<?php echo bck_getadditionalusermetathumb(); ?>" class="author-photo" />              <?php }                }      However, when I try to activate the plugin that this author image code is contained in, I get the following error:               Parse error: syntax error, unexpected '$', expecting '&' or variable (T_VARIABLE) in [the file's base URL]/authorimage.php on line 154      Line 154 is the first line of that jQuery snippet that I added above. I removed that snippet from the plugin altogether, and just left everything else, and it worked up to the point that no dialog box appeared when I press Upload Image on the User Profile page. Am I missing something here? I thought PHP could have jQuery in it, so long as it started with: `jQuery(document).ready(function($){ ....`


WooCommerce Total Inventory

I would like to show my users the total inventory of all products. Do we have a built in shortcode for this? If not how do i get this going. I look at all documentation and haven't found anything to this.


How to enqueue style before style.css

How do I enqueue a .css file before style.css is loaded? Or make the default style.css dependant on another .css file? I'm trying to load a .css reset, which style.css would overwrite. Here's what I have:               add_action('wp_enqueue_scripts', 'load_css_files');          function load_css_files() {         wp_register_style( 'normalize', get_template_directory_uri() . '/css/normalize.css');         wp_enqueue_style( 'normalize' );     }      However this is loaded after style.css.


List of filtered Events is breaking paging?

I have a list of events that are displaying in date order, with events in the past being hidden. The issue is that in total, there are 3 pages of events, but once the past events are hidden, there are only enough events to fill 2 pages. However, a third, blank page is still present and can be accessed through the paging links. This is the code on my events list page:               <?php $today = date("Ymd");?>          <?php $paged = 1;     if ( get_query_var('paged') ) $paged = get_query_var('paged');     if ( get_query_var('page') ) $paged = get_query_var('page');     query_posts( '&post_type=upcomingevents&paged=' . $paged );?>           <?php $loop = new WP_Query( array( 'post_type' => 'upcomingevents', 'paged'=> $paged, 'meta_key' => 'start_date', 'meta_compare' => '>=', 'meta_value' => $today, 'orderby' => 'meta_value_num', 'order' => 'ASC' )); ?>     <?php while ( $loop->have_posts('post_type=upcomingevents') ) : $loop->the_post(); ?>      And this is the paging code in my functions file:               function paginate() {     global $wp_query, $wp_rewrite;     $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;     $pagination = array(         'base' => @add_query_arg('page','%#%'),         'format' => '',         'total' => $wp_query->max_num_pages,         'current' => $current,         'show_all' => true,         'type' => 'plain'     );     if ( $wp_rewrite->using_permalinks() ) $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );     if ( !empty($wp_query->query_vars['s']) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) );     echo paginate_links( $pagination );      }


Where are custom field values stored in the database

I am using the advanced custom fields plugin for posts. I would like to know where custom fields are stored. I checked the `wp_posts` table. However, I could not find the posts with custom fields. I would like to know in which table are they stored in database.


wp_register_sidebar_widget() disappered my Widgets submenu - what am I doing wrong?

Working on a theme made by someone else as an official duty. At first it's causing error in the wp-admin Widgets page -- not working at all. Then the first thought came to my mind was debugging... **Debugging steps**   » Activated `WP_DEBUG`.   » Deactivated all the plugins.   » Switched to default theme 'T13'. **Errors**   Found that the problem was from the theme. Activated the theme again, and it's showing many DEBUG notices both in front-end and back-end. First of 'em was: > **`register_sidebar_widget()` is deprecated.** So without hesitation I went to `wp_register_sidebar_widget()`. But found myself in a claustrophobic arena -- I exactly don't know how to register widgets with `wp_register_sidebar_widget`. But with Codex and other WP.SE.com threads, I tried the following:               <?php     // Register widgetized areas     function theme_widgets_init() {              // Area 1            wp_register_sidebar_widget(             'primary_widget_area',          //widget_id/ widget_slug             'Primary Widget Area',          //widget_name             'primary_widget_display',       //callback function             array(                 'description' => 'The primary widget on the right side'             )         );              function primary_widget_display( $args ) {                  extract($args);             echo $before_widget;             echo $before_title . 'My Unique Widget' . $after_title;             echo $after_widget;             // print some HTML for the widget to display here             echo "Your Widget Test";              }              // Area 2              wp_register_sidebar_widget(             'secondary_widget_area', //widget_id/ widget_slug             'Secondary Widget Area', //widget_name             'secondary_widget_display', //callback function             array(                 'description' => 'The secondary widget on the right side'             )         );              function secondary_widget_display( $args ) {                     echo "show the secondary widget";                }          } // end theme_widgets_init          add_action( 'init', 'theme_widgets_init' );     ?>      ### PROBLEM #1: _The Widgets sub menu under the Appearance menu in wp-admin is totally gone._ ### PROBLEM #2: I'm struggling with new `callback_function` of `wp_register_sidebar_widget()`. How can I implement the old sidebar widget design with the new `callback_function`. So, for Primary Widget Area, you can see, I simply copied & pasted the code from Codex to understand how the code is working. But as the **Problem #1** occurred, I'm unable to test em. Here is the code-block primarily used in the theme, is now deprecated. _How can I use the new`callback_function` to do the same?_               <?php             // Deprecated Codes Below             register_sidebar_widget(                 array (                     'name' => 'Secondary Widget Area',                     'id' => 'secondary_widget_area',                     'before_widget' => '
',                     'after_widget' => "
",                     'before_title' => '
',                     'after_title' => '
',                 )             );     ?>      > **NOTE:** But the new code I pasted at the top solved one thing -- all the > DEBUG notices are gone. That's a relief, alHamduLILLAH! :)


Get only X number of categories

How can i get only x number of categories using `the_category`. I triesd a few thing but none worked. I dont want to use `get_the_category`


Show Pages in Categories

I created category function by adding this code to functions.php:               function page_category() {       register_taxonomy_for_object_type('category', 'page');       }      // Add to the admin_init hook of your theme functions.php file      add_action( 'init', 'page_category' );      But the thing is that when I go to a category page, the page does not show the pages that are in the category. I read it is because categories are meant to show only posts. Is there any way show pages in categories, without using a plugin? Thanks!


How to remove /blog/ prefix for custom post types in permalinks?

I have a client that used to have a static website and a blog powered from WordPress under the `/blog` subdirectory. Now he decided to move everything into WordPress so that he can also create and edit pages easily. However because the website is getting a lot of traffic and he already has likes, tweets and +1 in every blog post he wants to keep his blog under the `website.com/blog`. I thought it was as easy as heading over the permalinks and add `/blog/%postname%/` in the permalink structure. What the problem is right now is that I have a created a few custom post types to accommodate the needs of his content and custom post type's content resides now under the blog virtual directory. How can I specify that only the blog posts and the blog categories must be under the /blog virtual directory and everything else can use the permalink structure of /%postname%/. This is my custom post type               register_post_type( 'vm_products',         array(             'labels' => array(                 'name' => __( 'Products' ),                 'singular_name' => __( 'New product' ), //in the horizontal bar when you are logged in.                 'add_new' => __('Add new product'),                 'add_new_item' => __('New product'),                 'edit_item' => __('Edit product'),                 'new_item' => __('New product'),                 'view_item' => __('Show all products'),                 'search_items' => __('Search product'),                 'not_found' =>  __('No products found'),                 'not_found_in_trash' => __('No products found in trash'),                  'parent_item_colon' => '',                 'menu_name' => 'Products'             ),         'public' => true,         'has_archive' => true,         'show_in_menu' => true,          'show_ui' => true,         'supports' => array( 'title', 'custom-fields', 'editor', 'thumbnail'),         'rewrite' => array('slug' => 'product'),         'taxonomies' => array('vm_product_cats')         )     );


How to get posts published between a date and today?

Is it a way to get posts published between a date and today with `query_posts()` ? Example : All posts published since **2012-04-01** Thanks EDIT : How to add the filter date on this Query Posts ?               query_posts(array(             array('post'), 'tax_query' => array(array( 'taxonomy' => 'post_format',                                    'field' => 'slug',                                    'terms' => array('post-format-image'))),           'cat' => '-173',           'post_status' => 'publish')        );'


wordpress with many custom styled static pages

I am creating wordpress that constists of many many custom styled static pages. Some has tables, some has text+iages etc. - so each page has almost unique style with some commonalityes, of course. So I have a question - how to better style this. I have two options: 1) I create some static text, images, table etc. in wp-admin -> Pages; I will chante my style.css and create styles for each page or 2) i will use advancec tinymce editor; I will create different custom styles for tables, images etc.; I will add text in wp-admin and user will see all custom styles and how pages look like. It seems that in this case use rwill be able to see custom page style. And also in this case the page will contains more tables (and not divs), as I think that this is easier to create in tinymce editor for user. I have more than 40 custom styled pages. I wonder what is the best practice to style them so that user still will be able to modify text and some images. **EDIT:** Client have chosen to use Wordpress for this task and I do not have an option to choose any other CMS or other sollution. There are some commonilities in all pages like menu, header, footer. All pages has heading, subheading with the same styling. Also bulletins and numbering are mostly with the same style. SO I have already done basic page structure. However, if you imagine booklet, then you can imagine that every page has a bit different structure - some have three images in a row and that is it, some has text with 1 image, some has table, some has "image bar on the right side". Pages differ with content type and structure. Everythig could be achived with CSS, but I do not know what is better approach with WP when admin can edit the text. Probably I can take make some groups of very similar pages, but not much and those groups will consist of 2-3 pages.


May I change the order of the tags?

I have a list of all tag. I want set a order for them, form example, as order of slug? Here is the code for get all tags.               <?php     $tags = get_tags();     foreach ( $tags as $tag ) {         $tag_link = get_tag_link( $tag->term_id);         $html .= "name}' class='{$tag->slug}'>";         $html .= "{$tag->name}";     }     echo $html;     ?>


Looking for a Wordpress plugin to show five latest tweets one at a time?

As the question suggests, I'm looking for a plugin that can cycle through my latest five tweets one at a time, and via Javascript/jQuery, it automatically rotates between the tweets on a set interval. I've looked at quite a few, and all of them can only either show one or multiple, but with no automatic cycling. Thanks in advance.


Hardcode a form in Contact Form 7

I've been digging a little into Contact Form 7 source code without success, but I was wondering if, like in Advanced Custom Fields, it's possible to hardcode a complete form (fields, recipients and required rules) in a theme using the WordPress API. I don't expect a good straightforward way, but at least a way that I could deploy my websites without having to depend on DB-specific inputs. Also, I don't refer to this solution, that uses a `do_shortcode` and still needs us to create the forms. Has anyone done something similar with Contact Form 7?


List Custom Taxonomy Based on Post Count & Category

i have a custom taxonomy called 'bike-category' and a custom term called 'brand' and a custom post type called 'bikes' I want to list each bike-category then underneath list all brands _only_ which have bikes in them. Ive half got there however it seems very resource heavy/long winded and im sure im going about this the wrong way. Could someone suggest a better approach?
     <?php     // set up taxonomies     $tax_one = 'bike-category';     $tax_two = 'brands';     $post_type = 'bikes';          $categories = get_categories( array(         'type'                     => $post_type,         'orderby'                  => 'name',         'order'                    => 'ASC',         'hide_empty'               => 0,         'hierarchical'             => 1,         'taxonomy'                 => $tax_one ));              foreach ( $categories as $category ) : // list all categories              if($category->slug == $wp_query->query_vars['bike-category']) { $selected = ' class="selected"'; } else { $selected = ''; }                  echo '
slug.'">'.$category->name.'
';                      $terms = get_terms( $tax_two, array( 'hide_empty' => 0 ) );                      foreach ( $terms as $term ) :  // list all brands in each category                          $myquery['tax_query'] = array(                         array(                             'taxonomy' => $tax_one,                             'terms' => array($category->name),                             'field' => 'slug'                         ),                         array(                             'taxonomy' => $tax_two,                             'terms' => array($term->name),                             'field' => 'slug'                         )                     );                     $the_posts = new WP_Query($myquery);             print_r($myquery);                     if ( $the_posts->have_posts() ) : // if there are posts in the current brand and category then display it                              echo '
slug.'/'.$term->slug.'">'.$term->name.'
';                          endif;                      endforeach;                  echo '

';              endforeach; ?>


image_resize() with blank space

Any way to resize an image without crop and add new blank space? Using image_resize() from wordpress.


Why does dbDelta() not catch MysqlErrors?

From what I can see, `dbDelta()` is designed to suppress database errors that occur during its operation. Generally speaking, this seems to be the case, but New Relic is still reporting MysqlErrors from the function. The exact error message is of the format:               MysqlError: Table 'xxx.wp_yyy_posts' doesn't exist      From `dbDelta()` in `/wp-admin/includes/upgrade.php`, we have:               // Fetch the table column structure from the database     $suppress = $wpdb->suppress_errors();     $tablefields = $wpdb->get_results("DESCRIBE {$table};");     $wpdb->suppress_errors( $suppress );      It appears that `suppress_errors()` is doing it's job and preventing error messages from being echoed to the screen. **However, it also appears that these errors are not actually being handled, as shown by our New Relic installation.** Understandably, we would like to eliminate all possible sources of errors on our production app so that we can accurately use the New Relic tool for tracking actual error rates and associate them with New Relic's reporting tools. **Is there a compelling reason why`dbDelta()` doesn't handle this error?** The only reason I can think of is that this is a deliberate design decision to facilitate development and bug-fixing. It could be hard for a developer to track down issues when `dbDelta()` completely suppresses any errors. Of course, a new parameter/option could be introduced to specify whether or not this automatic error suppression should occur (which would make catching the MysqlError a no-brainer). This becomes a bit of an issue in our case in which every single call to `install_blog()` generates this error. Since we are running a large multisite installation, every time we create a new blog, an error is generated.


Migrate php folder to Wordpress

I am redesigning a cms-less, flat file php website and developing it in WordPress. The existing website is not using a database. One directory in the php site has over 100 pages and the content needs to be imported into WP. I've created a custom content type for this directory, but does anyone have best practices or tips or plugins to migrate/import such a massive folder?


Add a Custom Class to Admin Menus

I am looking for a way to add some custom classes to the admin menus using PHP. For example, here are the li tag for Posts and Pages:

      In the Posts li tag I would like to add a custom class (e.g. custom_one) so that it would look like this:
      But for the Pages li tag I would like to add a different custom class (e.g., custom_two) so that it would look like this:
      Any idea how to do this vis-a-vis the functions.php file? Thanks, Moshe


Creating conditional to display taxonomy term meta

I'm trying to display an extra meta field for taxonomy terms. wever I'm trying to create a conditional, in that, if the meta field is empty, show a default value. here's the code for creating the taxonomy meta field:               // Add phone number to location taxonomies     function nwtd_lpfs_taxonomy_add_new_meta_field() {         ?>
             <?php _e( 'Location Based Phone Number', 'nwtd' ); ?>             <input type="text" name="term_meta[phone]" id="term_meta[phone]" value="">
<?php _e( 'Enter a phone number for this location','nwtd' ); ?>

     <?php     }     add_action( 'locations_add_form_fields', 'nwtd_lpfs_taxonomy_add_new_meta_field', 10, 2 );          // Edit term page     function nwtd_lpfs_taxonomy_edit_meta_field($term) {              // put the term ID into a variable         $t_id = $term->term_id;              // retrieve the existing value(s) for this meta field. This returns an array         $term_meta = get_option( "taxonomy_$t_id" ); ?>
         <?php _e( 'Location Based Phone Number', 'nwtd' ); ?>	                              <input type="text" name="term_meta[phone]" id="term_meta[phone]" value="<?php echo esc_attr( $term_meta['phone'] ) ? esc_attr( $term_meta['phone'] ) : ''; ?>">
<?php _e( 'Enter a phone number for this location','nwtd' ); ?>

     <?php     }     add_action( 'locations_edit_form_fields', 'nwtd_lpfs_taxonomy_edit_meta_field', 10, 2 );          // Save extra taxonomy fields callback function.     function save_taxonomy_custom_meta( $term_id ) {         if ( isset( $_POST['term_meta'] ) ) {             $t_id = $term_id;             $term_meta = get_option( "taxonomy_$t_id" );             $cat_keys = array_keys( $_POST['term_meta'] );             foreach ( $cat_keys as $key ) {                 if ( isset ( $_POST['term_meta'][$key] ) ) {                     $term_meta[$key] = $_POST['term_meta'][$key];                 }             }             // Save the option array.             update_option( "taxonomy_$t_id", $term_meta );         }     }       add_action( 'edited_locations', 'save_taxonomy_custom_meta', 10, 2 );       add_action( 'create_locations', 'save_taxonomy_custom_meta', 10, 2 );      The conditional I'm trying to use in my template is:               <?php if( $term_meta['phone'] != "" ) {                       echo $term_meta['phone'];                                      } else {                                         echo '(555) 555-555';                                       }?>      Any thoughts? TIA


get_option() returning empty

I'm building a settings page for a theme and the `get_option()` that I'm using to retrieve the settings returns only `string(0) ""` even though there is a checkbox field. What I want is to retrieve the settings so I can use them to determine whether the checkbox should be checked/unchecked with `checked()`. Here's the relevant code:               function theme_settings_init(){     register_setting('theme_settings', 'theme_settings', 'sanitize_settings');          add_settings_section('general_settings', 'General Settings', 'general_settings', 'theme_settings.php');     function general_settings(){}          $home_blocks_args = array(       'type'      => 'checkbox',       'id'        => 'home_blocks_checkbox',       'name'      => 'home_blocks_checkbox',       'desc'      => 'Toggle the home blocks section on the front page',       'std'       => '',       'label_for' => 'home_blocks_checkbox',       'class'     => 'settings_field'     );     add_settings_field('display_home_blocks', 'Display Home Blocks', 'display_settings_field', 'theme_settings.php', 'general_settings', $home_blocks_args);          function display_settings_field($args){         extract($args);         $option_name = 'theme_settings';         $options = get_option($option_name);              switch($type){             case 'checkbox':                 $id = stripslashes($id);                 $id = esc_attr($id);                      ?><input type="checkbox" id="<?php echo $id; ?>" name="<?php echo $option_name; ?>[<?php echo $id; ?>]" value="true" <?php echo $option_name[$id] == "true" ? 'checked' : ''; ?> /><?php                 echo ($desc != '') ? "$desc" : "";                 break;              }     }     }     add_action('admin_init', 'theme_settings_init');     function sanitize_settings($input){     return $input;     }          function theme_settings_add_page() {     add_theme_page( __('Theme Settings'), __('Theme Settings'), 'edit_theme_options', 'theme_settings.php', 'theme_settings_do_page');     }      add_action('admin_menu', 'theme_settings_add_page');          function theme_settings_do_page(){ ?>

Custom Theme Options
       <form method="post" enctype="multipart/form-data" action="options.php">         <?php              settings_fields('theme_settings');              do_settings_sections('theme_settings.php');         ?>
                       <input type="submit" class="button-primary" value="<?php _e('Save   Changes')       ?>" />
                  </form>


Debug errors on sidebar

I'm uising a child theme of twentyfourteen on wordpress 3.8. When in debug mode, I get the following errors regarding a widget. > Notice: Trying to get property of non-object in \wordpress\wp- > content\themes\tema2014\functions\widgets.php on line 148               update_post_meta($post->ID, "_sidebar", $_POST["link"]);      And > Notice: Undefined index: link in \wordpress\wp- > content\themes\tema2014\functions\widgets.php on line 148               update_post_meta($post->ID, "_sidebar", $_POST["link"]);      And > Notice: Undefined index: _sidebar in \wordpress\wp- > content\themes\tema2014\functions\widgets.php on line 121               $link    = $custom["_sidebar"][0];      Here is the full code.               $dynamic_widget_areas = array (                                     'sidebar-21'       => __( 'Page Specific Sidebar 1', 'pietergoosen' ),                                     'sidebar-22'       => __( 'Page Specific Sidebar 2', 'pietergoosen' ),                                     'sidebar-23'       => __( 'Page Specific Sidebar 3', 'pietergoosen' ),                                     'sidebar-24'       => __( 'Page Specific Sidebar 4', 'pietergoosen' ),                                     'sidebar-25'       => __( 'Page Specific Sidebar 5', 'pietergoosen' ),                                     'sidebar-26'       => __( 'Page Specific Sidebar 6', 'pietergoosen' ),                                     'sidebar-27'       => __( 'Page Specific Sidebar 7', 'pietergoosen' ),                                     'sidebar-28'       => __( 'Page Specific Sidebar 8', 'pietergoosen' ),                                     'sidebar-29'       => __( 'Page Specific Sidebar 9', 'pietergoosen' ),                                     'sidebar-30'       => __( 'Page Specific Sidebar 10', 'pietergoosen' ),                     );          foreach ( $dynamic_widget_areas as $id => $dynamic_widget_area ) {             register_sidebar(                     array (                     'name'          => __( $dynamic_widget_area, 'pietergoosen' ),                     'id'            =>  $id,                                     'description'   => __( 'Page specific sidebars above the content sidebar', 'pietergoosen' ),                                     'before_widget' => '',                                     'after_widget'  => '',                                     'before_title'  => '
',                                     'after_title'   => '
',             ));         }     }     add_action( 'widgets_init', 'pietergoosen_widgets_init' );               // Add dynamic sidebars     add_action('admin_init', 'sidebar_init');             add_action('save_post', 'save_sidebar_link');             function sidebar_init(){                     add_meta_box("sidebar_meta", "Sidebar options", "sidebar_link", "page", "side", "default");             }             function sidebar_link(){                     global $post, $dynamic_widget_areas;                     $custom  = get_post_custom($post->ID);                     $link    = $custom["_sidebar"][0];             ?>
             <?             echo '<select name="link" class="sidebar-selection">';             echo '<option>Choose Sidebar</option>';             echo '<option>No sidebars to choose from</option>';             foreach ( $dynamic_widget_areas as $list ){                         if($link == $list){                           echo '<option value="'.$list.'" selected="true">'.$list.'</option>';                             }else{                           echo '<option value="'.$list.'">'.$list.'</option>';                             }                     }             echo '</select>
';             ?>

Choose the sidebar to use with this page.
     <?php     }     function save_sidebar_link(){     global $post;     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {return $post->ID;}             update_post_meta($post->ID, "_sidebar", $_POST["link"]);     }     add_action('admin_head', 'sidebar_css');     function sidebar_css() {             echo'                          ';     }      Any ideas how to solve this?


Random post permalink

I want to make a random permalink for each new post. For example when an author creates a new post, he gets this kind of permalink automatically: http://mysite.com/x5Kvy6 (like bit.ly). But I want to have the option to choose a keyword instead of the random key. Someone know the way or maybe a plugin to make this? P.S.: I didn't research an url shortener plugin. Any advice is welcome!


Redeclare/Change Slug of a Plugin's Custom Post Type

Is it possible to redeclare/change the slug of a plugin's existing custom post type (without simply editing the plugin)? That is, if Plugin X creates a custom post type with the slug /uncookedtoast/, is it possible to add a filter to functions.php (or something similar) that changes the slug to /bread/?


Custom menu walker: how can i check first item

I need to output different html code only for the first item of my submenus. How can I check in start_el() function if current item is first or not? Example:               Menu voice 1     -- Sub 1     -- Sub 2     -- Sub 3     Menu voice 2     Menu voice 3     Menu voice 4      I would know when I'm in Sub1 **UPDATE - I've solved using Static Var:**               class my_walker_nav_menu extends Walker_Nav_Menu {         static $count=0;         function start_el(&$output, $item, $depth, $args) {                      global $wp_query;                  $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $class_names = $value = '';                  $classes = empty( $item->classes ) ? array() : (array) $item->classes;                  $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';                  $output .= $indent . '
ID . '"' . $value . $class_names .'>';                  $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';             $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';             $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';             $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';                  $item_output = $args->before;             $item_output .= '';                  if ($depth==0) self::$count=0;  // reset var when we are in first level                       if ($depth==1 && self::$count==1) {  // if we are in submenu and items count is 1...                      //your custom code                                }                  $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;             $item_output .= '';             $item_output .= $args->after;                  $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );                  self::$count++;  // increase counter         }               }


Make a page (url) not cacheable

How to setup a wordpress-page in wordpress as non-cacheable in wordpress? I have made up a form manually for a page(wordpress) and I want to make that page not cacheable by browsers. How can it be done? Right now I am trying "nocache_headers();" function from wordpress, but it is not working.               nocache_headers();      If I submit data from the form and go back in the browser, it shows up the previous form.


Custom function for search form

I have the current function in my theme in order to alter Wordpress current search form:               function clarity_wpsearch($form) {     $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >     <label class="screen-reader-text" for="s">' . __('Search for:', 'claritytheme') . '</label>     <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="'.esc_attr__('Search the Site...','claritytheme').'" />     <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />     </form>';     return $form;      } However, I would like to change the submit input to an image. I found this code for reference:                <input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search.png" />      However, I have tried to integrate this code inside my function without luck, maybe it's a PHP issue I'm having, but I am having trouble figuring out. Thanks a lot for your help!


How to change the database prefix in multisite (WPMU) install

I am starting to implement security features on a client's website and so I would like to change the WP database prefix. However, the website is a multisite installation (WPMU) and so changing the prefix like you would normally does not work and I do not want to manually change the wp-config files for each sub-site (i.e. I will not be monitoring the sub-site creation). I tried using the database prefix change option on the All in One WP Security plugin too but no luck. Does anyone know how to go about this? Any thoughts would be appreciated. The website is running WP 3.6


Wordpress automatic plugin update

I am developing plugin. Currently my plugin has 1.0 version. If in future I will update my plugins with new version 1.1 , so how can user get message like below image ![enter image description here](http://i.stack.imgur.com/PXrbw.png) **How to compare current version with new version.**               I have stored my current version in database.      I have googled it. But didn't find any perfect solution.


WordPress internationalization + domains

Hello Dear WordPress'ers, I want to have a website on WordPress engine running with other languages too. I want to have a website + domains, for example like that:               myblog.com - main     myblog.de - translated to German     myblog.se - translated to Swedish     myblog.jp - translated to Japanese      Is it possible to run multiple websites (translated) like that with one WordPress + translations? How to do that?


Show a confirmation message on plugin deactivation

When my plugin is deactivated, I want to get a confirmation from the user whether all plugin options/tables need to be deleted or left as it is. Based on the option selected, I want to proceed further. Is it possible ? If yes, how ?


How do I add a forward slash to end of URL for Fetch as Google?

When trying to use the Fetch as Google tool I keep getting a redirect error. This error is because my URL address is http://www.example.com instead of http://www.example.com/ How do I add the forward slash to end of my URL?? Thanks in advance


Can you create a local wordpress network / multisite install on a mac with subdomains?

Is it possible to create a local wordpress network install on a mac (10.6) using mamp with subdomains? I have tried following some instructions I came across while googling, but apache seems to get hosed when I create virtual hosts. I came across another set of instructions that said only subdirectories will work on a local install. Does anyone know which one of these is the case and have you come across a good set of instructions for how to do it? Thanks,


Preparing a string in an array for localization

I'm working on a WordPress plugin and want to make sure that all text that is displayed is prepared for localization. I'm having trouble localizing the text that resides inside an array. For instance, I have the following code inside a class               var $control_type_default = array(         array(             'key' => 'automatic',             'value' => 'Automatic'         )     );          var $control_types = array(         array(             'key' => 'manual',             'value' => 'Manual'         )     );          function process_class_vars()     {         // Add default control type value to beginning of control types array         $this->control_types = array_merge($this->control_type_default, $this->control_types);              // Prepare values for localization         $temp_array = array();         foreach ($this->control_types as $control_type_array => $values)          {             $temp_array[] = array(                 'key' => $values['key'],                 'value' => __($values['value'], 'my_plugin')             );         }         $this->control_type = $temp_array;     }      Note that the "process_class_vars" function is called by the constructor. As you can see, I am attempting to pass the value in the array through the `__()` function (As a side note, I'm doing this with the function "process_class_vars" function instead of when I initially create the arrays because passing that function when I created the arrays initially threw an error). The problem is that when I run this through a .po generator, the "Automatic" and "Manual" string are completely missed. How can these values be processed correctly?


Add a checkbox in Media Upload window

I'm developing a theme and want to put an internal gallery. Do not want to use all photos uploaded to the media library. I want to create a field (checkbox) so you must select which of these photos should be in the gallery. I'm using `attachment_fields_to_edit` and `attachment_fields_to_save` to add the checkbox, but to mark each picture you must click on "Show" and select the checkbox. Some time ago I saw a plugin that adds a checkbox next to the link "Show" to not having to open each one of the options and select the photos checkbox. I do not remember the name of the plugin, but it was what I wanted to do. In other words, I add the checkbox next to the link "Show" for the user to click on this option and then click on "Save all changes".


Shortcode / plugin with custom (flexible) output

Following scenario: I'm building a theme framework which I want to reuse in various themes of mine. In this framework there is a collection of many shortcodes. For exemplary illustration of my problem, let's say one of these shortcodes fetches the recent posts ([recent_posts]) and displays them. Now, maybe I want sometimes to show the post titles above and sometimes below a post thumb image, sometimes I want to show the post date and sometimes not. In short I need some (as handy as possible) way to to change the output code while keeping the shortcode logic itself the same. Please have a look at the exact point of the concretely described use case: https://github.com/dotwired/Inferno/blob/master/inc/class-shortcodes.php#L591 (the code I want to be flexible starts at the marked line 591 and ends at line 595). I figured out following ways to do so:   * **apply_filters():**     * pro: feels like doing "WordPress way" ...     * contra: ...but I feel pretty uncomfortable with having too many filters added then (with possibly a large amount of passed arguments, e.g. in case that the post thumb is generated by another class accepting arguments)   * **a checking for a template file via file_exists() and then including:**     * pro: easy and functional     * contra: would require to add one file for each shortcode where I would want to have the HTML flexible, and the files should be all outside the framework directory. Also, this is surely not the "WordPress way"   * **a template string:**     * pro: No extra files or modular code needed, just specifying the HTML in the shortcode itself     * contra: easily would get too complicated in shortcode logic and especially in usability.


Automatically prepending '#' to slug in child page permalinks

I'd like to have any child page url like `http://www.foo.com/fooparent/foochild` automatically turns into `http://www.foo.com/fooparent/#foochild` Could this be done in the htaccess rewrite rules or can I directly change the way WordPress stores the slug name so I could add # in front of it? **Use case** I have the parent pages loading all the child pages content in the template. It's utilizing a onepage layout with anchor links scrolling down the page to each section as you navigate. There are cases where permalinks of the child pages are exposed and that would break the onepage functionality. A child permalink should just load it's parent page and add use its slug as a an #anchor in the URL.


Visual editor not working after update

After update wordpress visual editor are blank. ![Visual editor error](http://i.stack.imgur.com/GcHqP.png) I tried disabling all plugins, changing theme to 2014, and cleaning cache in server and pc. (not working)


Turn off comments for given CPT checkbox?

I'm wondering what's the best way of turning off comments for a Custom Post Type? I don't want to turn it off completely which is quite easy but to create a checkbox in wp-admin that will turn off comments if checked and show them as usual if not. Any ideas? :)


RSS feed url showing page not found. How to solve it?

Am developing a WordPress site. My site footer having a link to navigate RSS Feed URL. This URL is generated using `<?php bloginfo('rss2_url'); ?>` and it correctly generating the URL like `mysite.com/?feed=rss2` but this link is not working from home page. Showing page not found when i try to access it from home page. But When i try to access it from category page the link is working. Please help me to solve this issue. Thank you. Hariprasad **Update** Am not using default category or post of wordpress. Only using custom post type and custom taxonomies.


save_post action firing before I publish / save the post

I'm trying to update a posts meta only after it has been saved or updated. My function is pretty simple               function update_test( $post_id ) {            update_post_meta($post_id, 'copied', '1');       update_post_meta($post_id, 'blurb', 'this value updated by save_post action');          }          add_action( 'save_post', 'update_test');      When I add a new post at `wp-admin/post-new.php` I can see the two custom fields values have already been updated. The fields themselves exist with Advanced Custom Fields. But shouldn't be updated until after the post has been published / saved and or updated. Why is this updating the fields as soon as the post-new.php form loads?


Meta query with string starting like pattern

I have a custom WP_Query with the following meta_query:               $meta_query = array();          $meta_query['relation'] = 'AND';          if(!empty($postcode)) {         $meta_query[] = array(             'key' => 'postcode',             'value' => $postcode,             'compare' => 'LIKE'         );     }                         if(!empty($email)) {         $meta_query[] = array(             'key' => 'email_address',             'value' => $email,             'compare' => 'LIKE'         );     }      The problem with this is WordPress is wrapping each meta value in `%%` to use as part of the `LIKE` comparison in the query e.g `WHERE meta_value LIKE '%hello@example.com%'` Is it possible to set up a meta_query so only one percentage sign is used, so we can check if a value starts with or ends with a phrase? e.g `WHERE meta_value LIKE 'hello@%'`


"Allowed memory size" problem

I duplicated a wordpress website. On the new domain, the TYPES plugin causes big problems. I get several "Allowed memory size of ... bytes exhausted" error messages. They show up when I try to do the following:   * clicking on "Pages": Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /WWWROOT/234568/htdocs/wp-content/plugins/types/embedded/classes/loader.php on line 62   * when I want to add posts in Custom Post Types: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 122880 bytes) in /WWWROOT/234568/htdocs/wp-includes/class-wp-editor.php on line 847 I already tried to solve this problem by following these instructions here: http://wordpress.org/support/topic/allowed-memory-size-exhausted-what-does- that-mean But nothing has helped. My host provider told me I need to increase my RAM. It is set to 64 MB at the moment. BUT: At my old domain (same host provider) RAM is also set to 64 MB, and here everythings works fine. Why does it not work at my new domain? It's exactly the same website, just duplicated.


How To Remove Certain category Posts From the Blog Page

I'd like to know, Is there any ways to remove certain category posts from the blog page. Actually, I own a technology blog and I'd like to implement free software directory or marketplace in my blog within download category. But The download category post will not display in the blog page and only accessible from download category. I have heard about some plugin but I trust codes instead of the plugin. Thanks in Advance :)


Register users by e-mail

I want to use an email address instead of username to register and login my members. I've got the login part working using some of the code in this answer. Works fine but as expected wordpress still wants a username on the register page (custom, not the default). This line of code registers the user: `$user_signup = wp_insert_user( $user_data );`, and when registering I get the following error: > Cannot create a user with an empty login name. I'm guessing this can be solved by removing the appropriate filter, but I'm new to wordpress. What's the code to remove the username requirement?


wp_list_pages() not showing on posts

I have the following code showing up a sub-menu on my website (in my `header.php` file) that shows all well and good, however when I open up a post it dissapears:               <div id="dep-menu">         <?php global $post;         if (!is_front_page()) { // so I don't display a link on the homepage saying "Homepage"             if($post->post_parent) { //if page has parent                 $children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); //include a link to the parent                 $children.= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); //add the child pages             } else {                 $children = wp_list_pages("title_li=&include=".$post->ID."&echo=0");//parent link                 $children.= wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");//children             }             if ($children) { ?>                 <ul>                 <?php echo $children; ?>                 </ul>             <?php }         }     ?>     </div>      This works all well and good for my pages. The pages on this site are effectively `get x posts from y category and display title and excerpt`. No page is more than 2 deep cat wise meaning no url is more than `domain.com/cat-x/cat-y/` and the menu works on those pages. When I open a post with the url scheme of `domain.com/cat-x/post-title/` the menu drops off. **BEGIN EDIT** As there seemed to be some confusion, my page hierarchyis like so:               parent 1         child 1-1         child 1-2     parent 2         child 2-1         child 2-1      `parent 1` corresponds to a category name and when clicked a submenu showing `parent 1 | child 1-1 | child 2-1` shows up each displaying all the posts in their namesake categories. However when I click on a post the submenu disappears, and I need it to stay persistent. **END EDIT** Essentially, how do I get the menu to display again? As far as I can tell it should stay there as it still fits the url schema and has the same category.