How to get Ajax into a theme - without writing a plugin?

Okay, I'm starting out with some AJAX stuff in a wordpress theme 1) I'm building a child theme OFF the thematic framework 2) My child theme has a header.php, index.php, functions.php and style.css (at this stage) In my header.php I have the following (btw: the code is adapted from http://codex.wordpress.org/AJAX_in_Plugins):               <?php         if( !is_admin() ) {      add_action('wp_ajax_my_special_action', 'my_action_callback');      add_action('wp_ajax_nopriv_my_special_action', 'my_action_callback');      $_ajax = admin_url('admin-ajax.php');         }     ?>     <script type="text/javascript" >     jQuery(document).ready(function($) {           var data = {       action: 'my_special_action',       whatever: 1234      };           jQuery.post('<?php echo($_ajax); ?>', data, function(response) {       jQuery('#output').html('Got this from the server: ' + response);      });          });     </script>     </head>      Right so that's all cool - and it updates the OUTPUT div on the page with "Got this from the server: 0" I need a PHP function called "my_action_callback" - so in my theme's functions.php I have the following:               function my_action_callback() {           $whatever = $_POST['whatever'];           $whatever += 10;              echo 'whatever now equals: ' . $whatever;           die();     }      This is the ONLY function in my functions.php To make sure the PHP function is working I stick my_action_callback() into my index.php - and it outputs "whatever now equals: 10" as expected. HOWEVER - the AJAX response is always 'Got this from the server: 0' Ajax never seems to get the response from the PHP function. I tried adding .ajaxError() to see if there were any errors - nope. I tried adding the PHP functions to another plugin of mine - nope. What am I missing that jQuery isn't doing the ajax bit for me? Thanks in advance


Displaying a random user with a shortcode

I'm trying to setup a shortcode to show a single random user each time the page is refreshed. I've been successful in displaying **all** users or a select user by the user ID. Here is my shortcode as it is now:               //* Shortcode for getting users     function list_of_users( $atts ) {              extract( shortcode_atts(             array(                 'display' => 'all',                 'user' => '30'             ),             $atts         ));              switch ( $display ) {             case 'all':                 $content = display_all_users();                 break;             case 'single':                 $content = display_single_user( (int) $user );                 break;             case 'rotate':                 $content = display_rotate_users();                 break;             default:             break;         }         return $content;     }     add_shortcode('staff', 'list_of_users');      * * * Here's the function to display **all** users:               function display_all_users(){          $args = array(             'orderby' => 'ID',             'order' => 'ASC'         );         $users = get_users( $args );              $html = '
';             foreach( $users as $user ){                  $user_info = get_userdata($user->ID);                 $html .= '
';                 $html .= 'user_nicename.'" class="staff-image">';                 $html .= mt_profile_img( $user->ID, array('size' => '250x250','echo' => false));                 $html .= '';                 $html .= '
user_nicename.'" class="staff-name">
'.$user->display_name.'
';                 $html .= '
';                 $html .= get_field('certifications','user_'.$user->ID);                 $html .= '
';                 $html .= '
';                 $html .= get_field('short_bio','user_'.$user->ID);                 $html .= '
';                 $html .= 'user_nicename.'" class="more-staff-bio">Read more from ' . $user_info->user_firstname . '

';                 $html .= '
';             }         $html .= '
';         return $html;     }      * * * Here's the function to show a single user by ID:               function display_single_user( $user_id = 30 ){              $html = '
';         $html .=  mt_profile_img( $user_id, array('size' => '175x175','echo' => false));         $html .= '

';         $html .=  get_field('short_bio','user_'.$user_id);         $html .= '
Read more staff bios';              return $html;     }      * * * Where I'm stuck is to take the list of all users and then randomizing the user id to then use to display certain info. I would like to keep the output of the single user (above) for this random user...it's just a matter of how to get that random ID. Any suggestions on how to accomplish this?


Get the page address when using ajax

I have a page that uses jQuery to update some content. I want to run some PHP functions based on the url of the page. However, when I get the url of the page using PHP it returns the path of the WP Ajaz script. Is there anyway I can get the currently visible url in the browsers address bar? As an example if I go to: www.mydomain.com/page/?criteria=selection The following php code: `$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];` returns the following: www.mydomain.com/wp- admin/admin-ajax.php


How to let a role handle media without post permissions

I have a CPT to replace my "post"-post-type, but I still need to be able to use attachments. The problem is, that attachments have the post-capabilities. I don’t want to give post capabilities to my role, because of that, I tried to find a way to avoid it. I found a hack in the wordpress track: http://core.trac.wordpress.org/ticket/19834               function crunchhack() {        global $wp_post_types;        $wp_post_types['attachment']->cap->edit_post = 'upload_files';     }     add_action( 'init', 'crunchhack' );      I have added it to my `functions.php`. It did not work, because of that, I tried to replace all post-capabilities of the attachment post-type with `upload_files`:               function fix_media_permissions() {         global $wp_post_types;         $wp_post_types['attachment']->cap->edit_post = 'upload_files';         $wp_post_types['attachment']->cap->read_post = 'upload_files';         $wp_post_types['attachment']->cap->delete_post = 'upload_files';         $wp_post_types['attachment']->cap->edit_posts = 'upload_files';         $wp_post_types['attachment']->cap->edit_others_posts = 'upload_files';         $wp_post_types['attachment']->cap->edit_published_posts = 'upload_files';         $wp_post_types['attachment']->cap->publish_posts = 'upload_files';         $wp_post_types['attachment']->cap->delete_posts = 'upload_files';         $wp_post_types['attachment']->cap->delete_others_posts = 'upload_files';         $wp_post_types['attachment']->cap->delete_published_posts = 'upload_files';         $wp_post_types['attachment']->cap->delete_private_posts = 'upload_files';         $wp_post_types['attachment']->cap->edit_private_posts = 'upload_files';         $wp_post_types['attachment']->cap->read_private_posts = 'upload_files';     }     add_action( 'init',  'fix_media_permissions');      Sadly this doesn’t work either. I can see the uploaded images, but that’s it. Any ideas?


How can I make wp-pagenavi work on a custom query built upon a form submission?

I've also posted this on the wordpress support forums, for scribu's wp- pagenavi plugin: http://wordpress.org/support/topic/plugin-wp-pagenavi-custom-query-form- submit-part-2?replies=1 My situation: I am using a form to create a custom query that displays posts from a custom post type archive matching a certain custom field (Eg: For "custom-post-type" show only posts that have the "custom-field" value selected from the form). I know, it's called filtering :P My custom post type archive looks like this: `www.example.com/custom-post-type-archive` (note that I use the "post name" permalink setting) Upon form submission, the new url is this: `www.example.com/custom-post-type-archive?key=value` The custom query is set to show only posts with _value_ of _key_ custom field:               $value = $_GET['value'];     $paged = get_query_var('page');     $args = array(             'post_type' => 'custom-post-type',             'meta_key' => 'key',             'meta_value' => $value,             'paged' => $paged,             'posts_per_page' => 10     );     $my_query = new WP_Query($args);      After the loop I have:               wp_pagenavi(array('query' => $my_query));     wp_reset_postdata();      The query works, I get the right results. But I have problems getting pagination to work. When I go to the next page, I get this url: `www.example.com/custom-post-type-archive/page/2?key=value` but pagination still shows like I'm on the first page and the results are the same. If I manually enter:   `www.example.com/custom-post-type-archive?key=value&page=2`   I get the right results (from page 2), but the all navigation links are the same as the url I manually entered above. Please help (hints, resources, anything). Thx, Radu


Add social icons in a theme through custom admin menu

Is it possible to make a theme with an option of configuring social icons with links through the custom header control panel? I googled it and found nothing that could help me, any help on that topic will be very appreciated **UPDATE**   What I'm trying to achieve is that in the theme control panel (preferably inside the `header` panel and without using an external plugin) the user will be able to set which social icons will appear and to configure them.


Adding Multiple Images to Sidebar Through Dashboard

I have a sidebar with 3 images hardcoded. I'd like to make it so you can change these through the WordPress dashboard. What's the easiest way to accomplish this? Using a plugin, custom post type?
             <img class="img-sidebar" img src="<?php bloginfo('template_directory'); ?>/img/Sidebar1.png" />

             <img class="img-sidebar" img src="<?php bloginfo('template_directory'); ?>/img/Sidebar2.png" />

             <img class="img-sidebar" img src="<?php bloginfo('template_directory'); ?>/img/Sidebar3.png" />


WordPress most commented posts of last X days

I'm working on implementing a WP feature that shows the most commented posts from the last X days (e.g. lat 2 days). I've used the following code I found on the web (and here on SO), which does the job:
     <?php     function filter_where($where = '') {     //posts in the last 30 days     $where .= " AND post_date > '" . date('Y-m-d', strtotime('-10 days')) . "'";     return $where;     }          add_filter('posts_where', 'filter_where');          query_posts('post_type=post&posts_per_page=5&orderby=comment_count&order=DESC');          while (have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php          endwhile;          wp_reset_query();     ?>
      The problem that occurs is that the wp_reset_querry apparently doesn't work, as all category listings, tag cloud etc after the above code are messed up -- what happens is that if there's another WP code that lists posts in a category, it'll list only the X days that the above code mentions, despite having wp_reset_querry. I'm trying to figure out why that is and what I'm doing wrong here? I'd appreciate any help. Also, if there's an easier or better way of displaying the most commented posts over the last X days, please let me know. Thanks!


Updating the database with advanced custom fields

I'm having a real problem with updating a database table using advanced custom fields within a custom post type. I have a table in the database called 'wp_company_profiles' with fields 'address_1' and 'address_2', and have two advanced custom fields set up with the same values. I am trying to put together a hook that will update the table fields when a particular post in updated. Below is the code I am using, but I can't figure out why it won't work.               function update_company_profile($post_ID)  {         global $wpdb;              if ($parent_id = wp_is_post_revision( $post_id )) $post_ID = $parent_id;              $address_1 = get_post_meta($post_ID, 'address_1', true);         $address_2 = get_post_meta($post_ID, 'address_2', true);              $sql = $wpdb->query("UPDATE wp_company_profiles SET                 address_1 = '{$address_1}',                 address_2 = '{$address_2}',                 WHERE pid = {$post_ID}");              $wpdb->query($sql);     }          add_action('save_post', 'update_company_profile');


Rating system for users

I want to implement a system on my wordpress site. In my site, there are a bunch of users signed up. It is a social networking site. I would basically like a rating system that ranks the users based on their skill. I am using buddy press for users to create their own profiles. I almost thought of just adding a criteria on their profile, a drop down menu, that says rate your gaming skills 1-10. but the problem with that is that everyone will rank themselves high. I almost would like a system where the user could go and rank themselves, but I could come in and modify the ranking if I need to. Any suggestions?


Security around save_post hook

There are a lot of examples using the `save_post` hook, that include adding and verifying a nonce, and checking the user has appropriate permissions before you continue. Is this necessary? When updating/publishing a post, WP verifies the normal nonce, and checks permissions itself, redirecting to a 403 or 'Are you sure you want to do this?` page if something doesn't check out. As such, the hook won't even be called if a bad request was made, so why would I have to double check these things myself?


Previos and next post navigation - set to all posts not category

I have the following code which adds post navigation to the bottom of single posts. It currently displays the next and previous posts from whatever category the post is assigned to but i'd like it show prev and next for all posts instead. Code is below
     <?php $prevPost = get_previous_post(true);     if($prevPost) {?>

Previous
     <?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100) );?>     <?php previous_post_link('%link',"$prevthumbnail
%title
", TRUE); ?>
          <?php } $nextPost = get_next_post(true);     if($nextPost) { ?>

Next
     <?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(100,100) ); } ?>     <?php next_post_link('%link',"$nextthumbnail
%title
", TRUE); ?>
     <?php ?>


URL Encoding/decoding issue?

I am using chines language in my URL , It giving some issue . If you copy and past chines URL to address bar directly it will work . but when you create URL dynamical it creates some number in URL http://someting.com/%E6%96%B0%E5%8A%A0%E5%9D%A1%E5%8D%8E%E4%B9%90%E6%80%BB%E4%BC%9A%E6%88%90%E7%AB%8B%E5%A4%A7%E4%BC%9A-sme- test/ '%E6%96%B0%E5%8A%A0%E5%9D%A1%E5%8D%8E%E4%B9%90%E6%80%BB%E4%BC%9A%E6%88%90%E7%AB%8B%E5%A4%A7%E4%BC%9A' - this really some Chinese characters Please help me to solve this problem


W3 Total Cache + S3 + Cloudfront.

For a small site, what WordPress/site files normally go into the S3 bucket in order to get optimal use as a CDN?


Progress bar - JS + CSS

I'm trying to implement a progress bar to wordpress. Exactly this one : http://workshop.rs/2012/12/animated-progress-bar-in-4-lines-of-jquery/ **php shortcodes**               function progress_bar(  $atts, $content = null ) {         global $progress, $pbar_class;         extract( shortcode_atts( array(             'title' => '', //additional text             'progress' => '', //progress %             ), $atts) );         $pbar_class = '.progressBar'.rand(100,999);         return '

';     }          add_shortcode( 'pbar', 'progress_bar' );          function pbar_script() {         global $progress, $pbar_class;         foreach($pbar_class as $pb_class) {             echo '';        }     }          add_action( 'wp_footer', 'pbar_script' );      **js**               function progress(percent, $element) {         var progressBarWidth = percent * $element.width() / 100;         $element.find('div').delay(500).animate({ width: progressBarWidth }, 500).html(percent + "% ");     }      I have no idea how to make it work.


Prevent Hacking of Wordpress Site

My Wordpress site is beign hacked by some hackers of Saudi Arabia. How can i prevent them from hacking. I have also found that many other Wordpress sites have also been hacked.


One item not showing when programmatically Generating Navigation Menu

I am programmatically generating a navigation menu with the following....               add_action( 'init', 'register_navmenus' );     function register_navmenus() {          // Check if Top menu exists and make it if not     if ( !is_nav_menu( 'Navigation' )) {         $menu_id = wp_create_nav_menu( 'Navigation' );              $menu1 = array('menu-item-title' => 'Home','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('home')->ID,'menu-item-type' => 'post_type','menu-item-status' => 'publish');              $menu2 = array('menu-item-title' => 'Register','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('register')->ID,'menu-item-type' => 'post_type','menu-item-status' => 'publish');              $menu3 = array('menu-item-title' => 'Login','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('login')->ID,'menu-item-type' => 'post_type','menu-item-status' => 'publish');              wp_update_nav_menu_item( $menu_id, 0, $menu1 );         wp_update_nav_menu_item( $menu_id, 0, $menu2 );         wp_update_nav_menu_item( $menu_id, 0, $menu3 );     }            }      This all works correctly apart from Login, its not created. Is the 'login' slug already being used by the system or something similar? **NOTE** If I change the line to...                   $menu3 = array('menu-item-title' => 'Login','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('login1')->ID,'menu-item-type' => 'post_type','menu-item-status' => 'publish');      Then the page does get generated but obviously doesnt link as the slug is incorrect


the_post_thumbnail unless video id is added

I have 2 choices on the edit post page to insert an video ID from either vimeo or youtube. The user needs to select, with a select field (channel), if he wants to embed video from one or the other.               <?php if (get_field('channel') == 'Youtube') {             echo get_field('youtube_video_id');         }         if (get_field('channel') == 'Vimeo') {             echo get_field('vimeo_video_id');         }     ?>      Now I'd like this to overrule the_post_thumbnail. So when a video is posted is shows the video instead of the thumb. Is that possible?               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     <?php if ( has_post_thumbnail()) : ?>         <?php the_post_thumbnail(); ?>              *** MAGIC HERE I GUESS? ***              <?php endif; ?>     <?php endwhile; else: ?>
Nothing here
         <?php endif; ?>      Hope somebody can push me in the right direction. Or am I doing this the other way arround? I'm my PHP is still a learning curve. Thanks, /Paul


Display random image url from list of input values

I have created an options page in my WordPress theme that allows the user to input a url/upload an image to an input field. The field has the name headerimage_options[image] and when it is populated it can be saved and outputted in the theme with the following code: `<?php echo esc_url( $headerimage_options['image'] ); ?>` I have created three inputs with the names [image], [image2] and [image3]. I can save the content of the input fields and output all of the images using the code below:               <?php $headerimage_options = get_option( 'headerimage_options' ); ?>              <img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image'] ); ?>"/>              <img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image2'] ); ?>"/>              <img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image3'] ); ?>"/>      My question is how do I output just one of the images at random? I've searched but couldn't find an answer anywhere.


Custom post type isn't working

I just built up a beta environment for testing my new Wordpress site. I didn't migrate the database; I did my own installation again and ported over my theme (it's a simple theme) to my new instance. Everything is working great, except for the one custom post type that I am using. Here is the relevant code from `functions.php`:               function createCommunityPostType() {         $args = array(                 'public' => true,                 'label' => 'Community',                 'capability_type' => 'community',                     'capabilities' => array(                                     'edit_post' => 'edit_community',                                     'edit_private_posts' => 'edit_private_communities',                                     'edit_published_posts' => 'edit_published_communities',                                     'edit_posts' => 'edit_communities',                                     'edit_others_posts' => 'edit_others_communities',                                          'delete_post' => 'delete_community',                                     'delete_posts' => 'delete_communities',                                     'delete_others_posts' => 'delete_others_communities',                                     'delete_private_posts' => 'delete_private_communities',                                     'delete_published_posts' => 'delete_published_communities',                                          'read_private_posts' => 'read_private_communities',                                     'read_post' => 'read_community',                                     'publish_posts' => 'publish_communities'                     ),                     'map_meta_cap' => true,                     'has_archive' => true         );         register_post_type('community', $args );     }     add_action('init', 'createCommunityPostType');      My custom post type isn't showing up in the menu and I can see that the capabilities don't exist (I'm using the members plugin to make that more visible). I know the code is executing because I added some simple `print` statements before and after the call to `register_post_type`. The print statements were part of the HTML response. I can't figure out why this post type isn't working. I have other methods in `functions.php` to handle stylesheets, scripts, some overrides for menus and sidebars and so on. Those are all working fine. **Edit** : I changed to use default capabilities and the menu option is still not appearing:               function createCommunityPostType() {         $args = array(                 'public' => true,                 'label' => 'Community',                 'capability_type' => 'community',                     'capabilities' => array(                                     'edit_post' => 'edit_posts',                                     'edit_private_posts' => 'edit_posts',                                     'edit_published_posts' => 'edit_posts',                                     'edit_posts' => 'edit_posts',                                     'edit_others_posts' => 'edit_posts',                                          'delete_post' => 'delete_posts',                                     'delete_posts' => 'delete_posts',                                     'delete_others_posts' => 'delete_posts',                                     'delete_private_posts' => 'delete_posts',                                     'delete_published_posts' => 'delete_posts',                                          'read_private_posts' => 'read',                                     'read_post' => 'read',                                     'publish_posts' => 'publish_posts'                     ),                 'map_meta_cap' => true,                     'has_archive' => true         );         register_post_type('community', $args );     }     add_action('init', 'createCommunityPostType');      I did however switch to using some very basic sample code from Wordpress and that Custom Post Type (CPT) appears:               function codex_custom_init() {         $args = array( 'public' => true, 'label' => 'Books' );         register_post_type( 'book', $args );     }     add_action( 'init', 'codex_custom_init' );


Filter Select results based on selection

I am trying to filter which job results are rendered to the page whenever the user changes the select item on my form. The select items are dynamically populated by the code below which assigns them a value of their slug and their label.                       <div style="background: url('<?php bloginfo( 'template_directory'); ?>/images/drop-arrow2.png') no-repeat;" id="cat-select">                 <form name="job_select" action="<?php bloginfo('url'); ?>/jobs.php" method="get">                     <select class="job_cats" name="position_name" onchange='<?php echo ".$category->category_nicename."; ?>'>                              <?php                                    // For every child of blog                                   $post_count = 1;                                   $categories =  get_categories('child_of=16');                                    foreach ($categories as $category) {                                     $option = '<option value="'.$category->category_nicename.'">';                                     $option .= $category->cat_name;                                     $option .= '</option>';                                     echo $option;                                     $post_count++;                                   }                              ?>                      </select>                 </form>         </div>      The code then moves on to my main WP Loop where all of my posts are rendered to the page using this query -                   <?php          $node_id = 0;         $args = array(             'post_type' => 'jobs',             'category_name' => $_GET['position_name']         );              $the_query = new WP_Query( $args );               ?>      I want to the `$category->cat_name` (the slug) into the 'category_name' argument to filter the results however I am unsure of how I can a) make the page refresh to display these new filtered results (would I need AJAX to do this?) and b) How I can pass the current selected index of the select box to 'category_name' as a parameter, I have tried using `$_GET['position_name']` but this has failed to produce any result. To give a visual of how my page looks, a screenshot can be seen here Form Screengrab any suggestions would be greatly appreciated.


Combine and Minify wp-admin files, also re-write URI's for CDN

I'm currently using WP-MINIFY to combine and minify my front-end files as I have a large number of plugins, it has helped greatly and I'm looking for a similar solution to help with backend performance issues. Ideally a solution that would combine all backend admin files that are being loaded, especially those that are introduced by plugins. Thanks in advanced for any help.


Wordpress Plugin Authoring question about jquery and css

When I'm writing a plugin, do I assume that jquery is included, or should I always wp_enqueue_script it and let wordpress figure it out? Also, what's the best practice for getting an image path figured out in my bundled css file?


Should i use the wordpress Options table or to create database table..?

I have an application built in asp.net but i'd like to port it over to wordpress as a plugin. Is it practical to develop the php version of this app using the Wordpress options table or should i rather create new database tables in the existing wordpress database? Lastly this next question may be answered by answering the first question hopefully and that is: When should I use wordpress option tables over creating the database tables for the intended plugin? Thanks way in advance..


How to check if post has any tag?

I am displaying post tags like this:
<?php the_tags('Tags' , ' '); ?>
      It works fine, but if the post does not have any tag, then it adds empty div

      So, how can I use the condition to check if post has any tag, then display above.


Problem on register/login widgets

I have downloaded and uploaded, activated successfully the plugin : Sidebar login of wordpress.org, which can be found here : Sidebar login In the picture description of sidebar login(in the link above), there is register link, so that people can use it to generate a new username via email. However, in my blog, it has only the forget password link : ![enter image description here](http://i.stack.imgur.com/8COWV.png) So, what was the problem ? I beg your pardon for my question if you feel my question is not appropriate. Please help me. Thanks.


How to show custom taxonomy child posts through shortcode in WordPress

My question: I have custom taxonomy in WP named Videos and childs of this taxonomy named music-videos and game-videos. In my WP theme this is shortcode which shows ALL video posts from main taxonomy named VIDEOS:                   <?php     add_shortcode("video", "video_shortcode");     function video_shortcode($atts, $content) {         extract(shortcode_atts(array(             "items" => 3,             "cat" => null,             "id" => null,             "nav" => false,             "order" => "desc",             "orderby" => "ID",             "videos" => null         ), $atts));         $order       = strtoupper($order);         $items_count = 0;         $items_src   = null;         if ($id == null) {             $query = array(                 'post_type' => 'video',                 'orderby' => $orderby,                 'order' => $order,                 'posts_per_page' => $items,                 'cat' => $cat             );             if (of_get_option('shortcat_video', '1') == '1') {                 $query = array(                     'posts_per_page' => $items,                     'orderby' => $orderby,                     'order' => $order,                     'post_type' => 'video',                     'tax_query' => array(                         array(                             'taxonomy' => 'videos',                             'field' => 'slug',                             'terms' => array(                                 $cat                             )                         )                     )                 );             }             if ($videos != null) {                 $query['tax_query'] = array(                     array(                         'taxonomy' => 'videos',                         'field' => 'slug'                     )                 );             }             $wp_query_video = new WP_Query($query);         }         $items_src .= '

';         while ($wp_query_video->have_posts()):             $wp_query_video->the_post();             global $post;             $fix            = the_excerpt_max(0);             $title          = get_the_title($fix);             $video          = get_post_meta($post->ID, "video_link", true);             $image_id       = get_post_thumbnail_id();             $venue          = get_post_meta($post->ID, "vd_venue", true);             $data_video     = get_post_meta($post->ID, 'vd_date', true);             $time           = strtotime($data_video);             $pretty_date_yy = date('Y', $time);             $pretty_date_M  = date('F', $time);             $pretty_date_d  = date('d', $time);             $cover          = wp_get_attachment_image_src($image_id, 'video-shortcode');             $cover_large    = wp_get_attachment_image_src($image_id, 'photo-large');             $no_cover       = get_template_directory_uri();             $items_src .= '

';             if ($image_id) {                 $items_src .= '                          ';             } else {                 $items_src .= '                          ';             }             $items_src .= '

' . $title . '
';             if ($data_video) {                 $items_src .= '
' . $pretty_date_d . ' ' . $pretty_date_M . ' ' . $pretty_date_yy . '
';             } else {                 $items_src .= '
' . $venue . '
';             }             $items_src .= '

';         endwhile;         wp_reset_query();         $items_src .= '

';         return $items_src;     }     ?>      Question - how to show through shortcode only posts from child taxonomy: music-videos or only from games-videos? Thank you for your time and patience, guys and gals


Order custom posts by taxonomy, then by meta_key

I've created a custom post type called Player Manager, where I have all the players of a football team. The CPT has four different categories - goalkeepers, defenders, midfielders and strikers. I also gave it a few text fields, where the only important one, for now, is "number". Here's how I'd like it to show up in the archives page:               Goalkeepers     -1     -21     -24     Defenders     -3     -4     -5     -11      So, what I want is for the posts to be ordered first by the categories and then, within the categories, by the numbers. I've managed to have them ordered by either categories or numbers (right now by numbers):               $querystr = "     SELECT $wpdb->posts.*     FROM $wpdb->posts, $wpdb->postmeta     WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id     AND $wpdb->posts.post_type = 'players'     AND $wpdb->posts.post_status = 'publish'     AND $wpdb->postmeta.meta_key = 'number'     ORDER BY ABS ($wpdb->postmeta.meta_value) ASC     ";     $pageposts = $wpdb->get_results($querystr, OBJECT);      But that's not how I'd like it. I guess I could do the same loop 4 times, but with different categories.


Am I using get_posts wrong?

I have               <?php      $folioPosts = get_posts(array('category_name' => 'portfolio', 'numberposts' => 3));     if ($folioPosts->have_posts()) :     foreach ($folioPosts as $folioPost) :      setup_postdata($folioPost);     ?>
       <?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail() ?>
       <?php endif; ?>
<a href="<?php the_permalink() ?>"><?php the_title() ?>

          <?php     endforeach;     else :     ?>
No folio posts to display ...
     <?php endif; ?>      I am getting > Fatal error: Call to a member function have_posts() on a non-object ... I think its because my args to get_posts are wrong. Did I do something wrong?


LaTex MarkUp - align equations

I'm very elated by the fact that it has LaTeX support. I would like to know whether the `\begin{align} \end{align}` environment could be used, because it looks very good since the equations are aligned. If not how can i make this LaTeX command look better?               \begin{align*}     \int \frac{1}{(2x^{2}+4x-2)^{-\frac{3}{2}}} \ \textrm{dx} &= \frac{\sqrt{2}}{8} \int\frac{\sec{t} \cdot \tan{t}}{\tan^{3}{t}} \ \textrm{dt} \\\ &= \frac{\sqrt{2}}{8} \int\frac{\cos{t}}{\sin^{2}{t}} \ \textrm{dt}     \end{align*}


menu items outside of blog

Is there way that I can echo out my wordpress menu items to a main site menu. The wordpress install runs in a subfolder of my main site. I thought there might be a way to do this that is similar to referencing wp- load as a include outside of wordpress Thanks


want to stop stripping out from my post content

I have installed wordpress for my site. I am trying to insert posts using function `wp_insert_post()` from my self-made script.               content of my post contains video-embed code of google.     <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/-T9omX2XD2s?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-T9omX2XD2s?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>      when I am running script to insert this content in my post, by my surprise this code got stripped out from post. I have surfed the internet and wordpress forum, I found that It is a SECURITY feature of wordpress. I want to remove this security feature from my own wordpress site. so what should I do to opt-out this stripping function? so that I can add above html code as a content of a post. Please give me the function name which is stripping out this codes from my content, so I can stop it working. My complete code.               <?php     require('./wp-blog-header.php');     $contactObject['postTitle'] = $_POST['post_title'];     $contactObject['videoCode'] = $_POST['videoCode'];     $contactObject['description'] = $_POST['description'];     $categoryIds = $_POST['categories'];          insertPosts($contactObjects,$categoryIds);          function insertPosts($contactObjects,$categoryIds)     {                  $videoCode = $contactObject['videoCode'];             $videoEmbedCode = '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/'.$videoCode.'?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$videoCode.'?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>';                  $content = '';             if($contactObject['description'] != '')             {                     $content .= '
'.$contactObject['description'].'

';             }             $content .= $videoEmbedCode;                  // Create post object             $my_post = array(                      'post_title' => $contactObject['postTitle'],                      'post_content' => $content,                      'post_status' => 'publish',                      'post_author' => 1,                      'post_category' => $categoryIds,                  );                  // Insert the post into the database             $postId = wp_insert_post( $my_post );     }     ?>


Sort WP_User_Query by meta_key value with pre_user_query

I'm trying to order my users by their Member Number - which is a custom meta value. It seems I can't easily orderby a `meta_value`. I've read a few workarounds but I can't get my head around it. This is my code so far...               function sort_by_member_number( $vars ) {         if ( isset( $vars->query_vars['orderby'] ) && 'member-number' == $vars->query_vars['orderby'] ) {             $vars = array_merge(                 $vars->query_vars, array(                     'meta_key' => 'arcc_member_number'                 )             );         }         return $vars;     }     add_filter( 'pre_user_query', 'sort_by_member_number' );      `arcc_member_number` is a numeric value - how can I extend this to sort by that value?


Making custom field's 'Name' available in the dropdown list by default in a theme?

My single.php file has the following code:               <?php // Set and display custom field         $intro_image = get_post_meta($post->ID, 'Intro Image', true); ?>
             <img src="<?php echo $intro_image; ?>" alt="" />
 <?php     ?>      The user will have to type Intro Image (once) in the 'Name' field in order to see it next time in the drop-down list. I think it would be better if the user can see 'Intro Image' right after installing my Wordpress theme (I feel that the user should select options that are available, not write them down themselves). I'm not sure if what I'm saying make sense. But how to have those 'Names' available in the drop-down list before writing them?


Query post & loop problem.

i having trouble while i added query to loop. please have a look whats the problem. here is the link
      <?php $count = 1;      $the_query = new WP_Query( 'category_name=headline&orderby=post_date&order=desc' );              if ( $the_query->have_posts() ) : while (have_posts()) : $the_query->the_post();       if($count == 1) : ?>           <a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title(); ?>      <?php dynamic_excerpt(400); ?>      <?php else : ?>
      <a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php the_title(); ?>      <?php dynamic_excerpt(400); ?>
           <?php if ($count== 2 || $count == 4 ){ ?>             <?php dynamic_sidebar('index-insert') ?>      <?php } ?>      <?php $count = $count + 0; ?>         <?php endif; ?>     <?php $count++; ?>      <?php endwhile; ?>


Pagination in a Shortcode. Get_next_posts_link not working but get_previous_posts_link works fine right next to it

I'm trying to output a custom post type archive using a shortcode. Everything works fine except for the get_next_posts_link part. The weird part is that it's right next to a get_previous_posts_link that works perfectly. Here's the function               function output_tips() {     global $paged;     $paged = get_query_var('paged') ? get_query_var('paged') : 1;     $args = array( 'post_type' => 'ht_tips', 'posts_per_page' => 1, 'paged' => $paged, 'caller_get_posts' => 1, 'orderby' => 'date', 'order' => 'DESC' );     $loop = new WP_Query( $args );          $inner = '';          while ( $loop->have_posts() ): $loop->the_post(); global $post;              $title = '
'. get_the_title() .'
';              $content = get_the_content();              $output = '
' . $title . $content . '
';              $inner .= $output;          endwhile;           $prev = '
' . get_previous_posts_link( __( '← Previous' ) ) . '
';     $next = '
' . get_next_posts_link( __( 'Next →' ) ) . '
';          wp_reset_postdata();          $open = '
';     $close = '
';     $return = $open . $inner . $prev . $next . $close;          return $return;     }      Any idea why this might be?


How to change archieve frequency of the media file in uploads folder for wordpress blog

So far I can see my media file is divided into month and year as 2008/09 like directory. But I am getting concerned because I am currently hosting a community listing site that may incurr more than 1000 upload (which is the limit for most shared hosting for EACH directory). I realize recently that the shared site can not have more than 500,000 file/ file in combine. So I think it will be getting pretty limited after a while. Anyone has solution for this issue in term of changing the archieve frequency maybe into every week instead of every month? I googled it but can never find a answer for it all at! Or...am I getting into a wrong direction? Please help thank you all!


wp_list_pages by taxonomy?

I need help creating a Walker for wp_list_categories that filters through taxonomies and actually lists the pages at the end element. I'm completely lost on how to go about this. I've successfully implemented a Walker for the wp_list_pages function but that obviously doesn't apply in this case because my wp_list_pages Walker relied on child-parent relationships * * * Additionally, I'd like to be able to specify which terms I want to return. Basically, I need a list filtered by taxonomy and terms.


Which method is best to enqueue scripts

I'm currently authoring the development of a plugin for wordpress, and I'm having trouble figuring out which would be the best way to add scripts to the plugin. I'm in the process of adding more scripts, and I already have JQuery (through WordPress), JQuery UI (through googleapis). Eventually I'll be adding SWFUpload, but before I continue, I wanted to understand what would be the appropriate approach to my situation. From what I've gathered, and I'm not totally sure if I'm correct on it. There's 3 different ways to add/enqueue scripts.   1. Use the script already built inside WordPress - which I'm wondering could cause some issues with some webmasters using older versions of wordpress.   2. Download a stable version and add it to my plugin directory - which basically guarantees that the plugin will use the same version and will always be available.   3. Use the ajax.googleapis.com URL linking the script to enqueue - no changes to the version, but can connectivity with the webmaster's server or the googleapi server be an issue? The things I'm wondering about, is reliability, speed, and any standards to it, if any.


More than one search results page template

On my current project, I have to create 2, distinct templates to receive 2 distinct search results of the same site. Both researches are coming from different forms on different templates/pages. Thing is, there is only one search.php file in Wordpress, and I don't think it's possible to create another one. (like search-taxonomy.php) Is there a way to separate one search result of the other, and to then display the correct search page template in relation to which search form has been filled?


Replacing default display name to login name

I see a lot of forum threads about the possibility of changing the default WordPress display name to First Name and Last Name. By default, the default display name of my theme is set the First Name and Last Name and I would like to set it back to the login name by default. I'd like to know the bit of code I have to add to functions.php to get the job done. I am using Wordpress 3.8.1


Replacing Icons in the Dashboard

Is there a way for me to replace the icons in the WordPress Dashboard with custom ones? I'm imagining there's got to be a way to do this with the `functions.php` or, more ideally, with a custom-built plugin, but I have no idea how to do that kind of stuff, and Google has failed me. In particular, I'm looking to replace the Yoast SEO icon with a gray one to match the WordPress theme better: ![](http://i.imgur.com/nURHQLp.png)


I'm getting Georgia or Georgia-like on my blog when I don't want it wondering if wp-includes has been modified by a plugin

I'm trying to just use Lato which is used in twenty fourteen which is what is active in my http://janet.tokerud.com blog but getting something I used to use that doesn't fit this new theme. Thinking maybe when I did whatever I did - I think used a plug-in to get one the google fonts to show that it permanently changed something on the backend that is forcing this font to be used for body text in the blog post. Sorry I'm tech savvy but not a CSS professional or WordPress professional so I may be naming these things wrong. _**PROBLEM RESOLVED THANKS!_** See my comment below.


Add class name to post thumbnail

I'm using post thumbnails to link to a page. Is it possible to add a class name to the post thumbnail image.
<a href="<?php the_permalink(); ?>" ><?php the_post_thumbnail(); ?>


Export local WP install to live - help needed

This question I'm asking has been asked a thousand different ways, and I refuse to believe I'm the only one with a basic need here so here goes: I'm taking a simple local install and putting it live. I've exported before, but it didn't seem to carry over any categories/settings/authors/etc. HOWEVER, that was almost a year ago, and it's entirely possible I didn't do things properly since I was just starting to learn WordPress. So, what I need is to ask "If I login as admin, and click 'export', does it..."   1. Does it export all posts and authors, including the post meta? (what authors wrote what posts)   2. Does it export all settings? (permalinks, discussion, reading, etc)   3. Does it export all media? (images, videos, etc) It's a simple list, but I'm being asked to take a very messy existing WP install and make it sexy in local then put it live with the new theme I built. I just want to know what to expect, so I can plan accordingly. Thank you all!


Check for files and database integrity

Someone started an automatic update of the WP core via dashboard today, and as it was taking too long, decided to cancel it. How do I check the files and the database for integrity to detect a possible corruption?


Catch own Exceptions

I build some package with my own Exception but when I try to catch a exception I got fatal error: **Uncaught exception**. This situation is only when method with throw is passed by `add_action( 'init', array( $this, 'wp_some_method' ) );` Example:               class SomeClass {         public function __construct() {             add_action( 'init', array( $this, 'wp_some_method' ) );             echo '__constructor
';         }         function some_method(){             throw new \Exception('some message');         }         function wp_some_method( $post_type ){             throw new \Exception('Some second error');          }     }     try{         echo 'try
';         $o = new SomeClass();         //$o->some_method(); - this throw exception correct          } catch (\Exception $ex) {         echo $ex->getMessage();     }      Displayed on the screen: **try** **__constructor** And: **Fatal error: Uncaught exception 'Exception'**


How to process ajax requests correctly using ajax plugins

I've been stuck on this topic for a while. I followed Pippin's tutorial . According to a 2nd wordpress developer who I got advice from, this tutorial is now out of date/ not appropriate. He told me that I shouldn't `echo` things in the AJAX callback. > JavaScript should handle that. Also to send data in your callback, use > `wp_send_json()` or the higher level functions `wp_send_json_success()` and > `wp_send_json_error()`. All of them will `die` for you. No need to `exit` or > `die` afterward, like Pippin has done it in his tutorial. Which developer is correct? In the Codex, the example uses `echo` in the callback, just like Pippin has in his tutorial. Please can someone clarify? I've been getting conflicting advice & I'm confused by this topic.


How to keep a CPT from being visible on the front end?

Here's how I define the CPT:               $args = array(             'labels' => $labels,             'public' => FALSE,             'show_ui' => TRUE,             'capability_type' => SNG_CAP_SUPPORT,             'hierarchical' => FALSE,             'supports' => array(                 'title',                  'editor'             ),             'menu_icon' => SNG_PLUGIN_URL . '/images/admin-support.png',             'rewrite' => FALSE,             'has_archive' => FALSE );         register_post_type( SNG_SUPPORT_POSTTYPE, $args );      Basically when a user creates a post of this post_type there's a success message that says "view this post" which leads to the front end of my site _mysite.com/?sng-support=test-8_. I want to remove this message and link but I'm not looking for a CSS fix. There _MUST_ be a way to make this work? I tried playing with the args and I can't seem to figure out what I'm doing wrong... Essentially I don't want the posts to be accessible from the URL or the front end unless I specifically query for them. I appreciate any help! :)


Related Links Page with moderated, user suggested link submissions

Updating an old dinosaur of a site to Wordpress ( _3.5.1_ ),   one of the more popular pages on the old site is a “ **Related Links** ” page with links for and about kids. (e.g. _fitness, nutrition, education, bicycle safety etc._ ). We frequently receive email from teachers all over the U.S. indicating that -- _as the result of some sort of class project_ \-- their students have found sites they think relevant, asking if we would include the link(s) they’ve found on our “ **Related Links** ” page. On the new Wordpress site we would like to improve on the old “ **Related Links** ” page, providing users a means of submitting a request for inclusion ( _something like moderated comments?_   )   with a text-area to input the details of the request ( _comments?_ ) a **field for the suggested link** , a **field to suggest tags** ( _or categories_ ) as a means of categorizing the links, and a **user email field** for contact/validation. Ideally, approved link submissions would be **sortable by category, age or popularity** ( _via Google Analytics_ ), with a credit line for the submitting user e.g. ...               ( Courtesy of Little Suzie Smith, Mrs. Jones 3rd Grade Class 2012-2013 )      I fear this may require developing a plugin specifically for the case, but would sure feel silly re-inventing this wheel if there already exists the means to accomplish it without. Any Suggestions as to how this might be implemented ( _or approximated_ ) using an existing plugin and / or existing WP functionality ?


Change existing label in the admin bar with something else

In the admin bar an admin can create a new post by using the add new drop down. In there I want to change the label `Post` to something else. How can I do this? I just need the code to make the change in the admin bar as I have the code already to change the Post label everywhere else in the admin section. Bonus points if you can tell me how to change the order of the labels in the drop down too.


Set first level items to <h5> in wp_nav_menu()

News & Features

Industry News
                     ............

      First Menu need h5 tag then others menu need ul li tage.


How to pass data parameter to ajax action function handler

I have the following js to process an ajax request:               $('#someelement').click(function() {                  var cokeValue = 'coke';                  var data = {                 action: 'load_post',                 another_par: someVar             };                  jQuery.post(ajax_object.ajax_url, data, function(response) {                 alert(response);             });       });      And this is my ajax handler function (hopefully my terminology is correct):               add_action('wp_ajax_get_coke', 'get_coke_ajax');     function get_coke_ajax() {             // need to get another_par in here !!!!!!!             die();     }      As you can see, the action is `load_post` which is fine, but I need to pass the `another_par` parameter to my ajax function so that I can assign its value to a variable and use it for my purposes.


Extra Title field for Comments

I want to display an extra title field for comments, that can be edited by the admin in the backend. NB, The extra title field also needs to display when the user is logged in. I have tried a range of plugins with no success. Can anyone point me in the right direction. Thank you.


How do I make pagination_links show as 01 02 03, instead of 1 2 3?

Based on: http://codex.wordpress.org/Function_Reference/paginate_links how to make these links show as 01, 02, 03... rather than the normal single digit? thanks so much


How to filter a wordpress core function?

I would like to change the text in the wp media uploader. I managed to find the function at the media.php and i tried to using the filter to change the text like this:               function uploader_text() {     remove_action('post-html-upload-ui', 'media_upload_html_bypass' );     ?>
     <?php _e('mytext here'); ?>
     <?php     }       add_filter('post-html-upload-ui', 'uploader_text');      But I failed to do so. What I done wrong? **Update:** This is how I tried The related function in wp is like this:
                 <?php do_action('pre-html-upload-ui'); ?>
                         <?php _e('Upload'); ?>                         <input type="file" name="async-upload" id="async-upload" />                         <?php submit_button( __( 'Upload' ), 'button', 'html-upload', false ); ?>                         <?php _e('Cancel'); ?>

                 <?php do_action('post-html-upload-ui'); ?>
                       function media_upload_html_bypass() {                 ?>
               <?php _e('You are using the browser’s built-in file uploader. The new WordPress uploader includes multiple file selection and drag and drop capability. Switch to the new uploader.'); ?>
                 <?php             }             add_action('post-html-upload-ui', 'media_upload_html_bypass');      The text that i need to change is in media_upload_html_bypass() :               <?php _e('You are using the browser’s built-in file uploader. The new WordPress uploader includes multiple file selection and drag and drop capability. Switch to the new uploader.'); ?>      So I tried :               function uploader_text() {                          ?>
                     <?php _e('here is what i want to change the text.'); ?>
                          <?php                          }                  add_filter('media_upload_html_bypass', 'uploader_text');      Still not working.


videopress videos are not displayed when loading the content with ajax in a lightbox

I'm using videopress and I'm adding the videos into posts with the videopress shortcode, and when I visit the post I can see the videos and play them, but the problem is when loading the post with ajax and place just part of the content that contains the video in a lightbox, the videos are not displayed, someone can help me with this?, is it a problem with ajax when loading just part of the content?, thanks.


Comments from other blogs are getting added to my blog?

Today I started receiving a ton of requests to moderate comments on my blog, but when I looked at the comments they are clearly from multiple other people's blogs. What could be the cause of this and what do I do about this?


First post full width, rest in two columns

Here is my loop               <?php if ( have_posts() ) : ?>                  <?php /* Start the Loop */ ?>          <?php $i = 0; while ( have_posts() ) : the_post();  ?>         <?php if ($i++ == 0) : ?>
             <?php get_template_part( 'content', get_post_format() ); ?>
              <?php else: ?>
             <?php get_template_part( 'content', get_post_format() ); ?>
              <?php endif; ?>     <?php endwhile; ?>      and my css               .entry-content-rest {         width: 48.5%;         float: left;         border: 1px solid #ddd;         border-radius: 7px;         }      This displays my content as follow               Post1          Post2      Post3          Post4      Post5      My problem is, say post 2 is longer (have more contents) than post 3, then my columns is displayed way wacky like this               Post1          Post2      Post3          open       Post4          Post5      Post6      Any suggestions to fix this


Why is the Settings API is not saving my array of options

I am writing a set of classes to easily create options pages accessible via submenus of the standard WordPress menus and a way to easily create options for said menus. The way I am wiring it is via a settings class which you pass settings to and I intend to have it work along with a submenu class to create the menu, settings page and store the options neatly in a single option. The option is getting created in the database -- but nothing is being stored in the option. Can anyone lead me in the right direction? Here is my code: ## Settings Class               class settings_page {         public function __construct($args){             foreach($args['sections'] as $section){                 $section_name = $section['section_name'];                 $section_id = $section['section_id'];                 if( false == get_option( $section_id ) ) {                          add_option( $section_id );                   }                  $options = get_option($section_id);                 $section_text = $section['section_text'];                 $page = $section['page'];                 add_settings_section($section_id, $section_name, function(){return $section_text;}, $page);                 foreach($section['items'] as $item) {                     $type = $item['type'];                     $id = $item['id'];                     $description = $item['description'];                     $title = $item['title'];                     $choices = $item['choices'];                     if ($description) $title = $title . '
' . $description . '';                     switch($type){                         case "checkbox":                             add_settings_field($id, $title,                                      function ($section) use ($options) {                                         $id = $section[0];                                         $html = '<input type="checkbox" id="' . $id . '" name="' . $id . '" value="1" ' . checked(1, $options[$id], false) . '/>';                                           echo $html;                                       },                             $page, $section_id, array($id));                         break;                         case "text":                             add_settings_field($id, $title,                                      function ($section) use ($options) {                                         $id = $section[0];                                         unset($html);                                         $html .= '<input type="text" id="' . $id . '" name="' . $id . '" value="' . $options[$id] . '" />';                                           echo $html;                                       },                             $page, $section_id, array($id));                         break;                         case "textarea":                             add_settings_field($id, $title,                                      function ($section) use ($options) {                                         $id = $section[0];                                         unset($html);                                         $html .= '<textarea class="large-text" cols="50" rows="10" type="text" id="' . $id . '" name="' . $id . '">' . $options[$id] . '</textarea>';                                           echo $html;                                       },                             $page, $section_id, array($id));                         break;                         case "pulldown":                             add_settings_field($id, $title,                                      function ($section) use ($options) {                                         $id = $section[0];                                         $choices = $section[1];                                         $value = $options[$id];                                         unset($html);                                         $html = '<select id="' . $id . '" name="' . $id . '">';                                         $html .= '<option value=""> - Select - </option>';                                         foreach($choices as $key=>$val){                                             $selected = '';                                             if ($value== $key) $selected = ' selected="selected" ';                                             $html .= '<option value="' . $key . '"' . $selected . '>'.$val.'</option>';                                         }                                         $html .= '</select>';                                              echo $html;                                       },                             $page, $section_id, array($id, $choices));                         break;                                       }                      }                 register_setting($page, $section_id);             }                  new submenu(array(                 "parent" => $args['parent'],                 "title"=>$args['title'],                 "text"=>$args['text'],                 "capability"=>$args['capability'],                 "slug"=>$args['slug']                  ));              }     }      ## Submenu Class               <?php          class submenu {              function __construct($args=""){                 $parent = strtolower($args['parent']);                 $title = $args['title'];                 $text = $args['text'];                 $capability = $args['capability'];                 $slug = $args['slug'];                      switch($parent){                     case 'dashboard':                          $name = "index.php";                         break;                     case 'posts':                         $name = 'edit.php';                         break;                     case 'media':                         $name='upload.php';                         break;                     case 'links':                         $name='link-manager.php';                         break;                     case 'pages':                         $name='edit.php?post_type=page';                         break;                     case 'comments':                         $name='edit-comments.php';                         break;                     case 'appearance':                         $name='themes.php';                         break;                     case 'plugins':                         $name='plugins.php';                         break;                       case 'users':                         $name='users.php';                         break;                       case 'tools':                         $name='tools.php';                         break;                       case 'settings':                         $name='options-general.php';                         break;                       default:                         $name='options-general.php';                         break;                   }                 add_action('admin_menu', function() use ($name, $title, $text, $capability, $slug) {                              add_submenu_page(                               $name,                                               $title,                                       $text,                                               $capability,                                         $slug, function() use  ($name, $title, $text, $capability, $slug) {                            ?>

<?php echo $title; ?>
                                       <form method="post" action="options.php">                                           <?php settings_fields( $slug ); ?>                                           <?php do_settings_sections( $slug );?>                                             <?php submit_button(); ?>                                       </form>
                                 <?php                             }                              );                     }                 );                            }         }      ## Here is where I am actually calling the classes/methods               add_action('admin_menu',          function() {             $options['parent'] = "settings";             $options['title'] = "My Settings";             $options['text'] = "My Settings";             $options['capability'] = "manage_options";             $options['slug'] = "my_settings";                  $settings['section_name'] = "General Section";             $settings['section_id'] = "general_section";             $settings['section_text'] = "This be General Section Test";             $settings['page'] = "my_settings";             $settings['items'] = array(                 array(                     'type' => 'checkbox',                     'id' => 'show_header',                     'title' => 'The title, to show header',                     'description' => 'show the header now please',                     ),                 array(                     'type' => 'textarea',                     'id' => 'show_footer',                     'title' => 'The title, to show footer',                     'description' => 'show the footer now please',                     ),                   array(                     'type' => 'text',                     'id' => 'text_item',                     'title' => 'Enter anything here',                     'description' => '',                     ),                           array(                     'type' => 'pulldown',                     'id' => 'which_one',                     'title'=>'Who\'s on First?',                     'description'=>'',                     'choices'=>array(                             '1'=>'Who',                             '2'=>'What',                             '3'=>'Why',                         )                     ),                 );             $settings2['section_name'] = "Second Section";             $settings2['section_id'] = "second_section";             $settings2['section_text'] = "More Settings";             $settings2['page'] = "my_settings";             $settings2['items'] = array(                 array(                     'type' => 'checkbox',                     'id' => 'show_header_2',                     'description' => 'Show Second Header',                     'title' => 'Show the Second Header?',                     ),                 array(                     'type' => 'textarea',                     'id' => 'show_footer_2',                     'description' => 'Tell me a story',                     'title' => 'It can be about anything!',                     ),                   );                  $options['sections'][] = $settings;             $options['sections'][] = $settings2;             new settings_page($options);         }, 1);      What works: It works if I change **$options[$id]** to **get_option($id)** but this saves each individual setting to its own individual setting in the database which is wildly inefficient. I've error_logged $page, $section_id right before the register_setting call and everything is as it should be which leaves me baffled. What doesn't work: saving these settings to a serialized array :) I'm happy to provide anything else that can help you help me. Thanks.


Echo Parent of Current Pages

I'm using the above code to display sub-pages of the parent (even when the user is on that page). However, this code does not display the parent itself. I tried adding `$subpages = wp_list_pages('title_li=&include='.$id.'&depth=1&echo=0');` but to no avail.               <?php if ( // Maybe you want different conditionals?             (is_page() && ! is_front_page())             || is_category()         ) {             $id = get_the_ID();             $ancestors = get_ancestors($id, 'page');             if (! empty($ancestors)) $id = $ancestors[count($ancestors)-1];             $subpages = wp_list_pages('title_li=&child_of='.$id.'&depth=1&echo=0');             if ('' !== $subpages) {                 echo '
'.PHP_EOL                     .$subpages                     .'
'.PHP_EOL;             } } ?>          <?php $categories = get_the_category();     $catli = '';     if (!empty($categories)) { foreach($categories as $category){         $parent = $category->parent;         if($category->parent != 0){           $catli .= wp_list_categories("child_of=$parent&title_li&echo=0");         }       }       if (!empty($catli)) {         echo '
'.$catli.'
';       } } ?>


How to dynamically change spots of text in custom page?

When I create a page I'm suppose to describe the content on the editor of Wordpress. When it's a simple text with some images its ok. **But the problem is:** My custom layout has a lot of _deep HTML_ and I want to allow the client to change the dynamic text parts easily, and avoid him from having HTML parts inside the rich text editor. E.g. ![enter image description here](http://i.stack.imgur.com/yu2KK.png) Wordpress has some built-in feature to accomplish that or some plugin maybe? An similar idea is this plugin that I've found, but not for pages specifically: http://wordpress.org/extend/plugins/text-replace


Insert menus in the database

I want to create a large menu structure, and the admin pages time out, so I cannot insert them via the admin screens. How can I insert the menu entries directly in the database? Thank you


Send email for confirmation during user registration

I am very new to WP.How does a confirmation mail is sent during user registration.Is there any services being worked out here. is this a free service using php for any plugin.


Post type archive page not working

I registered a custom post type using Custom Post Type UI, and created an archive page and named it archive-recipe.php, 'recipe' is my custom post type name. But its not working, instead its using the default `archive.php`. I set the `has-archive` to `true` but still not working. How to fix that? Here's the code:               register_post_type(         'recipe', array(     'label' => 'Recipe',         'description' => 'This is a Recipe Custom Post Type',         'public' => true,         'show_ui' => true,         'show_in_menu' => true,         'capability_type' => 'post',         'hierarchical' => true,         'rewrite' => array('slug' => ''),         'query_var' => true,         'has_archive' => true,         'exclude_from_search' => false,         'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),         'labels' => array (               'name' => 'Recipe',               'singular_name' => 'Recipe',               'menu_name' => 'Recipe',               'add_new' => 'Add Recipe',               'add_new_item' => 'Add New Recipe',               'edit' => 'Edit',               'edit_item' => 'Edit Recipe',               'new_item' => 'New Recipe',               'view' => 'View Recipe',               'view_item' => 'View Recipe',               'search_items' => 'Search Recipe',               'not_found' => 'No Recipe Found',               'not_found_in_trash' => 'No Recipe Found in Trash',               'parent' => 'Parent Recipe',         ),         )     );


Update functions.php from Wordpress dashboard

I'm sure this isn't possible but I thought I would ask. In my functions.php file I have a wp_mail function that sends an email to moderators when posts are made. This email is sent to number of different address - these addresses might change. I thought it would easier to set these email addresses in the WP Dashboard something like on custom page and then have functions.php update with the new emails. Is this possible?


Need help with restricted page for users

I have 3 pages and i want one of the three to be restricted for normal users. I want there to be members, who only can view the page after they have been approved by the admin. To view the page i want them to 1. Register 2. get approved by the admin 3. able to view the page. Is there a plugin for this? or any solution of any kind? Thanks in advance.


Things to take care when moving from hosted wordpress to self-hosting

I have a hosted free wordpress blog. Now I am thinking to move that blog to self-hosting. What I already have /know/tried: 1: I have a domain name purchased from a companyA. 2: I have hosting accounts Linux as well as ASP.NET with the same companyA. 3: From the cPanel of companyA I can go and install wordpress. I tried that for test and it was pretty fast process. 4: I read that I can simply go to my current blog and Export everything and Import it to my self-hosted website. I have currently 30 posts. The Wordpress Stats shows from 200 to 500 views/day. I don't even know if that's a bad or good number. My questions/concerns: 1: Should I host on my Linux hosting account or Windows Hosting Account? Is there any pro/cons one over other? 2: Should I be concerned about page rankings /SE etc. when transferring the blog. (newbie to this and I want to learn that, one of the reason I am moving to self-hosting...learn) 3: I read this article and so I understand step 1-2. What I don't understand is, with Domain Mapping service, how long do I need to pay for it? Like a year or foreever? EDIT: I think now they have a Site Redirect upgrad option. So is that what I should be doing now? Any other suggestions welcome.


Basic File/Post restriction plugin

I am looking for a plugin that allows me to restrict access for a individual post/page to a specific role or individual. It also needs to restrict files attached to that post. I have tried several but none seem to have this complete combination or just dont work. What is the best plugin to achieve this or will I have to roll my own? I have tried:   * Role Scoper    * Members    * User Access Manager


Problems with the_time,the_date, get_the_time

I have som problems with the date functions in wordpress. I am trying to get different format on the post date on some pages and i have been trying "the_date()","the_time()" and "echo get_the_date()". They all behave in the same way. They output the correct date format when i just type for example the_time(). The output is the format i had setup in wordpress settings, as expected. The problems is that when i try to format the output by ex: the_time('d') the output is "d" or echo get_the_time('F j, Y'); the output is "'F j, Y'". I forgot to mention that the code is inside "the loop" This is my page.php               <?php get_header();?>     <?php get_sidebar('subnav');?>
     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title();?>
     <?php the_content();?>     Publicerades den <?php echo get_the_date('d');?>          <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>
     <?php get_footer();?>          I cannot understand what the problem is, please help!:)


Exclude a category of posts in author template

I'm using the following author archive code:               <?php     /**     * The template for displaying Author Archive pages.     *     * @package Cryout Creations     * @subpackage Parabola     * @since Parabola 1.0     */          get_header(); ?>              <section id="container" class="<?php echo parabola_get_layout_class(); ?>">
             <?php cryout_before_content_hook(); ?>                  <?php if ( have_posts() ) : ?>                      <?php                     /* Queue the first post, that way we know                      * what author we're dealing with (if that is the case).                      *                      * We reset this later so we can run the loop                      * properly with a call to rewind_posts().                      */                     the_post();                 ?>
<?php printf( __( 'Author Archives: %s', 'parabola' ), '' . get_the_author() . '' ); ?>
                                       <?php                     /* Since we called the_post() above, we need to                      * rewind the loop back to the beginning that way                      * we can run the loop properly, in full.                      */                     rewind_posts();                      // If a user has filled out their description, show a bio on their entries.                 if ( get_the_author_meta( 'description' ) ) : ?>

                         <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'parabola_author_bio_avatar_size', 60 ) ); ?>

<?php printf( __( 'About %s', 'parabola' ), get_the_author() ); ?>
                         <?php the_author_meta( 'description' ); ?>

                 <?php endif; ?>                      <?php /* Start the Loop */ ?>                 <?php while ( have_posts() ) : the_post(); ?>                          <?php                         /* Include the Post-Format-specific template for the content.                          * If you want to overload this in a child theme then include a file                          * called content-___.php (where ___ is the Post Format name) and that will be used instead.                          */                         get_template_part( 'content/content', get_post_format() );                     ?>                      <?php endwhile; ?>                      <?php if($parabola_pagination=="Enable") parabola_pagination(); else parabola_content_nav( 'nav-below' ); ?>                  <?php else : ?>

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

<?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'parabola' ); ?>
                         <?php get_search_form(); ?>

                  <?php endif; ?>                  <?php cryout_after_content_hook(); ?>
         <?php parabola_get_sidebar(); ?>
               <?php get_footer(); ?>      I need to exclude a category from the author page. However I can't get this to work. If added               query_posts (query_posts( 'cat=-x' ); where x is category to skip),       instead of looping through posts I always see one single/same post which is not of selected category. Any suggestions, why this might not work?


Wp_list_pages not showing children with custom page template

I seem to be having problems when using custom page templates using `wp_list_pages`.   These pages are always displayed at the bottom of the website in a menu. The problem is, that they should have a collapsible menu with the children in them, but the children are not showing. These children do not have the same template type as the parents, which is the cause of my problem, I guess. Below you can find how I call `wp_list_pages`. It does fetch and display the parents correctly, but not the children.               $brands = wp_list_pages(array('title_li' => '',         'post_type' => 'page',         'meta_value' => 'brands.php',         'lang' => $GLOBALS["pll_language"],         'showposts' => 20));      Any thoughts on how I can resolve this? **EDIT** This is an example of the structure of the pages.   * Nike      * Shoes        * Shoe 1       * Shoe 2       * Shoe 3     * Shirts     * Sunglasses   * Brand 2   * Brand 3   * etc... until brand 9 But shoe 1 could be removed at any time and shoe 4 can be added at any time. Since I don't want to update the menu all the time, I only want to have to add "Nike", "Brand 2" to the menu and all the other pages would have to load automatically. Any ideas?


404 not found error on pagination

Normal post (not custom post type), I did everything I should do, but 404 not found error in pagination. Here is my code               $category_id = get_query_var('cat'); //Using this to get category ID to meet some special requirements             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                  $args = array(                 'posts_per_page' => 4,                 'numberposts'    => 50,                 'paged' => $paged,                 'cat' => $category_id             );                  query_posts($args);             if ( have_posts() ) : while ( have_posts() ) : the_post();              $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );             ?>

<img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image[0]; ?>&w=224&h=224&zc=1" />

<?php  $category = get_the_category(); echo $category[0]->cat_name; ?> : <?php the_title(); ?>

<?php the_date(); ?>

<?php the_excerpt(); ?>

<a href="<?php the_permalink(); ?>"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/readmore.png" />

             <?php endwhile;              wp_reset_postdata();             else: ?>
<?php _e('No posts found'); ?>
              <?php endif; ?>

<?php next_posts_link('next »') ?>

<?php previous_posts_link('« previous') ?>

      I need your suggestion.


Use stylesheet from a different location

I haven't done wordpress development in quite some time so it looks like some things have changed (naturally). I'm using codekit to compile my themes sass files and minify my scripts as well. It requires that all files have a specific output path, in other words I can't specify that the style.scss file should compile to a style.css file in the root directory. It has to go into a folder of some sort relative to the root folder, like a /css folder. So in googling around trying to see if there was a way to tell wordpress to look into the /css folder and look for a file called site.css I found this code I can add to my functions.php file...               add_filter('stylesheet_uri','wpi_stylesheet_uri',10,2);          /**      * wpi_stylesheet_uri      * overwrite default theme stylesheet uri      * filter stylesheet_uri      * @see get_stylesheet_uri()      */     function wpi_stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri){              return $stylesheet_dir_uri.'/css/site.css';     }      Now if I'm not mistaken it looks like I have to call that function? But when I try to call it, say in my header.php I get an error. To summarize I am looking for the preferred way to change where wordpress looks for my themes stylesheet.


How to make a drop down menu with categories

I'm building a website in which there is a navigation menu with various links; in this menu there is the link to the blog section. My goal is to create a drop down menu that appears when the cursor is passed over the blog link; this link has to show the list of the categories. A few days ago I found this useful tutorial: But it creates another link called "Categories" in which appears the categories drop down menu; therefore how can I adapt that code in my case?


Using Advanced Custom Fields with Wordpress and Lightbox

I am using the ACF Plugin. I want to have a field where I can upload an image, and the result will display the full image in the Lightbox and then then full image will be resized into a thumbnail from that field (like a normal Lightbox). So far I have the script here, and this is where I am at:
     <a href="<?php echo the_field('image_gallery'); ?>" rel="lightbox" title="<?php the_title(); ?>">          <?php     $main_car_pic = addslashes(the_repeater_field('image_gallery'));     $reg_ext = "#.jpg#i";     $thumb_ext = "-150x150.jpg";     $car_thumb = preg_replace($reg_ext, $thumb_ext, $main_car_pic);          echo $car_thumb     ?>      The ACF Repeater field isn't working properly and I cannot work why, does anybody have any experience with ACF and resizing images for thumbnails.. Hope what code I have done helps and I'll be really appreciate it, if nto comment and I can supply anything that might help.


Is there a way to include some external script to some or all pages in a wordpress site?

My current requirement is to stick a countdown timer on the top of every page or on the side of all pages. But since i get too many requests like this, i was looking for a technique with which i can include some external javascript or jquery plugin or maybe some HTML code forced upon a particular location on some/all pages. Has anybody ever done this?? For my requirements, i have found some plugins for countdown timers but they would only create a sidebar or a post. What i had in mind that i would create a div with an iframe inside pointing to countdown page and will stick this div on the top of the page through CSS. But i wanna know if there is any standard way of doing such things.


Shortcode for Admin Theme Option?

I am trying to create a shortcode for 2 of my theme option. Basically I want to grabe my theme options to my shortcode so that I can display them anywhere on my posts something like this:               [ads_1] [ads_2]      However when I tried to get the options on my shortcode it wont work at all and its giving me an error > Parse error: syntax error, unexpected 'theme_settings' (T_STRING) in > C:\xampp\htdocs\themewp\wp-content\themes\bots_final\shortcodes.php on line > 86 Here's my snippet for my shortcode where in I am trying to grab my theme option data:               add_shortcode('ads_1', function($atts){         return '         <div>             <?php $options = get_option( 'theme_settings' ); ?>             <?php echo $options['banner1']; ?>         </div>';          });      I am trying to grab the options from my Theme options page. Check my theme options code:               <div>     <?php $options = get_option( 'theme_settings' ); ?>     <?php echo $options['banner1']; ?>     </div>      Any idea what's the problem why I can't grab it?


Editor stripping out data attribute when saving

I am on the Text version of the page editor on the backend and whenever I try to use something like `<div data-100="1500"></div>` and click the update button the data section is stripped out an it returns `<div></div>`. I searched around for a bit and all I could find was reference to the Raw HTML plugin but honestly I dont want to be committed to a plugin. Is there anyway to remove this functionality to allow me to use some data attributes? Thanks in advance


mysql query paging

Hi I have made an sql query that gets several posts according the parameters that i've selected. I'm showing these posts but the inner paging within wordpress doesnt do anything. It shows me that there are more pages but when i select the page number it shows me the same results as before. That makes sense because it probably runs the sql query again. I'm using WordPress and BuddyPress. How can i page between these query results? UPDATE: here is the code im using               $sql = "SELECT post_title, post_date, post_excerpt, guid, ID FROM wp_posts,wp_term_taxonomy, wp_terms, wp_term_relationships WHERE (post_status = 'publish' or post_status = 'inherit') and wp_term_taxonomy.term_taxonomy_id = ".$cat." and wp_posts.ID = wp_term_relationships.object_id and wp_terms.term_id = wp_term_taxonomy.term_taxonomy_id and wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and wp_term_taxonomy.taxonomy = 'category' ORDER by post_date DESC";     $matching_posts = $wpdb->get_results($sql,OBJECT);     <?php if ( have_posts() ) : ?>            <?php foreach ($matching_posts as $post): ?>       <?php setup_postdata($post);      then im showing the info i want like title.


How to pass data from page to widget functions?

I need help,need to pass data from page,to widget function,I need to pass author id to widget,any idea? Tnx


How can I set a draft page as parent without publishing?

Anyone know a way round this? http://wordpress.org/support/topic/set-draft-page-as-parent I can't risk publishing as a public-facing system updates periodically from the same install.


My wordpress multisite homepage redirects to signup page

So I just setup my website `fightify.com` and as you will see, visitors are automatically redirected to a signup page, which shouldnt be happening. This only occurs if the domain is typed without the www. prefix. `www.fightify.com` yields no errors. I have a feeling that it has something to do with the .htaccess file, but I'm no coder, and have no idea how to fix it. Has anybody seen this happen before?


How to support custom templates on a custom post type?

I'm stucked at some point developing my theme. I created a custom posts types to support an image gallery. So far, it's working great (have a look on 'galeria' on psaikali.com). I registered this custom post type (register_post_type( 'artwork', $args )) and activated the 'page attributes' function, to define a different template for my posts ('supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields' )). But it just shows the 'order' of the page, not the 'template selection' part. Does anyone knows what's wrong ? I did create the template file called single- artwork.php ... Screenshot of the page attributes page I see : http://img213.imageshack.us/img213/5348/notemplate.jpg Thanks for the help !


Wordpress Query Posts From Category Post on Static Page

So I'm trying to query some posts from 1 category only and it does seem to be working. I tried get_post() also but no luck and after awhile I just caved and used query_posts (which is apparently bad practice). Here's my code:

                     <?php query_posts('slug=cat1'); ?>                     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                                 <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">                                     <?php the_title(); ?>
                              <?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>

                                 <?php the_content(); ?>

                     <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
                     <?php endif; ?>

      The second `endif;` is from above I have a test against the page slug. But from my understanding the query_posts should populate $post with all the posts from that category but I'm still getting posts from uncatagorized and another category so it's not filtering at all... Suggestions? **Edit1** I tried using `cat=0` and `cat=1` also `cat=2` but the only one that actually filters is the `cat=1` which filters to uncategorized. All the others show all posts. Not sure why... **Edit2** `query_posts( array ( 'category_name' => 'Category1', 'posts_per_page' => -1 ) );` returned with the "else" statement saying there was no posts and nothing fit my criteria. I pulled that straight from the codex?


Conditional custom menu?

I'm trying to create a custom menu that displays a `<li></li>` when a user is logged in, and not display it when they're not. I have this so far, but it's not working. Does anyone know how to do this properly?               add_filter('wp_nav_menu_items','custom_nav_items',1,2);     function custom_nav_items($menu, $args) {     global $bp;     $args = (array)$args;     if ( $args['theme_location'] != 'primary' )         return $menu;     $customNav = '
loggedin_user->domain .'">'. $bp->loggedin_user->fullname .'

loggedin_user->domain .'">View Profile

loggedin_user->domain .'profile/edit/">Edit Profile

loggedin_user->domain .'settings/">Edit Settings
'     if ( is_user_logged_in() ) {         '
Logout
' }     '

';     return $menu.$customNav;     }


update_user_meta: How many is too many?

I am working on a community portal that may in future cater to extremely large user base. All users have about 50 settings that needs to be stored to the user meta. These settings would be frequently accessed and overwritten with new values when the user saves changes to their profile. This would lead to extremely large number of calls to update_user_meta courtesy: large user base and large number of settings per user. Would these high number of calls to update_user_meta cause any performance degradation? An alternative that I see, would be to write the user settings to an array and subsequently store the array to user meta using a single call to update_user_meta. Which of the two appears to be a better solution? Regards John


Link from tags to tag pages displaying all posts with that tag

`<a href="<?php echo get_tag_link($tag->id); ?>"><?php echo $tag->name; ?></a>` I was using this to try to list the first tag for a post, and make it so that when you click on that tag you go to a page which lists all of the posts with that tag. Instead, when you click the link it just refreshes the page. I tried going directly to one of our tag pages and it exists but it's totally empty. How do I get each tag to link to it's tag page and how do I populate tag pages with posts?


Only allow one login session to be active at a time

Is there any way to restrict accounts to login only once at the same time? Ex. Mike bought a subscription from my website and also lent it to his friend John. What I want to achieve is preventing Mike login if John is already logged in and the opposite. Is this possible?


pageYOffset problems in WordPress? Works on code playground, not on dev site

I am hoping someone will have some insight into my jQuery conundrum. I'm trying to implement a fairly simple script to add/remove a class to my navbar. I've mocked up a codepen here: http://codepen.io/anon/pen/Inmpb On scrolldown, a class is added to the navbar, so that I can target it. It works as expected on codepen, but I cannnot get it to work on my dev site. For the codepen, I simply copied and pasted the entirety of my html and css and then added my script and, there, it worked as expected. I have tried wrapping the script in the document ready function for wordpress: jQuery(document).ready(function($) { // function here }); I have tried adding the script directly to the footer. I have tried to enqueue it via functions.php. It simply doesn't work on my site. I just changed to twenty-fourteen and deactivated all plugins. Still no luck. However, I did try an even more simple script: http://pastebin.com/XJh2Bbvm and that did work, the class was added. I have no idea what I could be missing.


Strip hashtag off permalink with php

I use the_permalink() to pass the current page to the facebook like button. But when one goes directly to a comment link with a hashtag, such as example.com/post#comment1, it's considered a separate link and FB likes are counted separately. How can I have the_permalink() point to just example.com/post and strip the #comment1?


How to get blog-id of an MU site from functions.php

How can one determine, from functions.php, the blog-id of the site (or alternately, the path to the media directory)?


How to test for MU via functions.php?

What is the call to determine, from a theme's functions.php whether the site is an MU site or not? Updated with answer:               $dir =       is_multisite() ? 'wp-content/blogs.dir/'.$current_site->blog_id.'/files/'       : 'wp-content/uploads/';


new page sidebar-template by default

Using twenty-eleven theme, need to change default template for new page from standard to sidebar. anyone?


Plugin to Link Posts by Title

I'm looking for a plugin that will allow me to link to posts by title. That is, when I click the link icon in the editor (or some other icon), instead of entering a URL, I get a drop-down of posts to link. I select one, press okay, and tada! Link is done. I also expect that the link looks at the ID; so if I change the target page's title, post-slug, or any other features that may be in the permalink, the link is "smart enough" to still link the correct page. Does anything like this exist out there? I couldn't find anything.


Is it possible to know which category page the post was linked from?

For example, I have a post that's filed under category 1 and category 2. When someone clicks on it from category 2, I want to know the slug for category 2. If it links from the category 1 page, I want to know the category 1 slug. Is this even possible?


Can't get pagination to work for sticky posts only

I don't get my pagination to work. I need to filter my posts on sticky posts and display only two per page. Tried almost everything but can't get it to work. It is totally ignoring my posts_per_page setting. Anyone got a suggestion?               <?php query_posts(array('posts_per_page' =>2, 'paged' => get_query_var('page'), 'post__in'=>get_option('sticky_posts'))); ?>              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                          <?php the_content(''); ?>          <?php endwhile; ?>          <?php else : ?>          <?php endif; ?>              <?php next_posts_link('« Older Entries'); ?>         <?php previous_posts_link('Newer Entries »'); ?>


Automatically add paragraphs in long string

I have posts ported from VBulletin. I had to stripp all VBulletin tags so now I have long strings of text with no line breaks or any **br** or **p** tags. How can I add a **br br** instead of each 7-th dot for example? I would also prefer a conditional depending on the date created, because the new posts will be ok :)