Using jquery and javascript in Wordpress

After trying for many many days without any improvement, I think I have no other choice but to ask for your help. I have to admit that I don't know much about coding, but I've tried various tutorials, but just can't get to work what I want. The problem is that I want sidebar tabs using jquery tools as well as creating my own slider (no image slider, but a content slider). Although I did just as the tutorials say, the text just is displayed normally. No effect, no slide, no tabs, nothing. I uploaded the .js files, put the "script" info into the header.php, used the specific style.css, also put that into the header.php and then I tried to put some "divs" to create some content. For the tabs I used this tutorial. It's in German, but you can clearly see the steps where it tells you what to paste where. Is there anything missing? I put the "divs" into my home.php. Was that the mistake? Do I have to put anything in my function.php as well? I'm missing something, I'm sure of it, but I don't know what it is. I really hope that somebody can help me out here and give me a short "step-by-step" instruction or something. My website for reference. Sorry for asking a stupid question, but I can't seem to sovle this by myself. Thanks a lot :)


Blog.php or how to display recent posts?

I created a home.php which doesn't display the recent posts in the standard- blog-style. Just have a look at my website to see what I mean. I want to create a link that leads to something like "http://..../blog" where the recent posts are displayed "normally". I know how to do that, but what I don't know is how to create that new "link" that leads to ".../blog". Is it possible to create a "blog.php" just like a "home.php" where the recent posts will be displayed? But even if I create a "blog.php" I will get a 404 error message when clicking on "http://.../blog". I hope you get what I mean and can help me out here a bit. Do I have to modify the htaccess thingie for that or what? :/ Thanks a lot in advance :)


running arbitrary php files

I have a hostgator wordpress site. My friend wrote two small php scripts to help us with a medial task we do a lot in our work, but he is currently hosting this script on his server; I want to host it on our official server. Is there a way to straight-up ftp this folder containing   1. two php files    2. a larger js file   3. a subfolder of multiple images directly to my site and have it work? Every time I try to directly access the php file, wordpress automatically redirects to home (http://example.com). This is probably a very good security measure, but is there some way to whitelist these scripts to run without modifying them at all?


Geo Targeting articles on a WordPress site

I want to display the articles on my WordPress site depending on the **location of the User**. I am looking for a **country based** classification. Is there any already existing plugin that can help me with this? I searched on the **WP site** but the **plugins** available there just **hide a small block of the article**. What I am looking for is a way to **hide the article completely from the user**.ie in the normal operation the post isn't visible to the user.


Is that the query_posts() the real criminal here?

         <?php         // The Query         query_posts( $args );         // The Loop         if(have_posts()) :         while ( have_posts() ) : the_post();         ?>

<?php the_time('d') ?>

<?php the_time('M') ?>

<?php the_time('Y') ?>

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

             By: <?php the_author_posts_link(); ?>             <?php the_tags(); ?>

<?php the_content(); ?>

                 Read more                 Comment

         <?php             endwhile;             endif;             // Reset Query             wp_reset_query();         ?>
<?php next_posts_link( __( '← Older posts') ); ?>

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

      The whole code works fine. But the last two line ain't working, I mean the next posts and previous posts button ain't appeared.
<?php next_posts_link( __( '← Older posts') ); ?>

<?php previous_posts_link( __( 'Newer posts →') ); ?>
      Why is this happening? Is it for `query_posts( $args )` function what I used? What should I do now? I just want to show that two paginate link. I believe the solution should be very simple.


How to get taxonomy term of the current page and populate queries in the template

I've been stumbling around trying to figure out how to get a specific taxonomy term of the current page so that I can subsequently populate queries on the page for other post types that share the same term. Basically:   * Page 1 has taxonomy term - education policy   * page.php has four parts:      1. standard loop that outputs the page, but then has three subsequent queries     2. loop for events that have taxonomy term - education policy     3. loop for reports that have taxonomy term - education policy     4. loop for people that have taxonomy term - education policy I did page specific templates where I could just hardcode the term into the extra loops, but I need to figure out how to do it dynamically (what was originally supposed to be four or five pages is now forty or fifty). I've found a few similar questions, but none that I could really find my way through implementing. Get current page's taxonomy which was a little confusing to follow in terms of what was actually being asked. Get the term id belonging to custom taxonomy on a custom single-post-type.php template page. I hope this makes sense and many thanks.


Should I use Transients with W3 Total Cache APC Caching?

Should I use Transients in my queries like this?               <?php      if ( ! $my_paged = absint( get_query_var( 'paged' ) ) )     $my_paged = 1;          if ( ! $my_query = get_transient( "567recent_$my_paged" ) ) {         $my_query = new WP_Query ( "cat=2526&posts_per_page=1&paged=$my_paged" );         set_transient( "567recent_$my_paged", $my_query, 60 * 60 );     }     while ($my_query->have_posts()) : $my_query->the_post(); ?>       If so, could I also use W3 Total Cache with database caching and with APC enabled?


How to Call pages from a Options Panel

Need a little bit of help here. I am adding this dropdown to my options panel. However, when I call my option in my template. It does not display Here is the function for the dropdown:                   function page_test_setting(){         $options = get_option('meta_options');         $pages = get_pages();          echo '<select name="meta_options[page_test]">';          echo "<option value='{$options['page_test']}'>";         echo esc_attr( __( 'Select page' ) );         echo "</option>";          foreach ( $pages as $page ) {         $option = '<option value="' . get_page_link( $page->ID ) . '">';         $option .= $page->post_title;         $option .= '</option>';         echo $option;         echo '</select>';         }         }      The options field:                   add_settings_field('page_test', 'PAGE OUTPUT', 'page_test_setting', __FILE__, 'meta_section');      And here is how I am calling it in my theme:                  <?php echo get_permalink($options['page_test']); ?>      As you can probably guess is that I want the CALL to pull the page title and link to the appropiate page. Should I be using page titles instead for the call or what?


How to handle dates, trying to calculate time since a post

I am trying to create a "time since" post display so when someone views a post they will see "posted about a week ago" instead of the date. I've tried a few things but to no avail and I think it is because I found out that my default timezone is GMT (using date_default_timezone_get()) and my date.timezone (using ini_get('date.timezone')) is America/Denver. My actual timezone is America/New York (or EDT). I need to find the current logged in user's timezone (not sure how to do this - maybe a setting in their profile), and then show the time since the post was published. I am sure I need to take the time stamp from the DB (which I believe is all UTC) use strtotime and then figure out what the current logged in user's timezone is and create the "time since" message. I do have a method that calculates the time since a post but it has incorrect times based on the timezone info I found out. Here's the code I am using:               public function time_since($stored_time){          $time_elapsed = time() - strtotime($stored_time);          $tokens = array (         31536000 => 'year',         2592000 => 'month',         604800 => 'week',         86400 => 'day',         3600 => 'hour',         60 => 'minute',         1 => 'second'     );          foreach ($tokens as $unit => $text) {         if ($time_elapsed < $unit) continue;              $numberOfUnits = floor($time_elapsed / $unit);              return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');     }          }//end time_since      If anyone can push me in the right direction I would greatly appreciate it.


Hooks are not being removed in child theme

I have a hook file:               function load_admin_package(){         do_action('load_admin_package');     }          /*      * -----------------------------------      * Define hooks bellow      * -----------------------------------      */          function load_admin(){         $package = new AisisCore_Loader_Package();         $package->load_package('AdminPanel', CORETHEME);     }               /*      * -----------------------------------      * Asign hooks bellow      * -----------------------------------      */          add_action('load_admin_package', 'load_admin');      Very simple, very straight forward. This resides in the parent theme. this file is then required into the functions.php file. In the child functions.php I do:               function remove_hooks(){         remove_action('load_admin_package', 'load_admin');     }          add_action('after_theme_setup', 'remove_hooks');      `load_admin` essentially loads the admin options page for the parent theme. However in the child theme I am removing it so it doesn't load. Problem? The `remove_action()` returns `true`, yet in the child theme admin I still have access to the admin options which should not exist... What's going on?


How to implement a JavaScript and CSS file for my WordPress homepage?

I saw this Javascript feature tour file today, and was curious how I would go about implementing it on the homepage of a WordPress site. Ideally, I'd like to add it so it only shows up if and only if a user is on the homepage and have never been there before. I'm new to this though, and I'm not sure how to implement it. I found this previous question but I'm not sure how I would use it in this context. How would I use it on the homepage, and what files would I have to edit?


Check whether user can delete a given post

I have run into this problem where the following piece of code always returns true for any `post ID` supplied to it. `current_user_can('delete_posts', $post_id);` Normally, the above code should return false when the user is not the author of the post or does not have the capability to delete others post. However, it still returns true for any post ID. The user has been assigned a custom role, as defined below.               $standard_role_capabilities = array ('read'                 => true,                                         'delete_posts'              => true,                                         'edit_posts'                => true,                                         'delete_published_posts'    => true,                                         'publish_posts'             => true,                                         'edit_published_posts'      => true,                                         'comment'                   => true                                 );          add_role('standard', 'Standard', $standard_role_capabilities);      Any reasons for this not working?


What is the server IP comment hack

this is my first question about wordpress, because i don't know much about wordpress. i have installed AntiSpam bee in my wordpress blog. And i got comments which marked as spam with the reason `Server IP`, that i got first time. But i got shocked when i see that the comment don't had any **Email Address** . but as i know that without any user name and email no one can send any comment to any post. Please someone help me to telling that what exactly happen or what i did wrong.


Show comment number per author per day

Is this possible? I've never seen it used, but I need it... I want to show for each author (if they are logged in) on their own profile page, the amount of comments they have posted today. If the day passes by, than the counter has to be 0 and the comment counter has to start again.


get_posts inside cron

**Edited to rewrite my question** I'll try to be as clear as possible, as I need to get this resolved quickly. I disabled WordPress' cron, and added a real cron job on my server to call wp- cron.php every day. The function i'm calling is not working, however. Code execution seems to stop at `get_posts`, same thing if I try using the `WP_Query` class. No error message, and any code after just doesn't execute. When I don't add `numberposts`, it does however give me 5 posts, which is the default value for numberposts. Sample :                $posts = get_posts( array(          'post_type'    => 'post-type',          'numberposts' => -1,          'tax_query'    => array(                array(                     'taxonomy'  =>  'tax',                     'field'     =>  'slug',                     'terms' =>  'term-slug'                )           )      ));      **More Info**   * The post type and the taxonomy are created in my plugin file on the `init` hook.   * The function works fine when being executed from a PHP page, like my plugin's setting page.   * I tried hooking my function in `wp_ajax_nopriv`, and calling `admin-ajax.php?action=the-action` from my server cron, but with the exact same result.   * I haven't tried keeping WP's cron, because the function takes a long time to execute, and you need a visitor launch it by visiting the site. Please reply with any questions / code request if more information is required. **Edit - My loop**                set_time_limit( 1800 );           $stores = get_option( 'stores' );           foreach( $stores as $store_name => $store )      {                $ctime = 0;           $filename = '';           $xml_path = '';                $dir = dir( $store );                while( false !== ( $entry = $dir->read() ) )           {                     $info = pathinfo( $entry );                     $ext = strtolower( $info['extension'] );                     $filepath = "{$store}/{$entry}";                     if( is_file( $filepath ) && $ext == 'xml' && filectime( $filepath ) > $ctime )                {                          $ctime = filectime( $filepath );                          $filename = $entry;                          $xml_path = $filepath;                     }                }                if( file_exists( $xml_path ) && is_file( $xml_path ) )           {                     //                //Delete products first                //                $posts = get_posts( array(                     'post_type' => 'produit-xml',                     'posts_per_page' => -1,                     'tax_query' => array(                          array(                               'taxonomy'    =>  'succursale',                               'field'       =>  'slug',                               'terms'       =>  $store_name                          )                     )                ));                     foreach( $posts as $post )                {                          $image = get_post_meta( $post->ID, 'nom_photo', true );                          if( $image )                     {                               $fullpath = ABSPATH . get_option( $store_name . '-image-path' );                               $fullpath .= '/resized/' . $image;                               @unlink( $fullpath );                          }                          wp_delete_post( $post->ID, true );                     }                     //                //Insert operations follow....                //                }           }


Specific coditional usage

I have some trouble making work a conditional inside a Function. check this out: I'm using this function:               function get_spec_1(){       $desc1 = get_post_meta( get_the_ID(), 'eco_mb_tp_1', true!= ""  );            if(!empty ($desc1)){         foreach ( $desc1 as $d1 ){           $code = "

General

$d1

           ";           echo $code;         }            }     }      But this function causes this:

Generales

$metabox_cloned_value_1

Generales

$metabox_cloned_value_2

      But what I'm trying to achieve is this:

Generales

$metabox_cloned_value_1

$metabox_cloned_value_2

      And if there is no existing data. then the entire `<dl>` will not show. How can I obtain this result? thanks


Why are BuddyPress user avatars not displaying properly?

I have a BuddyPress 1.6.x installation on WordPress 3.4.2. User avatars are not displaying in the following situations. On pages like: `www.domain.com/members/USERNAME/profile/edit/group/1/` Here is the outputted code for the bigger user avatar, when they're editing their profile.                     Or on the sidebar, where it has a user's avatar, along with their username and a logout button. Here is the outputted code for the sidebar avatar.                     However, we are using some code to alter the mystery man avatar (If no avatar exists, it defaults to this avatar) Here is our mystery man avatar filtration code.               function myavatar_add_default_avatar($url){         return get_stylesheet_directory_uri() .'/images/c2c_avatar_2.jpg';     }     add_filter('bp_core_mysteryman_src', 'myavatar_add_default_avatar');      If I try copy/pasting the generated Image SRC into my browser, it returns "Sorry, the parameters you provided were not valid" If I copy just the relative domain URL from the outputted image SRC (Example: `www.domain.com/wp-content/themes/bp-dusk/images/c2c_avatar_2.jpg`) It loads the image correctly in my browser. I'm thinking this issue has something to do with BuddyPress and the Gravatar service. If there is no user avatar set, shouldn't it be displaying the mystery man avatar, and not looking on the Gravatar service? What are some of the actions or filters I should be checking? Can I override a hook so that I can force this to work?


Bring up the media uploader on click

In my theme's options page. I want to have a textfield where a user can enter a http path to an image. and have a button beside it which brings up the media uploader (library) where a user can upload an image and insert its path directly into the text field. Any ideas on how I can do this ?


nextgen gallery - filenames' character encoding issue

I am building a website using wordpress and i am planning to use Nextgen Gallery in order to show some pictures on a page. My issue is, when i upload an image which has a filename containing greek characters, it doesn't show properly. Actually it doesn't show at all. The filename on the server is saved as `%ce%bf%cf%81%cf%84%ce%b1%ce%bd%cf%83%ce%b9%ce%b1` The img src on the page appears to be ok, as `%ce%bf%cf%81%cf%84%ce%b1%ce%bd%cf%83%ce%b9%ce%b1.jpg` **But** the image doesn't show at all (is broken) and when i click "Open in a new tab", it returns the path of the image, but with the greek characters this time, like `http://localhost/wordpress/wp-content/gallery/test/ορτανσια.jpg` How should i fix this issue? Kind regards.


Can I get at WordPress code from inside a Selenium test?

I'm writing unit tests using PHPUnit and WP_UnitTestCase, and using Selenium for front-end testing. My Selenium test classes merrily click around my pages without trouble. What would be truly useful, though, would be if they could also execute code in the context of WordPress. So for example, I could test visiting a user's profile page, then change the path to the page and test that, too. As a stopgap I've made a very crude adapter for wp-cli, which I use inside my test. Obviously this is quite clunky. Is there any way I can get at all the goodness of a WP_UnitTestCase in the context of a Selenium test?


Display posts from Custom Post Type in category page on front-end

I created my Custom Post Type (bizdirectory), created a new post (Test Business) and created a new category (Business Directory). But if I add the Business Directory category (slug = business) to my Primary Navigation, the link shows, it registers as the category, but it says "nothing found". If I search my site (using the search bar on the front page) for Test Business it finds it - the URL it shows is - http://www.domain.com/dev/?bizdirectory=test-business \- my code for functions.php is below:               // Load Custom Post Type      function add_bizdirectory() {         $labels = array(              'name' => __( 'Businesses', 'text_domain' ),             'singular_name' => __( 'Business', 'text_domain' ),             'add_new' => __( 'Add New Business', '${4:Name}', 'text_domain' ),             'add_new_item' => __( 'Add New Business', 'text_domain}' ),             'edit_item' => __( 'Edit Business', 'text_domain' ),             'new_item' => __( 'New Business', 'text_domain' ),             'view_item' => __( 'View Business', 'text_domain' ),             'search_items' => __( 'Search Businesses', 'text_domain' ),             'not_found' => __( 'No Businesses found', 'text_domain' ),             'not_found_in_trash' => __( 'No Businesses found in Trash', 'text_domain' ),             'parent_item_colon' => __( 'Parent Business:', 'text_domain' ),             'menu_name' => __( 'Business Directory', 'text_domain' ),         );         $args = array(              'labels' => $labels,             'hierarchical' => true,             'description' => 'description',             'taxonomies' => array( 'category' ),             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'menu_position' => 5,             'show_in_nav_menus' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'has_archive' => true,             'query_var' => true,             'can_export' => true,             'rewrite' => true,             'capability_type' => 'post',              'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'custom-fields', 'revisions', 'post-formats' ),         );         register_post_type( 'bizdirectory', $args );     }     add_action( 'init', 'add_bizdirectory' );     // End      I have tried all of the rewrite rules options apart from the one where I manually delete the rewrite rules from wp_options - it didn't appear in wp_options. I appreciate any help or advice that you could give me :)


Strange behaviour with add_{$meta_type}_metadata | add_post_metadata filter

I'm unsuccesfully trying to use the add_{$meta_type}_metadata. This filter is called inside add_metadata function (wp-includes/meta.php:31 in Wordpress 3.4.2). In particular I wanna hook "add_post_metadata" filter among others. My target is to execute custom code to add,update,get custom meta, so I don't break wordpress way to do things. body of function add_metadata                    function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique =    false) {     [...]     $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key,          $meta_value, $unique );     if ( null !== $check )         return $check;           [...]      $ckeck after filter execution should contain the value I return from the function "filter_negozi_add_metadata" This is the code I use (inside my plugin):                add_action('init', array('my_plugin','init'));     class my_plugin     {      const META_KEY='my_plugin_key';     public static function init()     {         new self();     }          public function __construct()     {         $this->add_filters();     }          protected function add_filters()     {            ///function below works     add_filter('get_post_metadata',array(&$this,'filter_negozi_get_metadata'),10,4);     //the one below instead doesn't work      $ret=add_filter('add_post_metadata',array(&$this,'filter_negozi_add_metadata'),10,5);     //$ret contains true so add_filter works correctly     }     public function filter_negozi_add_metadata($foo=null,$object_id, $object_id, $meta_key, $meta_value, $unique )     {         if($meta_key==self::META_KEY)         {     $ret='foo';         }         return $ret;     }          }      The really strange fact is that global $wp_filter doesn't contain my function even if $ret is true. Thanks.


A question of etiquette when forking a plugin?

I am updating (forking) a WP plugin over on Github - with some functionality on the plugins roadmap - so I know this feature is desired by the developer and will probably be included in their next update through WP plugins. When updating the plugin with my additions, do I also update the readme.txt file etc and add my username as a contributor (I guess this should be the case)? Or should I contact them and ask to be put on? It is my expectation that if I had contributed then I would be credited here but not sure on the right approach! Thanks for any advice ;)


show Visual form builder in the front end

Iam anew in wordpress . i used this plugin http://wordpress.org/plugins/visual-form-builder/ to build custom pages then i tried to build a custom page called formbuilder.php to use it in the front end page .And in this page i tried to render the form builder creation page but nothing renderd .                               <?php // require 'wp-includes/formatting.php'; ?>                          <?php require 'wp-admin/includes/dashboard.php'; ?>                     <?php require 'wp-admin/includes/post.php'; ?>                              <?php require_once('wp-admin/includes/class-wp-list-table.php' ); ?>                     <?php require 'wp-admin/includes/template.php'; ?>                     <?php require 'wp-admin/includes/screen.php'; ?>                     <?php require 'wp-admin/includes/plugin.php'; ?>                     <?php $visual_form_builder->css() ?>                     <?php $visual_form_builder->scripts() ?>                     <?php $visual_form_builder->includes() ?>                     <?php // $visual_form_builder->add_admin(); ?>                     <?php // $visual_form_builder->dashboard_widget(); ?>                     <?php // $visual_form_builder->dashboard_widget_control(); ?>                     <?php // $visual_form_builder->meta_box_form_items(); ?>                     <?php // $visual_form_builder->ajax_media_button(); ?>                     <?php // $visual_form_builder->meta_box_display_forms(); ?>                     <?php // $visual_form_builder->add_dashboard_widget()?>                     <?php // $visual_form_builder->add_meta_boxes(); ?>                     <?php // $visual_form_builder->admin_add_new(); ?>      Could you please helping me with ana easy way to render the admin page in the custom page template .


how to avoid the character conversion of WordPress pages?

I am trying to use the WordPress pages but WordPress is overwriting certain characters. the '>' character is turned into '& gt;' why is WordPress changing these characters? is it possible to turn character conversion off for certain pages?


Shrinktheweb plugin problem

I've added the following code to a page:               <?php echo do_shortcode("[thumb]'".bp_profile_field_data('field=2')."'[/thumb]"); ?>      This pulls a url from my database, and it should, according to my plans, provide the Shrinktheweb plugin with the url for the shortcode, and generate a thumbnail of the site. However, all it is doing is adding the url as text, and a Shrinktheweb placeholder image beside it. Any idea what I'm doing wrong? Why isn't the url being interpreted correctly?Any help greatly appreciated. Thanks


How can I get an array of all IDs from the current queried object?

I am trying to join an array of post IDs together. Right now, it seems my code is creating a separate array for each ID, instead of one array with each ID. This is the code that I have come up with. It is inside of an include inside a `taxonomy.php` file. So basically, I am trying to get the ID of each post that would result from the query of the given taxonomy term. I feel like I am missing something very obvious? I have tried taking the variable outside of the loop but it will only output the first post ID.               <?php                   if( function_exists( 'wpseo_local_show_map' ) ) {                  while (have_posts()) : the_post();                      $post_ids = get_the_ID();                      var_dump($post_ids);                  endwhile;                              $params = array(                         'id' => $post_ids,                         'echo' => true,                         'width' => 425,                         'height' => 350,                         'zoom' => 10,                         'show_route' => true                         );                          wpseo_local_show_map( $params );                     }          ?>      The var_dump looks like this. Can anyone point me in the right direction?


Is it possible to change %post_id% in permalink by a constant?

I had an assignment of moving Joomla 1.0 content, categories and other stuff to the latest WordPress. Everything went fine, a few PHP scripts, a bit of fiddling with MySQL. But then, unexpected problem arose. I have to change permalinks to that:               $sitename/content/view/$post_id/$menu_id      The variables are from Joomla, and they have nothing to do with WordPress. I solved `$menu_id` thing through post_name in DB. But now I have to change the `$post_id` too, because it is exactly shifted by 44 (42'd be better though :) due to categories added first. So finally the question: can I somehow subtract 44 from the `%post_id%` I have in my permalink settings? (sth like "content/view/(%post_id% - 44)/") Or maybe a small change in the WordPress code? Thank you.


Link a widget or find the php that creates the widgets

I would like to make the entire widget a link. Ideally, I would like to find the php file that has created the widget and then modify that. **Q** : Is there a way to backtrace the HTML to find what php created it? **Q** : Is there a typical location that widget php files are located. I have looked in the body, header, for a widget.php. I am using Responsive theme.


'Bones' theme: Load stock scripts in footer instead of header?

I'm using the 'Bones' theme in my latest WordPress site, and when I run the site through Google PageSpeed, I receive the following error: > Eliminate render-blocking JavaScript and CSS in above-the-fold content: > > https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js/ > https://www.default.com/…includes/js/jquery/jquery-migrate.min.js > https://ajax.googleapis.com/…ax/libs/jqueryui/1.10.3/jquery-ui.min.js > https://www.default.com/…lugins/node.tmp/js/jquery.transit.min.js > https://www.default.com/…gins/node.tmp/js/jquery.touchwipe.min.js > https://www.default.com/…ntent/plugins/node.tmp/js/jquery.sidr.js > https://www.default.com/…ugins/node.tmp/js/mobile.nav.frontend.js > https://www.default.com/…/library/js/libs/modernizr.custom.min.js How can I load these scripts in the footer instead of the header as the theme is currently doing? The following is included in bones.php, which initializes the theme:               /*********************     SCRIPTS & ENQUEUEING     *********************/          // loading modernizr and jquery, and reply script     function bones_scripts_and_styles() {       global $wp_styles; // call global $wp_styles variable to add conditional wrapper around ie stylesheet the WordPress way       if (!is_admin()) {              // modernizr (without media query polyfill)         wp_register_script( 'bones-modernizr', get_stylesheet_directory_uri() . '/library/js/libs/modernizr.custom.min.js', array(), '2.5.3', false );              // register main stylesheet         wp_register_style( 'bones-stylesheet', get_stylesheet_directory_uri() . '/library/css/style.css', array(), '', 'all' );              // ie-only style sheet         wp_register_style( 'bones-ie-only', get_stylesheet_directory_uri() . '/library/css/ie.css', array(), '' );              // comment reply script for threaded comments         if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {             wp_enqueue_script( 'comment-reply' );         }              //adding scripts file in the footer         wp_register_script( 'bones-js', get_stylesheet_directory_uri() . '/library/js/scripts.js', array( 'jquery' ), '', true );              // enqueue styles and scripts         wp_enqueue_script( 'bones-modernizr' );         wp_enqueue_style( 'bones-stylesheet' );         wp_enqueue_style( 'bones-ie-only' );              $wp_styles->add_data( 'bones-ie-only', 'conditional', 'lt IE 9' ); // add conditional wrapper around ie stylesheet              /*         I recommend using a plugin to call jQuery         using the google cdn. That way it stays cached         and your site will load faster.         */         wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'bones-js' );            }     }


disable publish button until condition is not met

I currently wrote a plugins to customize my wordpress website. I surprisly find it easy to do many things with hook. Now I want to make author not be able to push publish button if no category is choosed ( I don't want uncategorized article and force author to choose something ) How I can did this with a little message telling to the user to choose a category when he try to click publish button if no category are checked. thanks


Add login hyperlink to secondary navigation menu

I have the following lines of code in my **functions.php** file:               #-----------------------------------------------------------------#     # Custom menu     #-----------------------------------------------------------------#     if ( function_exists( 'register_nav_menus' ) ) {         register_nav_menus(             array(               'top_nav' => 'Top Navigation Menu',               'secondary_nav' => 'Secondary Navigation Menu
 Will only display if applicable header layout is selected here.'             )         );     }                  //dropdown arrows     class Theme_Arrow_Walker_Nav_Menu extends Walker_Nav_Menu {         function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) {             $id_field = $this->db_fields['id'];             if (!empty($children_elements[$element->$id_field]) && $element->menu_item_parent == 0) {                  $element->title =  $element->title . '';                  $element->classes[] = 'sf-with-ul';             }                  if (!empty($children_elements[$element->$id_field]) && $element->menu_item_parent != 0) {                  $element->title =  $element->title . '';              }                  Walker_Nav_Menu::display_element($element, $children_elements, $max_depth, $depth, $args, $output);         }     }      And the following lines of code in my **header.php** file:               <?php if(has_nav_menu('secondary_nav')) { ?>
             <?php wp_nav_menu( array('walker' => new Theme_Arrow_Walker_Nav_Menu, 'theme_location' => 'secondary_nav', 'container' => '', 'items_wrap' => '%3$s' ) ); ?>
     <?php } ?>      Which displays a primary and more importantly regarding this issue, a secondary navigation menu: ![enter image description here](http://i.stack.imgur.com/6Vfcj.png) ![enter image description here](http://i.stack.imgur.com/qckMA.png) I would like to add a login navigation hyperlink, just below the _My Account_ hyperlink, and remove it if the user is logged-in. When adding this using the _Admin_ > _Appearance_ > _Menus_ settings... ![enter image description here](http://i.stack.imgur.com/fcKXh.png) It leaves the login navigation hyperlink there, even if the user is logged-in. How would I be able to add a login navigation hyperlink to my secondary navigation menu, and remove it from the list once the user is logged in to the website, and if possible without an additional plugin? Thank you.


Customized author slugs not working with get_author_posts_url method

I really appreciated the solution for the author rewrite rules here: Change Author Base Slug for different Roles The solution worked for me, however, when I now use the get_author_posts_url($id) method to get the author link url, it provides a link without the slug such as www.mysite.com//username -- if i type in the correct url into my browser www.mysite.com/slug/username it works and pulls up my author template. I'm trying to get the author post URL generated from WP to be correct. Any idea the get_author_posts_url method is returning the URL with a blank slug? Here's the code I did for modifying the author URLs:               $sds_author_levels = array( 'fans' );          add_action( 'init', 'sds_user_init' );     function sds_user_init()     {      global $wp_rewrite;      $author_levels = $GLOBALS['sds_author_levels'];           // Define the tag and use it in the rewrite rule      add_rewrite_tag( '%author_level%', '(' . implode( '|', $author_levels ) . ')' );      $wp_rewrite->author_base = '%author_level%';     }          add_filter( 'author_link', 'sds_author_link', 10, 2 );     function sds_author_link( $link, $author_id )     {       $author_level = 'fans';       $link = str_replace( '%author_level%', $author_levels, $link );       return $link;     }      So when I use the get_author_posts_url($id) method, it returns www.mysite.com//username rather than www.mysite.com/fans/username Any idea why the "fans" slug isn't being included?


Can't change local language with function

I'm trying to add a function in my theme to change the local language for certain pages.               function nfo_redefine_locale($locale) {       global $locale;       $locale = 'de_DE';       return $locale;     }     add_filter('locale','nfo_redefine_locale');       But it doesn't seem to be working, the language remains the one defined in wp- config.php?


Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?

I am building a theme in which I have a post type, which will have an archive in a grid layout. You're probably thinking, "Just use the CPT archive!" Well, there are some cons to that method that I'd like to avoid, which I've detailed below. This archive page needs to be as easy-to-use for the end user as possible, and ideally highly configurable. I am considering these three different ways to provide a CPT archive, and I am wondering which method will be the easiest to use for the person setting up the theme. I have the following criteria:   * The user needs to be able to add their own WYSIWYG content (text, images, etc.) above the post type archive, without editing template files and writing HTML manually.   * Adding content below the archive would be a plus, although not necessarily a hard requirement.   * The user needs to be able to easily add the post type archive page to their nav menu, and have it display the as the selected menu item when viewing the archive.   * The user needs to be able to easily change several archive grid display settings. I am wondering which method is best, given my requirements, but also whether I have overlooked any pros or cons to any of these methods that I should consider. Remember, I am trying to make this as easy for the user as possible. 1) **Built-in CPT archive** Pros:   * Most "WordPress-y" way to do it   * Page is created automatically by WordPress if the `has_archive` parameter is true in the post type registration   * I can easily retrieve the URL of the CPT archive for use elsewhere on the site. Cons:   * The only way to add text above or below the archive without manually editing the template file, would be to add a textarea in the customizer or theme options panel. This is a negative because it would most likely not be the full WordPress WYSIWYG editor experience, for instance the media library could not be browsed when inserting images.   * Does not appear in the nav menus, needs to be added as a custom link. My users will likely not be able to figure that out on their own.   * Does not trigger the "current menu item" css class in the menus when the CPT archive page is viewed on the frontend.   * The user cannot change the page title (unless a facility for doing so is provided in the theme options).   * The user cannot set a featured image for the page.   * The user cannot change the URL of the archive page. 2) **Page Template** Pros:   * User can use the page content WYSIWYG editor to create their page content.   * Archive settings can be changed in a meta box   * Easy to add to the menu Cons:   * Not the most "WordPress-y" way to do this   * Requires an extra step for the user to select the page template   * No place to edit WYSIWYG content for below the archive   * I cannot automatically retrieve the URL of the archive page elsewhere on the site. 3) **Archive Shortcode** Pros:   * Can add WYSIWYG content both above and below the archive grid   * Can specify archive settings via shortcode parameters Cons:   * The least "WordPress-y" way to do this   * Using shortcodes and shortcode parameters are not as easy to use as point-and-click settings in a meta box.   * I cannot automatically retrieve the URL of the archive page elsewhere on the site. Any advice, or pros/cons that I've overlooked would be welcome.


Link Back to Parent Category - Woocommerce

I´m using woocommerce and a custom post type=product and taxonomy=product_cat. I need a link back to parent category on every single product and category pages. Already read several posts in the web but couldn´t not make it work as I need. I was thinking to output the function in the sidebar when necessary via a text widget plugin that accepts php. Where do I insert the function as i´m using woocomerce, and I think theme uses different templates for single product and category pages? Just in functions.php? So, could you please help to do the function code and the html output? Thanks in advance


Bootstrap button menu on wordpress

I have a simple 4 item menu on wordpress. I want to use the bootstrap button style for this menu. This is the hand-made code of what I want to get.

Link 1

Link 2

Link 3

Link 4

      I have no clue on how to tell wp_nav_menu() to build the menu in this way. I am working over twentythirteen as starting theme so I have to change the default menu to this style I want. I tried to use this guide but I wan't able to get the result I want. Does anyone have a solution for this?


Failing to open advanced-cache.php which is breaking Media Library

On my WordPress install, which is 3.8 and has all plugins updated, it is using Magic Fields 2 and Hypercache amongst other plugins. I can't insert images into posts because when I upload, it gives me an error: > An error occurred in the upload. Please try again later. The Media Library window from a post's "Insert Media" appears blank although I know there are images there and can view them by going there in the sidebar. When I try to insert images with a Magic Field, when I click "insert into post", the window is blank and it doesn't insert the image. In wp-config.php, I've set debugging to true: > define('WP_DEBUG', true); And I'm getting these errors with ALL plugins disabled and the problem not resolved: > Warning: include(/myPath/wordpress/wp-content/advanced-cache.php) > [function.include]: failed to open stream: No such file or directory in > /myPath/wordpress/wp-settings.php on line 65 > > Warning: include() [function.include]: Failed opening '/myPath/wordpress/wp- > content/advanced-cache.php' for inclusion > (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in > /myPath/wordpress/wp-settings.php on line 65 I've checked the wp-content folder and am not seeing an advanced-cache.php - is the issue here that it SHOULD exist? Any suggestions? * * * UPDATE 4/27/2014 So as per Milo's suggestion, I went and set wp_cache to false: define('WP_CACHE', false); And I can insert images into regular posts again. I can't, however, insert images with the media type magic field still - same issue. When I click "set image" and choose an image to "insert into post", the window turns blank and the image never goes into the field if I refresh the page. ![Magic Field where "Set Image" is](http://i.stack.imgur.com/xlqdH.png) ![The window appears to choose an image for the Magic Field](http://i.stack.imgur.com/5cTD6.png) ![I choose an image and tried several sizes, and click "insert into post"](http://i.stack.imgur.com/89KUr.png) ![And this is the blank window once I've clicked "insert into post"](http://i.stack.imgur.com/iCnG8.png) The only errors I'm seeing with wp_debug still true is: > Notice: get_plugin_data was called with an argument that is deprecated since > version 3.0! The Site Wide Only: true plugin header is deprecated. Use > Network: true instead. in /myPath/wordpress/wp-includes/functions.php on > line 3006 I only see this errors on the Plugins page. And then I'm also getting a console error on the page where I'm trying to change those Magic Fields: > TypeError: a.ref is undefined Pointing to wp-includes/js/tinymce/tiny_mce.js So, suspecting maybe I had a script error in my theme files, I commented out all my js. Console error is now gone. But I still can't insert an image with Magic Fields - this has happened to me before when upgrading to 3.8 - and I just can't remember what the cause of it was after going through deprecated code. Open to more suggestions.


Custom Post Type - Rewrite

I'm making a reader sort of plugin that uses custom post types of 'series' & 'chapter' and need a custom rewrite rule that will allow me to do the following: /series/series_name/chapter/ I'm using the following code but get a 404 page when I goto a url in this manner               add_action('wp_loaded', 'reader_flush_rules');     function reader_flush_rules(){         $rules = get_option('rewrite_rules');              global $wp_rewrite;              if (!isset($rules['(series)/([^/]*)/(\d*)/?$'])) {             $wp_rewrite->flush_rules();             return;         }     }          add_action('init', 'reader_rewrite');     function reader_rewrite() {         add_rewrite_rule('(series)/([^/]*)/(\d*)/?$','index.php?post_type=$matches[1]&p=$matches[2]&chapter=$matches[3]','top');         add_rewrite_tag('%chapter%','(\d*)');     }      I'm using the Twenty Twelve theme and have no other plugins installed. I've updated my permalinks after applying the rewrites and still no luck. If anyone has any tips that could help me out, I would greatly appreciate it. Thanks!


Retrieve a specific number of words from post_Content

I would to retrieve a specific number of words from post_content, but I don't want the tags stripped. I was using wp_trim_words() before I realised that all my images are being removed, so I need an alternative way of doing it.


Need to create a function that will run regardless of W3TC PageCache for every page request

I want to create a specialized function that check certain parameters (page requested, ip of user against a list), if the user matches he will be redirected to a different site, if he doesn't match he will be allowed to continue to the original requested page. However the website is cached using W3TC Page Cache, and I can't seem to locate the place where I should put my code to act before W3TC returns the cached page.


How do I create a page template that doesn't show URL, sidebar, nav menu, footer? In Rupununi.org if you click on "Atta Rainforest Lodge" image, it will bring out a **lightbox** which displays the page template, and that exactly what I would like to create.


Outputting a custom field in PHP

I am a complete newbie at PHP so please forgive me. I am wanting to display some data in the following format: > "Post name" - "Custom Field String (in this case, 'custom_date')" I am currently using the following PHP code               $output .= $indent . '
ID.'">'.apply_filters( 'the_title', $page->post_title, get_post_meta($post->ID,'item_',TRUE), $current_custom_date = $page->$custom_date ) .' - ' . $current_custom_date . '';      The title and the dash are displaying perfectly. However, the Custom Field String is just displaying "Array" so now looks like this. > "Post name" - Array How would I get this to display the custom_date correctly? I've already set get_post_meta to 'true' as you can see so that shouldn't be the problem.


custom post type paging not working past page 3

I have a custom post type called services which has 23 custom posts, i also have a custom taxonomy for all the categories (5 categories). I am trying to create a list of all the custom posts of services and show only 5 posts at a time which i have done. I am also trying to have them paginated using wp_paginate, I can get page 1, 2 and 3 to page but for some reason i get a 404 on pages 4 and 5. this is the query i use to page the list:               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;       $wp_query = new WP_Query(array('post_type' => 'services', 'paged'=>$paged, 'posts_per_page' => 5, 'order' => 'DESC' ));      my custom post type code is:               register_post_type( 'services',             array(                 'labels' => array(                     'name' => __( 'Services' ),                     'singular_name' => __( 'Service' )                 ),                 'public' => true,                 'publicly_queryable' => true,                 'show_ui' => true,                 'show_in_menu' => true,                 'query_var' => 'services',                 'capability_type' => 'page',                 'has_archive' => 'our-services',                 'rewrite' => array( 'slug' => 'our-services/%service_categories%', 'with_front' => false),                 'taxonomies' => array( 'service_categories' ),                 'supports' => array(                     'title',                     'editor',                     'custom-fields',                     'revisions',                     'thumbnail',                     'page-attributes'                 )             )         );      and my custom taxonomy code is:               function init_service_categories() {         register_taxonomy(             'service_categories',             'services',             array(                 'labels' => array(                     'name' => 'Services Categories',                     'add_new_item' => 'Add New Services Category',                     'new_item_name' => "New Services Category"                 ),                 'show_ui' => true,                 'show_tagcloud' => false,                 'hierarchical' => true,                 'rewrite' => array( 'slug' => 'our-services' ),             )         );     }     add_action('init', 'init_service_categories', 0);      I also use this bit of code so when i go to a services single page it has the category infront of the service.               add_filter('post_type_link', 'glossary_term_permalink', 10, 4);     function glossary_term_permalink($post_link, $post, $leavename, $sample)     {         if ( false !== strpos( $post_link, '%service_categories%' ) ) {             $glossary_letter = get_the_terms( $post->ID, 'service_categories' );             $post_link = str_replace( '%service_categories%', array_pop( $glossary_letter )->slug, $post_link );         }         return $post_link;     }      I would really appreciate some help on this as I am so lost and do not understand why it doesn't work. Thanks


Decouple page name from page title

As far as I can see, the name of a page (in admin) is the same as the title for the page. In many cases you would want the page name to be something else to better grasp what it's about while glancing through the page admin. Perhaps you have a page with the title "This is what it is when it all comes around", which could be tagd as the "about" page and thus want it to be called "about" in the page listing in admin. Yes, you could add a custom field for another title but I think that would be backwards and not user friendly. Perhaps an additional name-field in quick-edit which will override the name (not title) of the page in admin? In the above case with page named "This is what it is when it all comes around", you would just quick-edit the page and enter "about" in the name field. Other ideas?


how to share register users in wordpress wtih another php site

I have two sites on two different domains. One site is a php / html / mysql and the other is WordPress site. I'd like it so that people who are registered on the first site can access the WordPress site like logged user and and vice versa... Anyone who registers to WordPress and logs in that could be taken up as the first site are logged...


Show Secondary Sidebar on Category pages (archive)

My site has the following structure where one column is for the main content (articles) and the other one, on the right, is for the sidebar (primary sidebar). The theme allows me to change the layout to three-col, however it's a "side- wide" change. I don't want three columns on main content section. Is there a way to show this second sidebar only on category pages? Here is the code for the secondary sidebar:               <?php     /**      * Alternate Sidebar Template      *      * If a `secondary` widget area is active and has widgets,      * and the selected layout has a third column, display the sidebar.      *      * @package WooFramework      * @subpackage Template      */     global $woo_options;          $selected_layout = 'one-col';     $layouts = array( 'three-col-left', 'three-col-middle', 'three-col-right' );     if ( is_array( $woo_options ) && array_key_exists( 'woo_layout', $woo_options ) )             { $selected_layout = $woo_options['woo_layout']; }          if ( in_array( $selected_layout, $layouts ) ) {          if ( woo_active_sidebar( 'secondary' ) ) {              woo_sidebar_before();     ?>     <aside id="sidebar-alt">     <?php     woo_sidebar_inside_before();     woo_sidebar( 'secondary' );     woo_sidebar_inside_after();     ?>         </aside><!-- /#sidebar-alt -->     <?php         woo_sidebar_after();     } // End IF Statement     } // End IF Statement     ?>      I think there are a few ways to achieve this: 1) We use a conditional function to display the secondary sidebar (which should be on the left of main content) only on category pages. 2) We can disable the secondary sidebar on the single pages. 3) Use CSS to disable sidebar (not sure if this can cause hidden content issue) I wonder if this sounds logical (unfortunately, I am not a "coder") Appreciate your help.


Additional Sidebar

Hi I wanted to create extra sidebar in my theme and I am not sure if what I did is correct. In my theme functions.php I found this function:                   function blankslate_widgets_init() {     register_sidebar( array (     'name' => __('Sidebar Widget Area', 'blankslate'),     'id' => 'primary-widget-area',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );     }      and Inside I pasted the new sidebar so it is like that now               register_sidebar( array (     'name' => __('Sidebar Widget Area', 'blankslate'),     'id' => 'primary-widget-area',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );               register_sidebar( array (     'name' => __('Left Sidebar', 'blankslate'),     'id' => 'left_sidebar',     'before_widget' => '
',     'after_widget' => "
",     'before_title' => '
',     'after_title' => '
',     ) );     }      after I've done this the widget appears in the dashboard perfectly then I add this code where I wanted the sidebar to appear               <?php dynamic_sidebar('left_sidebar'); ?>      and that worked perfectly for me. I'm not sure if this is the correct way and just worried if my theme will crush. Can anyone advise me please?


AJAX calendar navigation returns -1

I am trying to pass `$month` and `$year` values via AJAX when previous/next links are clicked, but all I am getting is a `-1` where the content should be. My JavaScript functions and AJAX call is located in a custom page template, `page-calendar.php` and `functions.php`, see all of the code here. To sum up though, here is the relevant AJAX script: In `functions.php`:               /* draw_ajax_calendar($month, $year) function, see link above for that */          // Date variable settings     $month = (int) ($_POST['month'] ? $_POST['month']                                     : ($_GET['month'] ? $_GET['month']                                                        : date('m')));          $year= (int) ($_POST['year'] ? $_POST['year']                                    : ($_GET['year'] ? $_GET['year']                                                        : date('Y')));               // Adding the AJAX hooks     add_action('wp_ajax_nopriv_draw_ajax_calendar', 'draw_ajax_calendar');     add_action('wp_ajax_draw_ajax_calendar', 'draw_ajax_calendar');      Script in `page-template.php` (also calendar-script.js. see below):               function nextMonthSwap(nextMonthVal,nextYearVal) {             jQuery("#calendar-container").html("
LOADING
").show();             var url="<?php echo $_ajax; ?>";             jQuery.post(url, {month: nextMonthVal, year: nextYearVal}, function(data){                 jQuery("#calendar-container").html(data).show();             });             return false;         }              // attach the link event handlers         jQuery(document).ready(function($) {             $('#prev-link').click(function(){ return prevMonthSwap(<?php echo $prevMonthVal; ?>,<?php echo $prevYearVal; ?>)});             $('#next-link').click(function(){ return nextMonthSwap(<?php echo $nextMonthVal; ?>,<?php echo $nextYearVal; ?>)});         });      Finally, the HTML also in `page-template.php`:
              <?php echo draw_ajax_calendar($month,$year); ?>              <a id="prev-link" href="<?php echo $prev_href; ?>">← Previous                                       <a id="next-link" href="<?php echo $next_href; ?>">Next →
      I have referenced this similar post and tried moving my JS from the `page- calendar.php` to `calendar-script.js` and including the script with this in `functions.php`:               function enqueue_calendar_script() {              // embed the javascript file that makes the AJAX request         wp_register_script( 'calendar-script.js', get_bloginfo('stylesheet_directory').'/scripts/calendar-script.js');         wp_enqueue_script( 'calendar-script.js' );              // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)         wp_localize_script( 'calendar-script.js', 'wp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );           }     add_action('wp_head', 'enqueue_calendar_scripts');      Enqueueing the `calendar-script.js` like this reverts to passing the `$month` and `$year` values via the URL. The behavior is the same logged in and logged out and according to the page source, the script is being called. Apologies if this is long winded, trying to be thorough. Any help is greatly appreciated!


How do I change the default WordPress e-mail ID for sent e-mail?

I have created a blog website at `careerdemo.com` and installed WordPress to run it. When a person signs up, they get an email from the address `wordpress@careerdemo.com` (this is, I guess, a default setting in WordPress). I want to change that, so that e-mails come from my own address,`contact@careerdemo.com`. (So any new user will get e-mails from my own e-mail address, `contact@careerdemo.com`.) How do I customize my FROM e-mail address?


Get the values from an array string to work with post__in

> Basically i need help to build a proper array to pass as value of `post__in` Basically code has to get featured images of posts **only for selected ids**. I need your help to extract the values of the concerned array string in the right manner as currently the code gives a warning `Warning: implode(): Invalid arguments passed in .../..`. It still displays images though. The issue is it displays images from across all posts instead of **images only from posts with selected ids** , as intended.                $sel_ids = $_SESSION['selected_ids'];           global $wpdb;       require_once('../../../../wp-load.php');           $args = array('post__in' => implode( ', ', $sel_ids ), 'post_type' => 'post');         $posts = get_posts($args);           foreach ($posts as $post) {          echo get_the_post_thumbnail($post->ID, 'coverimage');      }      In the first line of code block above, this string `$sel_ids` carries ids of selected posts. When `echoed` gives `Array`. When `var_dump($sel_ids)` shows               array(2) { [0]=> string(2) "67" [1]=> string(2) "16" }      and `foreach` gives a string such as `6716`. I do not need the `foreach` in my code but giving additional info so that it may help you infer better. The code above is not on a template page, but instead on a separate page. it is actually a form-processor. I need the code to run here as I need to grab those values and email them later. So I have loaded WordPress globals. The session is there to carry array value from the form. * * * UPDATE - @Mamaduka - Here is a relevant part of the source of the email in gmail               Array<img src="http://xxxxxxxxx.com/wp-content/uploads/2014/04/360.jpg">


Retrieve each widget separately from a sidebar

I would like to retrieve each widget existing in a sidebar in order e.g. to mix them with posts inside the main loop. I know I can use different widget areas (sidebars) but this approach clutters the widget admin page with some tens of sidebars. To mitigate this, I thought to just add them to a single sidebar and retrieve them consecutively when needed. But I'm stuck. I've no idea on how to retrieve a widget separately. My tentative approach is to use wp_get_sidebars_widgets and the_widget but I'm not able to retrieve the widget class name. Here is a simplified snippet of my code. In this case I'm trying to add a widget every three posts, but is an oversimplification of the logic (since I do not want just to add them regularly) in order to provide you the idea. I'd like to visualize every widget using `the_widget` or any other function. How can I accomplish this? Is it possible?                   <?php          $i = 1;         $widgets = wp_get_sidebars_widgets(); // I KNOW THE USE OF THIS IS DISCOURAGED (PRIVATE) BUT CANNOT FIND ALTERNATIVES.          if ( have_posts() ) : ?>                  <?php while ( have_posts() ) : the_post(); ?>                      <?php                     if ($i%3 == 0){                         echo "
WIDGET #".($i/3)."
";                         the_widget($widgets['homepage-1'][$i/3]); // THIS DOES NOT WORKS SINCE I'M NOT GIVING THE CLASS NAME. HOW TO RETRIEVE IT?                     }                     get_template_part( 'content', get_post_format() );                     $i++;                 ?>                  <?php endwhile; ?>                  <?php _s_paging_nav(); ?>              <?php else : ?>                  <?php get_template_part( 'content', 'none' ); ?>              <?php endif; ?>


PasswordHash not found in namespace

I'm very new to WordPress development, coming from a pure OO background I'm familiarising myself with object-orientation in PHP / WordPress. I have a class at entities\Member, that get's loaded via an autoloader implementation. This stuff I'm quite comfortable with, and up until now, I've not really used WordPress specific functions in my code. For members, I want to use the built in password hasher function that lives in the pluggable.php file, but for some reason the autoloader tries to 'lookup' the PasswordHash function as a class, which it should not be doing? I've browsed around for possible solutions to this, but it seems to be a limitation in WordPress and it's handling of object-orientation in PHP 5+? How can an 'fool' the autoloader to ignore WordPress functions, if at all possible? I have tried adding the require_once(ABSPATH . 'wp-includes/pluggable.php'); in the Members class, even in the functions.php class, just above the autoloader include. No go.


Frontend tag edit/submit form

I would like to have a separate page to submit/edit tags. Any user can edit or submit tags. But it should be published only after admin approval. Is there any function available like `wp_insert_tag()`? ## Update: After Kaiser's answer I've tried like this.               $x = wp_insert_term( 'test', 'post_tag', array('description' => 'This is a test tag') );     var_dump($x);      Its working fine. But it gets published automatically. Is it possible to publish it after admin approval?


Reusing header.php from Yii application

I'm building a website that uses Wordpress as the CMS and is built with Yii framework. All the business logic works fine. Most visible pages are filled with content from Wordpress admin and only the user profile section is built with Yii. My problem is that I would like to reuse the layout of the wordpress pages in the Yii app. Initially I tried to do it in a blank PHP file and everything worked as expected with this code:               <?php     require( '/var/www/wordpress/wp-load.php' );          get_header();     ?>          <div>     some content here     </div>          <?php     get_footer();     ?>      The problem is that when I make a new layout in Yii so that I can reuse the header and footer it crashes and displays blank page. I tried both with `require('/var/www/wordpress/wp-blog-header.php');` and `require( '/var/www/wordpress/wp-load.php' );`. This is the code I use to load wordpress functionality in Yii but unfortunately it does not work.               <?php /* @var $this Controller */     spl_autoload_unregister(array('YiiBase','autoload'));     require( '/var/www/wordpress/wp-load.php' );     get_header();          spl_autoload_register(array('YiiBase', 'autoload'));           ?>      All I see is a completely blank page (no markup). Any help would be much appreciated. Ideally I would like to use `get_header()` and `get_footer()` wordpress functions in Yii layouts/views. Thanks **UPDATE** I checked Apache logs and it seems that the following error is logged when I try to open the page in my browser: `PHP Fatal error: Call to a member function get() on a non-object in /var/www/wordpress/wp-includes/query.php on line 27` Also when I comment out the `get_header();` row the page opens without any errors (and without any styling too). So something prevents get_header() to work property in Yii.


Rating based off of number of comments or views

Is it possible to have some sort of rating feature based off of x amount of comments or views? ### Example: Instead of saying 200 views, have it say: > "Hot" 400 views, have it say: > "Very Hot" ### something similar to a if else statement > value=200 Echo "hot" if else echo "cold"


Custom Taxonomy for multiple Custom Post Types - Taxonomy Archive not working

I'm working on a project where I have a custom taxonomy, for example, called `class-formation`, that is shared for two Custom Post Types. On of them is the `product` CPT created by WooCommerce, and the another one is custom made for the project. I can assing the taxonomy to both CPT's. But the problem is when I try to access the taxonomy archive for `class-formation`, I didn't got a 404 not found error, but none posts are returned (`have_posts()` returns `false`) . And a weird thing is happening too: on this page, every custom menu that I have generated using `wp_nav_menu` is missing (I tested with some themes to check if was a theme related issue, but the behavior is the same). ## What I'm doing: in my **functions.php**               <?php          // registering the taxonomy "class-formation"     function theme_register_taxonomy(){              $labels = apply_filters( 'tax_class_formation_labels' ,array(             'name'                       => _x( 'Formações Acadêmicas', 'Taxonomy General Name', 'theme_slug' ),             'singular_name'              => _x( 'Formação Acadêmica', 'Taxonomy Singular Name', 'theme_slug' ),             'menu_name'                  => __( 'Formações', 'theme_slug' ),             'all_items'                  => __( 'Todos as Formações', 'theme_slug' ),             'parent_item'                => __( 'Formação Pai', 'theme_slug' ),             'parent_item_colon'          => __( 'Formação Pai:', 'theme_slug' ),             'new_item_name'              => __( 'Novo nome de Formação', 'theme_slug' ),             'add_new_item'               => __( 'Adicionar nova Formação', 'theme_slug' ),             'edit_item'                  => __( 'Editar Formação', 'theme_slug' ),             'update_item'                => __( 'Atualizar Formação', 'theme_slug' ),             'separate_items_with_commas' => __( 'Separe formações acadêmicas com vírgulas', 'theme_slug' ),             'search_items'               => __( 'Pesquisar formações', 'theme_slug' ),             'add_or_remove_items'        => __( 'Adiciona ou remova formações', 'theme_slug' ),             'choose_from_most_used'      => __( 'Escolha entre as formações mais usadas', 'theme_slug' ),         ) );              $rewrite = array(             'slug'                       => apply_filters( 'tax_class_formation_slug', _x( 'formacao-academica', 'Taxonomy Slug', 'theme_slug' ) ),             'with_front'                 => true,             'hierarchical'               => false,         );              $args = apply_filters( 'tax_class_formation_args', array(             'labels'                     => $labels,             'hierarchical'               => false,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'query_var'                  => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => false,             'rewrite'                    => $rewrite,         ) );              register_taxonomy( 'class-formation', array( 'theme-courses', 'product' ), $args );          }          add_action( 'init', 'theme_register_taxonomy' );          // filtering the archive taxonomy page to get posts with "theme-courses" CPT     add_action( 'pre_get_posts', 'filter_tax_archive', 1 );          function filter_tax_archive( $query ) {         if ( is_admin() || ! $query->is_main_query() )             return;              if ( $query->is_main_query() && $query->is_tax( 'class-formation' ) ) {             $query->set( 'post_type', array( 'theme-courses' ) );             return;         }     }      The `post_type` query var is successfully inserted, but I got an empty loop anyway. Any ideas for what's causing this issue? Thanks for any help! # Edit: The code above is a simplified version of all the code that I'm using. I made a gist with the full code if anyone want to check: https://gist.github.com/diegoliv/274f09e3f3d9094b204c # Edit 02: Maybe there is some conflict with WooCommerce? If I replace the `product` CPT with another one when I'm registering the taxonomy, the taxonomy page works ok. The same happens if I disable WooCommerce. But, with the actual code, when I'm inspecting the global `$wp_query` to check all the arguments used to build the query, there is some arguments coming from WooCommerce.


How to create a wp_query that contains both meta_query and tax_query

I have a wp_query that works great but I can't have both a meta query and a tax_query in it.               <?php          $event_query = new WP_Query(             array(                'post_type'  => 'event',        // only query events               'meta_key'    => 'event-date',  // load up the event_date meta               'orderby'     => 'meta_value',               'order'       => 'asc',         // ascending, so earlier events first               'posts_per_page' => '-1',               'meta_query'  => array(                  array(         // restrict posts based on meta values                   'key'     => 'event-date',  // which meta to query                   'value'   => date("Y/m/d"),  // value for comparison                   'compare' => '>',          // method of comparison                   'type'    => 'DATE'  )                  ),               'tax_query' => array(                 array(                     'taxonomy'  => 'event_category',                     'field'     => 'slug',                     'terms'     => $term_id,                     'operator'  => 'IN')                          ),                     ) // end array             ); // close WP_Query constructor call          ?>      I am trying to find all the events in taxonomy $term_id and then make sure they are all in the future and order by ASC Any ideas?


How to eliminate weird 404 errors in wp-admin?

I run a WordPress site with about 70 active plugins. Every so often, I'll get a random error page ("Not Found", though I haven't checked the headers to see if it's a 404) on a `/wp-admin/` page that pops up out of nowhere. Simply trying again resolves the error, however it's quite inconvenient if the error happens during a plugin upgrade (because the auto-reactivation fails). I think this same issue is responsible for certain modules on my Dashboard failing to load sometimes. Given the list of plugins I have installed, does anyone know of issues with or between any of them that might cause this problem? ### Edit: Hosting info: DreamHost; I think the server's running a custom Debian build with Apache httpd


Optimizing a Proximity-based Store Location Search on a Shared Web Host?

I've got a project where I need to build a store locator for a client. I'm using a custom post type "`restaurant-location`" and I have written the code to geocode the addresses stored in postmeta using the Google Geocoding API (heres the link that geocodes the US White House in JSON and I've stored the latitude and longitude back to custom fields. I've written a `get_posts_by_geo_distance()` function that returns a list of posts in order of those which are closest geographically using **the formula I found in the slideshow at this post**. You might call my function like so (I'm starting with a fixed "source" lat/long):               <?php     include "wp-load.php";          $source_lat = 30.3935337;     $source_long = -86.4957833;          $results = get_posts_by_geo_distance(         'restaurant-location',         'geo_latitude',         'geo_longitude',         $source_lat,         $source_long);          echo '
';     foreach($results as $post) {         $edit_url = get_edit_url($post->ID);         echo "
{$post->distance}: {$post->location}
";     }     echo '
';     return;      Here's the function `get_posts_by_geo_distance()` itself:               function get_posts_by_geo_distance($post_type,$lat_key,$lng_key,$source_lat,$source_lng) {         global $wpdb;         $sql =<<<SQL     SELECT         rl.ID,         rl.post_title AS location,         ROUND(3956*2*ASIN(SQRT(POWER(SIN(({$source_lat}-abs(lat.lat))*pi()/180/2),2)+         COS({$source_lat}*pi()/180)*COS(abs(lat.lat)*pi()/180)*         POWER(SIN(({$source_lng}-lng.lng)*pi()/180/2),2))),3) AS distance     FROM         wp_posts rl         INNER JOIN (SELECT post_id,CAST(meta_value AS DECIMAL(11,7)) AS lat FROM wp_postmeta lat WHERE lat.meta_key='{$lat_key}') lat ON lat.post_id = rl.ID         INNER JOIN (SELECT post_id,CAST(meta_value AS DECIMAL(11,7)) AS lng FROM wp_postmeta lng WHERE lng.meta_key='{$lng_key}') lng ON lng.post_id = rl.ID     WHERE         rl.post_type='{$post_type}' AND rl.post_name<>'auto-draft'     ORDER BY         distance     SQL;         $sql = $wpdb->prepare($sql,$source_lat,$source_lat,$source_lng);         return $wpdb->get_results($sql);     }      My concern is that the SQL is about as non-optimized as you can get. MySQL can't order by any available index since the _source geo_ is changeable and there's not a finite set of source geos to cache. Currently I'm stumped as to ways to optimize it. Taking into consideration what I've done already the question is: **How would you go about optimizing this use-case?** It's not important that I keep anything I've done if a better solution would have me throw it out. _I'm open to considering almost any solution_ except for one that requires doing something like installing a Sphinx server or anything that requires a customized MySQL configuration. Basically the solution needs to be able to work on any plain vanilla WordPress install. (That said, it would be great if anyone wants to list alternate solutions for others who might be able to get more advanced and for posterity.) ## Resources Found FYI, I did a bit of research on this so rather than have you do the research again or rather than have you post any of these links as an answer I'll go ahead and include them.   * http://jebaird.com/blog/calculating-distance-miles-latitude-and-longitude   * http://wordpress.org/extend/plugins/geolocation/screenshots/   * http://code.google.com/apis/maps/articles/phpsqlsearch.html   * http://www.rooftopsolutions.nl/blog/229   * http://planet.mysql.com/entry/?id=18085   * http://blog.peoplesdns.com/archives/24   * http://www.petefreitag.com/item/622.cfm   * http://www.phpro.org/tutorials/Geo-Targetting-With-PHP-And-MySQL.html   * http://forum.geonames.org/gforum/posts/list/692.page   * http://forums.mysql.com/list.php?23   * http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL   * http://developer.yahoo.com/maps/rest/V1/geocode.html   * http://geocoder.us/ ## Regarding Sphinx Search   * http://sphinxsearch.com/   * https://launchpad.net/wp-sphinx-plugin   * http://forums.site5.com/showthread.php?t=28981   * http://wordpress.org/extend/plugins/wordpress-sphinx-plugin/   * http://wordpress.org/extend/plugins/sphinx-search/   * http://www.mysqlperformanceblog.com/2008/02/15/mysql-performance-blog-now-uses-sphinx-for-site-search/


Free/Open-Source Theme Frameworks as an Alternate to Thesis?

What good free and open source alternatives exist to the Thesis theme ??


Insert new post for each user infinite loop error

I wrote this little function to automatically create a post for every user of the blog but it creates an infinite loop (I disabled it to stop it creating new posts). I'm not very skilled in php, I guess the error is in the use of wp_insert_post inside the foreach, but it doesn't work simply putting it outside the braces. How can I make this function insert JUST ONE post for each author? Thanks.               $blogusers = get_users();     foreach ($blogusers as $user) {         $my_post = array(         'post_title'    => $user->display_name,         'post_content'  => 'Bla bla bla.',         'post_status'   => 'publish',         'post_author'   => $user->ID,         'post_type'     => 'custom'         );              wp_insert_post( $my_post );     }


How to maintain W3C standards compliance of a theme

When I wrote a theme, I made sure it was compliant with XHTML 1.1 and CSS 2.1. Then I added plugins and the theme is no longer compliant with XHTMl 1.1. Then I used Google API font in my CSS and it is longer CSS 2.1 compliant. Is there a way I can keep the compliance without getting rid of the plugins, font etc or should I just ignore the validation errors?


Making the Header on the Twenty Ten Theme Less Tall?

The question is _How do I make the header on the Twenty Ten theme less tall?_ That question was asked over at the LinkedIn WordPress group that is hidden from search engines so I thought I'd copy my answer to here. I've also made it a community wiki so it doesn't pass reputation to me.


Custom Nav Walker sub-menu HTML construct

I've got my Custom Nav Walker set up and it works fine with the main menu items, and displays them how I want. However the same HTML is being applied to the `sub-menu` elements which isn't what I want. I'm aiming to get the `sub-menu` to have the following styling:

Blog 1

Blog 2

Blog 3

Blog 4

      Here is the HTML Structure for the full navigation

                 <img src="<?php echo get_template_directory_uri(); ?>/assets/drawing-pin.png">

Products

                 <img src="<?php echo get_template_directory_uri(); ?>/assets/corner-flick-cyan.png">

Products 1

Products 2

Products 3

Products 4

Products 5

      Here is the HTML call for the wp_nav_menu:
     <?php           $walker = new my_nav_walker;     wp_nav_menu( array( 'theme_location' => 'header-menu', 'menu' => 'ul', 'menu_class' => 'navigation', 'menu_id' => '', 'walker' => $walker ) );                ?>
      Here is the construct for my Custom Walker HTML: (NOTE: I'm really new to this, so this is going to be messy...)               class my_nav_walker extends Walker {            function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {                      $direct = get_template_directory_uri();                      $item_output = $args->before;                 $item_output .= '
';                 $item_output .= '';                 /** This filter is documented in wp-includes/post-template.php */                      $item_output .= '

';                 $item_output .= '

';                 $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;                      $item_output .= '

';                 $item_output .= '';                 $item_output .= '
';                 $item_output .= $args->after;                  }              } // Walker_Nav_Menu      Here's the CSS if needed: PasteBin Link I'm not sure if I'm doing the construct right to get the separate styling that I want. What would you advise? Are there any alternatives? Constructive Criticism on the code? (Don't be too harsh! :P) EDIT -----: I've done some more research into understanding the php code, and I now realise where the defining of the start and end of the sub-menu starts (With start_lvl and end_lvl), but I still don't understand how to separate what code goes to the Parent navigation panes, and which goes to their respective sub- menus. **This is what I'm after with the display of the naviagtion:http://jsfiddle.net/TPD5L/**


Pagination with WP_Query not working

I have a custom page template on my site, with a WP_Query pulling in a list of posts. I'd like to implement pagination but just can't seem to get it right. Here's the code I'm using blelow, which pulls in the most recent 2 posts fine, but then doesn't display the 'next' or 'previous' links as you might expect. For clarity, I have a total of 5 posts that meet the criteria in the query and this template is being used as the front page of my blog. Also, the inc-post- listing.php simply pulls in certain info from each post, like the thumbnail, title and permalink. I'm sure I'm missing something obvious so any help is very much appreciated.                <?php              $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;             // WP_Query arguments             $args = array (                 'post_type'              => 'post',                 'post_status'            => 'publish',                 'posts_per_page'         => '2',                 'paged'                  => $paged             );                  // The Query             $posts = new WP_Query( $args );                  // The Loop             if ( $posts->have_posts() ) {                 while ( $posts->have_posts() ) {                     $posts->the_post();                      include('inc-post-listing.php');                     }             } else {                 // no posts found             }                  // Restore original Post Data             wp_reset_postdata();         ?>
<?php posts_nav_link(' ','Previous Page','Next Page'); ?>

<?php posts_nav_link(' ','Go Back','Show More Tips'); ?>


Removing Mutlisite lines stop DB connection

I'm trying to revert my mutlisite to a single site and following a guide it recommends removing the following                   /*define( 'MULTISITE', true );*/     define( 'MULTISITE', false );     define( 'SUBDOMAIN_INSTALL', false );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'www.dreamdoors.co.uk' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      and also to make `define('WP_ALLOW_MULTISITE', true);` to false I've commented out the first part and changed the second path but then it says can not find Database connection.


Fancybox loading small white square

I know there is a similar topic with same title, but my problem is not the same.Fancybox was working perfectly in my html template, but after converting it to wordpress, images are not showing in the popup box, I can only see a square white box here is my code:               <?php $args = array( 'post_type' => 'portfolio' );     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post(); ?>
                       <?php the_post_thumbnail(); ?>
             <a href="<?php the_permalink(); ?>" class="project-title"><?php the_title(); ?>             <a href="<?php get_the_post_thumbnail(); ?>" class="project-img fancybox">             <a href="<?php the_permalink(); ?>" class="project-link">

     <?php endwhile; ?>      & here is the js:               $(".fancybox").fancybox({                  padding     : 0,             margin      : 100,             openEffect  : 'elastic',             closeEffect : 'elastic',             openSpeed   : 400,             closeSpeed  : 400,                  helpers : {                 overlay : {                     css : {                         'background' : 'rgba(0, 0, 0, 0.75)'                     }                 }             }         });      I'm not a pro. so couldn't find the mistake myself. what should I do?


Linking text within textarea of custom meta box

I'm using 'Meta Box Script for WordPress' to create custom meta boxes and everything is working great...except the following: We have a textarea that we want to act, basically as another WP the_content (It's for hidden content that is only shown once a link to show hidden content is clicked). My end-users want to be able to put something like the following in the box: `This is some pretty <a href="#">linked text</a>.` I'm using the following code in my template to show the custom meta box content: `<?php echo get_post_meta(get_the_ID(), 'oc_code', true); ?>` The content it shows is exactly like this (I'm guessing it's not parsing, if that's the correct phrase, the URL): `This is some pretty <a href="#">linked text</a>.` What can I do to show a clickable href within the template without adding more custom fields/meta boxes? I was looking at esc_attr, esc_url, etc. but don't know that that is the solution. TIA!


get_posts assigned to a specific custom taxonomy term, and not the term's children

Say I have the following taxonomy terms:               Term 1       Term 1.1       Term 1.2     Term 2       Term 2.1      How can I get only posts that are assigned to Term 1 and not include those that are assigned to Term 1.1 or Term 1.2? For example:               $pages = get_posts(array(       'post_type' => 'page',       'numberposts' => -1,       'tax_query' => array(         array(           'taxonomy' => 'taxonomy-name',           'field' => 'id',           'terms' => 1 // Where term_id of Term 1 is "1".         )       )     );      is also giving me posts that have Terms 1.1 and 1.2 assigned. Thanks.


jQuery Drill Down iPod Menu FOUC and Selecting Current page

I'm using Drill Down Ipod Menu and I'm really like the style of showing submenus , but I have two problems with it. 1-when i load a page it shows all submenus open for a second and I experience a Flash of Unstyled Content , it was good for a while when I changed style css but it backed again (i don't know if there's a relation between css file and the problem). my list of active plugins is below (I had some others that i deleted them): 1-Bulk Post Creator Plus 2-Cat + Tag Filter 3-Category Grid View Gallery 4-cforms 5-Custom Field Template 6-ShowID for Post/Page/Category/Tag/Comment 7-SwfObj 8-vSlider 9-wp-jalali how can I prevent showing my menu unstyled ? 2- when I navigate from a submenu to my homepage (from a link outside of menu) menu stay in previous state , i know it use cookies , but is there anyway to show current page instead of using cookies ? if it's impossible to solve this problems what plugin can I use instead to have folding menus from wordpress custom menus (not pages and categories ) ? sorry for my bad english thanks in advancce


dbDelta not doing what it says

Okay so I must have read hundreds of wordpress answers, google results etc on different people having trouble with dbDelta creating tables for their plugins. Ive tried many variations based off of those answers to see if it would do the trick but this code below does not seem to create the table. Even though the returned data from dbDelta says it created the table, if there is any help anyone can give me or see the error that I've made, I would be very grateful.               function activation() {       // Install table       global $wpdb;            $sql = "CREATE TABLE ".$this->table_name." (         id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,         PRIMARY KEY (id),           user_id BIGINT(20) NOT NULL UNSIGNED,           KEY user_id (user_id),             created DATETIME DEFAULT '0000-00-00 00:00:00'  NOT NULL,             url VARCHAR(55) DEFAULT '' NOT NULL,       );";            var_dump($sql);            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );       var_dump(dbDelta( $sql ));            add_option( "invite_db_version", $invite_db_version );     }      This function is registered to the activation hook in the constructor of my plugin class `register_activation_hook( __FILE__, array( &$this, 'activation' ) );`


wp_schedule_event not working?

I cannot get a Wordpress cron to trigger. I am trying to run this code to see if I can get an email sent to me hourly. It's taken directly from the Wordpress examples here: http://codex.wordpress.org/Function_Reference/wp_schedule_event. Except I removed underscores (see caveat in documentation). The code is running in my theme functions.php file. The cron seems to be registered but the `prefixdothishourly` function does not get fired (as far as I can tell.)               add_action( 'wp', 'prefixsetupschedule' );          /**      * On an early action hook, check if the hook is scheduled - if not, schedule it.      */     function prefixsetupschedule() {         if ( ! wp_next_scheduled( 'prefixhourlyevent' ) ) {             wp_schedule_event(time(), 'hourly', 'prefixhourlyevent');         }     }          add_action( 'prefixhourlyevent', 'prefixdothishourly' );          /**      * On the scheduled action hook, run a function.      */      function prefixdothishourly() {          return wp_mail("me@example.com", "Notification TEST", "TEST", null);      }


Wordpress in own directory not working

I have a site with a blog section (well, I'm trying to create the blog section now..) WordPress is installed (original install; not transferred from root) in `/blog/`. Post links (for example, when I click on the Hello World post that was autogenerated,) lead to the TLD. So if I click on it, instead of taking me to http://www.example.com/blog/?p=1, it takes me to http://www.example.com/?p=1. (The current TLD is occupied with an existing index page, so redirecting everything from `/` to `/blog/` won't work. A new subdomain would also be somewhat inconvenient at the moment, and I'd like to avoid that for aesthetic and site structure reasons, as well.) **I've already configured the site's URL in Settings > General > WordPress Address and Site Address.** That did not fix the problem. WordPress 3.9.1 on PHP 5.2.17.


Page template with custom html fields inside a content

I'm writing a custom page template and I want to do something like this: after typing tag inside page content, for example [custom-email-form] I want to place inside the content some html5 email form. How to achieve that? Thanks.


Paginated Taxonomy Term Archive including one post per term

I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in _all_ the taxonomies. Is there a way I can limit the number of taxonomies displayed to a set number per page and paginate them?               // Set post type     $post_type = 'prints';          // Get all the taxonomies for this post type     $taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );          foreach( $taxonomies as $taxonomy ) :               // Get every "category" (term) in this taxonomy to get the respective posts         $terms = get_terms( $taxonomy );              foreach( $terms as $term ) :                  // Query to show first post in taxonomy             $posts = new WP_Query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=1" );                  if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
                 <a href="<?php esc_url( the_permalink() ); ?>">                     <?php the_post_thumbnail ('medium'); ?>
<?php echo $term->name; ?>

<?php             endwhile; endif;              endforeach;          endforeach;


how to add Custom menu item like User name in Header Menu only

I am new to Wordpress I am setting up wordpress Site which has 3 Menus   * Top menu   * Header Menu   * Footer Menu  My issue is I need to add the User name to My Top menu Only when User is Logged in But using below Code snippet it adds the Custom menu Item in all the Menus the Below Code i found while googleing the Solution for the above Query               function my_custom_menu_item($items)     {         if(is_user_logged_in())         {             $user=wp_get_current_user();             $name=$user->display_name; // or user_login , user_firstname, user_lastname             $items .= '
Welcome '.$name.'
';         }        return $items;     }     add_filter( 'wp_nav_menu_items', 'my_custom_menu_item');      This is my Top menu Structure **if User is not logged in**   * My Account      * Login     * Signup     * Lost Password **if User is Logged In**   * Welcome Nikhil      * Profile     * Change Password     * Logout     * blogs


How to take list of words and insert them as terms to become tags of a post

I am working on a plugin that will take words with a certain number of characters from a post title and create a list of suggested tags in my Tag Suggester meta box.   I have created the function to find and display the words that meet my criteria. How do I take that list of words and insert them as terms to become tags for a post. Here is what I have so far:               <?php     //renders html for metabox     function tagsuggester_display_meta_box( $post, $args ) {        wp_nonce_field( plugins_url( __FILE__ ), 'tagsuggester_plugin_noncename' );     ?>
List of available tags:
     <?php         //get_the_title()         $title = get_the_title();          $title_array = explode(' ', $title);         foreach( $title_array as $word ) {             //var_dump( $word );             $word_length = strlen($word);             if ( $word_length > 3 )  {                 //echo  $word;                 echo '<input type="checkbox" name="tagsuggester" value="tagsuggester"> '.$word.'
';             }          }         $tags = get_terms( 'post_tag', array( 'search' => $title_array) );     }          //save the metabox content     function tagsuggester_save_meta_box( $post_id, $post ) {          // Do not save during autosave routines     if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )         return;     // Verify permissions before saving     if ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) {         if ( ! current_user_can( 'edit_page', $post_id ) ) {             return;         }     } else {         if ( ! current_user_can( 'edit_post', $post_id ) ) {             return;         }     }          }          add_action( 'save_post', 'tagsuggester_save_meta_box', 10, 2 );


file_get_contents_curl pulling wrong values

I'm using file_get_contents_curl to get the facebook likes of the post and store them in my database.                $fb = json_decode(file_get_contents_curl('http://graph.facebook.com/?id='.get_permalink($post->ID)));                 if( !isset( $fb->likes) && isset($fb->shares) )                 {                     $fb->likes = $fb->shares;                 }      Everything worked well until I added more posts (now 700+). The pulling of the likes needed more and more time. Now the script manages to get the right amount of Facebook likes for SOME posts, but for some other posts it just pulls an empty value. So some posts with lets say, 8 FB-Likes, still get the value of 0 FB likes written to the database. My curl function:               function file_get_contents_curl($url)      {         if ( function_exists('curl_init') )          {             $ch = curl_init();                  curl_setopt($ch, CURLOPT_HEADER, 0);             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.             curl_setopt($ch, CURLOPT_URL, $url);                  $data = curl_exec($ch);                  if ($data === FALSE) {                 $data =  "cURL Error: " . curl_error($ch);             }                  curl_close($ch);         } else {             $data = $url;         }         return $data;     }


Hide meta box for everything BUT a certain custom post type

I need to retain tag taxonomy for a single custom post type, but am struggling with it. Is there a way to remove this meta box for everything BUT? * * * `remove_meta_box('tagsdiv-post_tag', 'post', 'normal');` Will remove the tags from normal posts (desired), but it means they're also removed from ALL custom post types. I can remove the meta box for individual custom post types, like so: `remove_meta_box('tagsdiv-post_tag', 'cars', 'normal');` `remove_meta_box('tagsdiv-post_tag', 'hotels', 'normal');` etc. But that means I have to leave tags available on normal posts (undesired). So I guess I want something like this, to remove the meta box from everything apart from (e.g.) `airports`: `remove_meta_box('tagsdiv-post_tag', '!airports', 'normal');` Any ideas?