Widgets menu does not appear under "Appearance" in dashboard

I am developing a WordPress theme, but am stuck on widgetizing my theme. I have followed several tutorials but still cannot get it to work.   My widgets menu does not appear under _Appearance_ in my dashboard. This is my function file and sidebar.   From _function.php_:               function custom_enqueue_scripts() {                  wp_deregister_script( 'jquery' );                  wp_register_script( 'jquery', get_template_directory_uri() . '/bin/js/jquery-1.10.1.min.js', 'jquery', '1.10.1',TRUE);             wp_register_script( 'fittext', get_template_directory_uri() . '/bin/js/jquery.fittext.js', 'jquery', '1.0',TRUE );                  wp_enqueue_script( 'jquery' );             wp_enqueue_script( 'fittext' );          }     add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );          if (function_exists('register_sidebar')) {                  register_sidebar(array(                     'name' => 'Widgetized Area',                     'id'   => 'katuhu',                     'description'   => 'This is a widgetized area.',                     'before_widget' => '
',                     'after_widget'  => '
',                     'before_title'  => '
',                     'after_title'   => '
'             ));          }      From _sidebar.php_:
          <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Widgetized Area')) : else : ?>

Widgetized Area

This panel is active and ready for you to add some widgets via the WP Admin

          <?php endif; ?>      `


How to output the menue structured for tabbed navigation?

I've got a design for my webpage that uses tabbed navigation with two levels. In this example 'TAB2' tab is selected and it's children item are desplayed below of it.                                     ˬ               |TAB1|    |TAB2|    |TAB3|                     tab2-item1    tab2-item2    tab2-item3ˬ   tab2-item4 ...      The only webpage I could find that uses something simmilar is really old fashioned but shows what I want in general. sample webpage (not mine) I think that I need the following html structure for this - using bootstrap:                //Bootstrap 2.32 nav tabs

TAB 1

TAB 2

tab1-item1

tab1-item2

tab1-item3

tab2-item1

tab2-item2

tab2-item3

tab2-item4

      What is the best way to print the menue out in this format?


How can I Protect my Q/A site from Unexpected /Spam Post?

I have a Bengali Q/A site which is created in WordPress. Recently I am getting unexpected post to my site from different users in english which are not any question or answer, just some junk content. I installed WP-reCaptcha plugin to protect spam post. But it can't prevent them. Can anyone help me to get rid of from this problem. This is my site: http://prosnouttar.com/


If a hacker changed the blog_charset to UTF-7 does that make WordPress vulnerable to further attacks?

I had a client who got hacked recently and I noticed that there were weird characters appearing on her site, like Â and Æ. It turns out that the hackers changed the blog_charset to UTF-7 in the `wp_options` table in the database. I set it back to UTF-8, but I was wondering if during the time it was set to UTF-7, could that create any security vulnerabilities? I did some searching and discovered there used to be a WordPress UTF-7 vulnerability that was fixed in version 2.0.6. We're running the most recent version of WordPress, so they couldn't have used that exploit, but are there any other exploits related to UTF-7? Really, is there any reason the hackers would change the blog_charset other than to be a pain? I've been trying to determine how they got in and I'm wondering if this is connected somehow.


How to set "with_front'=>false" to a plugin-generated cpt?

I am using an external plugin (not my own CPT) to manage events on a site where the blog permalinks structure is /news/%category%/%postname%/ Normally for CPTs I could set the prepend with front to FALSE when creating the CPT but in this case I don't know how since the plugin controls the definition. The developer sent me the snippet below but it does not work in either correctly changing the slug (actaully breaks event permalinks) or setting with_front to false:               //     //    EVENTON Calendar SLUG correction     //     //             add_filter('eventon_register_post_type_ajde_events', 'fix_event_slug', 10, 1);      function fix_event_slug($array){               $newar = $array;      $newar['rewrite']= array( 'with_front'=>false, 'slug'=>'events' ); //     // print_r($newar); return $newar; // test     }      Any help much appreciated.


RW Meta Box ,Problem setting post title

I'm using RW_Meta_Box plugin by Rilwis. I'm using a CPT and added a custom meta-box and removed the `title` and `editor`. But I still want to set the title for some obvious reasons. I created the CPT and meta-box and everything worked perfectly including the `all posts` page using `custom column` hooks. As soon as I sat to set post title to one of the fields in the meta-box, I failed to get the desired results.I tried to solutions I picked by searching through this Q&A site. Initially I tried: **SOLUTION1:**               add_action('submitpost_box', 'hidden_type_title');          function hidden_type_title() {         global $current_user, $post, $post_type;         global $prefix;         $md = rwmb_meta($prefix . 'name', array('type' => 'text'), $post->ID);         if ($post->post_type == 'MY_CPT_NAME') {         ?>         <input type="hidden" name="post_title" value="<?php echo esc_attr(htmlspecialchars($md)); ?>" id="title" />         <?php         } else {         return;         }     }      The above code works fine but it has a problem I am unable to detect. which is, I need to update the post twice to set the post title. Therefore I went on to try the `save_post` hook like so: **SOLUTION2:**               add_action('save_post', 'post_updated');          function post_updated($post_id) {         global $current_user, $post;         if ($post->post_type != 'MY_CPT_NAME') {         return;         }              global $prefix;         $md = rwmb_meta($prefix . 'name', array('type' => 'text'), $post_id);         // verify post is not a revision & not an autosave         if (!wp_is_post_revision($post_id) && !(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {         // set the new post title         $post->ID = $post_id;         $post->post_title = $md;              // update the post, removing the action to prevent an infinite loop         remove_action('save_post', 'post_updated');         wp_update_post($post);         add_action('save_post', 'post_updated');         return;         }     }      Now, I'm in a worse situation, the post title is instantly set but my meta-box data is somehow not being saved. What might be wrong with the first solution?


WordPress database error on a query working fine in MySQL Workbench

On activating my plugin Wordpress adds an entry to the error log...               WordPress database error  for query SELECT * FROM wp_c2pprojects WHERE projectid = 20 made by require_once('C:\\wamp\\www\\csv2post\\wp-admin\\admin.php'), require_once('C:\\wamp\\www\\csv2post\\wp-load.php'), require_once('C:\\wamp\\www\\csv2post\\wp-config.php'), require_once('C:\\wamp\\www\\csv2post\\wp-settings.php'), include_once('C:\\wamp\\www\\csv2post\\wp-content\\plugins\\csv-2-post\\csv-2-post.php'), CSV2POST->debugmode, referer: http://localhost/csv2post/wp-admin/admin.php?page=csv2post      As you can see, a simple query. I copied and paste the query into MySQL workbench to find that it works, returning the project with ID 20. The query runs during the plugins use and so this issue is related to activation somehow. Does anyone have any ideas why? I did try wrapping the '20' and it made no difference. Thank you for any help.


Make URL in custom field hyper link

In my WordPress site I have created a custom field for author website link. but I don't know how to make it hyperlink, so people can click on it to surf that website. at this moment it only shows raw text. like: `"www.example.com"` my code is:               <?php echo get_post_meta($post->ID, 'Author Website', true); ?>


Importing changes to Child Theme

I've made numerous changes to my theme via the CSS block in Theme Options. Wondering if there's a seamless method to migrate these changes to a Child Theme. I don't have much coding knowledge but I suspect there must be a way to grab a version of the blog as it is (modified) and save that as the child theme. Maybe?


How to Add Image to Wordpress RSS-Feed with no Plug-in?

I have searched for adding featuring image to rss feed with no plug-in for WordPress. I have found some examples and applied how it was instructed. But All I have got now is nothing. Still can't reach the image. The last and the best (according to me) solution (as told here) I have found is adding the following code to current theme's `functions.php`               function featured_image_in_feed( $content ) {         global $post;         if( is_feed() ) {             if ( has_post_thumbnail( $post->ID ) ){                 $output = get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );                 $content = $output . $content;             }         }         return $content;     }     add_filter( 'the_content', 'featured_image_in_feed' );      I have not seen any change. Is there something else to be done? What I want to do is adding featuring image as another key in the XML. It would be easier to show it for my slider.


Choose To Display Post Views With An Options Panel

I have post views enabled and I'm attempting to make **an options panel option to allow users to choose if they would like to display post views in each post**. If they choose 'Yes," then they will be shown post views. If they choose 'No,' then they will not. I'm hoping somebody can help me create the correct get_option to display post views based on what is chosen in the options panel. What I tried to grab my post views, and it did not work:               <?php     if (get_option('to_post_views') != 'No' and function_exists('post_views_count'))         post_views_count(); ?>      Without options enabled, I can grab my post views with the following:               <!-- Remember Post Views -->     <?php setPostViews(get_the_ID()); ?>          <!-- Display Post Views-->     <?php echo getPostViews(get_the_ID()); ?>      My function for post views:               // Post views     function getPostViews($postID){         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');             return "0 View";         }         return $count.' Views';     }     function setPostViews($postID) {         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             $count = 0;             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');         }else{             $count++;             update_post_meta($postID, $count_key, $count);         }     }          remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);      My array for the options panel:               array( "name" => "Display post views?",         "desc" => "Choose whether or not to display post views.",         "id" => $shortname."_post_views",         "type" => "select",         "options" => array("Yes", "No"),         "std" => "Yes"),


Show posts without content in RSS 2 FEED

Those posts that do not have a content, do not show up inside my feed via the URL. I want all of them to show up, even the ones without content. How ?


lost css when overriding themes templates

i have copied and modified the template file :                 header.php      in my theme child and i kept the same path. here is the full file                <?php      /**     * Your Inspiration Themes      *       * @package WordPress     * @subpackage Your Inspiration Themes      * @author Your Inspiration Themes Team <info@yithemes.com>      *      * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)      * that is bundled with this package in the file LICENSE.txt.      * It is also available through the world-wide-web at this URL:      * http://www.gnu.org/licenses/gpl-3.0.txt      */           global $yit_is_header;     $yit_is_header = true;           do_action( 'yit_before_logo' ) ?>

             <?php             /**              * @see yit_logo              */             do_action( 'yit_logo' ) ?>
                  <?php do_action( 'yit_after_logo' ) ?>

         <?php               do_action( 'yit_main_navigation');                     get_sidebar('product-menu');                   ?>

           <?php $yit_is_header = false; ?>      I have lost the CSS, why?


<?php wp_list_comments(); ?> is it possible to have the full code instead in the comments.php page

I strongly need to edit some parts of the comments left by the users, I want to add a link to the commenter's author.php page if he/she is a registered user by placing a text link somewhere next to his/her name. I've this code `<?php wp_list_comments(); ?>` but I wonder if it's possible to have the full code instead to replace it in comments.php Thanks!


Click Swatch, Change Image

I'm using the Advanced Custom Fields plugin and am trying to get a series of images to change when their corresponding Swatch Colour is clicked. Here's what I've got so far for my images loop:               <?php if(get_field('images')) { ?>
             <?php while(has_sub_field('images')) {                 $attachment_id = get_sub_field('image');                 $size = "thumbnail";                 $image = wp_get_attachment_image_src( $attachment_id, $size );             ?>
                     <img src="<?php echo $image[0]; ?>" class="<?php the_sub_field('swatch_number'); ?>" />
             <?php } ?>
     <?php } ?>      And this generates the series of swatches attached to each image:               <?php if(get_field('images')) { ?>

                 <?php while(has_sub_field('images')) { ?>                         <li class="swatch <?php the_sub_field('swatch_number'); ?>"><?php the_sub_field('swatch_name'); ?>
                 <?php } ?>

     <?php } ?>      I believe I'm getting hung up on the Javascript, because I need to find a way to: when a swatch colour is clicked (i.e. `.swatch.14`), show the image that has a class of `img.14`. Do I need to mix PHP and JS, and is something like this possible. Any help on this is appreciated. Thanks in advance!


What is the issue with our links? It creates a loop

On behalf of the university's radio station, I am trying to solve the issue with our links. When you go to our site http://brookesradio.com, if you click one of the nav bar or header, twice or go to the front page the link becomes 'http://brookesradio.com/#http://brookesradio.com/' and then if it is a category or page the page title. What is causing this issue, I tried a few things like manual links and looking through the theme's setting but nothing was jumping out at me. Thanks for reading Mike.


Functions.php in Child Theme - load JS

My theme uses this function to load Javascript and CSS               function aitEnqueueScriptsAndStyles()     {         // just shortcuts         $s = THEME_CSS_URL;         $j = THEME_JS_URL;              aitAddStyles(array(             'ait-jquery-prettyPhoto'  => array('file' => "$s/prettyPhoto.css"),             'ait-jquery-fancybox'     => array('file' => "$s/fancybox/jquery.fancybox-1.3.4.css"),             'ait-jquery-hover-zoom'   => array('file' => "$s/hoverZoom.css"),             'ait-jquery-fancycheckbox'=> array('file' => "$s/jquery.fancycheckbox.min.css"),             'jquery-ui-css'           => array('file' => "$s/jquery-ui-1.10.1.custom.min.css"),         ));              aitAddScripts(array(             'jquery-ui-tabs'              => true,             'jquery-ui-accordion'         => true,             'jquery-ui-autocomplete'      => true,             'jquery-ui-slider'            => true,             'ait-jquery-fancycheckbox'    => array('file' => "$j/libs/jquery.fancycheckbox.min.js", 'deps' => array('jquery')),             'ait-jquery-html5placeholder' => array('file' => "$j/libs/jquery.simpleplaceholder.js", 'deps' => array('jquery')),             'ait-googlemaps-api'          => array('file' => 'http://maps.google.com/maps/api/js?sensor=false&language=en', 'deps' => array('jquery')),             'ait-jquery-gmap3-label'      => array('file' => "$j/libs/gmap3.infobox.js", 'deps' => array('jquery')),             'ait-jquery-gmap3'            => array('file' => "$j/libs/gmap3.min.js", 'deps' => array('jquery')),             'ait-jquery-infieldlabel'     => array('file' => "$j/libs/jquery.infieldlabel.js", 'deps' => array('jquery')),             'ait-jquery-prettyPhoto'      => array('file' => "$j/libs/jquery.prettyPhoto.js", 'deps' => array('jquery')),             'ait-jquery-fancybox'         => array('file' => "$j/libs/jquery.fancybox-1.3.4.js", 'deps' => array('jquery')),             'ait-jquery-easing'           => array('file' => "$j/libs/jquery.easing-1.3.min.js", 'deps' => array('jquery')),             'ait-jquery-nicescroll'       => array('file' => "$j/libs/jquery.nicescroll.min.js", 'deps' => array('jquery')),             'ait-jquery-quicksand'        => array('file' => "$j/libs/jquery.quicksand.js", 'deps' => array('jquery')),             'ait-jquery-hover-zoom'       => array('file' => "$j/libs/hover.zoom.js", 'deps' => array('jquery')),             'ait-jquery-finished-typing'  => array('file' => "$j/libs/jquery.finishedTyping.js", 'deps' => array('jquery')),             'ait-jquery-jcarousel'        => array('file' => "$j/libs/jquery.jcarousel.min.js", 'deps' => array('jquery')),             'ait-spin-ajax-loader'        => array('file' => "$j/libs/spin.min.js"),             'ait-modernizr-touch'         => array('file' => "$j/libs/modernizr.touch.js"),             'ait-gridgallery'             => array('file' => "$j/gridgallery.js", 'deps' => array('jquery')),             'ait-rating'                  => array('file' => "$j/rating.js", 'deps' => array('jquery')),             'ait-script'                  => array('file' => "$j/script.js", 'deps' => array('jquery')),              ));              wp_localize_script( 'ait-script', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'ajaxnonce' => wp_create_nonce('ajax-nonce') ) );     }     add_action('wp_enqueue_scripts', 'aitEnqueueScriptsAndStyles');      I am using a child theme and I was wondering how can I load additional Javascript in the functions.php inside the child theme. The reason for using this is that any changes i make to the code above will be overwritten in the next update.


Specify strict 'order by' in WordPress query

I have a custom post type called `Employees` where an employee's name is the `post_title` of each post. I am trying to figure out how I would sort the `post_title` column by last name. So for instance, if we have the following post entries: `1. Justin Bieber 2. Selena Gomez 3. Jessica Alba 4. Nicholas Cage` The query would contain the entire list of employees sorted by last name, so: `1. Jessica Alba 2. Justin Bieber 3. Nicholas Cage 4. Selena Gomez` Anybody? Thanks.


Password-protected page redirecting to frontpage when I enter the password

I've enabled built-in password protection on one of my pages. The password form shows up, I enter a password, press _Submit_ button and I'm redirected to my front page. Now if I revisit the protected page, it will be unlocked (if the password was correct). But I think after I enter the password, I should land directly on the page I'm trying to access, right? I'm using Wordpress 3.5.2 with a custom theme. What I've tried:   * tested it on another blog with WP 3.5.2   * switched theme to unmodified Twenty Twelve   * disabled all plugins   * clean WP install on a local server No luck with any of these, still the same problem - I'm redirected to the server's root (i.e. `example.com/`, not `example.com/wordpress` or `example.com/wordpress/passpage`). Is it a bug or intended behavior? Is there any workaround I could use?


Modify query after meta value

I would like to change the calendar so it will display some posts based on a custom date field. For now i am interested to modify this query:               $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "         ."FROM $wpdb->posts "         ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "         ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "         ."AND post_type = 'post' AND post_status = 'publish'"     );      to something like this:               $wpdb->get_results("SELECT a.ID, a.post_title, DAYOFMONTH(b.meta_value) as dom "         ."FROM $wpdb->posts a, $wpdb->postmeta b "         ."WHERE b.meta_value >= '{$thisyear}-{$thismonth}-01 00:00:00' "         ."AND b.meta_value <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "         ."AND a.post_type = 'post' AND a.post_status = 'publish' AND a.ID = b.postid AND b.meta_key='Event Date'"     );      I did try the above query but it does not work, it returns an empty array. How can I change that the calendar will look after the meta value instead of post_date ? Thank you.


How can I revert to showing cached pages when no database connection is available?

I don't know much about how super cache works, but I see that at the very least, I can find most of the pages of my site in the wp- content/cache/supercache folder. Now, if WordPress cannot connect to the database due to the MySQL server being down (as is the case right now), should it be showing an error message or should it be showing the cached pages? I would think that it should work regardless of whether the connection can be made or not. Is there an option or a flag that I am missing? Also, it looks like the main page of the site is _not_ cached, while everything else is. Is there any way to deal with that? Obviously I can't do anything about that right now, since the database is down, but for the future?


How to query the content of a specific custom post type?

I have created a custom post type called "Single Neighborhood" in it i have 5 custom fields:   1. Background Color (color picker)   2. Background Image (image upload)   3. Latest news (WYSIWYG editor to list external links to news)   4. Local Events (WYSIWYG to display other RSS feeds)   5. Listings (WYSIWYG to write out a custom paragraph)   6. Taxonomy menu (to select a custom neighborhood like "Adams Morgan") All of these fields will be in different divs throughout the template page so would it be best to just insert all the divs within the "while" loop and just use on loop or would multiple loops be better? Finally how do i reference a taxonomy in the query? I mean i'm using the same Single-neighborhood template for 27 neighborhoods but i can't reference just one taxonomy within the template because then it would just pull the content for that one neighborhood, is there a dynamic way for WordPress to know what content from which neighborhood to pull by use of what link the user came in from? I've been dealing with this issue for 4 days now and i can't seem to understand the best approach to take. Will accomplishing something like this require custom functions, conditions within the loop to work it out? If anyone has for example made a real estate site or a site with hierarchical structure of Neighborhoods > Neighborhood > Places > Place > Sub pages of that place that required custom content for (in the same location of each page) specific pages please advise. Thanks.


How do I turn off local pickup for a specific shipping category?

Can anybody provide me with some code that would help? I need to be able to offer flat rate shipping AND local pickup for all product categories apart from 2, which I have assigned to a separate shipping class. I thought Local Pickup Plus would enable me to do this, but I was wrong. Please help. I am going around in circles. I thought something like this would work, but it doesn't:               // Hide standard local pick-up when shipping class is Pillivuyt     add_filter( 'woocommerce_available_shipping_methods',                  'hide_local_pickup_when_shipping_class_is_Pillivuyt' , 10, 1 );          /**      *  Hide Local Pickup option when shipping class is Pillivuyt      *       * @param array $available_methods      */     function hide_local_pickup_when_shipping_class_is_Pillivuyt( $available_methods ) {     if( isset( $product_shipping_class['pillivuyt'] )          AND isset( $available_methods['local_pickup'] ) ) {         // remove local pickup option         unset( $available_methods['local_pickup'] );     }     return $available_methods;     }


Order by custom field attribute

I'm try to get the output of this post type to order by the staff name alphabetically and I can't seem to figure out if needs to be within the beginning `array()` or if I been do something within the `foreach()` loop. Here's my constructed loop:                <?php      $mypost = array('post_type' => 'staff', 'posts_per_page' => 20, 'orderby' => 'staff-name',         'order' => 'ASC' );      $loop = new WP_Query( $mypost );           ?>
          <?php while ( $loop->have_posts() ) : $loop->the_post();?>           <?php $items = get_post_meta( $post->ID, 'elements', true );       foreach( $items as $i){          echo'
         ' . $i['staff-name'] . '
         ';     }     ?>            <?php endwhile; wp_reset_query(); ?>      The `staff-name` field hold the first and last name of the staff member, but for some reason it doesn't look like it's sorting them alphabetically correctly. I do notice that if I change it from `ASC` to `DESC` it does change the order of the output, but it's not alphabetized. It's almost like it's ignoring the field `staff-name` and ordering it by the post ID instead.


Order custom taxonomy by date

I have custom taxonomy called series. I want to have a page where it lists all the Series with latest on the top. Series   * Series about fish     * Post 1     * Post 2   * Series about dog     * Post 1     * Post 2 I created a taxonomy-series.php which list the individual series, but I go to http://example.com/series. I get a 404. Do I need to create a separate page on the theme? to list al the series arranged by date?


W3 Total Cache, CDN and Custom Post Types

I have W3 Total Cache installed so that I can serve images from my live website to a local development version. Everything seems to be working as expected, apart from the URL rewrite doesn't seem to happen on a custom post types pages. I don't have the caching switched on, and the CDN hostname replacement is working very well on every other page. Any ideas?


Ranking authors by post meta value

I have custom post-type with custom post-meta and i want to rank authors by post meta value.I can show the SUM of a meta value on author page with this code               <? php             $points = $wpdb->get_var("        SELECT SUM(meta_value)        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta        WHERE wposts.ID = wpostmeta.post_id        AND wposts.post_author = '" . $curauth->ID . "'         AND wpostmeta.meta_key = 'winnings'        AND wposts.post_status = 'publish'        AND wposts.post_type = 'tips'           ");     echo '
Points:' . $points . '
';          ?>      I want to rank authors by value of 'winnings' meta-key. I guess i have to join the users and post-meta tables but i don't know how. Please can someone help with this? ## UPDATE Yes every user has a ' **winning** ' post-meta that is auto calculated from two other meta-key values.To be more specific it is a tipster competition where user can send prediction for a match.The user adds info in custom fields like: odds,stake,prediction.After revised by admin the post can get status like **won** or **lost**. Now the winning meta is auto calculated based on won or lost status. Let say if the status is lost then the 'winning' value is -(stake_value). What i want is to rank users by 'winning' value.Hope i state this clear.


wp_login action hook not working

I have spent many time looking for a solution to my issue, but in vain. Your help is invaluable. I am creating a simplified badge system. The goal is to increment the number of badges for a user if he performs some things on the website. For example, for each post published, I give a user one badge. To do so, I opted for user meta data, and the use of publish_post action hook. in my `functions.php`, I put:               function publish_badge($post_ID) {          global $current_user;      get_currentuserinfo();          $number_of_badges= get_user_meta($current_user->id,'user_number_of_badges',true);          $number_of_badges= $number_of_badges + 1;          update_user_meta($current_user->id, 'user_number_of_badges', $number_of_badges);          return $post_ID;                     }          add_action('publish_post', 'publish_badge');      I am new in using Wordpress action hooks, and I spent a lot of time making it work. I know I am missing something, since for other hooks, the problem remains. Note I have in total 4 actions for which I want to give users more badges: publish_post,edit_post,wp_login,comment_post. Your usual help is always appreciated. **Edit:** I found solution for all the hooks except wp_login, In fact, I am using custom post types so I should change my hook names. in other words, publish_post will become publish_cpt. What to do with wp_login??                   function login_badge($user_login) {         global $current_user;               get_currentuserinfo();      $number_of_badges= get_user_meta($current_user->id,'user_number_of_badges2',true);        $number_of_badges= $number_of_badges +5;            update_user_meta($current_user->id, 'user_number_of_badges2', $number_of_badges);              }               add_action('wp_login', 'login_badge');      thank you for your time.


Update user meta on custom wordpress form and redirect

I have a fully functioning custom wordpress form that updates the user meta when they are logged in, however when I submit it just reloads the same page I am on, I am trying to get it to redirect to a thank you page. How would I go about this? Current working code I am using below. Thanks.                   <?php               global $current_user;             get_currentuserinfo();         if($_POST['gender'] != '') {         $gender_update = $_POST['gender'];         update_user_meta($current_user->ID,'gender', $gender_update);         }             ?>          <?php     function curURL() {     $pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];     return $pageURL;     }     ?>          <form name="userform" method="post" id="adduser" class="user-forms" action="<?php echo curURL(); ?>"  >


Include category title in wp_title

I'm using this in `functions.php` to output my page `<title>`:               /**      * Creates a nicely formatted and more specific title element text      * for output in head of document, based on current view      *      * @param string $title Default title text for current view      * @param string $sep Optional separator      * @return string Filtered title      */     function sitename_wp_title( $title, $sep ) {         global $paged, $page;              if ( is_feed() )             return $title;              // Adds the site name         $title .= get_bloginfo( 'name' );              // Adds the site description for the front page         $site_description = get_bloginfo( 'description', 'display' );         if ( $site_description && ( is_front_page() ) )             $title = "$title $sep $site_description";              // Adds a page number if necessary         if ( $paged >= 2 || $page >= 2 )             $title = "$title $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );              return $title;     }     add_filter( 'wp_title', 'sitename_wp_title', 10, 2 );      I'd like to include the **top level category name** on sub pages. For example currently with a site structure of this:   * Home   * About   * Work      * Large     * Small   * Contact Posts in the "Large" category will output a page title like this: `<title>$postname | $blog_name</title>` I'd like the output to be: `<title>$postname | Work | $blog_name</title>` So the top-level category name is added, but not the secondary level category (Large).


Restrict post navigation to current sub menu

This is what I'm using to output my post navigation:               <?php if (is_single() ) { ?>
Post Navigation

<?php previous_post_link('%link', '%title', 'in_same_cat'); ?>

<?php next_post_link('%link', '%title', 'in_same_cat'); ?>

          <?php } ?>      This will restrict the navigation to the current category (sub and parent category). I'd like to restrict this to only the current sub category. What would be the best way to do this?


Move Genesis Single Page/Single Post Title

Im not sure on how to do this .. But what i want to do is .   1. Move the Page/Single Post Page title.    2. Remove the title for Homepage only.   3. Keep the titles of my posts. (Loop page) or (Blog Page) Here's what i have:                   remove_action('genesis_post_title', 'genesis_do_post_title');         add_action ('genesis_after_header','title_slider');             function title_slider() {                 if (is_page('Home')) {                     remove_action('genesis_after_header', 'genesis_do_post_title');                 }                       if (is_page() || is_single()){                 echo "
";                 the_title( '
', '
' );                 echo "
";             }         }      It did move the single post / page titles, also it did remove the title in the Homepage.. But When i check my BLOG page, the titles are not there... Here's the structure i want for the BLOG page (A typical normal blog page structure) * * * (logo)(menus)   **BLOG PAGE TITLE** * * * Post title here   posted by: meh etc.   Content here..   readmore...   * * * Post title here   posted by: meh etc.   Content here..   readmore...   * * * Post title here   posted by: meh etc.   Content here..   readmore...   * * * I hope everything is clear! Thanks guys!


jQuery loaded in wrong order for non-admin page views only

I am calling /js/gallery_sugar.js with the following block of code in my plugin. It works fine while viewing the pages logged in as admin, but it doesn't seem to be running when I am just viewing the page without being logged in as admin: **Here is the code in the plugin:**               add_action('init','gallery_sugar_js_init');          function gallery_sugar_js_init() {         wp_enqueue_script( 'gallery_sugar_js', plugins_url( '/js/gallery_sugar.js', __FILE__ ), array( 'jquery' ) );         wp_register_style( 'prefix-style', plugins_url('/css/gallery_sugar.css', __FILE__) );         wp_enqueue_style( 'prefix-style' );     }      **Source code while not logged in as admin (This does not work - jquery not called first):**               <script type='text/javascript' src='http://localhost/projects/lightbox/wp-content/plugins/custom-gallery/js/gallery_sugar.js?ver=3.7'></script>     <script type='text/javascript' src='http://localhost/projects/lightbox/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>     <script type='text/javascript' src='http://localhost/projects/lightbox/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>      **Source code while logged in as admin (This works - jquery called first):**               <script type='text/javascript' src='http://localhost/projects/lightbox/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>     <script type='text/javascript' src='http://localhost/projects/lightbox/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>     <script type='text/javascript' src='http://localhost/projects/lightbox/wp-content/plugins/custom-gallery/js/gallery_sugar.js?ver=3.7'></script>      I am trying to work out what I am doing wrong in that it doesn't display in both cases.


Ensure an external javascript file called from plugin is loaded after jquery is called

I am calling a javascript file from my wordpress plugin code using:               add_action('init','gallery_sugar_js_init');              function gallery_sugar_js_init() {             wp_enqueue_script( 'gallery_sugar_js', plugins_url( '/js/gallery_sugar.js', __FILE__ ));     }      But in source code for WordPress I'm seeing this (my javascript file loading first):               <script type='text/javascript' src='http://localhost/projects/lightbox/wp-content/plugins/custom-gallery/js/gallery_sugar.js?ver=3.7'></script>     <script type='text/javascript' src='http://localhost/projects/lightbox/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>      How do I make sure jquery is loaded first in my Wordpress plugin file?


Custom category URL rewriting

Here is the situation: let say I have a page called Press and that page has this url: www.example.com/press-center Now, let say that I have a category Press (slug is press) and subcategory called News and it's content is available on www.example.com/category/press/news I want to rewrite the category URL so every time someone types www.example.com/category/press/news should get: www.example.com/press- center/news. If there is a post in this category, then the URL should look like: www.example.com/press-center/news/some-post-in-this-category Is this possible and how?


Adding a form at the end of the content

I'm trying to add a little form after each post for a plugin I have to code, but I'm not very familiar with Wordpress. By using add_action with the_content as hook, I was able to add some text to the content. My trouble is that the whole text stored in the $content variable seemed to be processed somehow. Specifically, there is a br/ added after each of my input fields, which break the layout of my form. I noticed that I don't have this issue if I had my form right before the comment form, for instance. But I don't want to put my form here, I need it to be really just after the post itself, prior to anything related to comments. Is there a way to disable this text and html formatting, but only for the form I'll be adding to the content ? In case there is no easy way to do so, I've tried finding a hook that would allow me to add something AFTER the content and BEFORE the comments to do so, but had no luck finding one. Is there such a hook ?


Calling widget via function in themes files (hard code)

Finally I finished to write my widget, and now want to call it using function inside themes php files. My widget looks like this:                   function reg_custom_widget() {             register_widget('wp_custom_widget');         }         class wp_custom_widget extends WP_Widget {             function wp_custom_widget() { /* constructor */ }             function widget($args, $instance) { /* here is the code, that uses 'core' functions to build the result and display it */ }             function shortcode_handler($atts) { /* the same code as in widget() with a couple of features */ }                  /* here are basic functions, strongly related. they perform main widget functionality */             function core_func_one($input) { }             function core_func_two($input) { }             function core_func_three($input) { }             function core_func_four($input) { }             function core_func_five($input) { }                  function update($new_instance, $old_instance) { /* updating settings */ }                function form($instance) {  /* building widget setup-form */ }         }      I already know about following methods, that call widget, and can be placed in themes files:   **1**. calling via shortcode with `do_shortcode()` wp function;   **2**. calling widget with `the_widget()` wp function;   Both this methods work great, but my designer rejects them.   He want to hard code calling of widget in this way: `if(function_exists('custom_widget')) { custom_widget(); }` How can I realize this option? Maybe is reasonable to make another one function in the widget class, make it global or something, it will run the widget from inside of it? Sounds like delirium, but I don't really understand now how to resolve this problem.


Post Link Filter Help

I Am probably being a complete tool here but I am trying to change the permalink on my custom post type to a particular category child. The code in essence works but I cannot for the life of me figure out how to replace the wildcard for the custom taxonomy. I have created the taxonomy product_cat and set rewrite to true. I am probably doing this all wrong or what I want is not achievable but thought I would ask you all anyway.               add_filter('post_link', 'product_cat_permalink', 10, 4);     add_filter('post_type_link', 'product_cat_permalink', 10, 4);          function product_cat_permalink($permalink, $post_id, $leavename) {          if (strpos($permalink, '%product_cat%') === FALSE) return $permalink;          $post = get_post($post_id);     if (!$post) return $permalink;          $terms = wp_get_object_terms($post->ID, 'product_cat');       $term_to_use = null;          // -- Loop The Terms     foreach($terms as $term) {         if($term->parent == 17) {             $term_to_use = $term;         }     }               if (!is_wp_error($terms) && !empty($terms) && is_object($term_to_use)) {         $taxonomy_slug = $term_to_use->slug;         return str_replace('%product_cat%', $taxonomy_slug, $permalink);     } else {         return $permalink;     }     }      Thanks in advance.


Custom WP deactivate an email activation link sent to user's email.

As the title stated, instead of using the WP default recovery password page, I created a custom reset password recovery page template. Everything is working except I'm not sure how deactivate the the activate email link sent to the user. Is there a way to deactivate the link sent to them? I've searched online and I'm stuck on how this process works in WordPress. I've also looked at the WP DB description and not able to find a field related to this issue. Has anyone encounter the same problem or have an idea of how it works? Any help would be great!


Using a default CPT archive slug as a page and using a different URL for the archive

I want to have a custom post type whose "slug" also shares the name on a core page. Basically because I want to give said page more custom look and look nothing like an archive (it don't need pagination, for one). However, when I try to do that, the page permalink works, but not the ones of the CPT (or vice-versa if I change some other settings), so I would like to fix it. However, I would still like to generate a conventional archive for most post types, but using a different string, something like "example.com/archive/post_type".


JSON get data from registration

I just want send data from wordpress registration of each new user to Emailomat (API here: http://hikaru.cz/doc.htm ). But I don't know JSON and this documentation is not helpfull for me. Can anybody help, please?               <?php     /**     * Used to be the page which displayed the registration form.     *     * This file is no longer used in WordPress and is     * deprecated.     *     * @package WordPress     * @deprecated Use wp_register() to create a registration link instead     */          require('./wp-load.php');     function register_new_user($user_login, $user_email, $nocomerce='') {     $errors = new WP_Error();          $user_login = sanitize_user( $user_login );     $user_email = apply_filters( 'user_registration_email', $user_email );          // Check the username     if ( $user_login == '' )         $errors->add('empty_username', __('ERROR: Please enter a username.'));     elseif ( !validate_username( $user_login ) ) {         $errors->add('invalid_username', __('ERROR: This username is invalid.  Please enter a valid username.'));         $user_login = '';     } elseif ( username_exists( $user_login ) )         $errors->add('username_exists', __('ERROR: This username is already registered, please choose another one.'));          // Check the e-mail address     if ($user_email == '') {         $errors->add('empty_email', __('ERROR: Please type your e-mail address.'));     } elseif ( !is_email( $user_email ) ) {         $errors->add('invalid_email', __('ERROR: The email address isn’t correct.'));         $user_email = '';     } elseif ( email_exists( $user_email ) )         $errors->add('email_exists', __('ERROR: This email is already registered, please choose another one.'));          do_action('register_post', $user_login, $user_email, $errors);          $errors = apply_filters( 'registration_errors', $errors );          if ( $errors->get_error_code() )         return $errors;          $user_pass = wp_generate_password();     $user_id = wp_create_user( $user_login, $user_pass, $user_email, $nocomerce );     if ( !$user_id ) {         $errors->add('registerfail', sprintf(__('ERROR: Couldn’t register you... please contact the webmaster !'), get_option('admin_email')));         return $errors;     }          wp_new_user_notification($user_id, $user_pass);          return $user_id;     }     $registerfile = get_theme_root()."/".get_stylesheet()."/register.php";     if(file_exists($registerfile)) {     include $registerfile;     }     wp_redirect('wp-register.php?action=register');          ?>      What I must doing with this?


changing wp-admin/widgets.php

We want to design the widgets page in the admin panel a little differently, mainly in order to help the site administrator understand where each widget will appear in the site: ![enter image description here](http://i.stack.imgur.com/jAZMg.png) For that, we need to change the HTML that widgets.php renders (simply changing the css isn't enough). How would we go about doing that without touching the core?


The Hook registration_errors was not called

I can't validate the custom fields in my plugin. I want to skip some registration on WordPress. My code snippet is here:               add_filter( 'registration_errors', 'reg_user_register', 10, 3);     function reg_user_register($errors, $sanitized_user_login, $user_email){         global $wpdb;         echo "<pre>";  /*need the values that are post from registration page*/         print_r($_POST);         exit();}     }


WP 3.3.1 Cant get jQuery Datepicker to work

at first i want to tell that i **HAVE** read the post: **jQuery UI Datepicker not working** already. I followed the instructions, but stll, i cant get it work. I am using WP 3.3.1 with the standard theme twentyeleven. There are 2 other jQueries running: "jExpand.js" and "sorttable.js" Thats it. very plain. In the functions i added this:               add_action( 'wp_print_scripts', 'wp33r01_date_picker' );          function wp33r01_date_picker() {         wp_enqueue_script( 'jquery' );         wp_enqueue_script('jquery-ui-core');            wp_enqueue_script('jquery-ui-datepicker');         wp_enqueue_style('jquery.ui.theme', get_bloginfo('wpurl') . '/' . '/css/ui-darkness/jquery-ui-1.8.17.custom.css');     }      which generates this in the DOM (footer):               <script src="http://sge.cashier-software.com/js/jExpand.js" type="text/javascript">     <script src="http://sge.cashier-software.com/js/js_script.js" type="text/javascript">     <link id="jquery.ui.theme-css" media="all" type="text/css" href="http://sge.cashier-software.com//css/ui-darkness/jquery-ui-1.8.17.custom.css?ver=3.3.1" rel="stylesheet">     <script src="http://sge.cashier-software.com/wp-includes/js/admin-bar.dev.js?ver=20111130" type="text/javascript">     <script src="http://sge.cashier-software.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.8.16" type="text/javascript">     <script src="http://sge.cashier-software.com/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js?ver=1.8.16" type="text/javascript">      Then i have on Document ready these lines:               jQuery(document).ready(function(){              // $("#atcs tr:odd").addClass("odd");         jQuery("#atcs tr:not(.odd)").hide();         jQuery("#atcs tr:first-child").show();              jQuery("#atcs tr.odd").click(function(){             $(this).next("tr").toggle('slow');             $(this).find(".arrow").toggleClass("up");          });         jQuery('tr.detail_row').css({'display':'table-row'});              //$("#atcs").jExpand();                  jQuery('#date_from').datepicker();          });      And finally, the simple Form in which i wanted the Datepicker to work:               <form method="post" action="<?php echo get_permalink(); ?>">        <input type="text" id="date_from" name="sge_date_from">        <input type="submit" name="sge_submit" value="Submit Form"><br>     </form>      But it simply does **NOTHING** :( I hope my description works, so might somebody can help. Many thanks in advance, Joe


Customizer - detect iframe load

I'm trying to get the initial styles from WordPress Customizer's iframe but this is what happens:               // ATTEMPT #1     var test = jQuery('#customize-preview iframe').contents().find('body').css('width');     console.log(test); // returns undefined          // ATTEMPT #2     setTimeout(function(){       var test = jQuery('#customize-preview iframe').contents().find('body').css('width');       console.log(test); // returns undefined     }, 100);          // ATTEMPT #3 (Success but not reliable)     setTimeout(function(){       var test = jQuery('#customize-preview iframe').contents().find('body').css('width');       console.log(test); // returns 1000px     }, 3500);      In /wp-admin/js/customize-controls.js on line 401 in WordPress 3.8 you'll find WordPress creating and appending this iframe. Does anyone have any idea if I can attach my own function that will read iframe's initial values there? I have also tried:               jQuery('#customize-preview iframe').one('load', function(){         // no success, probably my function is attached too late.     });     jQuery(document).one('load', 'iframe', function(){         // no success, probably my function is attached too late.     });


Conditional to use 'full' image size with animated GIFs

I am using ACF and pulling images into my category archives via ‘wp_get_attachment_image_src’ like this:               <?php $image = wp_get_attachment_image_src(get_field('image'), ‘grid’); ?>     <img src="<?php echo $image[0]; ?>" alt="" />      My client will be uploading animated gifs to this field and I need Wordpress to use the ‘grid’ image size if the image is a jpeg, but use ‘full’ if it is a gif, so that we retain the animation. How should I go about this? Thanks in advance!


Display newest posts from multiple categories ordered by date

I have the categories listed below in my `post` post type.               Category Name: Test 1 ID: 1     Category Name: Test 2 ID: 2     Category Name: Test 3 ID: 3     Category Name: Test 4 ID: 4      I'd like to retrieve for each `category` the latest 2 posts, except `category` with ID `4`, with posts ordered by date. Some posts may be attached to more than one `category`. On each every post I would like to display also the `category` name. But only one category. For example if I have already listed 2 posts from `Category ID #1` and the following post is attached to `Category ID #2 & #1`, the name of the `Category ID #2` should be displayed. I can retrieve the latest 2 posts from each `category` but hey are grouped into categories. Sometimes I might have the following post order depending to which categories I have attached the latest posts:               - post with ID 111 to Category ID 1     - post with ID 110 to Category ID 1     - post with ID 109 to Category ID 3     - post with ID 108 to Category ID 2     - post with ID 107 to Category ID 3     - post with ID 106 to Category ID 2      As you can see the order is NOT 1, 1, 2, 2, 3, 3. It must be ordered by the posted date. I have tried several methods, with custom sql queries or Transient API, but without any success. Maybe I have written something wrong, which is very possible since I wanted to avoid multiple queries and having less experience with custom sql queries. I've inspired from the following tickets:   * Retrieve latest post by multiple categories with ID   * http://wordpress.org/support/topic/display-newest-posts-from-multiple-categories-on-front-page?replies=4#post-1248334   * Using WP_Query to Query Multiple Categories with Limited Posts Per Category?   * Query Posts but only return 1 from a custom taxonomy? I have tried also with a for loop:               global $exclude_ids;     for ( $i = 1; $i <= 3; $i++ ) {         if ( $i==1 ) { $cat_name = "cat-1"; }         if ( $i==2 ) { $cat_name = "cat-2"; }         if ( $i==3 ) { $cat_name = "cat-3"; }         $query = 'category_name='.$cat_name.'&showposts=2';         $recent = new WP_Query( $query );         if ( $recent->have_posts() ) :         while ( $recent->have_posts() ) : $recent->the_post();         // get category name         $category = get_the_category();         // store id to exclude later         $exclude_ids[] = get_the_id();     ?>
             <a href="<?php the_permalink(); ?>" class="text"><?php the_title(); ?>             <?php              // though here I need the same name as $cat_name             echo $category[0]->cat_name;             ?>
     <?php         endwhile;         endif;     }      Again, the posts are grouped by categories. I'm not posting any other code here ( _have spent almost all the day with this_ ), since all my tries have failed. Some good directions would be very helpful for me.


How many times can I hook into the same action?

I have a theme which includes some setup, using `after_setup_theme` but I'd like to write my own functions which also need to run `after_setup_theme`. I'd prefer to keep my stuff in a separate file. Can I call `after_setup_theme` multiple times?


Custom post types - remove default post supports through empty array?

I recently asked a question the other day and got what I was looking for. Today I put that knowledge to practice, but I can't seem to figure how to remove the title and editor fields from the "edit" page. Below shows the arguments I'm using with `register_post_type`. Logically, I think providing an empty array for "supports" would make it not support anything by default. Am I missing something?                       $v_args = array(                     'labels' => array (                             'name' => 'Visitors',                             'singular_name' => 'Visitor',                             'add_new_item' => 'Register New Visitor',                         ),                     'public' => true,                     'publicly_queryable' => false,                     'exclude_from_search' => true,                     'show_ui' => true,                     'hiearchical' => false,                     'supports' => array( ),                 );      Thanks,   -Zack


Automatically adding categories and authors in custom menu?

I've spent a couple of days googleling around, looking for a way to automatically add categories and authors to my custom menu as soon as they are created (the same way that pages are automatically added!), but so far no luck! I'd really like for my client to not have to go to menu and add the category or the author to the menu manually every time a new one is created. Any ideas?


What does it mean by "Home page / Archives" in JetPack Site Stats?

![JetPack Stat Site visit Stat](http://i.stack.imgur.com/4KjJv.png)   In the JetPack SiteStats, on the "Top Posts & Pages" the first page or link got most views (8) is the **Home page / Archives**. What does it actually denote? JetPack support says: > **Top Posts & Pages**   >  This section of stats will list the Posts and Pages which have received the > most views. A view is only counted for a post or page when the permalink URL > is visited. For example, if a visitor reads a post titled “Hello World” > while viewing the home page of your blog, the view will not be counted > towards the post, only towards total views. As the last line says, the home page won't be counted here, only the Permalink URLs will be counted. Then, which Archive does it mean? A category archive, a tag archive, a day archive, a month archive, a year archive -- there are a lot of possibilities.


Determine WP_Query parameters from URL

I'm wondering if it's possible to determine WP_Query parameters by **only** using the given page URL. The reason I'm trying to do this because I'm developing a SPA theme (and ultimately a JSON response) and would need to be able to determine a query without reloading the page. Thought it's pretty hacky, I've been successful in pairing a post URL with the Permalink structure in order to determine what a single post query should be:               <?php          function api_query_url() {            // Check that the URL is set and is in fact a string       if ( ! isset( $_POST['url'] ) || gettype( $_POST['url'] ) !== 'string' ) {         api_response( false, 400, "'url' is a required parameter!" );       }            // Parse the URL for parameters and path       $query_url = parse_url( $_POST['url'] );            // Pass query-based URL directly to Single API request       if ( isset( $query_url['query'] ) ) {         api_single( $query_url['query'] );       }            // Map Permalink structure tags to WP_Query parameters       $structure_refs = array(         'year'     => 'year',         'monthnum' => 'monthnum',         'day'      => 'day',         'hour'     => 'hour',         'minute'   => 'minute',         'second'   => 'second',         'post_id'  => 'p',         'postname' => 'name',         'category' => 'category_name',         'author'   => 'author_name'       );            // Retreive the site's Permalink Structure and break it in to an array       $structure = array_filter( explode( '/', get_option( 'permalink_structure' ) ) );            // Break our query parameters in to an array       $query_params = array_filter( explode( '/', $query_url['path'] ) );            // Set up an empty query array       $query = array();            // For each query parameter received       foreach ($query_params as $param) {              // Using the parameter value's position, locate its corresponding structure key         $key_position  = array_search( $param, $query_params );         $structure_key = str_replace( '%', '', $structure[$key_position] );              // If the structure key exists in the structure references, add to to the query         if ( array_key_exists( $structure_key, $structure_refs) ) {           $query[$structure_refs[$structure_key]] = $param;         }       }            // Pass off to Query handler to create JSON response       api_single( $query );          }     add_action( 'wp_ajax_nopriv_api_query_url', 'api_query_url' );      Using the above function I'm able to pass `url` as a parameter to it to perform an ajax call, and it will parse it to find the WP_Query parameters. So, a URL like `http://example.com/blog/my-first-post/` will be parsed to extract `name => 'my-first-post'` and a URL like `http://example.com/?p=124` will be parsed to extract `p => 124`. This then gets passed to a `WP_Query` and so forth. FTR, I also remove any blacklisted parameters, like `post_status` or `has_password` in an attempt to keep things secure. In order to parse a pretty URL structure I take the components of the path, so for `/2014/07/hello-world/` we get _2014_ , _07_ , and _hello-world_ , and then I compare them to the set permalink structure, which in this case would be `/%year%/%monthnum%/%postname%/` \- and since some permalink tags don't work with WP_Query, I do some conversion; for example, `postname` would be `name`. **Anyhow**... it felt like I was off to a good start, until I ran in to pages. With my above code a page URL like `http://example.com/about/` and the above permalink structure the parameters extracted would be `year => 'about'`. Not good. If anyone has any guidance as to how I should approach this it would be _much_ appreciated. Also, please let me know if I'm approaching this all wrong. I just need to determine a query without reloading the page.


How to use RSS reader plugin for displaying as posts?

I am running WP 3.7.1-powered website. I would like to read news from several RSS sources and display them on one page in very similar manner as if they were posts from users of my site. Particularly, I need them to be displayed in the main area of a page (not in a widget) and I need them to be commented as regular posts. I tried "WP Simple Rss Feed Reader" and "RSS Importer", but I did not manage to configure or use them in such a way which would solve my problem. Is there any solution? Thanks.


Is it possible to add the_post_thumbnail to style.css?

I'm wondering if it's possible to add `the_post_thumbnail` location to style.css. I'm using these images as backgrounds, and I can easily do that on the template, of course, but I'm thinking that for responsive design it would be way easier to simply add `the_post_thumbnail` location to style.css and then reference that location to serve the proper background to any given size instead of serving one giant image for (say) mobile devices. Is there a way to do this?


Get frequency of scheduled event

How do I get the frequency of a scheduled event? I am writing a plugin, that would do something in a user defined schedule. The way I am trying to do this, is creating a custom cron schedule, which take a user input value as the `interval`. This is how I do it. Please note that everything is in classes.               class classA{         private function createCustomTimeFrame() {             add_filter( 'cron_schedules', array( $this, 'xxx_customTimeFrame' ) );         }              public function xxx_customTimeFrame( $schedules ) {             $schedules['xxx'] = array(                 'interval'   => $userDefinedInterval,                 'display'    => 'XXX Custom Timeframe'             );                  return $schedules;         }     }      I have assigned a scheduled tasks using the custom schedule "xxx" like this:               class classB{         private function scheduleDoingIt(){             if(wp_next_scheduled('xxx_doIt') == FALSE){                 wp_schedule_event(time(), 'xxx', 'xxx_doIt');                 //I am using the "xxx" custom schedule defined above.             }                  add_action('xxx_doIt', array($this, 'xxx_doItNow'));         }              public function xxx_doItNow(){             //Dominate the world.         }     }      I have installed "WP Crontrol" plugin. Using that, I can see the interval of the custom schedule "xxx" is being changed successfully when the user provide a new value for `$userDefinedInterval`. However, that doesn't change the frequency of executing the method `xxx_doItNow()`. It continues to execute with the original frequency, not the new one that user updated. Imagine there exists a WordPress function named "`wp_get_scheduled_event_frequency()`" that returns the actual frequency of the scheduled event in seconds, without referring to the cron schedule it was originally created with (i.e. "xxx"). Then I could do this:               if(wp_get_scheduled_event_frequency('xxx_doIt') == wp_get_schedules()['xxx']['interval']){         //If the frequency of the scheduled event is different than the interval of cron schedule.         $timestamp    = //Have to find the next time the scheduled task would have ran.         $recurrence   = 'xxx';         $hook         = 'xxx_doIt'         wp_schedule_event($timestamp, $recurrence, $hook);     }      In other words, if `wp_get_schedule('xxx_doIt')` could return actual current frequency, rather than the cron schedule name (i.e. 'xxx'), that would do it. So, any idea?


alot of errors with feedwordpress

Iam using feedwordpress for more than 1 year after some changes in my site this plugin caused a lot of errors in my site frontend & backend infortunatley i don't remeber all the changes i made in the database & my wordpress site & also i deleted my error log so i can't know the exact day this start to happens when i tried to deactivate the plugin the errors disappears when i tried to turn off the debugging mode of the plugin the errors still available when i tried to uninstall the plugin, delete it & reinstall the errors still **I tried to install it on fresh wordpress install on my localhost it works fine**               Strict Standards: Declaration of FeedWordPress_Walker_Category_Checklist::start_el()      should be compatible with      Walker_Category_Checklist::start_el(&$output, $category, $depth, $args, $id = 0)     in /home/elnhrda/public_html/e/wp-content/plugins/     feedwordpress/feedwordpress-walker-category-checklist.class.php on line 13          Strict Standards: Redefining already defined constructor for class      FeedWordPress_File in /home/elnhrda/public_html/e/wp-content/plugins/feedwordpress     /feedwordpress_file.class.php on line 11           Strict Standards: Non-static method FeedWordPress::needs_upgrade()       should not be called statically in /home/elnhrda/public_html/e/wp-content/plugins      /feedwordpress/feedwordpress.php on line 144          Strict Standards: Non-static method FeedWordPressCompatibility::link_category_id()      should not be called statically, assuming $this from incompatible context in      /home/elnhrda/public_html/e/wp-content/plugins/feedwordpress/feedwordpress.php      on line 1699          Strict Standards: Non-static method FeedWordPressSettingsUI::is_admin()      should not be called statically, assuming $this from incompatible context in      /home/elnhrda/public_html/e/wp-content/plugins/fwp-sic-em/SicEm.php on line 46          Strict Standards: call_user_func_array() expects parameter 1 to be a valid      callback, non-static method FeedWordPress::admin_api() should not be called     statically in /home/elnhrda/public_html/e/wp-includes/plugin.php on line 406          Strict Standards: Non-static method FeedWordPressSettingsUI::is_admin()      should not be called statically, assuming $this from incompatible context in      /home/elnhrda/public_html/e/wp-content/plugins/feedwordpress/feedwordpress.php on line 1246      this is the log_error at the begining of this issue               [02-Nov-2013 14:31:20 Africa/Cairo] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/p in Unknown on line 0     [02-Nov-2013 14:31:20 Africa/Cairo] PHP Warning:  PHP Startup: pdo_sqlite: Unable to initialize module     Module compiled with module API=20090626     PHP    c in Unknown on line 0     [02-Nov-2013 14:31:20 Africa/Cairo] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/s in Unknown on line 0     [02-Nov-2013 14:31:20 Africa/Cairo] PHP Warning:  PHP Startup: pdo_mysql: Unable to initialize module     Module compiled with module API=20090626     PHP    co in Unknown on line 0     [02-Nov-2013 14:31:20 Africa/Cairo] PHP Warning:  PHP Startup: SourceGuardian: Unable to initialize module     Module compiled with module API=20090626     PHP  in Unknown on line 0     [02-Nov-2013 12:31:20 UTC] PHP Strict Standards:  Declaration of FeedWordPress_Walker_Category_Checklist::start_el() should be compatible with Walker_Ca in /home/elnhrda/public_html/e/wp-content/plugins/feedwordpress/feedwordpress-walker-category-checklist.class.php on line 13      any idea how to fix this!


Let users register weight each day and save it in DB

I need a way that lets my users register they're weight (kg) and maybe % of bodyfat and save that information on each user in the DB. Then i need a way to output that number again on the logged in user What would be the easiest approach to do something like this?


Author profile comments system

I have a custom PHP file to get all the users/authors from the DB in WP, so it's all showing correctly and working BUT, I want to make the comment to work properly, what i did now is:                 <?php comments_template(); ?>      I added the above line in the file, but the issue is that if i comment on one author the comment won't stay ONLY on his profile page, but it will publish in all the authors page, it's like the comment are not individual.... Any ideas how can i make the commenting work for each author separated from the other?


wpdb prepare: passing varible number of fields as second argument

As i want to manage the NULL fields in my db and wordpress functions doesn't allow to do so, i will need to dynamically generate a query depending on the situation. The problem is that i don't know how to pass a variable number of fields as second argument! this is what i've been tr but it returns an "Empty query" error:               if ($a == '') {         $fields = 'b, c';         $placeholders = "'%s', '%s'";         $vars = $b . ', ' . c;     } else {         $fields = 'a, b, c';         $placeholders = "'%s', '%s', '%s'";         $vars = $a . ', ' .$b . ', ' . c;     }     global $wpdb;     $wpdb->show_errors();     $query = 'INSERT INTO table (' . $fields . ') VALUES (' . $placeholders . ')';     $wpdb->query($wpdb->prepare($query, $vars));      is there any way to do so (even using $wpdb->insert)?


Are plugins like WP Robot considered as spammy by the community?

WP Robot looks like a very powerful plugin, but one which could be used for all sorts of spammy websites. Just wondering what the general community opinion is of these plugins? Are they useful or damaging to a website?


Setting WP Admin passwords to expire

I'm aware it's not a feature of Wordpress, but I was wondering if there was a way or a plug-in (haven't found one from searching) that allows me to force a user to change their password after a defined number of days.


List Child Categorie and hide the parent

Greetings! I'm trying to list child categories in a sidebar, but also hide the parent cat. I'm using this at the moment:               <?php wp_list_categories('orderby=id&show_count=0&use_desc_for_title=0&child_of=5'); ?>      This has a unfortunate effect of displaying 'Categories' above the list. Is there any way to get rid of this? Thanks


How to change sidebar per page?

I am new to theming with wordpress. I have a theme layout with one sidebar at the right side of the website. Now on my homepage and one other page i dont want to have the sidebar. On all other pages it needs to stay. How can i do this. Any help would be appreciated. Thanks.


How deactivate the http-api

give it an tipp or solution for deactivate the method request() in class WP_Http_Streams? I use WordPress also on offline-servers and have wp_debug true for development and tests. But i have many warnings from functions to use the http-class; as example the functions to read the feeds in dashboard. Current i have deactivate all hooks for update themes, plugins, core and the crons; see my small plugin for this: https://github.com/bueltge/WP-Offline Thanks for a reply


HTTPS on dev server issues

I copied a live woocommerce site back to the dev server. The live site uses https. So when I tried accessing it on the dev server, it redirected me to the live site. I figured the issue was the .htaccess file. I tried editing it, but the file is encrypted. So I just removed it all together. That stopped the redirecting, and I was able to access the front-end of the dev site. However when I try to access the wp-admin or wp-login.php I get a 404. I also noticed that the broswer changed from http to https. So there's something still trying to make the website run under https. What I've tried:   1. I deactivated woocommerce plugin (by renaming it) but that didn't help.   2. I also searched in the database for instances of https:// but I could not find any that related to the website.   3. I also found and removed a cert.html file in the root which I think it's related to the https certification, but I still can't access the backend.   4. And last, I tried to add a new .htaccess file with the basic wordpress permalinks in it, but that just gave 500 server errors. Can anyone give some pointers where to look? Or what could be causing the browser to use https, instead of http.


Possible to display posts containing a short code ?

i have some posts with a certain shortcode in them. unfortunately these posts are in different categories and contain different tags so i am not able to query them. is it possible that i run a query which will display all posts containing this shortcode [fileurl=xx] where xx is a certain id (number). Help is appreciated . cheers


What is the best way to load the WP environment in a subdomain of my multisite Wordpress install?

I have a subfolder install of WP multisite, let's say at "domain.com". I now need to load the WP environment in subdomains of domain.com, say "sub1.domain.com", "sub2.domain.com", ... "subN.domain.com". Note that these subdomains do not correspond to WP blogs. But I do need to have access to the logged in user, the database, etc. I have set up wildcard subdomains to load a php file that will display what I need for any particular subdomain, and I am including "wp-load.php" early in that file. The problem is that near line 99 in "ms-settings.php" it redirects to the main page of the site because $_SERVER[ 'HTTP_HOST'] is the subdomain, not the main site domain. So how can I load the WP environment correctly in a non-blog subdomain? I have a prototype that works, but I'm worried about the side effects of what I'm doing so it would be great if someone who's familiar with the core could weigh in. What I am doing is pre-populating the $current_site and $current_blog globals appropriately before including "wp-load". Then, "ms-settings" doesn't try to create these and doesn't hit the code path that detects the subdomain and redirects to the front page. I can now access member information (e.g. using 'get_userdata') and $wpdb. Does this seem like a reasonable approach?


display span element if in certain post types

On lines 4-6, I've inserted three conditional statements to determine which post type the post is in so I can insert a span which I will use to insert an image. The way I wrote it isn't working. What statement would I need to use? And is there a simpler way to set this up?
             <?php if (have_posts()) : while (have_posts()) : the_post(); ?>             <article class="search-post" id="post-<?php the_ID(); ?>">                 <?php if (is_singular('projects')) {echo'';} ?>                 <?php if (is_singular('videos')) {echo'';} ?>                 <?php if (is_singular('friends')) {echo'';} ?>
<?php the_title(); ?>

                     <?php the_excerpt(); ?>

             <?php endwhile; endif; ?>             <?php my_paginate_links(); ?>
      For categories, I usually use `in_category`. Is there something like an `in_post_type`?


All Posts Linking to Author Posts directly

I want to do "All Posts" hyperlinked to Author-Link so when user clicked All posts then user will be directed to Author's all posts, instead of "All Posts of: Author-Link" I don't want repeatation of name. My site is www.engineeringfailurerecord.com Help please, tell me where to code and what to code. Thanks.


Ajax with OOP doesn't work

I have a small script within theme's `functions.php` file that uses ajax, principle like this:               add_action('admin_head', 'rw_script');     function rw_script() {         echo '         <script type="text/javascript">             // delete image             $(".delete_image").click(function(){                 var data = $(this).attr("rel");                 $.post(                     ajaxurl,                     {action: \'rw_delete_image\', data: data}, function(response){                         alert(response); // debug                     }                 );                      return false;             });         });         </script>';     }     function delete_image() {         if (isset($_POST['attach_id'])) wp_delete_attachment($_POST['attach_id']);             die();     }     add_action('wp_ajax_rw_delete_image', 'delete_image');      It works fine. But when I turned it into OOP, the ajax doens't work:               class RW_Test {         function __construct() {             add_action('admin_head', array(&$this, 'rw_script'));             add_action('wp_ajax_rw_delete_image', array(&$this, 'delete_image'));         }         function rw_script() {             echo '             <script type="text/javascript">                 // delete image                 $(".delete_image").click(function(){                     var data = $(this).attr("rel");                     $.post(                         ajaxurl,                         {action: \'rw_delete_image\', data: data}, function(response){                             alert(response); // debug                         }                     );                          return false;                 });             });             </script>';         }         function delete_image() {             if (isset($_POST['attach_id'])) wp_delete_attachment($_POST['attach_id']);                 die();         }     }      The javascript works fine, i.e when I click on delete links, data is sent properly. But the action for deleting image isn't fired. Do you know how to solve this? Please help me. Thank you.


Pulling current post/page data into header.php

I want to pull some post/page specific data (author name, post ID, publish time, etc) into header.php to be used in meta tags. I am having trouble figuring out the most efficient way to do this. It is my understanding that I will need to create a loop within header.php to pull this data. How can I go about creating a loop for the current page/post if I don't yet know the ID?


wp-login not processing when not localhost

I'm trying to get a site up for a client on IIS7, MySQL. The front-end works fine no matter what and, as long as the siteurl and home parameters are set to "localhost" (either in database or hard-coded), I can log into wp-admin. If I change it to the customers URL, however, I get the wp-login page but when I submit I just get error 404. The front-end still works fine. When I enter invalid login credentials it does not give the "shake" error, it just goes to error 404. I've tried a different theme and disabled plugins.


Retrieve meta_value from add_comment_meta

I have a voting function for comments which needs to display the avatars of the users who voted for a specific comment. I am having trouble getting the user id of the voter ($supporter). All I seem to get is the user ID of the user who made the comment > I need to get the user ID of the user who voted. My function:               function addServiceSupporter($comment_id, $user_id) {         add_comment_meta( $comment_id, 'supporting_user', $user_id, false );     }      So the $user_id is stored under meta_value in the wp_commentmeta table. Before this function I have this the following which seems to have a user_id in it.               /**      * After an ajax call try to add the supporter      */     if (isset($_POST['new_service'])) {         $new_service_supporter = $_POST['new_service'];         try {             addServiceSupporter($new_service_supporter['comment_id'], $new_service_supporter['user_id']);         } catch (Exception $e) {             print_r($e);         }         die;     }      The call:               foreach($supporters as $supporter) {         $supporting_user = get_comment_meta(get_comment_ID(),'supporting_user', true);         $avatar = get_avatar($supporting_user, 24 );              echo $avatar;      }      I also have tried:               $avatar = get_avatar($supporting_user, 24 );      But that of course gives the avatar of the user currently active on the page. How do I get the $user_id aka meta_value of this comment_meta? The result should be: Comment votes (or likes if you want) by users to the comments of others. Then showing the avatars of the people who voted. My problem = how to get the user id of the **voters** (not the comment author, not the current user) so I can show the right avatar?


First post of each category

I'm trying to create a simple loop, that gets the latest post of 3 selected categories. I've searched for something similar to learn from, but most are overly complex. At the moment, I have:                   <?php               // WP_Query arguments     $args = array (         'category_name'          => array('lifestyle', 'fashion', 'beauty')     );          // The Query     $query = new WP_Query( $args[0] );          // The Loop     if ( $query->have_posts() ) {         while ( $query->have_posts() ) {             $query->the_post();             // do something         }     } else {         // no posts found     }          // Restore original Post Data     wp_reset_postdata();          ?>      I assume I'd need a `foreach` loop, but I'm unsure how to implement it in this scenario, and for just the latest of each post? Any help would be great.


How to use author id in post permalink

Currently, Wordpress supports author name in the post permalink by using %author%. Is it possible to add the author id to the permalink? For example, changing this: http://www.site.com/john/my-first-post to this: http://www.site.com/1/my-first-post Where '1' is the id of the author 'john'.


Redirecting to a post based on a GET parameter and a custom field

I'm trying to redirect to a specific post based on a GET parameter. The value of the GET parameter is the value of a specific custom field. For example: http://somedomain.com/wordpress/?fid=xyzzy I have this working when a post matches. But, it's not working properly when there is no match.                   add_filter('query_vars', 'fid_query_vars');     function fid_query_vars($vars) {         // add fid to the valid list of variables         $new_vars = array('fid');         $vars = $new_vars + $vars;         return $vars;     }      and               add_action('parse_request', 'fid_parse_request');     function fid_parse_request($wp) {         // only process requests with "fid"         if (array_key_exists('fid', $wp->query_vars) && $wp->query_vars['fid'] != '') {             $args = array('post_type' => 'faculty_profile', 'meta_key' => 'wid', 'meta_value' => $wp->query_vars['fid'] , 'numberposts' => 1);             $redirect_to_post = get_posts($args);     if (!empty($redirect_to_post ) ) {             foreach ($redirect_to_post as $p) {                 $link = get_permalink($p->ID);                             wp_redirect( $link , 301 );                 exit;             }                  }     else {         $url = 'http://cnn.com/';         wp_redirect( $url , 404 );             }              }      I'd expect this to redirect to cnn.com with a 404 error, if there is no match. But, instead, I get the blog's homepage, with a status of 200. Any ideas? thanks.


What's wrong with my $wpdb prepare

I can't get my head around this. I get this error: Parse error: syntax error, unexpected '"' in 224. The line is this between foreach $html:               $html = '';        foreach ( $recent_across_network as $post ) {           $html .= 'blog_id, $post->ID ) . '">' . $post->post_title . '';        }        $html .= '';      Also I get error on $wpdb-prepare:               $site_list = $wpdb->get_results( $wpdb->prepare('SELECT * FROM wp_blogs ORDER BY blog_id') );      Prepare I believe would need to have to arguments? So I tried this:               $site_list = $wpdb->get_results( $wpdb->prepare('SELECT * FROM wp_blogs ORDER BY blog_id = %d', $wpdb->blogid) );      But this doesn't work :s EDIT: The code is based on the function "wp_recent_across_network" on this article: http://www.smashingmagazine.com/2011/11/17/wordpress-multisite- practical-functions-methods/


Seperating Custom Post Search Results

I have a site that has a few custom post types. When a customer searches it shows a combination of all the different posts. I'd like to segment the two on the same page resulting in something that looks like the example below. Any help would be appreciated. > **Showing results for: really cool search**   >  **Video Management**   >  from a central location. Radius offers interactive map capability, and > multiple monitor support. Designed for a multiple monitor environmen... > http://openeye.net/products/software/video-management   >   > > > * * * > > **Knowledge Base Entries:**   >  **Repairing your device**   >  from a central location. Radius offers interactive map capability, and > multiple monitor support. Designed for a multiple monitor environmen... > http://openeye.net/?faq=video-management-repair Example of my loop from loop-search.php               <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
     <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
             <?php the_post_thumbnail; ?>             <?php if (function_exists('relevanssi_the_excerpt')) { relevanssi_the_excerpt(); }; ?>             <a href="<?php the_permalink(); ?>"><?php the_permalink(); ?>
     <?php else : ?>
             <?php the_post_thumbnail; ?>             <?php the_content( __( 'Continue reading', 'twentyten' ) ); ?>             <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentyten' ), 'after' => '
' ) ); ?>             <a href="<?php the_permalink(); ?>"><?php the_permalink(); ?>
     <?php endif; ?>      my changes to search.php               <?php if ( have_posts() ) : $posts_per_page = 20; ?>         <?php printf( __( 'Showing results for: %s', 'twentyten' ), '' . get_search_query() . '' ); ?>         <?php         /* Run the loop for the search to output the results.          * If you want to overload this in a child theme then include a file          * called loop-search.php and that will be used instead.          */          get_template_part( 'loop', 'search' );         ?>     <?php else : ?>

<?php _e( 'Nothing Found', 'twentyten' ); ?>

         <?php if (function_exists('relevanssi_didyoumean')) {             relevanssi_didyoumean(get_search_query(), "
Sorry, but nothing matched your search criteria. Please try again with some different keywords. Or you can also try ", "
", 5);         }?>                 <?php related_searches(); ?>

     <?php endif; ?>


Is fopen() forbidden in WP?

I badly need to create an .XML file inside my theme every time user comes to my site. But I can't. This code in header:                   <?php $ourFileName = "testFile.txt";               $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");               fclose($ourFileHandle); ?>      Just does nothing. It doesn't display "can't open file", but it doesn't create the file as well. I'm testing it at my /localhost machine and this code works perfectly everywhere there (so file permissions are alright), but not in Wordpress. Why is it happening? :(


Sort posts by number of matched terms

I have form where I list all terms associated with posts as check boxes, user should pick few of them, hit search and get all posts that match all chosen terms. It works great when there are posts that match search criteria. My question is how do I display posts that have just few of matched terms and how to sort results based on number of matches. Any help is much appreciated. Thanx. So this is the form inside search page:               <form action="<?php bloginfo('template_url') ?>/build_search.php" method="post" accept-charset="utf-8">     <?php $terms = get_terms( 'my_tax' );     $checkboxes = '';     foreach($terms as $term) :         $checkboxes .='<input type="checkbox" name="term[]" value="'.$term -> slug.'" id="term-'.$term->term_id.'" /><label for="term-'.$term->term_id.'">'.$term->name.'</label>';     endforeach;     print $checkboxes;     ?>     <input id="submit" type="submit" value="Search">      This is what I put in build_search.php file               if (isset($_POST["term"])){ $terms_array = array(); $terms_array = $_POST["term"]; foreach ($terms_array as $key => $value) { $string .= $value.'+'; } $terms_string = substr($string, 0, -1); $term = $terms_string; } else { $term = ""; } $url = header("Location:/?my_tax=$term");      after that I have only taxonomy-my_tax.php with regular loop in it.


attach a PDF to an archives template?

I have a custom post type called "media" and I would like to be able to upload a single pdf called, "presskit" for the archive page that contains ALL of the media custom posts. I only need to upload / associate a single PDF with the archive...it would be nice to make this is a submenu page, i.e. something like:               add_action('admin_menu', 'register_media_submenu_page');               function register_media_submenu_page() {             add_submenu_page( 'edit.php?post_type=media', 'Press Kit', 'Press Kit', 'manage_options', 'press_kit_file', press_kit );         }              function press_kit() {             echo '
';             echo '
Upload a press kit
';                  echo '
';         }      However, if this is too complicated I think the next best option is if the client could replace the pdf in the media library with a new pdf whenever they wanted to (keeping the same ID?)


How to create a Wordpress plugin for another wordpress plugin?

I always do changes on the Wordpress plugins for clients. But these changes are always in danger to be lost if the plugin is updated. Is there is a way to make a plugin for another plugin in Wordpress? Is there is a way to preserve the changes or re-apply it after each plugin update.


How to use other shortcodes inside Contact form 7- forms?

I noticed that any shortcode that is not part of the contact form 7 builtin shortcodes dont work. For example: I am trying to use an accordion shortcode between form elements in contact form 7. But the code dont work. How to solve this without editing contact form 7 core files?


Selecting which pages to display custom post type on using checkbox

I have a custom post type called Testimonies. What I'm trying to do is allow a user to create a new Testimony and then select from a list of checkboxes which page(s) on the site he wants this testimony to display on. I have managed to create the checkboxes to list all the site pages and code is below:               add_action("admin_init", "admin_init3");          function admin_init3(){      add_meta_box("credits_meta", "Choose on which pages to display",     "myplugin_inner_custom_box", "testimonies", "normal", "low");     }          function myplugin_inner_custom_box( $post ) {     // we store data as an array, we need to unserialize it     $checkfield = maybe_unserialize( get_post_meta($post->ID, "checkfield", true) );          // Nonce to verify intention later     wp_nonce_field( 'save_quote_meta', 'custom_nonce' );           $pages = get_pages();      foreach ( $pages as $page ) { ?>         <input id="page_<?php echo $page->ID; ?>" type="checkbox" name="checkfield[]" value="<?php echo $page->ID; ?>" <?php if ( in_array($page->ID, (array) $checkfield) ) { ?> checked <?php } ?>/> <label for="page_<?php echo $page->ID; ?>"><?php echo $page->post_title; ?>
     <?php      }      }     //save the meta box action     add_action( 'save_post', 'myplugin_meta_save', 10, 2 );          //save the meta box     function myplugin_meta_save($post_id, $post)     {        if ( isset($_POST['checkfield']) ) { // if we get new data              update_post_meta($post_id, "checkfield", $_POST['checkfield'] );          }     }      However, I'm having difficulty with the next step. My idea is to put the checkbox values in a variable, then check whether the current page id matches one of these values. If it does, I'll display the custom post. This is all a bit hazy though, and I'm not sure if I'm going about it the right way. Currently, I'm struggling to pass the checkbox values into a variable and echo these out. I have the below code but it's just echoing array, array, array, array.               <?php  $checkboxes=get_post_meta($post->ID, "checklist", false);     if ($checkboxes) {     foreach($checkboxes as $checkbox) {     echo  $checkbox;     }     } ?>      Any help would be much appreciated. Many thanks.


List all the categories with or without post

I have a simple question! I'm showing the WP categories with this code :               wp_dropdown_categories(         array (             'orderby' => 'name',             // ID of the already selected category:             'selected' => 4,             // If no category is selected:             'show_option_none' => 'Choose one'         )     );      Problem is that how can i list every category that have post or not. specially the code just shows the categories that have post , but i want to show **ALL** categories . How can i change that code ? ALso , it's important to get the HTML output like this :               <select name='cat' id='cat' class='postform' >         <option value='-1'>Choose one</option>         <option class="level-0" value="4" selected="selected">Animals</option>         <option class="level-0" value="6">Hyperbolica</option>         <option class="level-0" value="5">Nonsense</option>         <option class="level-0" value="1">Uncategorized</option>     </select>


Custom Post Type single and archive pages are not working

In an attempt to use the custom post type, after having registered a brand new CPT I have duplicated both the single and the archive pages appending the "-posttype" bit as specified in the register_post_type function. However, if I try to load a single post or the archive page, both the pages are not loaded. I can't understand where the problem is. Here is the code I use to register my Custom Post Type               $labels = array(         'name' => _x('Facebook', 'post type general name'),         'singular_name' => _x('Facebook', 'post type singular name'),         'all_items' => __( 'All posts' ),         'add_new' => _x('Add new post', 'Facebook'),         'add_new_item' => __("Add new Facebook post"),         'edit_item' => __("Edit Facebook post"),         'new_item' => __("New Facebook post"),         'view_item' => __("View Facebook posts"),         'search_items' => __("Search in Facebook posts"),         'not_found' =>  __('No facebook posts found'),         'not_found_in_trash' => __('No facebook posts found in trash'),         'parent_item_colon' => ''       );     //$post_supports = array('title','editor','comments','thumbnail','excerpt');     $post_supports = array('title','editor','thumbnail');     $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         //'menu_icon' => get_stylesheet_directory_uri() . '/images/slider.png',         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         'supports' => $post_supports       );      Any suggestions to why it is not working?


Moving to Wordpress Premium versus a hosting provider

My blog is now over a year old, and I've been considering moving my blog from Wordpress.com for a while. My main reason for this is that I now how enough visitors that I believe I'd rather take the advertising revenue myself. As I understand it, I can move this to a separate hosting provider, or simply upgrade to the WordPress "Premium" service. I've seen a few questions regarding similar topics; but my questions are (I believe) slightly more specific. First, these are some assumptions that I've made from the research I've done so far (are they all correct?):   1. WordPress Premium protects any Google ranking I may have.   2. I can add my own advertising plug-ins to Wordpress, but am restricted in their type (http://www.wpbeginner.com/plugins/what-are-the-best-ad-management-plugins-and-solutions-for-wordpress/).   3. That a Wordpress hosted site will require no more maintenance that I currently do on my Wordpress.com site; also, that it will require no work from me to upgrade.   4. I will be able to maintain and edit my blog in exactly the same way as I currently do.   5. That I am restricted to using my current domain name. The things I don't know:   1. Do I have enough visitors to cover the cost of doing this (currently 500/month)?   2. What I am restricted from doing if I do go with Wordpress.org?   3. If I make the decision to go one way or the other, how difficult is that decision to reverse?


How does routing on wordpress work?

How does the core wp routing works? I am having a hard time understanding... In MVC, your url looks like mycontroller/myaction that maps to MyController->myaction() In drupal, it's index.php?q=mycustomerpath/hello which can be mapped to any function you like that returns a content that is "themed" into your theme layout. But in wp, i have no clue how things are done... it's ?p=1 then ?product=1 ... I have searched for documentation of the routing flow but can't find any (google just returns articles on custom routes).. i want to understand the fundamentals of the core routing first..


How to get raw unwritten querystring

Without permalink enabled, the urls look like ?p=1 and when permalink is activated it's the postname that appears... question .. isn't this a rewritten version of ?p=1 .. When I use $_GET['p'], there is nothing in there... is that normal?


Migrating a taxonomy's tags to the native category

So, I've inherited a website that uses a custom taxonomy for no real reason, leaving the native 'category' taxonomy unused. As the site is undergoing a redesign, I'm going to want to use some new plugins and a new theme. Many of which, rely on the native 'categories' for various things. I'd like to migrate the tags in the existing custom taxonomy to the native, and I wonder if anyone can suggest how? I'm aware it'll need a little SQL surgery. Consider that the custom taxonomy is called `pp_eventcategory` and applies to all the custom post types in the system including the native post type. Thanks in advance!