Why do themes have `while( have_posts() )` in templates like single.php?

Example: https://github.com/markjaquith/WordPress/blob/master/wp- content/themes/twentyeleven/single.php Isn't single.php's purpose to show single posts?


Edit custom HTML page from WP admin dashboard

I needed to make custom HTML page in root which will not use default wordpress theme and show content and I linked it on menu as custom links. So in front end everything perfect. But this page is not part of wordpress and I am not sure if it will harm SEO or something. Is there any way plugin or something so text on this pages can be edited from dashboard. Is there any way so this page to be covered with wordpress sitemap.xml, SEO settings and plugins, and chaching plugins


is there a simple way to list every templates / php files used to generate a specific page?

To customize a theme , it is not always easy to trace every files that are used and find out which one do what . For example i' like to find out how my menu is generated so i can add some conditions to it , and also change the display. Is there a way to find out all the files loaded ? which header is used ...etc... maybe put a bit of code somewhere in the autoload sytem? or using firebug?


Parent page for CPT

Alright, there's been numerous topics about this, but it doesn't seem to work for me. I have one normal page, called "Resources". Then I have several Custom Post Types. One of wich is "Video's". I want "Video's" to be a child page of "Resources". At the moment, I can both access the video's page by the URL: http://site.com/resources/videos AND http://site.com/videos (they both work). My Videos CPT is as follows: function register_custom_post_video() {               $labels = array(         'name' => _x('Videos', 'videos'),         'singular_name' => _x('Video', 'video'),         'add_new' => _x('Add New Video', 'Video'),         'add_new_item' => __('Add New Video'),         'edit_item' => __('Edit Video'),         'new_item' => __('New Video'),         'view_item' => __('View Video'),         'search_items' => __('Search Videos'),         'not_found' =>  __('No Videos found'),         'not_found_in_trash' => __('No Videos found in Trash'),         'parent_item_colon' => ''     );          $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => array('slug' => 'resources', 'with_front' => true),         'capability_type' => 'page',         'hierarchical' => true,         'menu_position' => null,         'supports' => array('title','editor','author','excerpt','page-attributes')     );          register_post_type( 'videos' , $args );     }     add_action('init', 'register_custom_post_video');      But the rewrite doesn't seem to work. Also, when I resave the permalinks settings, it doesn't work. I use archive-videos.php as the page. Also, according to a WP Tuts+ quicktip, the > Therefore, to make a hierarchical custom post type, you have to have the > ‘page-attributes‘ set in the ‘supports‘ array and the ‘hierarchical‘ flag > set to true. I hope this was helpful to you as well! does not work either. Am I doing something wrong?


Removing capabilities from cloned admin role

I'm trying to create a new role within my wordpress theme that has almost all the same rights as an admin. Basically, it's a cross between Editor and Administrator. One of the issues I'm having is allowing the Editor to "see" the add custom image header submenu in Appearances. I either want to allow the Editor to see that submenu or create a new role that allows them almost all the same capabilities as an admin. I saw the below link on cloning a role but how do I go about taking capabilities away and finding out what those capabilities would be? http://wordpress.stackexchange.com/a/31472/7662 TIA!


Does BuddyPress Have An Action Hook for remove_user?

BuddyPress has a behavior for removing users that does not run through WP's `deleted_user` action. I have a hook in my plugin for `add_action('deleted_user', 'myScript');` but it only works for WP-related user deletes. It does not run when I remove a user in BuddyPress. Has anyone hooked to the BP remove user action in their plugin? If so, what is the action to catch? Thanks!


Force WordPress 3.3 to use Flash uploader

Is there any way to force WordPress 3.3 to use the old Flash uploader instead of the new HTML5 version? (you can read below if you care about why I want to do this...) I'm working with someone on WordPress 3.3 whose image uploader occasionally freezes when bulk uploading large numbers of images. I've tried troubleshooting every way I could think of and can't find a solution. He never had this problem before upgrading to WordPress 3.3, so I'm wondering if it is an issue with the HTML5 uploader. He doesn't want to use the old browser uploader because he does lots of bulk uploading, so I'd like to find a way to force WordPress to use the Flash uploader.


Wordpress doesn't recognise created theme

I just started creating new theme in wordpress, I got the html/css, I put the heading in css like usual:               /*     Theme Name: Your Theme Name     Theme URI: http://your-theme-homepage.com     Description: Oh what a lovely description of your theme you'll put here!     Author: Your Name     Author URI: http://your-website.com     Template: If this is a child theme, you'll set the template theme's folder name here     Version: 3.1     Any general information, license statements, plugin requirements, or any other information you           might want to share.               */      and html site in the same directory. Wordpress doesn't recognise the theme and I get error like > Broken Themes > > The following themes are installed but incomplete. Themes must have a > stylesheet and a template. > > Name Description Wp_theme Stylesheet is missing. or something similar. What is EXACTLY the requirement for wordpress to register theme in directory? Is it just css heading or something else must be added? Thanks


Adding google authenticator and use only email address of user

I think most of you have seen SO way of authenticating. SO uses only ask for email address through Google Authentication. Can this feature be applied to a wordpress site.. like allowing users to give only their email and no password since the user will only have the ability to view the content, we dont't need users to provide passwords, so just email is sufficient for identity.. Is their any plugin to achieve this? If not a little help with StackExchange team how do they implement that signup from google resources..


List most recent image uploads, but only for specific custom post type

I can get a list of the most recent image attachments like so:               $attachments = get_posts( array(         'post_type' => 'attachment',         'posts_per_page' => $number,         'post_mime_type' => 'image'     ) );      This returns all images that have been recently uploaded, whether they are attached to a post or page, or unattached through the Media menu. What I'd like is to limit that list to only images that are attached to a custom post type I've created. (The custom post type is not that important; the same question could be: 'only images attached to Posts' or 'only images attached to Pages.') I realize I could test each image after running the above query and eliminate any whose parent is not the right post type, but I want to return a specific number of images (`$number`), and this method could eliminate some or all of the returned images!


Hide parts of the post content after typing it's name or searching it by category

Code "nohome" worked for displaying wanted (hided'n'waiting) content on home page (just postname and image) How it could be adjusted or modified to make the same after name of post has been typed in searchbox or searched by Categories? (At the moment the result of that 2 actions is simply = display whole founded posts) Sincerely Jacob


Common abstract class for plugins

I have a few plugins and intend to move them to a very common base with an abstract class. The issue is that even if I apply solutions in order to avoid class duplications ( like EarnestoDev's answer for #31034 ) the system could end up with different versions of the abstract class if more of my plugins are present. In order to avoid this I should update all my plugins when the abstract class is updated, but that seems to be an overkill. Is there any other way to include classes only for a specific plugin rather than using namespaces?


Sell photos through Wordpress

I have an existing photo blog, which displays photos with width of 670 pixels. I'd like to sell higher resolution photos from the same page the lower resolution photo is displayed. Does anyone know of a way to do this? I'm thinking something as simple as using WP E-Commerce could do the job. I just create a catalog of high resolution images, and add a link to the product page on the blog post. Can you see that working?


$ not defined using jQuery in Wordpress

I know that jQuery is loaded, because I can switch out the $ for 'jQuery' and everything behaves as expected, but this will be a messy script if I can't fix this This script:               jQuery(document).ready(function(){         $("ul.vimeo_desc_feed li a").click(function(){             alert($(this).attr('href'));             return false;         })          });      Produces the error **$ is not a function** This script:               jQuery(document).ready(function(){         jQuery("ul.vimeo_desc_feed li a").click(function(){             alert(jQuery(this).attr('href'));             return false;         })          });      works fine.


Wordpress Lightbox plugin not working with jQuery

I have an image gallery set up and divided into about five sections. Everything works great w/ the Lightbox Gallery plugin at this point--click any image, the lightbox comes up, can scroll through, etc. However, each section has a large amount of images and I used a bit of jquery to make it where each section is collapsed and only when you click a section header do the images it contains appear. This works well, but once I include the script for jQuery in my WP page, it disables the Lightbox plugin somehow. Each image thumbnail that you click goes straight to that image's url rather than the lightbox view. One potential solution I've found is to write this right after the jQuery inclusion:               <script>jQuery.noConflict();</script>      ...and then replace each instance of $ w/ jQuery, so there's no conflict between jq and plugins. However, as this is a WordPress page I cannot include script snippets like this. Instead I tried placing that snippet at the top of my jQuery file (not jQuery itself, the section collapse code). Unfortunately, I'm still having the same issues. Does anyone know how I might be able to either use this solution effectively or does anyone know another possible way to deal with this problem? Thanks


Cannot get jQuery to work in WordPress

I had the following jQuery script on a static HTML page and it worked fine. However, when I enqueue it into WordPress it doesn't work. Here is the JS file.               $(window).scroll(function()       if ($(".navbar").offset().top > 50) {          $(".navbar-fixed-top").addClass("top-nav-collapse");       } else {          $(".navbar-fixed-top").removeClass("top-nav-collapse");       }     )};      And here is the functions.php               function hat_rack_media_scripts() {        //THEME CUSTOM STYLES AND SCRIPTS        wp_enqueue_style( 'hat-rack-media-style', get_stylesheet_uri() );        wp_register_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array('jquery'), '1', true );         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {         wp_enqueue_script( 'comment-reply' );         }     }     add_action( 'wp_enqueue_scripts', 'hat_rack_media_scripts' );      I feel like i included the file correctly, it is mapped to the right location, and it worked just fine in a static html page. Thanks.


Javascript not bring used in 3.8

I'm getting an issue on http://bollywoodbang.ca/wp/, it appears that my javascript files aren't working. I called them in functions.php using wp_enqueue_script(), and in the inspector says that the right files are getting called. However, the script that's in the files isn't being run. Am I missing something obvious? Ps: the files that aren't working is to re-create this affect for the gallery


Using jQuery safe mode in WP?

I am pretty new in WordPress and I know just a litle about jQuery and Javascript and I have the following problem: Into my **functions.php** file I load **jQuery** , the jQuery **FlexSlider** pluging (that create a slideshow) and another personal **jQuery** scripts file, in this way:               /* Function automatically executed by the hook 'load_java_scripts':      * 1) Load all my JavaScripts      */     function load_java_scripts() {              // Load jQuery:         wp_enqueue_script('jquery');         // Load FlexSlider JavaScript         wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true);         // Load scripts.js:         wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);     }     add_action('wp_enqueue_scripts', 'load_java_scripts');      Ok so the **FlexSlider** neeeds **jQuery** and in the last **scripts-js** file I have the following JavaScript:               /* Slider */     $(window).load(function() {      $('#main-slider').flexslider({          animation: "slide",          useCSS: false,          pauseOnHover: true      });     });      I don't know very well jQuery but I think that this script create my FlexSlider slideshow into the **#main-slider** div of my theme, this one (correct me if I am wrong):               <div id="main-slider" class="flexslider">         ...........         ...........         ...........     </div>      The problem is that if I execute the previous scripts into a simple pure HTML website all work well but if I put these scripts into a WP theme the slide show is not shown After a few hours of panic I found this documentation about the **jQuery no conflict mode in WP** : http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers So I have change the previous script that create my slideshow in this way (replacing the $ with the explicit jQuery function):               jQuery(window).load(function() {      jQuery('#main-slider').flexslider({          animation: "slide",          useCSS: false,          pauseOnHover: true      });     });      and now all work fine and the slideshow is shown. Reading the jQuery documentation related to how avoid conflict(http://learn.jquery.com/using-jquery-core/avoid-conflicts-other- libraries/) it seems to me that exist some other JavaScript framework different from jQuery that also use the **$** character and that the safe mode disable the use of **$** to avoid interpretation conflicts between Jquery code and other library code. And if I can't use **$** in my code I have to replace it using the explicit namespace* _jQuery_ *. Ok, in this WP documentations: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers show how continue to use $ even if jQuery is set in safe mode, and it do the following example: **ORIGINAL JQUERY FUNCTION THAT USE $** :               $(document).ready(function(){          $(#somefunction) ...     });      This function can't work if jQuery is setted in safe mode So if I want to use **$** and I don't want replace all **$** with **jQuery** in my code I can do:               jQuery(document).ready(function($) {         // Inside of this function, $() will work as an alias for jQuery()         // and other libraries also using $ will not be accessible under this shortcut     });      So it means that I have to replace the first **$** (before my ready() function) and the pass the $ symbol as parameter on my definied function, so in this function I can still use $ without replace it? Is this one the correct meaning?


why jquery never trigger

very simple think it was working before on my other project but now for this. i have no idea why.. i have simple drop down menu in wordpress. made via jquery and css.. actually everything fine... just if i add `<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> ` this to **before my js** then drop down menu working but if i don't use that then no work even fire bug show **TypeError: $ is not a function $('#menu- mainmenu li').hover(** but on my wordpress theme jquery already loaded on top i checked in view source it's show               <script type='text/javascript' src='http://localhost/LBW/site/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>      bellow is code               <?php wp_nav_menu( array('menu' => 'mainmenu','container' => false, 'menu_class'      => 'location ' )); ?>      JS               <script type="text/javascript">     jQuery(document).ready(function(){          $('#menu-mainmenu li').hover(         function () {             //show its submenu             $('ul', this).stop().fadeIn(300);              },          function () {             //hide its submenu             $('ul', this).stop().fadeOut(300);                   }     );          });     </script>      CSS               #menu-mainmenu  li {         position:relative;         z-index:500;     }     #menu-mainmenu  li a {     }     #menu-mainmenu  li a:hover {         color:#fff;         background-color: #09F;     }     #menu-mainmenu  a.selected {         color:#09F;     }     #menu-mainmenu  ul {         position:absolute;         left:0;         top:56px;         padding:0;         list-style:none;     }     #menu-mainmenu  ul li {         float:left;         font-size:11px;     }     #menu-mainmenu  ul a {         display:block;         padding: 6px 6px 6px 10px;         width:180px;         color:#FFF;         font-weight: normal;         background-color: #007575;     }     #menu-mainmenu  ul a:hover {         text-decoration:none;         background-color: #099;     }


FancyBox2 WordPress Plugin - Nearly Working

I have FancyBox2 installed. Clicking on an image launches the image in FancyBox as expected. What I'm trying to achieve though is the use of the button 'helper'. I've called the button function, and the helper buttons appear, but they just don't work. When I use the console feature within Chrome, I'm getting: "Uncaught TypeError: Cannot read property 'fancybox' of undefined" Regardless of the button I click on. The normal left and right and close buttons work fine, it's just the helpers. An example button within the helper looks like this: `<a class="btnPlay" title="Slideshow" href="javascript:$.fancybox.play();;">Play</a>` If someone knows jQuery well and can get to the bottom of this, I would be very grateful! Thanks in advance


retrieving page content per AJAX

I am currently working on a single page website. I am trying to retrieve the page content via AJAX. The page URL is `http://mylocalserver/sad/wp/clients`.                   $.get( 'http://mylocalserver/sad/wp/wp-admin/wp-ajax.php',                {                 'action' : 'retrieve_content',                'page_title' : 'clients'               }, function( response ){                 if ( !response.error ) {                   alert ('AJAX request made! The post title is ' + response.post_title );                 } else {                   alert ('error: ' + response.error );                     }             });      in my php functions.php                   function retrieve_content(){         $page = get_page_by_title( 'clients' );         $content = apply_filters('the_content', $page->post_content);          var_dump($content);         exit();          }      It says _Page not found_ , whereas if I visit the page via URL the content appears. I have hard coded the page title in the PHP function as-well.


JQUERY on my custom WP page wont work

Code below, works properly here http://jsfiddle.net/sushanth009/rE2dW/ but when i put this on my custom wordpress page, Jquery doesnt seem to work. what below page does, is when i select a value in my `<select>` HTML markup, `<div id="divPie">` should appear. by default, it is hidden as declared in my `<style>`               <?php get_header(); ?>                                             <select id="category">     <option name="choice1" value="pie">Pie</option>     </select>

this is pie

               <?php get_footer(); ?>      This is my `script.js`               $('#category').change(function () {         var value = this.value;              value = value.substr(0,1).toUpperCase() + value.substr(1, value.length);              $('.food').hide();         $('#div'+ value).show();     });


Wordpress 3.5 Gallery Menu Order not set?

With the new Gallery editor in Wordpress I am able to set up my galleries and to drag the Thumbnails to re-arrange the image order. On the backend that seems to work fine. But I ran into an issue when I try to display the gallery on the front end using the 'orderby' => 'menu_order' attribute. The display was not using menu_order. When I looked in the database I noticed that the menu_order value for my attachments was still '0' for all gallery images. So it looks like reordering and saving Galleries in Wordpress 3.5 does not set the menu_order value in the database. Is this a bug? Has anyone else run across this? If so do you know of a fix?


Security to delete post by Admin

My code is so simple like when admin delete a post by Wordpress fucntion (PHP) and do action with jQuery               <?php     include('../../../../../../wp-config.php');     if(current_user_can('edit_posts')){     $id = $_POST['ID'];           wp_delete_post($id);          }else{die();}     ?>      This is my code , what are you think about security ? this is enough ?


Search page loop banner image issue

In Header file I have added               while ( have_posts() ) : the_post();  ?>     <img src='banner.jpg' />     <?php }  ?>      ` But in Search page the banner is loop equal to number of results. How can i avoid this. I want to show banner just one time in search page


A bunch of unrelated wordpress using same memcached don't store correctly their datas

Before begin I've to warn the reader: watch out the **d**! On a **single web server** (CentOS 6.3) using php-5.3.3 I've a bunch of **unrelated** wordpress sites (3.5), each one has its own DB (Mysql5.1) so the table_prefix is the same ("wp_"). To speep-up the wordpress I think to APC for the code and a memcache backend for the data, so on my web server I've compile & install libmemcached-1.0.15 and (using "pecl install") php-pecl-memcached 2.1.0 (pay attention to the ending " **d** "). As wp-plugin I used "memcached redux". On two different servers (CentOS 6.3) I've compiled & installed memcached-1.4.15 backend daemon. **The Issue** First I login on _wp.first-domain.com_ and everything is fine. When I try to log on on _wp.second-domain.net_ I found myself redirect on _wp.first- domain.com_! If I clean the memcached cache I can login on _wp.second-domain.net_ , but then every other wp I try to login redirect me on _wp.second-domain.net_. In my _wp-config.php_ I use these settings:               // server list definition     $GLOBALS['memcached_servers']=           array("memcache1.internal:11211","memcache2.internal:11211",);               // try to add a server-related prefix          $GLOBALS['blog_id']=$_SERVER['SERVER_NAME'];     ini_set('memcached.sess_prefix','memc.sess.key.'.$_SERVER['SERVER_NAME'].'.');      **IMHO the wp don't store the data with a significant prefix/salt so one blog fetch onother blog datas!** **The work around** As workaround I've intalled the wp-plugin "Memcached Object Cache", that uses php-pecl-memcache (2.2.7) (note the missing " **d** ") and the following code in config:               define( 'WP_CACHE_KEY_SALT', $_SERVER['SERVER_NAME'] );      I think that I miss some set-up of memcached-redux but I don't exclude a missing functionality (or a bug). **ADD** Final goal is to use php-pecl-memcached, so my work around can be the solution.


Large front end file uploads on cloud

I need to setup a front end page to permits users not registered to send me big files (500mb). I would prefer to host theese files in the cloud and not on my webserver. I thought the best solution was dropbox with the dropbox uploader form, but it is limited to 300mb per file. There are any file upload services that doesn't have this limitation?


Want a form to appear in a post via wp_insert_post, form tags appear, fields don't

I use wp_insert_post to import external data in WP3.8. Part of the post_content field is a small form, see below.               $content="

";     $content.="<form action=\"http://www.mydomain.nl/solliciteren.html\" method=\"get\"><input type=\"hidden\" name=\"ref\" value=\"$reference\" /><input class=\"button\" type=\"submit\" value=\"Solliciteer naar deze functie\" /></form>	";     $content.="

";       When I echo this it looks fine, but after using wp_insert_post to import it I get the following result:

          <form action='http://www.mydomain.nl/solliciteren.html' method='get'></form>

      My question is: does anyony has a clue where my hidden field and button have gone? I think it has something to do with filtering, but (if that's the case) how can I prevent that in a save way?


Ajax navigation and scripts loaded only on certain pages

I'm building a theme. The theme post navigation is done through jQuery Ajax. I've been several plugins to see compatibility and I have a problem with the Ajax functionallity. Some plugins such as Jetpack, load certain scripts depending on the post content.Say for example Page1 has no post with VideoPress functionallity and Page2 does. Then scripts necessary will be loaded on Page2 **only**. I get into a problem as the user might go to Page1, then Page2 posts will load through Ajax and the Video post (from Page2) will break as the scripts were not loaded at first on Page 1. Is there a way to solve this? I'm quite lost on how to.


How can I get List Category Posts to work as a widget?

This plugin works just fine in a post/page, but I need it to appear in a Text widget. Anyway to make it work in this location?


Buddypress create custom tab on my profile and add on home page

I have been trying to add 2 tabs on user profile. “posts”,”gallery” posts : my posted posts. it will display a custom-post-type “user-post” gallery : my pictures .. or any thing.. it will display a custom-post-type “user-images”               // Set up Cutsom BP navigation      function my_setup_nav() {       global $bp;            bp_core_new_nav_item( array(             'name' => __( 'Posts', 'buddypress' ),             'slug' => 'user-posts',             'position' => 19,             'screen_function' => 'jv_user_posts',              'show_for_displayed_user' => true            ) );            bp_core_new_nav_item( array(             'name' => __( 'Gallery', 'buddypress' ),             'slug' => 'user-gallery',             'position' => 20,             'screen_function' => 'jv_user_gallery'        ) );            // Change the order of menu items       $bp->bp_nav['messages']['position'] = 100;            // Remove a menu item       $bp->bp_nav['activity'] = false;       $bp->bp_nav['blogs'] = false;            // Change name of menu item       $bp->bp_nav['groups']['name'] = 'community';      }      add_action( 'bp_setup_nav', 'my_setup_nav' );           // Load a page template      function jv_user_posts() {       bp_core_load_template( 'buddypress/bp/cst-user-posts' );      }      function jv_user_gallery() {       bp_core_load_template( 'buddypress/bp/cst-user-gallery' );      }      it has successfully created 2 tabs! works ok! BUT it goes to own “cst-user-posts.php” page and “cst-user-gallery.php” page. I mean I want to add them in /buddypress/members/sigle/home.php file Then they will be below profile head part. I guess the part is here on home.php                <?php do_action( ‘bp_before_member_body’ );           if ( bp_is_user_activity() || !bp_current_component() ) :       bp_get_template_part( ‘members/single/activity’ );           elseif ( bp_is_user_blogs() ) :      bp_get_template_part( ‘members/single/blogs’ );           elseif ( bp_is_user_friends() ) :      bp_get_template_part( ‘members/single/friends’ );           elseif ( bp_is_user_groups() ) :      bp_get_template_part( ‘members/single/groups’ );           elseif ( bp_is_user_messages() ) :      bp_get_template_part( ‘members/single/messages’ );           elseif ( bp_is_user_profile() ) :      bp_get_template_part( ‘members/single/profile’ );           elseif ( bp_is_user_forums() ) :      bp_get_template_part( ‘members/single/forums’ );           elseif ( bp_is_user_notifications() ) :      bp_get_template_part( ‘members/single/notifications’ );           elseif ( bp_is_user_settings() ) :      bp_get_template_part( ‘members/single/settings’ );           // If nothing sticks, load a generic template      else :      bp_get_template_part( ‘members/single/plugins’ );           endif;           do_action( ‘bp_after_member_body’ ); ?>      How can I make “if” condition for those 2 pages? I don’t know how to create “bp_is_user_posts” or “bp_is_user_posts” functions. if I could, I just need to add … if conditions. I can't even fine "bp_is_user_profile()" these functions on bp files. how it works?? Please advice me! Thanks, pulla


Display ajax preloader for large images within posts

Our WordPress installation runs only images within posts. Generally medium, lightweight images; but we are also publishing larger images, sometimes gif animated which take enormous time to load. When a post has a description, it is a bit different. The visitor has something to read and then the images pops out when loaded, but that's not our case. As I said, we only display images within our posts. When a post contains a big image, it is simply empty until the image is loaded, and I believe we are loosing a lot of possible future regular visitors because of this. They could believe we have empty pages. I've searched everywhere for a solution, a plugin, anything; in vain. I am really surprised that this issue has never came up before. My solution would be to display a tiny (ajax?) preloader until the image is loaded, so the visitor is notified that some content is being loaded. I'm a designer, and my programming skills are limited to html and css.


How to display every pictures from all the posts on one page?

So i want to create a gallery of all the pictures from all the posts into one page. I tried different plugins but they need constant maintain i.e. I have to go add the new picture in the gallery plugin everytime. What I want this gallery to be able to do is to auto-generate or auto-pull all the pictures from all the posts. So my client or I do not need to update both the post as well as the gallery everytime. However, I have no idea how to do this! haha Your help and kindness would be greatly appreciated! Thank you in advance! :)


wordpress testimonials

I have add a testimonial plugin to show the all featured testimonial on my wordpress home, and category pages. But on category page testimonial slider not working properly. I have also check the JS issue, nothing have to find. Please give me specified answer. Thanks in advance. Please specify me where I need to put the testimonials JS.


Wordpress running SQL query to update database from form

Basically I want to take information in from a form and use a separate php page to update the database. so here is the original wordpress php page (add_person.php):               <?php     /*     Template Name: tpl_add_person     */     ?>          <?php get_header(); ?>

<?php echo the_title(); ?>
              <?php             if (is_user_logged_in()): ?>                 <form action="/wordpress/add_user.php" method="post">                     <input name="forename" type="text">                     <input type="submit" value="submit">                 </form>                  <?php endif; ?>
     <?php get_footer(); ?>      And here is the add_user.php form to update the database (note this works if I put it on the above page with dummy information and let it update the database on page load)               <?php         global $wpdb;              $wpdb->insert('tbl_pupils',             array(                 'forename'=>$_POST['forename']             ),             array(             '%s'                        )         );     ?>      But my problem is that when i click the submit button it shows the homepage, nothing done to the database and the url link in the url address bar is: localhost/wordpress/add_user.php can anyone help?


Child Theme Performance

I've read a lot of discussions here and elsewhere about creating a child theme being the recommended way to create a theme based on some other existing theme. I'd like to know about possible performance disadvantages of such approach, compared to creating a non-child theme. It seems that a parent-and-child-theme approach has to deal with loading a hell of a lot more files than a single theme – unless I'm missing something in the codex explanation. And if so, it has to slow down loading, probably significantly. I would appreciate if someone could clarify this for me.


How to create a button click counter meta box?

I am trying to create button click counter meta box in a custom post type, but I can't get it to work. What I want to do is when a user click the submit button, then it will do `update_post_meta` in the background and display the value on the current screen by `echo` `get_post_meta` with ajax. Here is my codes so far: **Hooks the metabox function**               add_action('add_meta_boxes', 'add_custom_categories_box');      **Add metabox function**               function add_custom_categories_box() {        add_meta_box(             'wpse_54822_sectionid',             __( 'Page Attachments' ),              'wpse_54822_inner_custom_box',             'indtablea', 'normal'         );     }       **Meta box**               function wpse_54822_inner_custom_box(){     ?>          <?php     ?>     <button id="target" type="button">Click Me</button>
10

1
     <input type="submit" name="submit" class="submitmeplease" value="Submit" />     <?php     }      **Ajax Response**                // Response to ajax script     function ajaxResponse($post){       $data = $_POST['submit'];     update_post_meta($post_ID, 'my_key', $data);      }       add_action('wp_ajax_ak_attach', 'ajaxResponse');      I can't figure out what is the string of the variable `$data` in the `ajaxResponse` function should be. Could somebody walking me through on creating that button click counter in metabox? Please help me..


Remove Internal Style Sheet if no Value Provided?

I am using this code to add my options inside head section code works but my problem is that if no values are provided my function still echoes an empty `<style type="text/css"><style>` into my head.      _How can I remove style tags if no values are returned?_   Thank You!!               //Hook into WP head and add our options     add_action('wp_head', 'dynamic_options');     function dynamic_options() {         $checkbox = get_option('sandbox_theme_social_options');     $checkbox['hide_sidebar'] ='';       $css = array( 'headercolor'=>'blank',                    'wrapper_background_color'=>'blank' );               $css['headercolor'] = get_header_textcolor(); // get_header_textcolor();               $css['wrapper_background_color'] = get_option('wrapper_background_color');             foreach( $css as $itm => $value ) {                 if($value !='blank') {                        echo '<style type="text/css">';                     if($css['wrapper_background_color']!=''){                      echo "#wrapper{background-color:".$css['wrapper_background_color'].";                      }"; break;                      }//End if background color                          if ($checkbox['hide_sidebar'] == 'on'){                          echo '.sidebar_sec{display:none;}';                         }//End if sidebar on                     echo '</style>';                 }//End If value Blank                  }//End Foreach          }// End Dynamic options


update_post_meta, xml parser

I'm hitting the wall for nearly two hours now, trying to figure this out. Here is the thing' I have made a xml parser to read xml file and add posts (with content) from xml:               $ch = curl_init( "http://abc.xml" );          curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );     curl_setopt( $ch, CURLOPT_HEADER, 0 );     $data = curl_exec( $ch );     curl_close( $ch );     $doc = new SimpleXmlElement( $data, LIBXML_NOCDATA );               $size = count( $doc );     $count_added = 0;     for( $i = 0; $i <= 1; $i++ )     {         $img = $doc->prod[$i]->awImage;         // skipping the part of post adding         $my_post_id = wp_insert_post( $new_post );         update_post_meta( $my_post_id, 'prod_image', $img );     }      Problem is that custom filed doesn't get my `$img` value, even though if I do echo `$img` - I get the content... Strange thing is if I create some other variable `$var="test"` and enter this instead `$img` in `update_post_meta` - the custom field gets the value of `$test`... Whats wrong here, because I'm starting to hit keyboard really badly... Regards.


SFTP define in wp-config.php

just wondering if theres a way to define sftp info in wp-config.php the same way you can with ftp. makes plugin adding a lot easier! best,Dan.


How can I include a post in a theme?

Sometimes it might be necessary to include frequently-changing content in a theme, but themes take some time to modify, it may also be necessary to let a non-technical user maintain some content that appears on more than one page. Is it possible (without heavily impacting performance) to include a post in a theme? ![alt text](http://i.stack.imgur.com/hLWPU.png)


Custom Nav walker display current menu item children, or siblings on no children

I've been messing around / searching for hours and still can't get this to work, so i'm finally giving in and asking for some help. I'm trying to write a custom walker that shows only the current pages children, or if there are no children display the pages siblings. For example, take the following menu tree:   * 1.0      * 1.2.0        * 1.3.0       * 1.3.1       * 1.3.2     * 1.2.1     * 1.2.2   * 2.0 Let's assume that i am on the current page 1.2.0. On this page I want to display it's children (1.3.0, 1.3.1, 1.3.2) however, if i'm on the page 1.2.2, since it doesn't have any children, it should display it's current level siblings, so it should show me (1.2.0, 1.2.1, 1.2.2).


Put Microsoft Excel xlsx document

I want display Microsoft Excel xlsx sheet in wordpress. How i can do that? Also it will be looking like excel sheet.   http://i.stack.imgur.com/tBofs.png Thanks.


Hide meta box based on post format

I'm currently using a version of this function - post formats - how to switch meta boxes when changing format? which hides all meta boxes until a corresponding post format is selected (Ie; If someone selects "Video" then my custom Video meta box shows up) But when the post is saved all the meta boxes become hidden again unless I reselect the post format. Is there a way to show the appropriate meta box even when the post has been saved? This is the main function;               jQuery( document ).ready( function($)             {                 // Starts by hiding the "Video Options" meta box                 $( "#video-options" ).addClass( "hidden" );                      // If "Video" post format is selected, show the "Video Options" meta box                 $( "input#post-format-video" ).change( function() {                     $( "#video-options" ).removeClass( "hidden" );                 } );                  }         );


Is there possibility to Customize the present theme adding sidebars

I am using a WordPress theme which has just header and footer. I would like to continue using it by changing the width and adding side bars. Could anyone help me to change the width (to fit to the screen) of the theme. Does anybody have an idea on how to add sidebars to this theme? ========== Sorry for not making clear in my earlier question. The theme I am using is Minicard The lines similar to ...               if (function_exists('register_sidebar') )         register_sidebar(array(             'name' => 'Sidebar Widgets',             'before_widget' => '
',             'after_widget' => '
',             'before_title' => '
',             'after_title' => '
'         ));      are already there. This is the code I found there:               if ( function_exists('register_sidebar') ) {              register_sidebar(array(             'name' => __('Beneath the Card (Top)', 'minicard'),             'before_widget' => '
',             'after_widget' => '

',             'before_title' => '
',             'after_title' => '
',         ));         register_sidebar(array(             'name' => __('Beneath the Card (Bottom)', 'minicard'),             'before_widget' => '
',             'after_widget' => '

',             'before_title' => '
',             'after_title' => '
',         ));     }      So I have created `sidebar.php` file and added the code you have given for side bar. Later I have tried to add the following code:               #sidebar {         width: 240px;         float:right;         padding:0 20px 20px;     }      to CSS. After making these changes I've looked for the sidebar and I havn't found any additional one.


How do I know if a user has a blog in Wordpress Multisite?

I have a Wordpress Multisite installation with Buddypress. I would want to restrict people from creating another blog so that they have only one blog. How do I achieve this?


Password protected Profile View

I have extended the user profile page in the backend so that each user profile has several extra custom fields for data such as favorite movies, birthday and so on can be stored. Creating a dating website, that is why more fields are needed. People with the proper code can see these profiles in the front end using an entry code which basically is some random code plus userID as number at the end. Using PHP substring the userID is grabbed and access is granted See code:               if(empty($_REQUEST['enterCodeId'])){                 echo "";         }else{                 $getId=substr($_REQUEST['enterCodeId'], 4, 10);                 $querystr ="SELECT ID FROM wp_prefixcode_users WHERE ID='".$getId."'";                 $querystrChecking = mysql_query($querystr);                 if(mysql_num_rows($querystrChecking)<=0){                     echo "";                 }                 $uploads = wp_upload_dir();              //         }      This setup is not ideal because a: the code cannot be added from the profile page yet, which can be remedied with an extra `get_the_author_meta()`, but I need a better way to generate a password, but also because b: a password will always end in the same userID number. How can I give users the option to automatically generate an access password from the Dashboard > Users > User Profile so users can regenerate a new access key? This is needed so access given to another user can be revoked. I need a PHP function to generate a new key and get it stored as an author_meta field in the database. **Solution** Thanks to Toscho and another dev I got this code to load it all. In functions.php I added:               add_action( 'init', 'accesskeygen_func' );          function accesskeygen_func() {         $phpfile = explode('/', $_SERVER['PHP_SELF']);         $phpfile = $phpfile[count($phpfile)-1];              if (($phpfile=='profile.php') && isset($_GET['accesskeygen'])) {             echo wp_generate_password();             exit;         }}      and
     <?php _e("Access Key"); ?>	          <input type="text" name="myaccesskey" id="myaccesskey" value="<?php echo esc_attr( get_the_author_meta( 'myaccesskey', $user->ID ) ); ?>" class="regular-text" />
              <input type="button" class="button-secondary" id="myaccesskeygen" value="Generate Access Key"/>          <?php _e("Please click the button generate access key."); ?>


Is there a way to delete images from the Media Library programatically?

I did a custom user profile page for wordpress that lets you update your profile including uploading your custom avatar and save that photo to the Media Library. Is there a way for the a specific avatar to be deleted using it's attachment ID?


Combining queries with different arguments per post type

I am building a section on a site where I am merging _two different post types_ into one loop, and then displaying them randomly. The problem is, I'm having a hard time finding a way to limit the amount of posts _per_ type. Here's what I've tried:   * One query with multiple post types can be achieved with an array:              $args = array( 'post_type' => array( 'photos', 'quotes' ), ...      ... but cannot limited to a certain number of posts per type.        * Merging two query argument arrays before running **WP_Query** on it:              $photos = array( 'post_type' => 'photos', 'posts_per_page' => 15, 'orderby' => 'rand' );     $quotes = array( 'post_type' => 'quotes', 'posts_per_page' => 5, 'orderby' => 'rand' );          $args = $photos + $quotes;     // Also tried array_merge( $photos, $quotes );      No luck on this. What happens is the latter variable `$quotes` overwrites `$photos` and only shows the quotes.        * Merging two **WP_Query** objects together through typecasting:              $photos_query = new WP_Query( $photos );     $quotes_query = new WP_Query( $quotes );     $result = (object)array_merge( (array)$photos_query, (array)$quotes_query );      ... and so on. I could probably use an SQL query straight to the database, but I _need_ to be able to combine these two separate post types for one loop, arranged randomly, AND limited to a certain amount of posts per type. Thanks for your help!


Is it possible to use object in add_action?

So is it possible to do something like this with `add_action`?               class class{}     $my_class = new class;     add_action('init', 'my_class');


How to create a plugin that notifies for updates?

At this point when I activate a plugin and an update is available it updates the plugin. I like to create a plugin myself that I want to use private, I have several WordPress blogs and if I made an update to the plugin I like those several WordPress blogs to state that there is an update available. Does anyone know how to do that?


How to customly read JWPlayer's "Playlist" items by using its "playlistid"?

In Wordpress (3.8.1) and JW Plugin (v2.1.2) with JW Player (v5), I need to read off the items contained in the Playlists of the JWPlayer Plugin. ## Normally The **JWPlayer Plugin** works like this, via Shortcode:               [jwplayer playlistid="1234"]      .. then a `Video Player` will be being rendered on the Page, together with a Playlist inside. * * * ## What i want to do (The Customizing) So now how do i customly do by myself .. **if i want to know (or pull out) the items inside a Playlist** , by using its `playlistid` or `1234`. Lets say in a totally New Page ( **without using JWPlayer Shortcodes** ), i will use my **own Custom Shortcode** , like:               [playlistitems id="1234"]      (The `id` is the ID of JWPlayer "existing" Playlist)   Then **The New Page** will be showing (just list down) the Items inside, like:               - intro.mp4     - chapter-1.mp4     - chapter-6.mp4     - wrapup.mp4      .. something like that **which needs to be done by my custom module (or) functions**. * * * In more simple words:   * I want to list down the Items inside the JWPlayer's `playlist` (by using its ID)   * How does JWPlayer reads a Playlist. Then i may need to clone its function. Thank you.


switching theme in WordPress theme customizer control panel

I am working with WordPress theme customizer. My client wants several options in customizer screen like site title, tagline and few other options. i had gone well with above options but i am getting confused how switch the themes in customizer for example i am working on twenty fourteen, i have to show drop down options in customizer to change the theme preview to twenty thirteen, twenty twelve or all existing themes in that drop down. if the admin select the twenty twelve from drop down the customizer live preview has to be change to twenty twelve preview and once he press save & publish the website theme has to be change to twenty twelve. anybody have idea how to add this option to WordPress customizer ...


Show different time stamp based on time

What's the best way to show a time stamp based on different times? For example: if a post is under 24 hours, show _%% mins/hours ago_. If a post is over 24 hours, show _month/day/time_. If a post if over a year ago, show _month/day/year/time_. I've done this so far:               <?php if(get_the_time('G') < 23) {     the_time('Y'); } else {     the_time('F j, Y at g:i a'); } ?>


window.send_to_editor throws unterminated string literal error when adding image with multi line description

I am using `media-upload.php?type=image&tab=library` script to add an image to a post with a description that contains html. This php script uses the javascript function `window.send_to_editor` to send the html to the page. This allows you to insert image html into a post. The problem is, if you try to add an image with a description that has text broken up on multiple lines(html) you will get a `unterminated string literal` error from javascript b/c the string is not converted correctly before it is used. Is there anyway around this?


ACF Relationship Posts how to show additional content

I have created a relationship between my custom posts Work and Talent using Advanced Custom Fields. I am currently showing posts from Talent on my work pages with the following posts:               <?php                               $artist = get_field('artist');                              ?>                         <?php if( $artist ): ?>
                             <?php foreach( $artist as $artist ): ?>
                                     <a href="<?php echo get_permalink( $artist->ID ); ?>">                                         <?php echo get_the_title( $artist->ID ); ?>
                             <?php endforeach; ?>
                         <?php endif; ?>      However I would like to be able to show/pull-through a field that is in my artist sections on my work pages. I have tried doing the below but it doesnt work:               <?php                               $artist = get_field('artist');                              ?>                         <?php if( $artist ): ?>
                             <?php foreach( $artist as $artist ): ?>
                                     <a href="<?php echo get_permalink( $artist->ID ); ?>">                                         <?php echo get_the_title( $artist->ID ); ?>                                                                                <?php the_field( 'artist_summary' ); ?>
                             <?php endforeach; ?>
                         <?php endif; ?>


Garbage in uploads folder

I have massive number of files in my uploads folder. Is there a way of identifying those which are not linked to any post? Note: some of those files are manually copied to uploads folder not via "media library"


Page navigation doesn't show when query category

**Problem** :   when I do www.example.com?cat=4 or choose category through custom menu or from category widget it shows only first page without navigation at the bottom, where it supposed to be. It's the same if I use index.php or category-slug.php as template. For test, when I do www.example.com?year=2012 it works. Also, www.example.com?cat=4&paged=2 works. So it must be something with categories. **My setup:** Wordpress 3.5, Free WP tube theme, SQLite **Relevant code:** index.php               <?php get_header(); ?>                                                                              query_posts($query_string.$orderby.'&cat=4'); //in this case showing category with navigation works                                 if (have_posts()) : ?>                                 <?php $i=0; while (have_posts()) : the_post(); $i++; ?>                                                                          <?php if($i%3==0) : ?>

<?php endif; ?>                                      <?php endwhile; wp_reset_query(); ?>                                 <?php                                  $next_page = get_next_posts_link('Previous');                                  $prev_pages = get_previous_posts_link('Next');                                 if(!empty($next_page) || !empty($prev_pages)) :                                 ?>
                                     <?php if(!function_exists('wp_pagenavi')) : ?>
<?php echo $next_page; ?>

<?php echo $prev_pages; ?>
                                     <?php else : wp_pagenavi(); endif; ?>
                                                                  <?php endif; ?>      Note: you can see I'm using the `&cat=4` in query. It is the same as `category_name=video` because I want to show only videos on home page. But also, I want to make able to choose that category from custom menu in which case doesn't show page navigation. **What I have tried:** Making `$wp_query = null` then making new query before the Loop. http://wordpress.org/support/topic/next-page-navigation-doesnt-work. Basically any variation of this               <?php     $myqueryname = $wp_query;     $wp_query = null;     $wp_query = new WP_Query();     $wp_query->query('showposts=5'.'&paged='.$paged);     ?>      Doesn't work. Adding $paged as suggested by the creator of WP-pagenavi and forums:               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>                                       <?php query_posts("cat=-11&paged='.$paged);; ?>      Doesn't work. **Testings:** besides the simple ones in the "problem" part of the question i did `print_r($wp_query)` all the way to see where to problem starts and it starts right on the beginning, ie. when i put `print_r($wp_query)` as the first line in header.php. So, the problem is not in the custom query of the theme, am I right? I did it for the working $wp_query and not working $wp_query then compared them. This is the relevant comparison part of the code: Working $wp_query:               [category_name] =>     [cat] => 4     ...     **//most important part**     [found_posts] => 382         [max_num_pages] => 43     ...     [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')  ORDER BY wp_posts.post_date DESC LIMIT 0, 9     ...     //here shows code for some posts even if not displaying them, because they're not in the cat=4 or category_name=video       non working $wp_query:               [category_name] => video     [cat] => 4     ...     **//most important part**     [found_posts] => 1     [max_num_pages] => 1     ...     [tax_query] => WP_Tax_Query Object             (                 [queries] => Array                     (                         [0] => Array                             (                                 [taxonomy] => category                                 [terms] => Array                                     (                                         [0] => video                                     )                                      [include_children] => 1                                 [field] => slug                                 [operator] => IN                             )                          )                      [relation] => AND             )     ...     [query] => Array             (                 [category_name] => video             )              [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1  AND ( wp_term_relationships.term_taxonomy_id IN (4) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 9     ...     //this $wp_query doesn't show code for the posts which are not from video category     ...     [queried_object] => objArray Object             (                 [term_id] => 4                 [name] => Video                 [slug] => video                 [term_group] => 0                 [term_taxonomy_id] => 4                 [taxonomy] => category                 [description] =>                  [parent] => 0                 [count] => 379                 [cat_ID] => 4                 [category_count] => 379                 [category_description] =>                  [cat_name] => Video                 [category_nicename] => video                 [category_parent] => 0             )      **Edit #1:** This is the comparison BEFORE the custom query! When I dumped $wp_query inside the Loop, after the custom `query_posts()` they are identical. So the problem is not in the $wp_query. Also, from the index.php code `get_next_posts_link('Previous')` returns NULL when choose category form menu or `?category_name=video` **Conclusion:** something is happening before the template files with default query, but I don't know what. Can somebody help me to show page navigation? **Edit #2:** Since the `get_next_posts_link('Previous')` returns NULL I knew it's something about the `$wp_query->max_num_pages;` That number must be bigger than 1 to show navigation. So i tested by putting code `<pre><?php echo $wp_query->max_num_pages; ?></pre>` to see when it changes from 1 to >1. I discovered that in working version it changes after the `<?php endwhile; wp_reset_query(); ?>` and in non working it doesn't change.


Formatting <code>?

I have serious trouble displaying code blocks in my theme. I want to display something like:               <something>          <something-else>               Content          </something-else>     </something>      And it works fine everywhere, but doing that inside code tag:               <code>         <something>              <something-else>                   Content              </something-else>         </something>     </code>      Displays code block looking like:               <something>     <something-else>     Content     </something-else>     </something>      And setting code's CSS to:               white-space: pre-wrap;      Produces confusing:               <something>     </br>        <something-else>     </br>           Content     </br>        </something-else>     </br>     </something>      Almost perfect, but where these come from? Additionally I'm disabling WP AutoP and it works, but not within code tags: **functions.php**               remove_filter ('the_content',  'wpautop');     add_filter( 'the_content', 'wpautop' , 12);      Any ideas?


How and why can a hook call itself without causing recursion?

When looking in WP hooks' code, I often see hooks that call themselves. For example, this snippet from image_downsize():               function image_downsize($id, $size = 'medium') {              if ( !wp_attachment_is_image($id) )            return false;              if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) {            return $out;         }      Why doesn't this cause recursion? Thanks


Can I paginate this get_attachment query?

Yeah, basically I want to be able to show 15 images attached to a certain page and have pagination when the page has more than 15 images. I'm not very well versed on this kind of query so I'm a bit stumped.                <?php $args = array('numberposts' => 15, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID); ?>                              <?php if ( $photos = get_posts($args) ) : ?>                                  <?php foreach ( $photos as $photo ) : ?>                                      <a href="<?php echo $photo->guid; ?>" target="_blank" class="lightbox" rel="[<?php echo $post->ID; ?>]"><?php echo wp_get_attachment_image($photo->ID,'thumbnail'); ?>                                  <?php endforeach; ?>                              <?php endif; ?>


WPML string translation not saving

I have a template file where I have a string. I would like to translate it, using WPML - Multilingual Blog. My setup is a following: functions.php               ##################################################################     # Language      ##################################################################     icl_register_string("template_fullwidth", "relatedSubjects", "Se relaterede emner:");      in my template file:               <?php echo "<h3>".icl_t("template_fullwidth", "relatedSubjects", "Se relaterede emner:")."</h3>"; ?>      When i go to the backend interface and enter the translation and press save the "spinning wheel of death" appears and nothing happens, see image. Image: https://lh6.googleusercontent.com/-paBv76Z3db8/UekaeUjtu6I/AAAAAAAAMoc/PQLV3n2XkO4/w685-h192-no/WPML.png (The spinning wheel of death is on top of the word "Related" in the translations field) In my JS console i get the following messages:               Warning: The page at https://<sitename>/wp-admin/admin.php?page=wpml-string-translation/menu/string-translation.php#icl-st-toggle-translations displayed insecure content from http://<sitename>/wp-admin/admin.php?page=sitepress-multilingual-cms/menu/languages.php.      [VM] admin.php?page=wpml-string-translation/menu/string-translation.php (1428):1     Error: Failed to load resource: the server responded with a status of 404 (Not Found) https://dev.studerende.dk/wp-admin/images/gray-grad.png     2     Error(2): Uncaught TypeError: Cannot read property 'parentNode' of undefined load-scripts.php?c=0&load%5B%5D=jquery,colorpicker,utils&ver=3.5.2:5     Warning: The page at https://<sitename>/wp-admin/admin.php?page=wpml-string-translation/menu/string-translation.php#icl-st-toggle-translations displayed insecure content from http://<sitename>/wp-admin/admin.php?page=sitepress-multilingual-cms/menu/languages.php.      [VM] admin.php?page=wpml-string-translation/menu/string-translation.php (1428):1      What am i doing wrong? And how do I make it translate my string?


get_children filter with postmeta

I am doing the following to get all the children associated with a post:                   $args = array(             'order'=> 'ASC',             'post_parent' => get_the_ID(),             'post_status' => 'publish',             'post_type' => 'task'         );         $tasks = get_children( $args );      Now the posts of type `task` have postmeta associated with them. One particular meta_key is `task_progress`. I would like to get all the children whose `task_progress` meta_value is less than 100. What is the best way to filter the results?


Add Post Author body class to WordPress

I'm trying to add a custom body class to WordPress which should be the author of the post which is displayed. I looked at different how to's and tried to create some code but it doesn't work:               add_filter( 'body_class' , 'ft_add_guest_body_class' );          function ft_add_guest_body_class( $classes ) {              // add 'wp_admin' to the $classes array              if (get_the_author() != 'MrX')             $classes[] = 'wp_admin';              // return the $classes array         return $classes;          }      The problem is that the `wp_admin` body class is displayed on every page and post. When I remove the conditional the body class is still applied so it must be that.


wordpress admin is broken

I have just installed a fresh version of the latest wordpress locally but the backend admin area looks like this http://grab.by/iGik Not sure what is causing this, I have tried redownloading and reinstalling witha new database but still doesnt work. uggh! DEBUG INFO I get the following error when I go to the updates page, but I have no errors or warnings on the homepage.               Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /Volumes/data/Documents/websites/mrskitson2012/wp-includes/functions.php on line 2690


Open WordPress Page from selected option dropdown

Code/process to get option dropdown menu selection to open page in WordPress with php? Tried all kinds of plug-ins, widgets, but none will make menu that fits requirements of project so far. Selections are page titles that are dynamically loaded from a table of address and other data. Based on previous selection of state, then city, then place, the next step is to open WordPress page from selected title, called place. This is a normal option-select box:               <input type="submit" name="submit" value="place">      The selections are WordPress page titles. When submit is pressed, the issue is to go to page selected, a page for the selected business. What I'm actually trying to do is produce a menu that can select among pages by state, city, and choose the place - the page belonging to that place. Eventually this will expand to country but right now the US. Each place has its own page. Tried a **lot** of plug ins and widgets and none has so far been up to this. I don't know beans about java so I went with php.


Upload folder is not writable, even when permissions are correct

I recent migrated my site from Godaddy to Webfaction. On migration, I get this error: > Upload folder is not writable. Export and file upload features will not be > functional. Naturally, I check the permissions of the folder - and they are correct. Just to be safe, I changed it recursively to "777" (as a test, not permanently), and I still cannot upload images. How can I troubleshoot this issue?


Array: What is this value based on?

I need to do an import of an array of checkboxes, but there is a value that I don't how it is determined. The array is based on a user meta option that I created that shows a list of category checkbox options. It grabs all of the categories and creates a checkbox option that can be saved to a user's profile. This is part of the coding I used to create the user meta option:               $args = array( 'hide_empty' => 0, 'taxonomy'=> 'category');     $categories =  get_categories($args);          if ($categories){                             foreach ( $categories as $category ){                                  if(in_array($category->term_id,(array)$data)) {                                     $selected = 'checked="checked""';                                 } else {                                     $selected = '';                                 }                                 echo '<input name="user_cats[]" value="'.$category->term_id.'" '.$selected.' type="checkbox"/> '.$category->name.'<br/>';                             }                         }      This is what the options look like in the user profile page: ![enter image description here](http://i.stack.imgur.com/duVqo.jpg) After doing a test save of the some of the checkbox selections, I examined the database value of the "user_cats" field, it gives me something like this: **a:2:{i:0;s:2:"20";i:1;s:3:"343";}** Now, I know what all but one of the variables stand for. **a** = Total amount (quantity) of selections **i** = Sequential number of the selection (*Starting with 0) **"X"** = The number value within the parenthesis is the category ID My question is, what is the **s:** value based on? I tried comparing to


Last class on last headline?

I have the following code which should add a last class to the fourth post but doesn't appear to be, what is wrong with this coding? It show's 4 posts fine but the fourth one doesn't have the class last attached to it.

               <?php if (have_posts()) : while (have_posts()) : the_post(); $count = 1;       if( $post->ID == $do_not_duplicate ) continue; ?>               <li <?php if ($count == 4) : ?>class="last"<?php endif; ?>><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">                 <?php the_post_thumbnail( array (176,176) );?>                                  <?php the_title(); ?>
               <?php endwhile; $count++; endif; ?>


Why does WP allow to view and media item as a page

Every media item that is uploaded to Wordpress can be viewed in a page. This can be seen if you browse to the Media section, hover on any item and click view. Are there any benefits to this because I am not seeing any at the moment. Can this feature be edited (or removed)?


Front end submit form with jquery form plugin

Maybe someone can help me with a small problem I'm having. I'm trying to use this: http://jquery.malsup.com/form/ to create a submit form for Wordpress. I've tested it on a regular site(not WP) and it works. I can't figure out why it won't work in wp. This is my form. I've created two page templates, one has the form, the other has the wp_insert_post code. If I change the form action to action="http://mysite.com/page.php" it works, if I point it to a page template it doesn't. I need it to point to a page template for the wp_insert_post code to work. This is on one first page:               <form id="myForm" action="http://mysite.com/submitest" method="post">      Name: <input type="text" name="name" />      Comment: <textarea name="comment"></textarea>      <input type="submit" value="Submit Comment" />       Thanks


Custom Post Type Archives by Year & Month?

How do you display the archives of a Custom Post Type by Year & Month?


jquery: getting contents of #content field on post page

I managed to get the #content field html with this jquery call:               jQuery("#content").html()      This seems to be failing though on "Add New Post" pages. Any tips on how to get the contents of the #content div? Cheers


custom data in url

Inside a WordPress site I load a external xml file parse it and show some links. The link looks like this:   `domain.com/prof/vac/item?guid=1234&title=foo`   This works, but now i would like the url to look like this:   `domain.com/prof/vac/item/1234-bar`   when I create a link to that url and click it it says it kind find the page. However if i just put the guid in and forget about the title it works:   `domain.com/prof/vac/item/1234` can anyone point me in the right direction?


Front end user meta options for users

I have created user meta options using this tutorial. Now I want to know how to allow users to edit (update) certain custom user meta options that I created. Users already have a template account page where they have access to some user meta options. I added the a function to the users' page to update the meta field upon clicking the update button on the page. Im using text input fields for the new user metas. This is the code I used to update the options:               add_action( 'personal_options_update', 'my_save_extra_user_fields' );     add_action( 'edit_user_profile_update', 'my_save_extra_user_fields' );          function my_save_extra_user_fields( $userId ) {              if ( !current_user_can( 'edit_user', $userId ) )             return false;              update_usermeta( $userId, 'address2', $_POST['address2'] ); // Custom meta 1         update_usermeta( $userId, 'address3', $_POST['address3'] ); // Custom meta 2         update_usermeta( $userId, 'hours', $_POST['hours'] ); // Custom meta 3     }      But when I update the page it shows the previous values saved in the back-end (admin) section of wordpress. Of course, any values saved in the back end are saved correctly and displayed on the front-end. I wanted to save either way, from back-end and from front-end. What am I doing wrong? How do I fix this? Thanks **UPDATE:** Here is the code for the template page that users use to update their existing meta information:               <?php get_header(); ?>                         <?php           $user_info = get_userdata($current_user->ID);      $userId = $userdata->ID;          $location = $userdata->jabber;     $lsplit = explode('**',$location);     $full_location =  ''.$lsplit[2]. ', ' .$lsplit[3]. ' ' .$lsplit[1]. ' ' .$lsplit[4]. ''; // 0 = Country; 1 = State; 2 = Address; 3 = City; 4 = Zip Code; 5 = Phone Number     $statesplit = explode(', ', $lsplit[1]); // State split: 0 = State name; 1 = State Abbreviation     $location_pt1 =  $lsplit[2];     $location_pt2 =  ''.$lsplit[3]. ', ' .$statesplit[1]. ' ' .$lsplit[4]. '';          ?>               <?php echo $PPTDesign->GL_ALERT($GLOBALS['error_msg'],$GLOBALS['error_type']); ?>

My Account

              <a href="javascript:void(0);" onClick="jQuery('#My').hide(); jQuery('#MyDetails').show()" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount2']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a1.png" style="float:left; padding-right:20px; margin-top:10px;" />             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount2']) ?>
             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount3']) ?>

                           <img src="<?php echo IMAGE_PATH; ?>artwork1.png" style="float:left; padding-right:20px; margin-top:10px;" />             Artwork
             Approve your artwork

              <a href="<?php echo get_option("manage_url"); ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount6']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a3.png" style="float:left; padding-right:20px; margin-top:10px;" />             Manage My Offers
             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount7']) ?>

              <a href="<?php echo get_option('submit_url'); ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount8']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a5.png" style="float:left; padding-right:20px; margin-top:10px;" />             Create New Offers
            <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount9']) ?>

              <a href="<?php echo get_option("messages_url"); ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount4']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a2.png" style="float:left; padding-right:20px; margin-top:10px;" />             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount4']) ?>
             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount5']) ?>

              <a href="<?php echo get_option("contact_url"); ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount10']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a4.png" style="float:left; padding-right:20px; margin-top:10px;" />             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount10']) ?>
             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount11']) ?>

              <a href="<?php  echo wp_logout_url(); ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount12']) ?>">             <img src="<?php echo IMAGE_PATH; ?>a6.png" style="float:left; padding-right:20px; margin-top:10px;" />             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount12']) ?>
             <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount13']) ?>

 Account Details<?php // echo SPEC($GLOBALS['_LANG']['_tpl_myaccount1']) ?>

<a href="<?php echo $GLOBALS['premiumpress']['dashboard_url']; ?>" title="<?php echo SPEC($GLOBALS['_LANG']['_head4']) ?>">Back

             <form action="" method="post" enctype="multipart/form-data">      <input type="hidden" name="action" value="1" />          <fieldset>

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount15']) ?> <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount16']) ?>
          <input type="text" value="<?php echo $userdata->user_login; ?>" disabled class="short" />

          Email *
          <input type="text" name="form[user_email]" value="<?php echo $userdata->user_email; ?>" class="short" tabindex="10" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount17']) ?> *
          <input type="text" name="form[user_url]" value="<?php echo $userdata->user_url; ?>" class="short" tabindex="11" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount18']) ?> *
          <textarea tabindex="5" class="short" rows="4" name="form[description]"><?php echo $userdata->description; ?></textarea>

          </fieldset>
<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount19']) ?>
          <fieldset>

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount20']) ?> *
          <input type="text" name="form[first_name]" value="<?php echo $userdata->first_name; ?>" class="short" tabindex="12" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount21']) ?> *
          <input type="text" name="form[last_name]" value="<?php echo $userdata->last_name; ?>" class="short" tabindex="13" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount25']) ?> *
          <input type="text" name="address[address]" value="<?php echo $ADD[2]; ?>" class="short" tabindex="17" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount23']) ?> *
          <select type="text" name="address[state]" id="first" value="<?php echo $ADD[1]; ?>" class="short" tabindex="15"><option value=""></option></select>

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount24']) ?> *
          <select type="text" name="address[city]" id="second" value="<?php echo $ADD[3]; ?>" class="short" tabindex="16"><option value=""></option></select>

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount26']) ?> *
          <input type="text" name="address[zip]" value="<?php echo $ADD[4]; ?>" class="short" tabindex="18" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount27']) ?> *
          <input type="text" name="address[phone]" value="<?php echo $ADD[5]; ?>" class="short" tabindex="19" />

          <?php if ($current_user->ID == 1){ ?>

            Address 2
           <input type="text" name="address2" id="address2" value="<?php echo esc_attr( get_the_author_meta( 'address2', $userId ) ); ?>" class="short" />
           E.g. Street Address, City, State Zipcode

            Address 3
           <input type="text" name="address3" id="address3" value="<?php echo esc_attr( get_the_author_meta( 'address3', $userId ) ); ?>" class="short" />
           E.g. Street Address, City, State Zipcode

            Hours
           <input type="text" name="hours" id="hours" value="<?php echo esc_attr( get_the_author_meta( 'hours', $userId ) ); ?>" class="short" />
           Enter your hours of operation. (Optional)

          <?php } ?>           </fieldset>
<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount30']) ?>
          <fieldset>

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount31']) ?> *
          <input type="text" name="password" class="short" tabindex="20" />

          <?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount32']) ?> *
          <input type="text" name="password_r" class="short" tabindex="21" />

                                    </fieldset>          <?php if ($current_user->ID == 1){ ?>          <?php           add_action( 'personal_options_update', 'my_save_extra_user_fields' );     add_action( 'edit_user_profile_update', 'my_save_extra_user_fields' );          function my_save_extra_user_fields( $userId ) {              if ( !current_user_can( 'edit_user', $userId ) )             return false;              update_usermeta( $userId, 'address2', $_POST['address2'] );         update_usermeta( $userId, 'address3', $_POST['address3'] );         update_usermeta( $userId, 'hours', $_POST['hours'] );     }          ?>          <?php } ?>

      <input type="submit" name="submit" id="submit" class="button grey" tabindex="15" value="<?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount33']) ?>" />

          </form>

          <?php get_footer(); ?>      You can that I created three test meta fields (address 1, address 2, and hours), but Im not able to save them from the front end of the site.


Strip post_tags from list of returned taxonomy terms

Thanks to GhostToast for helping me on my way with this post. Now I am successfully able to echo out all of the taxonomy associated terms dynamically. However, this unfortunately also seems to spit out all the site's post_tags too. So how can I use the following code, but not show the standard post_tags (I'd like to keep the post_tags available for use, just not show them as a result of this query)               // taxonomy term archives     $post_type = get_post_type();     $taxonomies = get_object_taxonomies($post_type);     if(!empty($taxonomies)){     foreach($taxonomies as $taxonomy){         $terms = get_terms($taxonomy);         if(!empty($terms)){              echo "
";             foreach ( $terms as $term ) {                 echo '
slug, $taxonomy).'">'.     $term->name . "
";             }             echo "
";         }     }     }


Query to return maximum of one post per author

We are introducing a "featured author" area on our site and would like to display the most recent articles by a select group of authors. However, we only want a maximum of one post per author to display. So an author could potentially have posted 5 times since another author had posted, but regardless only one of their posts should appear. Currently this is the code I've got:               <?php     $args = array(     'showposts' => 5,     'author' => "6800,3845,1720,7045,4949"     );          $the_query = new WP_Query( $args );          while ( $the_query->have_posts() ) : $the_query->the_post();           ?>          // DISPLAYING STUFF          <?php endwhile; wp_reset_query(); ?>      One potential solution I have considered is querying more posts and setting up an array, then checking the array each time to see if an author is already in it. If they are, it would continue to the next row. But an obvious issue with this would be that I may potentially end up having to pull back 100's of posts if a particular "featured author" hadn't wrote for a while. I'm still fairly new to PHP/MySQL and a solution is probably starring me in the face. Appreciate any assistance.


Require custom post type if is_admin() - template doesn't show up?

In my functions.php I require PHP files which register custom post types, if I'm logged in as an admin.               if (is_admin())         require_once(TEMPLATEPATH . '/custom-post-types/cpt.php');      This works great, except that the wrong template is loaded. Instead of `single-{cpt}.php` the `index.php` is used. If I remove `if (is_admin())` everything works correct, but of course the custom post type becomes visible for every non-admin. How can I solve that?


Display a custom field rating system in the front end

I have added a content rating system to my platform where the authors can select which audience their post is appropriate for. Currently, these options are available: > Unrated > > G > > PG > > R The code that I use to display the rating options on the post edit page is:               // Article Content Rating     add_action( 'add_meta_boxes', 'rating_select_box' );     function rating_select_box() {         add_meta_box(             'rating_select_box', // id, used as the html id att             __( 'Content Rating (optional)' ), // meta box title             'rating_select_cb', // callback function, spits out the content             'post', // post type or page. This adds to posts only             'side', // context, where on the screen             'low' // priority, where should this go in the context         );          }          function rating_select_cb( $post ) {         global $wpdb;         $value = get_post_meta($post->ID, 'rating', true);         echo '
Article Content Rating: ';              $ratings = array(             1 => ' G ',             2 => ' PG ',             3 => ' R ',         );              echo '<select name="rating">';         echo '<option value=""' . ((($value == '') || !isset($ratings[$value])) ? ' selected="selected"' : '') . '> Unrated </option>';              // output each rating as an option         foreach ($ratings as $id => $text) {             echo '<option value="' . $id . '"' . (($value == $id) ? ' selected="selected"' : '') . '">' . $text. '</option>';         }         echo '</select>';              echo '
';     }          add_action( 'save_post', 'save_metadata');          function save_metadata($postid)     {            if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return false;         if ( !current_user_can( 'edit_page', $postid ) ) return false;         if( empty($postid) ) return false;                   if ( is_null($_REQUEST["rating"]) ) {             delete_post_meta($postid, 'rating');         } else {             update_post_meta($postid, 'rating', $_REQUEST['rating']);         }          }     // END Article Content Rating      Now, the problem is, what code do I add to `single.php` to display their choice? So for instance, if the author selected PG, then I want to `echo 'Content Rating: PG';` or if it was on default (unrated), I want to `echo 'Content Rating: Unrated';`. How is this possible? Ideally, a solution that is light on the server as my platform is heavily trafficked.


Using nextGen Gallery.. how can I call a list of all Gallery Names?

I'm trying to make a nav to access all the different galleries on a single page. Instead of hard-coding all their names out. I was curious if it was possible to make this dynamic and just call all the ID's of all the galleries, with maybe an exclusionary on the two that are slideshows. Anyone got any fresh ideas?


Post incorrectly displaying as page

I have a small WordPress install that I'm setting up, and have run into an issue that I've encountered before, but do not understand the cause. Issue: With permalinks set to `/%postname%/`, on a site with the following:   1. Home page    2. About page (slug: "about")   3. Two links to categories (there are two categories, with slugs of "digital" and "broadcast")   4. About 35 posts Most everything works as expected, however there is one post with a slug of "swampism" which displays (incorrectly) in the page.php template file, rather than the single.php template file (where all other posts properly display). How does this happen? Why does it happen? And how can I fix it and/or avoid it in the future. **Note:** Changing the permalink structure to default, or date driven is not an option. Besides, that is (in my mind) a work-around, not a solution/explanation of the problem.


How can I see a list of all pages my WordPress site has generated?

I would like to be able to to see some sort of list of all the individual pages my WordPress site has generated that would inevitably be visible to a user or a search engine. For example, I know tags and categories and even some plugins generate new types of pages many may be unaware of.


Multiple wp_localize_script

Is it possible to localize a script more than once? I want to send two separate arrays of params. Or is it only possible to localize a script once, in which case, I'll have to combine the arrays? I'd like to do something like this:               wp_localize_script('my-handle', 'my_object1', $data1 );     wp_localize_script('my-handle', 'my_object2', $data2 );


Check against server time to display SQL entries - Radio Station DJ Rotator Plugin

I'm building a WordPress plugin that will create a radio station "On-Air Now" DJ rotator. **Working options panel I've built so far:** http://i.stack.imgur.com/SiYde.png I've based the idea on a PHP case statement I wrote back in 2007 where you specify the DJ's start time which is then checked against the server time. I know how to pull the image, description, and link out of the DB and display it. _I just don't know how to code the logic behind showing only ONE DJ during his/her scheduled TIME-FRAME._ e.g.; 6a-9a. **Would it be?** script: _"hello server, what time is it?"_ server: _"it's 6:25am"_ script: _"ok, database it's 6:25am...who is scheduled?"_ database: _"neal boortz"_ script: _"thank you sir. i will now write some HTML"_ **What I have built so far:** https://github.com/gregrickaby/DJ-Rotator-for- WordPress/blob/master/dj-rotator-for-wordpress.php I'm not asking for someone to write it for me. Just shove me in the right direction with the logic. Maybe a code example or two. Thank you!


Exclude post_type from admin comments_list

I'm trying not to show comments from a certain custom post type int the comments list on the admin interface. I went to the "wp-admin/includes/class-wp-comments-list-table.php" and tried to play with the $args array which is passed into the "get_comments" function in order to feed the comments list table. If I add a post_type parameter there I can filter the comments in order to only see comments from that post type. But what I want is the opposite: I would like to see all comments but those from one specific post type. I tried several things like: 1) create a white list by adding all the post types I need but the one I want to exclude. The problem is that it only shows the first type of the array               $args = array(         ...,         'post_type' => array('aaa','bbb','ccc','ddd')     );      2) I tried to create a black list by excluding the post type I need. It just doesn't consider the filter and shows comments from all post types.               $args = array(         ...,         'exclude' => array('post_type'=>'xxx')     );          //OR           $posts_to_exclude=get_posts(array('post_type'=> 'xxx'));     foreach ($posts_to_exclude as $single)     {         $target[] = $single->ID;        };     $args = array(         ...,         'posts__not_in' => $target     );      Nothing worked. I just don't know what else to do. What concerns me is that the white list seems to be ok according to what I can read over the internet but for some reason it only shows me the first element of the post_type array (and I'm sure I have comments for all posts as they all show up when I don't filter the comments list table. Thank you for your help.


WordPress Automatic Filename Changer

So I used this function that allows me to change the literal filename in the directory on upload. But, it doesn't actually change the filename, hence changing the slug to the ID when attaching to a post. For example, I upload a file with the filename "Grumpy-Cat-Ate-Nemo", it'll change to ID "89" because of the function. But it doesn't actually change the filename in the WordPress database, so it stay's as "Grumpy-Cat-Ate-Nemo.png" on WordPress even when the file is renamed to the ID. I want the attachment url of a post to be http://example.com/grumpy-cat/89, not http://example.com/grumpy-cat/Grumpy-Cat-Ate-Nemo               add_action('add_attachment', 'rename_attacment');     function rename_attacment($post_ID){         $post = get_post($post_ID);         $file = get_attached_file($post_ID);         $path = pathinfo($file);             //dirname   = File Path             //basename  = Filename.Extension             //extension = Extension             //filename  = Filename              $newfilename = $post_ID;         $newfile = $path['dirname']."/".$newfilename.".".$path['extension'];              rename($file, $newfile);             update_attached_file( $post_ID, $newfile );      }


How to use bloginfo( 'template_directory' ) in array

I want to pass `bloginfo( 'template_directory' )` in an array I tried this but not working. How to write it correctly?               <?php     get_the_image( array( 'size' => 'full',                   'default_image' => bloginfo( "template_directory" ) .'/img/dflt.png',                   'image_scan' => true,                   'link_to_post' => false ) );     ?>      `get_the_image` is a function from Justin Tadlock plugin


SSL problems with WordPress

I want to use SSL with my WordPress installation but only on the admin interface (because it is self signed). Now my problem is that when I go to the main site I become redirected to the https version. How can I prevent this behavior so that **only** the admin interface is using ssl?


I cannot get pagination to work on my home page code. it keeps displaying the same posts

Please can someone tell me what is wrong with my code and why it keeps showing the same content on the paginated pages? It has two loops.. the first is for the featured post and then the rest of the posts.               <?php       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;       $postArgs = array(           'showposts' => get_option('posts_per_page'),           'offset' => 0,           'orderby' => 'post_date',           'order' => 'DESC',           'post_type' => 'post',           'post_status' => 'publish',           'paged' => $paged);       $the_query = new WP_Query( $postArgs );     ?>
       <?php         $a = 0;         while ( $the_query->have_posts() ) : $the_query->the_post();           if ($a == 0)           { ?>

<?php the_title(); ?>

by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?>

<?php the_excerpt(); ?>

           <?php } else {             break;           }           $a++;         endwhile;       ?>

         <?php           $b = 0;           while ( $the_query->have_posts() ) : $the_query->the_post();             if ($b > 0) { ?>

<?php the_title(); ?>

by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?>

<?php the_excerpt(); ?>

                   <?php comments_number( '', 'one Comment', '% Comments' ); ?>

              <?php }                  $b++;           endwhile;     ?>

<?php next_posts_link('Older Entries  »', $the_query->max_num_pages) ?>
     <?php previous_posts_link('« Newer Entries »') ?>
          <?php     if($the_query->max_num_pages>1){?>
         <?php           if ($paged > 1) { ?>             <a href="<?php echo '?paged=' . ($paged -1); //prev link ?>"><                             <?php }         for($i=1;$i<=$the_query->max_num_pages;$i++){?>             <a href="<?php echo '?paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?>             <?php         }         if($paged < $the_query->max_num_pages){?>             <a href="<?php echo '?paged=' . ($paged + 1); //next link ?>">>         <?php } ?>
     <?php } ?>           <?php      wp_reset_postdata();     wp_reset_query();     ?>


Writing into MySQL Table

I'm trying to write some data from the frontend into a custom database table. As long there is no value in the input field this script creates an empty line in the database table, but if the input field has some value nothing happens. Where is the mistake?!?!?               function insert_directory() {          //get the form elements and store them in variables     $name=$_POST['name'];     $submit=$_POST['submit'];          if(isset($_POST['submit'])) {global $wpdb; $wpdb->insert( 'directory', array('name' => $name,));          $inserted_entry = $wpdb->get_row($wpdb->prepare("SELECT * FROM directory ORDER BY id DESC LIMIT 0,1"));     echo '
The following entries were succsessfully added
';     echo'
';     echo '
Name:	'.$inserted_entry->name.'
';     echo '
';          }  else {           echo '<form method="post" action="">';      echo '
';      echo '
Name:	<input id="name" type="text" name="name" />
';      echo '
';      echo '
<input type="submit" name="submit" value="Insert Entry" />';      echo '</form>';     }     }


Location of twentyeleven theme's option filters?

Hi I'm learning theming options based on the existing theme TwentyEleven. I've come across the following code in inc/theme-options.php               return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );      I can't seem to find the add_filter for 'twentyeleven_default_theme_options', or does it not even exist?


How to show only subcategories in parent category not parent category?

I just want to show only subcategories of specific parent category on parent category page. I have 1 parent category `videos` and 3 child categories `art,funny,and technology` of that parent. I didn't assigned my parent `videos` category to my child categories, but I made them child of that `videos` parent cateogry. and I don't want to show parent categories on parent category page and neither want to show any category when go to any post related of child category page. How to do this? any idea? I am using this code. And I used this code into my category.php file.                  <?php                 if (is_category())                 {                 $cur_cat = get_query_var('cat');                 if ($cur_cat)                     {                     $new_cats = wp_list_categories('echo=false&child_of=' . $cur_cat  .'&depth=1&title_li=&&show_count=1&hide_empty=0');                         }                 }             ?>      But this is not working desired as I want. I also tried 1 more solution for that,I made another template called `content- videos.php` and I call that template with                  <?php if ( in_category('videos')):?>             <?php get_template_part( 'content', 'videos' ); ?>             <?php else:?>                 <?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format()    ); ?>
                      <?php endwhile; ?>                      <?php endif;?>      in my `category.php` template. and I put my 1st code into `content- videos.php`.that solved my 1st problem, but my next problem was that when I go to in any subcategory page there is noting show except `No categories` please suggest me any solution of this I am suffered too much to finding the right solution what I want.


How to link to "most recent" document in the Media Library?

Our customer wants a "Latest Newsletter" type link on the homepage. I figured there'd be an easy way to specify a document from the media library (perhaps by name or title) but nothing is coming up in Google. So he'll be uploading jan.doc, then feb.doc etc to the media library. He doesn't want to keep overwriting the same one, as it's neat to build up a little library of these things in his WordPress dashboard. But I think he'd be prepared to flag or tag the latest one, or even rename the latest one each month to "Latest Newsletter" as its title in Wordpress (not the filename). But how can our theme's header reliably link to his chosen/latest newsletter?


How to get the blogs owned by a user?

I have setup WP MU and I would like to get a list of blogs a user owns. Is there a method that gets this info? **More info:**   I only have one page for the user to login. I need to get the blogs they own to redirect to their own blog.