CPU Resource Management For Bulk Attachment Insert Share Host

I've created a page on a shared host which loops through a series of posts and then attaches images to each of the posts. The images are already on the server and are copied into the WP-Content folder. It 'works' but after about the 3rd iteration of the loop, the web page gives a timeout error and if I look at the server's CPU utilisation it is 100%. So the question(s) are: 1) Is there some sort of generalised 'garbage collection' I should be using after each iteration of the loop to prevent the CPU/memory build-up? 2) Failing that, is there a tool I can use to profile what is going on, with a shared hosting account? Here is the code for the main loop. The guts is in a separate function 'save_post()' which calls wp_insert_post and then wp_generate_attachment_metadata. I figured I'd start with asking about some -general- memory/resource management before going into the weeds with that. I assume this would be many times more efficient if I could use bulk SQL statements rather than individual SQL requests for each insert/attachment but it seems like there is too much complexity in what happens when WP creates thumbnails and assigns postmeta for me to want to tackle that for a one-off project. ` $args = array('post_type' => 'ims_gallery', 'post_status' => 'draft', 'posts_per_page' => 10); $pwp_query = new WP_Query($args);                                   while( $pwp_query->have_posts() ) : $pwp_query->the_post();                                      $post = get_post();                                                         // var_dump($post);                                 $gallery = $post;                                 $galid = $gallery->ID;                                 $galmeta = get_post_custom( $galid );                                 $galpath = '/' . trim( $galmeta['_ims_folder_path'][0], '.,/' );                                      $titlename = preg_replace('/\s+/', '', get_the_title() );                                 $sourcefolder =  '/home/myserver2/public_html/source/CurrentImages/' . $titlename;                                      echo('Processing: ' . $sourcefolder);                                 $destfolder =  '/home/myserver2/public_html/myserver.net/wp-content/_imsgalleries/gallery-' . $galid;                                                                $_resized_destfolder = $destfolder . '/_resized';                                 $flist = '';                                 $files1 = scandir($sourcefolder);                                                                if($files1) {                                         $flist = implode(',', $files1);                                         echo($galpath);                                         // @mkdir( $destfolder, 0751, true );                                         @mkdir( $destfolder, 0751, true );                                                                                @mkdir( $_resized_destfolder, 0751, true );                                                                                @shell_exec('cp -a ' . $sourcefolder . '/* ' . $destfolder);                                                                                // code to generate attachments is here.                                         save_post( $galid, $post );                                      }                                 else                                 echo('No files for: ' . $sourcefolder);                              endwhile; ?>      `


edit search.php to include subdomain posts

Is there a way for us to edit the search.php to include the subdomains with its search results? The only "condition" the code has is... ...and I have really nothing more to go by. =/ And oh, I kinda want to avoid installing plug-ins, so please don't tell me to download and install the Multisite Global Search plugin. Many thanks~


Grabbing the first image attached to a post and use it with the admin columns

I'm currently using @kovshenin's tutorial here on adding a thumbnail (a featured image) to my post type admin columns. Would it perhaps be possible ( and how :) ) to retrieve the first image attached to a post first, if no featured image available? (and perhaps return a local hosted image if also no featured image available) This is the code I currently have:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;       switch ( $column ) {         case 'thumbnail':           echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );           break;       }     }      **Edit:** As mentioned in the next comments, it took some time to figure things out :). In the end, and with the suggestions of @ifdion I came up with the next result:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;            $args = array(         'numberposts' => 1,         'post_mime_type' => 'image',         'post_parent' => $post->ID,         'post_type' => 'attachment',       );       $attachments = get_children( $args );            if ( has_post_thumbnail() ) {         echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );            } elseif ( $attachments ) {         foreach ( $attachments as $attachment ) {           $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'edit-screen-thumbnail' );           echo '';         }            } else {         echo '';       }     }      **Another edit** Not entirely sure if this grabs the **last** image attached to a post, but anyways, this code will get it:               add_action( 'after_setup_theme', 'cor_after_setup_theme' );     function cor_after_setup_theme() {       add_image_size( 'edit-screen-thumbnail', 48, 48, true );     }          add_filter( 'manage_edit-product_columns', 'cor_add_product_column', 10, 1 );     function cor_add_product_column( $column ) {       $column_thumbnail = array(         'thumbnail' => ''       );       $column = array_slice( $column, 0, 1, true ) + $column_thumbnail + array_slice( $column, 1, NULL, true );       return $column;     }          add_action( 'manage_posts_custom_column', 'cor_manage_product_column', 10, 1 );     function cor_manage_product_column( $column ) {       global $post;            $args = array(         'numberposts' => 1,         'post_mime_type' => 'image',         'post_parent' => $post->ID,         'post_type' => 'attachment',         'post_status' => null,       );       $attachments = get_posts( $args );            if ( has_post_thumbnail() ) {         echo get_the_post_thumbnail( $post->ID, 'edit-screen-thumbnail' );            } elseif ( $attachments ) {         foreach ( $attachments as $attachment ) {           echo wp_get_attachment_image( $attachment->ID, 'edit-screen-thumbnail' );         }            } else {         echo '';       }     }


Static directories in a WordPress multisite network

I’m planning ahead for a class website, where students will have the choice to either build their pages from scratch, or to use a WordPress multisite install as a CMS. I would like their work to sport URLs such as : http:// myschool.edu/2011/project1 ➤ WP blog   http:// myschool.edu/2011/project2 ➤ serves files directly uploaded by the students   http:// myschool.edu/2011/project3 ➤ WP blog And to have it work for future years too (2012, etc.). My gut feeling is that this would be possible to achieve with some Redirect rules in the Apache configuration. Even if I have to manually write them. Can someone with more experience with the WP Network feature and ModRewrite confirm this is possible? Or suggest an altogether better alternative? Thanks!


Link to a .po file in a child theme

i'm working in a twenty ten child theme, i want to change the               load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );          $locale = get_locale();     $locale_file = TEMPLATEPATH . "/languages/$locale.php";     if ( is_readable( $locale_file ) )       require_once( $locale_file );      locate in the twentyten functions by the one in my child theme :               load_theme_textdomain( 'BETA', STYLESHEETPATH . '/languages' );     $locale = get_locale();     $locale_file = STYLESHEETPATH . "/languages/$locale.php";     if ( is_readable( $locale_file ) )       require_once( $locale_file );       With this change in the stylesheetpath the twenty ten function is still taking over my own function How can i fix that ?


Designing a custom archive.php inspired by the Autofocus theme

I've been trying to use the front page from the Autofocus theme in a different theme by copy pasting the code from index.php in the Autofocus theme to my new archive.php file. I have also copied the related functions from functions.php from Autofocus, I also tried to get some of the css over to the new theme. I have tried this for a long time and with multiple tweaks but I can't get it to work. I get both images and text, but not in the same style as in the Autofocus theme, and definitely not with the cropping autofocus has on its front screen. Am I missing something here? Shouldn't it work if I copy the whole fuctions.php in to the new one and copy all the css?


Extend Screen Options

I'm customizing the WP-admin and want to add a toggle button to switch between the customized admin and the default admin. I'd like to place that button in the Screen Options drop down tab. Is there any way to extend this area? In wp-admin/includes/screen.php I found               public function render_screen_meta() {      and attempted to copy the function into my dashboard.php file which contains all of my dashboard customization as               function render_screen_meta() {      and appending my changes to the default function, but it work. It didn't cause an error, but it was unsuccessful in altering the function. I tried creating it as a public function in my dashboard.php file but PHPStorm kept giving me an error saying "expecting statement". I'm not really familiar with the use of public. * * * What I'm attempting to do is create the button as illustrated in the screenshot below: ![enter image description here](http://i.stack.imgur.com/tLffy.jpg)


How to paginate wordpress [gallery] shortcode?

I am using wordpress gallery shortcode [gallery] I was wondering if there is anyway to paginate them without using a plugin.


List Hierarchical Term List with Count with Related Term

What I have are custom posts (of a custom post type, wps_business) that have two taxonomies (wps_location & wps_type), and I would like to list all the terms from type of a specific location. For example:   * POST 1: King's English Cafe, location: London, type: Restaurant (parent), English    * POST 2: La Madeline, location: Paris, type Restaurant (parent), French   * POST 3: Uncle Julios, location: London, type: Restaurant (parent), Mexican   * POST 4: San Marinos, location: London, type: Restaurant (parent), Italian   * POST 5: Chipotle, location: London, type: Restaurant (parent), Mexican   * POST 6: Olive Garden, location: London, type: Restaurant (parent), Italian   * POST 7: Home Depot, location: London, type: Home & Garden (parent), [no-child]   * POST 8: Lowe's, location: London, type: Home & Garden (parent), [no-child]   * POST 9: Frank's Car, location: London, type: Local (parent), Mechanic   * POST 10: Smith's Car, location: London, type: Local (parent), Mechanic   * POST 11: King's Bank, location: London, type: Local (parent), Bank ..etc.. So what I would like to is have a display on the location London page is just a list of terms from type that have posts associated with location London (taxonomy: location). So... Home & Garden (2) Local (3)   * Mechanic (2)   * Bank (1) Restaurant (5)   * English (1)   * Mexican (2)   * Italian (2) I was thinking that I needed to customize Walker_Category class; however, I believe that a more complex query may be needed. I'd rather not fetch all posts and cycle through to create this. Suggestions? Is there a SQL that will fetch these?


How can I get Wordpress to save comments in markdown format?

I love markdown, and I have the Wordpress markdown-for-wordpress-and-bbpress parsing markdown in my posts and comments. However, I've noticed that Wordpress saves the comments rendered in html format. This makes it more difficult to go back and edit comments. How can I get wordpress to save comments in markdown format? I couldn't find a plugin for it. Maybe there's an easy php hack? (Cross posted from stackoverflow I hope that's ok)


Wordpress page with non-English text

I have a simple Wordpress page that takes input from users and store into a database. I am able to get the values and update the database properly. However, whenever I try to enter some non-English text, it gets converted to something like '?????????'. But the issue is only with my page. If I use the Wordpress comments form, the text is stored in the database correctly. My complete code is available at http://pastebin.com/MDLJBXpQ Please help.


Is it possible to uninstall one plugin from within another plugin?

I'd like to be able to automatically uninstall certain plugins if they're detected (specifically Akismet and Hello Dolly), either by writing another plugin to do so or via my theme's functions.php file. Is that possible?


Wanting to apply different featured images for each post

This is my first wordpress website here and so far it'll looking good. The only thing I have left that I just can't figure out is the featured image for my blog page. I have set the main blog banner to a default featured image that's hard coded into the header.php file (and my blog page does not have a featured image so it usually shows the default like i should), which looks like this.               <?php                          // Check to see if we're on a non-home-page and if the non-home-page has a featured image.                     if( !is_front_page() && has_post_thumbnail() ) {                              the_post_thumbnail( '960, 403' );                          // if we're on the home page                      } elseif ( function_exists('dynamic_sidebar') && is_dynamic_sidebar('banner-widget') && is_front_page() ) {                              dynamic_sidebar('banner-widget');                          // no featured image set                     } else {                         echo '<img src="http://www.averylawoffice.ca/Avery-Banner-Default.jpg" alt="Avery Law Office | Summerland, BC">';                     }                     ?>      Which was working fine. Now I'm trying to set individual featured banners for each post but the minute I set one for the newest post the banner on the main blog page changes to that one. However all other later posts do what I want them to do. Is there something in the header I should change or have to set in single.php that I might be missing? If you need to see a specific code please let me know. I wasn't sure what page/code to show so I started with the header conditional tag. Any help or advice is appreciated as always!


Locate authors on Google map version 3

      in the body               <?php if ( have_posts() ) : ?>
       <?php $i = 1; ?>       <?php while ( have_posts() ) : the_post(); ?>       <?php if ( get_post_meta($post->ID, 'latlng', true) !== '' ) : ?>       <div id="item<?php echo $i; ?>">
<a href="<?php the_permalink(); ?>">           <?php the_title(); ?>
         <?php the_content(); ?>
       <?php endif; ?>       <?php $i++;   ?>       <?php endwhile; ?>

     <?php else : ?>
Error 404 — Page not found.
     <?php endif; ?>      I have some difficulty switching from longitude and latitude to address. I will appreciate any help in the right direction.


Not One 'Contact Form Plugin' will send email // Work

I've tried over a dozen 'Contact Form' Wordpress Plugins. None of which will function and send the form contents to any email. I'm working on top of the 'PremiumPress DirectoryPress Theme' I'm thinking that the issue might be, that this theme came with a Contact Form Template (Very Terrible One), which I've removed in the code awhile ago. So, any new plugins are conflicting with the old default ?


Displaying syntax highlighted code

I have a blog that I write up entries for that sometimes has programming code as part of the text within my writing's. Normally I use the quote function to give it a bit of highlighting, but was wondering if there's a better way that anyone has come across in their travels. Something that could do this for example:               function foo() {          $var = "bar";     }      to highlight various property for the code like an IDE would. Thought that this would have been asked before, but after searching didn't have any luck, so thought I'd ask. Thanks for anyone that can offer some help on this matter.


Functions are causing errors

I'm declaring a function on a plugin's PHP. The plugin loads code at the top of each post (Post Layout is the plugins name). > Cannot redeclare vote_up() (previously declared in > /home/content/08/10290908/html/wp-content/plugins/post- > layout/plugin.php(181) : eval()'d code:4) in > /home/content/08/10290908/html/wp-content/plugins/post- > layout/plugin.php(181) : eval()'d code on line 36 that's the displayed error message, it isnt because the function has already been declared in the functions.php (I know because I tested it by renaming it to all sorts of names) It says it's already declared in the plugin I'm using to load the code. Heres the code:               <?php           function vote_up(){                         if($post_vote == "9"){                  }             elseif($post_vote == "8"){             update_post_meta( get_the_ID(), 'post_vote', '9', '8');             }             elseif($post_vote == "7"){             update_post_meta( get_the_ID(), 'post_vote', '8', '7');             }             elseif($post_vote == "6"){             update_post_meta( get_the_ID(), 'post_vote', '7', '6');             }             elseif($post_vote == "5"){             update_post_meta( get_the_ID(), 'post_vote', '6', '5');             }             elseif($post_vote == "4"){             update_post_meta( get_the_ID(), 'post_vote', '5', '4');             }             elseif($post_vote == "3"){             update_post_meta( get_the_ID(), 'post_vote', '4', '3');             }             elseif($post_vote == "2"){             update_post_meta( get_the_ID(), 'post_vote', '3', '2');             }             elseif($post_vote == "1"){             update_post_meta( get_the_ID(), 'post_vote', '2', '1');             }             elseif($post_vote == "0"){             update_post_meta( get_the_ID(), 'post_vote', '1', '0');             }                 else{//do nothing             };     }          //if the post is pending show     if(get_post_status() == 'pending') {          //if the user is logged in show     if ( is_user_logged_in() ) {              add_post_meta( get_the_ID(), 'post_vote', '0', true );         $post_vote = get_post_meta( get_the_ID(), 'post_vote', true );              echo 'Votes: ' . $post_vote;                     echo ' <form action="xxx" method="post" onclick="return vote_up()">';                echo ' <input type="button" value="Vote Up" />';                echo '</form>';               } else {         echo'Please Sign in to Vote';     }          } else {     // do nothing     }               ?>      The code above is basically trying to make it so that when you click on the button, the vote meta_key goes up by one. It's for voting so once 10 users vote on it, it will publish. This stupid buttons such a hassle, I can't move on until I have it working even tried to pay some guy to fix the button and he didn't have a clue


Sorting/Ordering Poll Plugin?

I want to create a poll in which the user is presented with a short list of items which they are then to sort in an order they choose related to the question. After looking around for a while, I found a few good poll plugins for WordPress, but they were all of the simple radio-button/check-box variety; none of them supported this type. Writing my own simple form is simple enough, but then I have to accommodate the data storage somehow. It would be better if I could find some sort of plugin.


How to Add Custom CSS Buttons to WordPress as a Shortcode?

How do I add custom CSS buttons as a shortcode like this: [button class="mybutton1" link="home"] I have the CSS of the button from here               .myButton {              -moz-box-shadow:inset 0px 1px 0px 0px #cf866c;         -webkit-box-shadow:inset 0px 1px 0px 0px #cf866c;         box-shadow:inset 0px 1px 0px 0px #cf866c;              background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));         background:-moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);         background:-webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);         background:-o-linear-gradient(top, #d0451b 5%, #bc3315 100%);         background:-ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);         background:linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);         filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315',GradientType=0);              background-color:#d0451b;              -moz-border-radius:3px;         -webkit-border-radius:3px;         border-radius:3px;              border:1px solid #942911;              display:inline-block;         color:#ffffff;         font-family:arial;         font-size:13px;         font-weight:normal;         padding:6px 24px;         text-decoration:none;              text-shadow:0px 1px 0px #854629;          }     .myButton:hover {              background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));         background:-moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);         background:-webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);         background:-o-linear-gradient(top, #bc3315 5%, #d0451b 100%);         background:-ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);         background:linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);         filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b',GradientType=0);              background-color:#bc3315;     }     .myButton:active {         position:relative;         top:1px;     }      I wish to add this to my WordPress site as a shortcode. How do I do this? Thanks!


Text Stating the Domain Name Appears on Every Page... How to Get Rid of It

For some reason, every page on my website has my domain name on the bottom of the page - to the right of the thumbnails. This never used to happen. I can see it in Firebug, but I still have no idea where it is coming from. How can I get rid of it? Thanks.


Path in dev server works; same path in prod server is broken

on my development wordpress server (using Desktop Server's "ServerPress"), one my pages has a list of pdfs; each tag has this path: /wp- content/themes/accessgroup/docs/thePDF.pdf. When I upload my installation to my production server, and I click on one of these links to view a pdf, I get Wordpress's default 404 page. The path to the file did not change, so how is it not seeing them? I've verified that these pdfs have indeed made it to the production server. Even weirder - I have another page with links of pdfs that link to the very same directory above, and I'm able to view those PDFs (although different than the ones above). Any ideas? UPDATE - I added a link to one of the PDFs that did not work to the actual template file for the page of PDFs, and I was able to download and view the pdf in the browser. This is pretty bizarre..same exact link...but if I click on the one added through the wp admin page editor, it doesn't work. If I click on the same one added directly to my template file, it works. What is going on?


Editing the Number at the end of Page URLs / Editing Page Slugs

I am playing around with wordpress and a few plugins. Say I have something called "Shopping Cart" and I delete the page. Then I recreate it, I can't have the old URL back. I get domain.com/shopping-cart-2 and I want the old one back. How can I do this?


Else statement not triggering after a failed if statement

I am working on a client site and the statement I wrote 6 months ago seems to have stopped working after the WordPress update to 3.8 I can't see or figure out why. There are no errors appearing it just returns empty divs with post Id's in the class field. If the the if statement is false then it needs to echo out different data. But sadly it isn't it still spits out the the first H3 tag.
         <?php // Blog post query         $today = date('Y-m-d');              $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $currentID = get_the_ID();         query_posts(array(            'post' => 'ID',             'post_type' => 'foodswaps',             'posts_per_page' => 3,             'meta_key' => '00.event-date',            'meta_value' => $today,            'meta_compare' => '>=',            'orderby' => 'meta_value',            'order' => 'ASC'           ));              if (have_posts()) : ?>
Upcoming Swaps
         <?php while (have_posts()) : the_post(); ?>             <div <?php post_class('clear-spacer no-margin'); ?>>                                                         <?php                      $field_name = "00.event-date";                     $listEventDate = get_post_meta($post->ID, $field_name, true);                     if (($listEventDate == 'E.g. yyyy-mm-dd') && ($listEventDate == '')) { ?>                          <a href="<?php the_permalink(); ?>" title="<?php  the_title_attribute( 'echo=0' ); ?>">
<?php the_title();?>
                         <?php                          $converted = date('Y-m-d', strtotime($listEventDate));                         $reversedDate = date('jS F Y', strtotime($converted));                              echo $reversedDate;?>                                          <?php  } ?>
         <?php // end of blog post loop.         endwhile; wp_reset_query(); // end of the loop and reset the query.          else:              echo '
Our Social Networks
';             echo '
Why not visit us on our social networks?
';         endif;?>


Default value in wordpress metabox

I would like to set as default 'small_post_size' on my metabox options. I set 'std' options but it doesn't work. Can you help me?               $meta_boxes[] = array(         'id'         => 'post_size',         'title'      => __('Post listing size', 'liquidfolio'),         'pages'      => array('post'), // Page type         'context'    => 'side',         'priority'   => 'low',         'show_names' => false, // Show field names on the left         'fields'     => array(             array(                 'std'     => 'small_post_size',                 'name'    => '',                 'desc'    => '',                 'id'      => SHORTNAME . '_post_size',                 'options' => array(                     array( 'name' => 'Normal', 'value' => '', ),                     array( 'name' => 'Small', 'value' => 'small_post_size', ),                 ),                 'type'    => 'select',             ),              ),     );      Thanks in advance! :)


Multisite User restriction

I am new to wordpress. My company using multiple site using WP multisite, which is installed and working normally in "multiple subdomains" mode. This creates multiple WP sites like domain.com site1.domain.com site2.domain.com site3.domain.com I have an issue with multisite user login. The user logged in one site **i.e site1.domain.com.** i am opening the other site **i.e site2.domain.com** the user logged in the site1.domain.com is already logged here also. I want restrict this, if user logged in site1.domain.com and opens site2.domain.com in same browser need to login again. I am using session to save and use the user details. I am using same database for all the subsites. How can i do this in wordpress and php?


Media Modal load and select external images

I've been trying to extend WordPress/Backbone Modal to use in a plugin I'm developing; basically the point is that I host all my photos somewhere accessible via an API and I want to provide my users with a selection of these photos to upload and include in posts. Photos are fetched using AJAX and previewed in an extended media modal, at least I managed to achieve that. What I can't figure out is: how can I select the images by clicking them like the regular media modal, and access/return the selected images to an upload script? Here's what I've done so far. Javascript part:               var _frame = wp.media({         title: 'Import images',         frame: 'select',         searchable: false,         library: {             // Dummy: avoid any image to be loaded             // Without this WordPress will populate the modal             // with unrelated previously imported media             type : 'image',             post__in:[0],             post__not_in:[0],             s: { Album_ID: $('#album_id').val() }         },         multiple: true,         button: {             text: 'Import images'         }     });          $('#trigger').click(function(e) {              e.preventDefault();              _frame.on('ready', function() {             $(_frame.router.selector).remove();             $.ajax({                 url: ajaxurl,                 method: 'GET',                 data: {                     action: 'load_images',                     album_id: $('#album_id').val()                 },                 success: function(response) {                     $(_frame.content.selector).html( $(response) );                 }             });         });              _frame.open();     });      PHP callback stripped of any security check:               public static function load_images_callback() {              $album_id = esc_attr( $_GET['album_id'] );         $images = MyMedia::get_images( $album_id );              $_images  = '
';         $_images .= '
';         foreach ( $images as $image )             $_images .= sprintf( '

', $image['url'], __( 'Deselect', MYMEDIA_SLUG ) );         $_images .= '
';         $_images .= '
';              echo $_images;              die();     }      Images show nicely in the modal, but I can't find a way to select any of it, clicking doesn't do anything. Am I doing something wrong? How can I make my images selectable and how to handle them?


Custom Page Pagination

Hoping someone can help me with a problem. I am using a custom page to display all posts with pagination, I noticed last night in webmaster tools that I am getting some soft 404's from the custom page. After looking at the soft 404 I have realised that instead of stopping at the last page the rel next/prev is pointing to the next page, even though pagination isn't. When I visit any page after the last paginated page I am getting the "no posts found" instead of a 404. This is the code I am using http://pastebin.com/CJAPR5Sb Would appreciate any help. Thanks


Hide View and preview from custom post types

Is it possible to hide the ability to view or preview custom post types? I as, for custom post types like carousels and other forms that render in a particular way where viewing or previewing them out side their intended rendering purpose would not make any sense.


Sort Posts with custom meta key by default which is currently set as optional

I'm new to Wordpress so please bear with me. Please check this link The posts are currently sorted by date. But if you mouse over on `Latest Articles` you see there are other options for sorting like `Most Viewed` `Most Liked` etc. What I'm trying to do is make `Most Liked` the default sorting value instead of `Latest Articles` I believe this could be done by modifying codes where the `wp_query args` are setup The php file which controls the panel has this code - `$args = array('posts_per_page' => $postsperpage);` I've tried modifying it with this - `$args = array('posts_per_page' => $postsperpage, 'orderby' => 'meta_value_num', 'meta_key' => IT_META_TOTAL_LIKES);` But it doesn't solve the purpose! Can anyone tell me how do I do this?


Display Categories Assigned to a WooCommerce Product

I am using WooCommerce with SuperStore theme. In meta.php file is this line,               echo $product->get_categories( ', ', '' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '.' );       which displays the assigned categories to the post, but not in hierarchical order. I want to display these in hierarchical order. I also found these piece of code, after some changes it is displaying the categories in correct order, but I need a new line tag if the top parent class is other then the previous category.               $taxonomy = 'product_cat';              // get the term IDs assigned to post.         $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );         // separator between links         $separator = ' » ';              if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {                  $term_ids = implode( ',' , $post_terms );             $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );             $terms = rtrim( trim( str_replace( '
',  $separator, $terms ) ), $separator );                  // display post categories             echo  $terms;         }      Example: Shoes -Kids(sub) Kids -Shoes(sub) Now it is displayed as: Shoes » Kids » Kids » Shoes I need it to display as: Shoes » Kids Kids » Shoes Thank you for the help :)


Are these wp-content permissions safe?

I have just started out with a VPS running centos 6.3 to host my blog and play around. After Installing WordPress 3.5.1, when I tried to install some plugins from the admin console, it complained of the folders in wp-content (upgrades, plugins, themes ..) not being writable. I changed the owner and group of these folders to 'apache' which didn't work and then made the ftp user the owner which worked. After this, I installed the BackWpup plugin which required the wp-content itself to be writable by 'apache' (owning by ftp user account did't work). In the end I have folder permissions like below               [krishnaraj@myhost]$ pwd     /var/www/html/krishnaraj.mydomain.com/wp-content     [krishnaraj@myhost]$ ls -lrt     total 28     -rw-r--r-- 1 root   root                28 Feb  3 03:08 index.php     drwxr-xr-x 2 apache apache            4096 Feb  3 03:11 cache     drwxr-xr-x 4 apache apache            4096 Feb  3 06:52 uploads     drwxrwxr-x 5 myftpuser myftpuser      4096 Feb  3 07:22 themes     drwxrwxr-x 7 myftpuser myftpuser      4096 Feb  3 09:14 plugins     drwxrwxr-x 2 myftpuser myftpuser      4096 Feb  3 09:14 upgrade     drwxr-xr-x 2 apache apache            4096 Feb  3 09:32 backwpup-98372-logs     [krishnaraj@myhost wp-content]$          [krishnaraj@myhost]$ pwd                /var/www/html/krishnaraj.mydomain.com     [krishnaraj@myhost]$ ls -lrt | grep wp-content      drwxr-xr-x 8 apache apache  4096 Feb  3 09:32 wp-content     [krishnaraj@myhost]$      Are these permissions safe ? or should I be worrying about a security hole ?


Resolve the debugs

I enable the debugs, and i have these that describe below. In the `wp- config.php` write :               define('WP_DEBUG', true);     define('WP_DEBUG', false);      1) > Notice: Undefined index: type in C:\xampp\htdocs\mywebsite\wp- > content\plugins\oqey-gallery\gallcore.php on line 252 _on line 252 :_               //media_upload_header();         if($_GET['type'] == "oqeygallery"){ include ("insert_in_post.php"); }      > 2) Notice: add_custom_background is deprecated since version 3.4! Use > add_theme_support( 'custom-background', $args ) instead. in > C:\xampp\htdocs\mywebsite\wp-includes\functions.php on line 2638 > > 3) Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() > instead. in C:\xampp\htdocs\mywebsite\wp-includes\functions.php on line 2638 > > 4)Notice: Trying to get property of non-object in > C:\xampp\htdocs\mywebsite\wp- > content\themes\mywebsite\includes\for_articles\get_excerpt.php on line 12               function get_excerpt()         {             $excerpt = get_the_content();             $excerpt = preg_replace(" (\[.*?\])",'',$excerpt);             $excerpt = strip_shortcodes($excerpt);             $excerpt = strip_tags($excerpt);             $excerpt = substr($excerpt, 0, 440);             $excerpt = substr($excerpt, 0, strripos($excerpt, " "));             $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));             $excerpt = $excerpt.'<a class="read-more" ID) . '">Read more »»';             return $excerpt;         }     ?>      Edit: Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead. in /home/www/server/mywebsite/www/wp-includes/functions.php on line 2638               function _deprecated_function( $function, $version, $replacement = null ) {              do_action( 'deprecated_function_run', $function, $replacement, $version );              // Allow plugin to filter the output error trigger         if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {                 if ( ! is_null($replacement) )     **2638**                trigger_error( sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );                 else                     trigger_error( sprintf( __('%1$s is deprecated since version %2$s with no alternative available.'), $function, $version ) );                  }         }      **Update :** Only when activate the plugin oQey Gallery, display some errors like:               Notice: Undefined index: type in C:\xampp\htdocs\website\wp-content\plugins\oqey-gallery\gallcore.php on line 252     Notice: Undefined index: page in C:\xampp\htdocs\website\wp-content\plugins\oqey-gallery\oqeygallery.php on line 346     Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in C:\xampp\htdocs\website\wp-includes\functions.php on line 2723


WordPress Translation to french, at -> à not working

I have a german / french blog. I installed the german WordPress version, so I already had de_DE.mo and de_DE.po in wp-content/languages. After I realized that the content of a comment's `<time>`-element wasn't translated, I googled and downloaded fr_FR.mo and fr_FR.po and put them in wp-content/languages. Now everything I tested works, except that 'at' doesn't get translated to 'à' ( I get: 3. février 2013 at 17:00). So I opened fr_FR.po to see whether there is a translation available. I found this:               #. translators: 1: date, 2: time     #: wp-includes/comment-template.php:1367     msgid "%1$s at %2$s"     msgstr "%1$s à %2$s"      Which seems alright to me. So to make sure, I replaced the existing mo file with this. Still it does not work. How do I make it translate 'at' to 'à'? I'm using WPML.


How can i list the categories of a post type, the taxonomy

How can i retrive the categories from a post_type that i select. I have a Custom_field - categorie_serial               <?php          $values = get_field('categorie_serial');     if($values)     {         echo '
';              foreach($values as $value)         {             echo '
' . $value . '
';         }              echo '
';     }          // always good to see exactly what you are working with     var_dump($values);          ?>      This code retrive me the categories but it retrive me an error The line 40 is "foreach($values as $value)"                   Warning: Invalid argument supplied for foreach() in /home/****/public_html/****/wp-content/themes/movies/tabserial/detali-serial.php on line 40          string(334) "Gen SerialeActiuneAnimatieAventura"       How can i retrive the only the parent categories? I do not want to retrive Gen Seriale - categoriy , only Actiune.. * * * RESOLVED:               <?php      $terms = get_terms('seriale','child_of=668');foreach ($terms as $term) {echo ''.$term->name.'';}     ?>


Dashboard Widget Form

I created a Dashboard widget to send push notifications to an app, but the way I have it coded, whenever I make changes in the Plugin Editor and press Update File, the code gets ran and I get a blank push notification. I am sure my problem lies in this part of the plugin code:               if('POST' == $_SERVER['REQUEST_METHOD']) {         // process the form here     }      Any suggestions on how to fix this or a better way to do it? Here is the gist of my plugin code               if('POST' == $_SERVER['REQUEST_METHOD']) {       //do the stuff with the 'message'     }               // Function that outputs the contents of the dashboard widget     function dashboard_widget_function() {         echo '<form method="post">
Message: <input type="text" name="message" />

<input type="submit" />
         </form>';     }          // Function used in the action hook     function add_dashboard_widgets() {         wp_add_dashboard_widget('push_notification', 'Push Notification', 'dashboard_widget_function');     }          // Register the new dashboard widget with the 'wp_dashboard_setup' action     add_action('wp_dashboard_setup', 'add_dashboard_widgets' );


Getting error to display radio button value in General Settings page

I'm constantly getting the errors bellow when printing the radio button values from General Settings screen: > Illegal string offset 'service' in F:\wamp\www\plugin-tester\wp- > content\themes\twentythirteen\functions.php on line 565 > > Illegal string offset 'service' in F:\wamp\www\plugin-tester\wp- > content\themes\twentythirteen\functions.php on line 568 Here is the code which I added to `functions.php` file:               add_filter('admin_init', 'myservice_register_function');     function myservice_register_function(){         register_setting('general', 'my_service', 'esc_attr');         add_settings_field('my_service', '<label for="service_need">'.__('Do You need My    Service' , 'my_service' ).'</label>' , 'service_function', 'general');     }          function service_function(){         $options = get_option( 'my_service', '');         //  $options = get_settings( 'my_service');              if($options['service'] == 'YES') { //line number 565             echo 'Yes, Service Need';          }         if($options['service'] == 'NO') { // line number 568             echo 'No Need Service';         }         $html = '<input type="radio"  name="my_service[service]" value="YES"/>';          $html .= '<label> NEED </label>';               $html .= '<input type="radio"  name="my_service[service]" value="NO"/>';          $html .= '<label > NO NEED </label>';               echo $html;     }      What's the mistake?


Custom post type single page returns 404 error

I have a custom post type called `slide`. It has content and some custom fields. I want **WP** to show the `single.php` theme or `single-slide.php` theme when the user clicks the slide single page link. the problem I have is that **WP** throws 404 error, when I want to see the single slide page. here is my code in `functions.php`:               function create_slide_post_type() {         $labels = array(             'name'               => _x( 'اسلایدها', 'i2sa' ),             'singular_name'      => _x( 'اسلاید', 'i2sa' ),             'menu_name'          => _x( 'اسلایدها', 'i2sa' ),             'name_admin_bar'     => _x( 'اسلاید', 'i2sa' ),             'add_new'            => _x( 'افزودن', 'i2sa' ),             'add_new_item'       => __( 'افزودن اسلاید جدید', 'i2sa' ),             'new_item'           => __( 'اسلاید جدید', 'i2sa' ),             'edit_item'          => __( 'ویرایش اسلاید', 'i2sa' ),             'view_item'          => __( 'نمایش اسلاید', 'i2sa' ),             'all_items'          => __( 'همه اسلایدها', 'i2sa' ),             'search_items'       => __( 'جستجوی اسلایدها', 'i2sa' ),             'parent_item_colon'  => __( 'اسلایدهای مادر:', 'i2sa' ),             'not_found'          => __( 'اسلایدی پیدا نشد.', 'i2sa' ),             'not_found_in_trash' => __( 'اسلایدی در زباله دان پیدا نشد.', 'i2sa' )         );              $args = array(             'labels'             => $labels,             'description'        => "اسلایدهای شرکت i2sa",             'public'             => true,             'exclude_from_search'=> true,             'publicly_queryable' => false,             'show_in_nav_menus'  => false,             'menu_icon'          => 'dashicons-images-alt2',             'show_ui'            => true,             'show_in_menu'       => true,             'query_var'          => true,             'rewrite'            => array( 'slug' => 'slide' ),             'capability_type'    => 'post',             'has_archive'        => true,             'hierarchical'       => false,             'menu_position'      => null,             'supports'           => array( 'title', 'editor', 'thumbnail', 'excerpt' ),         );         register_post_type( 'slide', $args );         flush_rewrite_rules();     }     add_action( 'init', 'create_slide_post_type' );


Secondary menu > Active item: How can I output the class "current item"?

I'm using wordpress for my website and i have created a secondary menu. I'm using this secondary menu to work as filter for categories (filter different type of content). > -> root website: www.imagecolor.net (under development) > > -> filter by categories: www.imagecolor.net/category/craft/ > > -> my problem -> http://tinyurl.com/klplq3u PROBLEM: secondary menu is not adding CLASS "current-item".               functions.php            register_nav_menus( array(            'Galleries' => 'Galleries Filter',           'Categories' => 'Categories Filter'             ) );               display.php             <?php wp_nav_menu( array( 'theme_location' => 'Categories' ) ); ?>      WHAT I WOULD LIKE ACHIEVE: highlight the current activated item in the menu to let user know that's the current active location. Can someone tell me how to solve this little problem?


Using wp_insert_post() with Networking enabled

I'm working on a script that will drop articles directly into the wordpress database, using wp_insert_posts(). However, I have networking enabled and the wp_insert_post() reference page has no documentation relating to using wp_insert_post() to upload to a specific site on the network. How can I do this with wp_insert_posts()? Or is their another function which does this?


How to list posts by term (custom taxonomy)

I created a custom post type **(portfolio)** , with custom taxonomy **(portfolio-category)**. I created a template, this template lists all "portfolio" posts.                       <?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
             <?php the_content(); ?>             <?php endwhile; ?>             <?php $mypost = array( 'post_type' => 'portfolio', );             $loop = new WP_Query( $mypost ); ?>

                     <?php while ( $loop->have_posts() ) : $loop->the_post();?>                     <li  id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php the_title(); ?>
                             <?php the_date(); ?>                             <?php the_content(); ?>
                         <?php if ( has_post_thumbnail() ) { ?>
                             <?php the_post_thumbnail( 'portfolio-size' ); ?>
                             <?php                                 $fullimage_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" );                                 echo'';                               ?>

                         <?php } ?>
                     <?php endwhile;  ?>

      As you can see `<?php while ( have_posts() ) : the_post(); ?>` in this page template the user can add content above the wp_query. I created a file, taxonomy-portfolio-category.php with same content. With this I would like to list posts by term, but I would like to show the "user managed" content above the query too. _(The result is: I get same page, but instead of the unique content (user managed) I see the list by the term.)_ How can I do that? Or what's the best way for that?


Missing argument 2 for wpdb::prepare() Issue

I'm having to update a WP installation for a community organisations from version 2.9.1 to the current 3.9.1. The installation has a couple of custom built plugins that arent documented. Ive just performed the WP version update and now I see a warning (Missing argument 2 for wpdb::prepare()) on every page that relates to the following line in the code of one of these custom built plugin:               $rows = $wpdb->get_results($wpdb->prepare("SELECT id, name FROM ".$table_name));      From what Ive read online, this is due to a change in the coding, that requires 2 values to be sent to wpdb::prepare(), but Ive no idea how the line of code gicen above, needs to be changed. If someone could help me out, Id really appreciate it. Thanks in advance.


upload image in a meta box

im trying to implement uploading via a meta box without using the media manager, but i want it to add as a post attachment. im currently doing it just uploading and saving to the server.               <?php          define("THUMB_DIR", WP_CONTENT_DIR . '/plugins/meta-upload/thumbs/');      define("THUMB_URL", WP_CONTENT_URL . '/plugins/meta-upload/thumbs/');           // this needs to be implemented          function fileupload( $label ) { ?>
          <?php             echo $label; ?>         	                      <form name="uploadfile" id="uploadfile_form" method="POST" enctype="multipart/form-data" action="<?php echo $this->filepath.'#uploadfile'; ?>" accept-charset="utf-8" >                 <input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />                 <input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Upload"  />             </form>
        <?php     }          //this needs to be added too          function fileupload_process() {      $uploadfiles = $_FILES['uploadfiles'];          if (is_array($uploadfiles)) {              foreach ($uploadfiles['name'] as $key => $value) {                  // look only for uploded files             if ($uploadfiles['error'][$key] == 0) {                      $filetmp = $uploadfiles['tmp_name'][$key];                      //clean filename and extract extension                 $filename = $uploadfiles['name'][$key];                      // get file info                 // @fixme: wp checks the file extension....                 $filetype = wp_check_filetype( basename( $filename ), null );                 $filetitle = preg_replace('/\.[^.]+$/', '', basename( $filename ) );                 $filename = $filetitle . '.' . $filetype['ext'];                 $upload_dir = wp_upload_dir();                      /**                  * Check if the filename already exist in the directory and rename the                  * file if necessary                  */                 $i = 0;                 while ( file_exists( $upload_dir['path'] .'/' . $filename ) ) {                     $filename = $filetitle . '_' . $i . '.' . $filetype['ext'];                     $i++;                 }                 $filedest = $upload_dir['path'] . '/' . $filename;                      /**                  * Check write permissions                  */                 if ( !is_writeable( $upload_dir['path'] ) ) {                     $this->msg_e('Unable to write to directory %s. Is this directory writable by the server?');                     return;                 }                      /**                  * Save temporary file to uploads dir                  */                 if ( !@move_uploaded_file($filetmp, $filedest) ){                     $this->msg_e("Error, the file $filetmp could not moved to : $filedest ");                     continue;                 }                      $attachment = array(                     'post_mime_type' => $filetype['type'],                     'post_title' => $filetitle,                     'post_content' => '',                     'post_status' => 'inherit'                 );                      $attach_id = wp_insert_attachment( $attachment, $filedest );                 require_once( ABSPATH . "wp-admin" . '/includes/image.php' );                 $attach_data = wp_generate_attachment_metadata( $attach_id, $filedest );                 wp_update_attachment_metadata( $attach_id,  $attach_data );             }         }     }     }          add_action('admin_menu', "post_upload_box_init");     add_action('save_post', 'post_save_thumb');          function post_upload_box_init() {         add_meta_box("post-thumbnail-posting", "Dark Toob Thumbnail", "post_upload_thumbnail", "post", "advanced");          }          function post_upload_thumbnail() {         global $post;     ?>               <?php         $thumb = get_post_meta($post->ID, 'custom_thumbnail',true);              if ( $thumb )         {     ?>
         <img style="border: 1px solid #ccc; padding: 3px;" src="<?php echo THUMB_URL . $thumb; ?>" alt="Thumbnail preview" />
     <?php         }         else         {     ?>
Thumbnail preview
     <?php } ?>

             <?php _e("Upload via URL, or Select Image (Below)"); ?>:
             <input style="width: 300px; margin-top:5px;" id="thumb-url-upload" name="thumb-url-upload" type="text" />

<?php _e("Upload a thumbnail"); ?>:
             <input id="thumbnail" type="file" name="thumbnail" />

<input id="thumb-delete" type="checkbox" name="thumb-delete"> <?php _e("Delete thumbnail"); ?>

<input id="publish" class="button-primary" type="submit" value="<?php _e("Update Post"); ?>" accesskey="p" tabindex="5" name="save"/>

     <?php     }          function post_save_thumb( $postID )     {     global $wpdb;          // Get the correct post ID if revision.     if ( $wpdb->get_var("SELECT post_type FROM $wpdb->posts WHERE ID=$postID")=='revision')         $postID = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID=$postID");          if ( $_POST['thumb-delete'] )     {         @unlink(THUMB_DIR . get_post_meta($postID, 'custom_thumbnail', true));         delete_post_meta($postID, 'custom_thumbnail');     }     elseif ( $_POST['thumb-url-upload'] || !empty($_FILES['thumbnail']['tmp_name']) )     {         if ( !empty($_FILES['thumbnail']['name']) )             preg_match("/(\.(?:jpg|jpeg|png|gif))$/i", $_FILES['thumbnail']['name'], $matches);         else             preg_match("/(\.(?:jpg|jpeg|png|gif))$/i", $_POST['thumb-url-upload'], $matches);              $thumbFileName = $postID . strtolower($matches[0]);              // Location of thumbnail on server.         $loc = THUMB_DIR . $thumbFileName;              $thumbUploaded = false;              if ( $_POST['thumb-url-upload'] )         {             // Try just using fopen to download the image.             if( ini_get('allow_url_fopen') )             {                 copy($_POST['thumb-url-upload'], $loc);                 $thumbUploaded = true;                  }             else                  // If fopen doesn't work, try cURL.             if( function_exists('curl_init') )             {                 $ch = curl_init($_POST['thumb-url-upload']);                 $fp = fopen($loc, "wb");                      $options = array(CURLOPT_FILE => $fp,                     CURLOPT_HEADER => 0,                     CURLOPT_FOLLOWLOCATION => 1,                     CURLOPT_TIMEOUT => 60);                 curl_setopt_array($ch, $options);                      curl_exec($ch);                 curl_close($ch);                      fclose($fp);                 $thumbUploaded = true;             }         }         else              // Attempt to move the uploaded thumbnail to the thumbnail directory.         if ( !empty($_FILES['thumbnail']['tmp_name']) && move_uploaded_file($_FILES['thumbnail']['tmp_name'], $loc) )             $thumbUploaded = true;              if ( $thumbUploaded )         {             if ( !update_post_meta($postID, 'custom_thumbnail', $thumbFileName) )                 add_post_meta($postID, 'custom_thumbnail', $thumbFileName);         }          }     }


How can i create a function to get youtube video time

Tom J Nowell posted this code to help me retrieve the YouTube video time. Functions               // function to parse the code from the URL     function parse_youtube_video_id_from_url( $video_url ) {         $splited_data = explode( '=', $video_url );         $video_unique_code = substr( $splited_data[1], 0, -strlen( strrchr( $splited_data[1], '&' ) ) );         return $video_unique_code;     }          // use the youtube APIs to get a json string containing data about the video     function get_youtube_json_video_data( $video_code ) {         $api_url = 'https://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q='.$video_code;         $data = wp_remote_get( $api_url );         return $data['body'];     }      Getting the data:               <?php $youtubecode = 'QiNIfGiNiOk';     $video_data = get_youtube_json_video_data($youtubecode);     $video_data = json_decode( $video_data );      echo '<pre>'.print_r($video_data,true).'</pre>';     ?>      The data that the above code retrieves (e.g.):               stdClass Object     (         [apiVersion] => 2.1         [data] => stdClass Object             (                 [updated] => 2013-02-27T18:29:22.395Z                 [totalItems] => 1                 [startIndex] => 1                 [itemsPerPage] => 25                 [items] => Array                     (                         [0] => stdClass Object                             (                                 [id] => QiNIfGiNiOk                                 [uploaded] => 2012-11-30T18:20:08.000Z                                 [updated] => 2013-02-26T22:33:56.000Z                                 [uploader] => ramonsteck                                 [category] => Entertainment                                 [title] => After Earth - Trailer 2013                                 [description] => Unete www.facebook.com/Cinemovs Historias Paranormales Reales, Películas de Terror Online y proximos estrenos de cine.                                 [thumbnail] => stdClass Object                                     (                                         [sqDefault] => http://i.ytimg.com/vi/QiNIfGiNiOk/default.jpg                                         [hqDefault] => http://i.ytimg.com/vi/QiNIfGiNiOk/hqdefault.jpg                                     )                                      [player] => stdClass Object                                     (                                         [default] => https://www.youtube.com/watch?v=QiNIfGiNiOk&feature=youtube_gdata_player                                         [mobile] => https://m.youtube.com/details?v=QiNIfGiNiOk                                     )                                      [content] => stdClass Object                                     (                                         [5] => https://www.youtube.com/v/QiNIfGiNiOk?version=3&f=videos&app=youtube_gdata                                         [1] => rtsp://v1.cache6.c.youtube.com/CiILENy73wIaGQnpiI1ofEgjQhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp                                         [6] => rtsp://v1.cache6.c.youtube.com/CiILENy73wIaGQnpiI1ofEgjQhMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp                                     )                                      [duration] => 123                                 [aspectRatio] => widescreen                                 [rating] => 2.6722891                                 [likeCount] => 174                                 [ratingCount] => 415                                 [viewCount] => 247218                                 [favoriteCount] => 0                                 [commentCount] => 63                                 [accessControl] => stdClass Object                                     (                                         [comment] => allowed                                         [commentVote] => allowed                                         [videoRespond] => moderated                                         [rate] => allowed                                         [embed] => allowed                                         [list] => allowed                                         [autoPlay] => allowed                                         [syndicate] => allowed                                     )                                  )                          )                  )          )      How can I get the duration of the video (e.g. '1:23'). He told me to: > create a function, hook that function into the 'save_post' and > 'publish_post' actions, that updates the post meta/custom field based on the > above code How can I create that function hook? And how can i put together: Custom Field were I put the key:               <?php $key="trailer"; echo get_post_meta($post->ID, $key, true); ?>      To retrieve the video data, specify the YouTube URL code such as:               $youtubecode = 'QiNIfGiNiOk';      \-------------------------- UPDATE - The code that Works -------------------------               <?php      $key="trailer";     $youtubecode = get_post_meta($post->ID, $key, true);     $video_data = get_youtube_json_video_data($youtubecode);     $video_data = json_decode( $video_data );      foreach ( $video_data->data->items as $data ){                     echo brsfl_secondsToTime($data->duration);         }     ?>      \--------------------------------- Thanks to Brasofilo ----------------------------


wrap text around custom fields array

I'm using this code here to grab all my custom fields from a post for use in an gallery array. http://www.kevinleary.net/get-all-custom-fields-attached-post-page-post-type/ **function:**               //  Get all custom fields attached to a page     if ( !function_exists('base_get_all_custom_fields') ) {     function base_get_all_custom_fields()     {         global $post;         $custom_fields = get_post_custom($post->ID);         $hidden_field = '_';         foreach( $custom_fields as $key => $value ){             if( !empty($value) ) {                 $pos = strpos($key, $hidden_field);                 if( $pos !== false && $pos == 0 ) {                     unset($custom_fields[$key]);                 }             }         }         return $custom_fields;     }     }      **single.php:**               // Get all custom fields attached to this post and store them in an array     $custom_fields = base_get_all_custom_fields();     if( !empty($custom_fields) ) {     print_r($custom_fields);     }      It works, but outputs text like this around the custom post `Array ( [photo1] => Array ( [0] =>` Is there a way to customise what you wrap before & after a custom field output, and remove the array text? What I'm trying to achieve is               {image : 'http://website.com/slides/photo1.jpg'},      {image : 'http://website.com/slides/photo2.jpg'},       {image : 'http://website.com/slides/photo3.jpg'},       so I need to wrap `{image : '` before and `'},` after the link. I can sort of do it with single queries but the array system would be better               {image : '<?php echo $custom_fields['photo1'][0]; ?>'},     {image : '<?php echo $custom_fields['photo2'][0]; ?>'},     {image : '<?php echo $custom_fields['photo3'][0]; ?>'},


Loop Custom Post Type for Single Author

I am creating a custom author.php page and on that page I want to have different areas where I can display custom post types (cpt). So in one area I will display the cpt 'blogs', in another area the cpt 'audio' and in another area cpt 'video', etc. -- but all for one author -- say by Albert Einstein, and on his author page. Ideally, each loop would be conditional so that when there was no cpt, say for 'video' or 'blogs', nothing would display. I have looked around but cannot find code that works for me. If anyone can help provide code for looping at least one of these cpt's that would be very helpful. Thank you! Here is the code that I am using -- for some reason it is not calling the ctp so no posts are appearing on the page:               <?php         $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));         query_posts( array(                 'post_type' => array('video'),                 'author' => $author,                 'posts_per_page' => 10 )             );     ?>


Unable to retrieve data from multiple Wordpress websites on same server

I am trying to retrieve data from multiple client Wordpress websites on a single php page. So I can monitor all these websites without going through each one. I am able to display data from one single website. Like this, I am listing all plugin installed on one Wordpress.               <?php       require( './domain1/wp-blog-header.php' );       if ( ! function_exists( 'get_plugins' ) ) {         require_once ABSPATH . 'wp-admin/includes/plugin.php';       }       $plugins = get_plugins();       echo '
 ' . get_bloginfo( 'name' ) . '
';       foreach ( $plugins as $plugin ) {         echo $plugin['Name'] . '
';       }     ?>      This works fine as I want. But when I try to do this for multiple website, it does not work but shows data from first website multiple times.               <?php       $websites = array( 'domain1', 'domain2', 'domain3', 'domain4', 'domain5', 'domain6' );            foreach ( $websites as $website ) {         $file = './' . $website . '/wp-blog-header.php';         require( $file );         if ( ! function_exists( 'get_plugins' ) ) {           require_once ABSPATH . 'wp-admin/includes/plugin.php';         }         $plugins = get_plugins();         echo '
 ' . get_bloginfo( 'name' ) . '
';         foreach ( $plugins as $plugin ) {           echo $plugin['Name'] . '
';         }       }     ?>      Why it's only showing details from first domain only? What am I doing wrong? Can someone help me with this. Thanks.


Apply code for all else first block

I have this code for sidebar in Wordpress :-                register_sidebar(array(     'name' => 'Main sidebar',     'description' => 'main sidebar.',     'before_widget' => '

',     'after_widget' => '

',     'before_title' => '
',     'after_title' => '

'       ));      In this cod will add every widget attribute `style="visibility: hidden;"`, but i need to add this attribute for all widget else first widget. How can do that by php or JQuery.


How to call for bloginfo inside function in functions.php?

I am new to WordPress and PHP, so I have this question: I want to add a Link to the "New Post" for a Custom Post Type I implemented. But it will only let me put static links, connected to my localhost test installation. How do I add a non-static URL right there, like a `bloginfo('wpurl')` that it will actually read out? This is what I want:                function wp_admin_bar_new_item(){             global $wp_admin_bar;             $wp_admin_bar->add_menu(array(                 'id'=>'wp-admin-bar-new-item',                 'title'=>__("Kunstwerk hinzufügen"),                      'href'=>//Here it I want a link to my Custom Post Type                 ));         }      And this is what I tried that didn't work:               function wp_admin_bar_new_item(){         global $wp_admin_bar;         $wp_admin_bar->add_menu(array(             'id'=>'wp-admin-bar-new-item',             'title'=>__("Kunstwerk hinzufügen"),                  'href'=>'bloginfo("wpurl");/../../wp-admin/post-new.php?post_type=albertis-kunstwerke'             ));     }      and this is what is working with my localhost, but I don't want it to be static.               function wp_admin_bar_new_item(){         global $wp_admin_bar;         $wp_admin_bar->add_menu(array(             'id'=>'wp-admin-bar-new-item',             'title'=>__("Kunstwerk hinzufügen"),             'href'=>'http://localhost:8888/test/wp-admin/post-new.php?post_type=albertis-kunstwerke'             ));     }


Cron Lock Timeout, when to use?

When is it a good idea to use this constant in relation to WordPress Cron? WP_CRON_LOCK_TIMEOUT


Basically the opposite MultiSite URL question that most people ask

Going to install a wordpress multisite in a subdirectory format. So a new site will be `site.com/sitetwo/` or `site.com/sitethree/` but what I need to do for the specific task at hand is change the url to `site.com/string/sitetwo` I could easily accomplish it with a second install of wordpress in the `/string/` folder but that doesn't sound elegant. I've exhausted all other ideas and would greatly appreciate another perspective. My wp.org post, with more details: http://wordpress.org/support/topic/multisite-subdirectory-possibly-htaccess- question?replies=1


Adding an Arbitrary Link to the Admin Menu?

Is there a way to add a arbitrary hyperlink to the WordPress admin menu (I mean the menu on the left when you log into the admin dashboard)? For example, can one add a link to Google? In my particular case, I'd like to add a styleguide page for a Wordpress theme I'm working on so I can show the user how different HTML elements are styled with the theme and to demo how to style various things nicely. This is the code I have so far ( _note: it is incomplete_ ): In _functions.php_ I have added a new menu item in the _Appearance_ section:               add_action('admin_menu', 'create_theme_style_page');          function create_theme_style_page() {       add_theme_page('Theme Styleguide', 'Theme Styleguide', 'administrator', basename(__FILE__),'build_styleguide_page');     }          function build_styleguide_page() {      echo "Not sure what goes here to redirect admin to a arbitrary url?";     }      In `build_styleguide_page()`, attempting to redirect with `header()` gives a error ( _Cannot modify header information_ ).


Basic analytics across WordPress Multisite network

I'd like to capture basic analytics (page views, visitors, time on site, etc.) across all of the sites in our network while also allowing users to install the analytics software of their choice. The network contains sites on a subdomain of a primary domain, as well as custom domains. What's the best analytics tool for this purpose? Ideally, it would be just one analytics tag that could be installed across an arbitrary number of domains and subdomains. I'd prefer not having to register each domain by hand. **Update 9/11:** I've installed Quantcast for the time being, and I think it will do the trick, but a more full-featured tool would be awesome.


URL Design for Sub-Posts?

I currently have this:               mysite.com/product-name     mysite.com/another-product      etc where product-name and another-product are posts. I then have a custom post type called Changelogs, which I have for each product, is it possible to have the url something like:               mysite.com/product-name/changelog     mysite.com/another-product/changelog      If so, how would I go about doing it?


Can I set some default pages to be created on every creation of a new blog

The pages like "about" will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites. How can I configure the default pages to be created with a new blog under a multisite? For ex.: If I have a multisite on `example.com`. Every blog created under this site should have Home, About, My store, My address.


Renaming Custom Post Types and Taxonomies

I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just running a SQL update query that I'll miss some places where I need to change things or overwrite part of serialized data. I have already inputed over 3,000 items, so I can't just restart with a clean database. What would be the best way to rename a custom post type? How about renaming a taxonomy?


Why is there no global function in wordpress to return the output of any function call?

We have template tags and some functions that start with get. Sometimes it would be just nice in themes to do like:               $title = the_title();      to use the html later on. This is just a simplified example, naturally there is some function like get_the_title(); But that works for that function only. I'm wondering why there is no such function like this:               function get_output() {         $args     = func_get_args();         $callback = array_shift($args);         ob_start();         call_user_func_array($callback, $args);         return ob_end_clean();     }      That could convert any function that has output into a returning function:               $title = get_output('the_title');      Any idea why about that has never been thought about? Every theme author or hacker can make use of such, right?


Limiting the number of words or characters in the slug/permalink

Limiting the number of words or characters in Wordpress slug/permalink. I would like to limit the number to the first 5 words (or 20 characters) even if the post title is longer.   example:   Title: Welcome to my site - this is my first post   url: mysite.com/welcome-to-my-site Some function or alteration in the core Wordpress to achieve this result?


WordPress MU - pages to other domains

I have a problem with Wordpress Multisite. Does somebody know how to redirect page address to other addresses?? I have for ex.: > http : / / serv12349 . local . com / page_1 =====> http : / / www . d1 . > domain . com > > http : / / serv12349 . local . com / page_1 / page_2 =====> http : / / www . > d2 . domain . com WP MU is installed in sub folders - so WP MU Domain Mapping doesn't work I read a lot of articles and still don't know how to do it.


How can I only display one link rather than many?

So using this snippet:                  <?php        foreach((get_the_category()) as $childcat) {     if (cat_is_ancestor_of(10, $childcat)) {     echo 'cat_ID).'">';      echo $childcat->cat_name . '';     }}     ?>      I'm able to output all the child categories of the parent category with the id 106. However, I only want to output _one_ child category if there's more than one. How can I do this, please?


Filter to change the content of 404 page

I have created custom rewrite rules. These rules now go to 404 page as expected. I can use action hook `template_redirect` to change the template matching `query_var`. But I don't want to create separate template files as the page structure depend on the current theme in use. Rather I just want to change the content and title. I have tried change the content using `the_content` filter, but it seems the filter doesn't even get called for 404 page. I also tried loading `index.php` template and then using `the_content` filter, but it also doesn't work. Is there any way to achieve this?


Custom Post Type Author limit

It's possible limit creation of custom post type named "ofertas" to 1? Only for authors. I have installed Wordpress 3.8 and plugins don't work (Limit Post Creation 1.4, Bainternet Post Creation Limits 3.1 and Custom Post Limits 3.6). Any idea? thanks


How to properly use Categories with Custom Post Types

I'm really struggling with this... I created a few Custom Post Types, let's say...   * Books   * CD's   * Maps Now I also have a whole bunch of existing categories and some of these would apply to more than one Custom Post Type. For example, the "Available" category could be assigned to all of these Custom Post Types. Now I'm running into a whole bunch of issues when I try to access the categories, either programmatically, or through the front end's archive pages. For example, to put recent posts from all Custom Post Types on the home page, I had to do this...               function get_custom_posts( $query ) {         if ( ! is_admin() && empty($query->query_vars['suppress_filters']) ) { // is not in Dashboard (is_admin => Dashboard)                    if ( is_home() ) { // home page                 return $query->set( 'post_type', array( 'post', 'books', 'cds', 'maps' ) );             } else if .....         }     }     add_filter( 'pre_get_posts', 'get_custom_posts' );      And the more I discover working strangely, the more I have to go back and fix. Presently I'm trying to retrieve all posts from the "Available" category for a slideshow and the Dashboard is showing me there are 19 posts in this category. However, when I run this code...               <?php          global $post;          $featured_posts = get_posts(          array(             'post_type' => array( 'post', 'books', 'cds', 'maps' ),             'category' => get_theme_option('featured_posts_category')             )         );          foreach($featured_posts as $post) {              setup_postdata($post);              $slide_image = get_the_post_thumbnail($post->ID, 'medium');         echo 'ID).'">'.$slide_image.'';         ....     }          ?>      I'm getting far fewer posts than the 19 I expect and the ones I'm getting back are only coming from the "CDs" Custom Post Type and all other Post Types are ignored. Similarly, I get other unpredictable or strange results when selecting other categories. This all leads me to believe that I shouldn't be sharing the same category across multiple Post Types... can anyone confirm this or explain further what I may be missing here?


How to prepare the back button action to deal with infinite scroll?

Unfortunately my question is not fixing or understanding code. I have a problem with infinite scrolling, where the user can scrolldown `x` far, click on `xStory` and enter a new page. Then naturally hit back, and expect to return to `x`, but in my case users are returned to the "bottom", which is the height if whatever page they came from. But the page that the back button returns to has the default number of posts, and not however many were revealed by scrolling. I'm looking for some conceptual ways to look at solving this. Of course real examples would be great! I'm using the plugin Infinite Scroll which operates on CSS selectors: ![enter image description here](http://i.stack.imgur.com/r06hT.png)


Custom post_type search pages

So I have a section on my site that specifically searches a custom post type for YouTube videos. I'm absolutely able to search the custom type. However, I'm unsure how to create a search page that has custom formatting geared toward this type of search. I've created a custom loop-youtube.php and modified within search.php `get_template_part( 'loop');` to `get_template_part( 'loop', 'youtube');` however, it affects the search results globally. Is there a way to create a custom search.php page for a specific post_type? Thanks for any help.


delete attachment from front end

logged in as admin and trying to code that deletes posts to delete an attachment. got,               <?php if (current_user_can('edit_post', $attachment->ID))      echo "ID."", 'delete-post_' . $attachment->ID) . "'>Delete" ?>      but it just takes me to a page that says; _Are you sure you want to do this? Please try again._ and the please try again links back to the post... is it something to do with the **delete-post_** best, dan.


How to appending to the_content using add_filter with custom post type?

I have a custom post type running fine, but some of the text in the page is the same for every post, so I want to add it in using a function. I have this set up:               function new_default_content($content) {     global $post;         if ($post->post_type == 'custom-post-type') {         $content = 'Test text here';         }         return $content;         }     add_filter('the_content', 'new_default_content');      However when I refresh the page, I only see "Text test here" and not the the post's content (from the_content). If I comment out this function, the post content reappears. What am I doing wrong?


wordpress blog, is there a way to make anyone post in a blog without having login info

I am creating a wordpress blog site with some custom function. One on the thing that I need to do to have a function where user can post to blog without using login information. Is that doable? I know this will create lots of spam stuff, but this is what the owner of the site wants.


facebook like - image display and description

i have some difficulties with the new Facebook like feature. usually, each one of my blog post has an image in it. when i use the facebook share feature everything is going well: it lets me choose as a thumbnail between the images embedded in my post and in the description it shows the entire first paragraph (or at least most of it). recently i've added the new facebook like feature to my blog but i can't make it behave like the share feature - when i like a post it doesn't use the post embedded image as a thumbnail. i managed to to make it display a default thumbnail by inserting this to header.php -               <meta property="og:tag name" content="tag value"/>       however, this is is only a partial solution. is there a way to make it use the post image as a thumbnail? in addition to the thumbnail issue, the like shown on my news feed doesn't grab the first paragraph as a description but only the 85 characters of it. is there a way to make it show the whole paragraph or at least more characters? thanks!


What is the Object for WP_Error Class?

i want to know what is the **object** for `WP_Error` Class located in **wp- includes/class-wp-error.php** because i used a custom registration form plugin in there for validation i used this below function                function custom_validation($errors) {                      if (($_POST['birthday']) != 1)                     $errors->add('birthday', "ERROR:" . please finish birthday);                return $errors;         }          add_filter('registration_errors', array('customregistration', 'custom_validation'), 10, 3);      Above function works fine with WordPress default themes(twentytwelve,twentyeleven). but if i use with other themes on registration it shows `Call to a member function add() on a non-object` So i searched for $errors object in `WP_Error` Class but i couldn't able to see a `new` keyword which is used to create an object for a class. Now   1. what is the object for `WP_Error` Class?   2. if it is $errors then why am i facing a fatal error called `Call to a member function add() on a non-object`?   3. i can't able to see a class instance in `WP_Error` by using `new` keyword.   4. if it not $errors how this is working in default theme? **Note** :Other theme registration page looks different from default registration page.


Change 2 fields in the post depending on the 3rd field before save

I have a custom content type called **cards**. I have 3 custom meta fields called: **my_cards_activity** (select field type; options 0 and 1) **my_cards_user** (select type; many options) **my_cards_datetime** (text field type; yyyy-mm-dd hh:mm format) When I press SAVE button I want to get the value of the `my_cards_activity` field (value can be 0 or 1) and if the value is 0 then change `my_cards_datetime` and `my_cards_user` to empty value and only after the change save it all. If it is 1 then do nothing. How to do such before save thing? How should my code in functions.php look like?


How to: 301 Redirect /category/ to /customname/

I've changed our "category base" in WP settings from the default "category" to "customname". Now there are 404 errors to links containing the old category slug eg. mysite.com/category/names What do I enter in .htaccss to 301 redirect mysite.com/ **category** /xxx to mysite.com/ **customname** /xxx Thanks,


Cannot retrieve home url with custom queries

This is just driving me crazy. I cannot get wp to return the home page/url link. I have tried various combinations of               <?php echo esc_url( home_url( '/' ) ) ?>     <?php echo esc_url( bloginfo( 'url' ) ) ?>     <?php echo home_url() ?>      But they all return the current page. In this case a page with attached queries. Now I should mention that 1. I am not using the loop. I have not yet got to that stage though I did write it in to test this problem. 2. I have registered custom search queries.               function add_query_vars($aVars) {         $aVars[] = "search";         $aVars[] = 'special';         return $aVars;     }          add_filter('query_vars', 'add_query_vars');      The problem only seems to occur in search.php when these custom queries are in use. As you have probably guessed the returned home url is always .../wp- install/?search=foo&special=bar. Is there any way around this problem?


How to? Redirect /category/sci-fi/ to /category/scifi/?

I changed the wordpress category slug from "sci-fi" to "scifi" a few months back by accident. How can I redirect `/category/sci-fi/` to `/category/scifi/` so that `/category/sci-fi/page/2/`, `/category/sci-fi/page/3/` etc stops resulting in 404 errors? Thanks


How to add multiple featured images to post/page without a plugin

For example, in portfolio section I want to have 3 images that are positioned always in the same place in all the posts. I know there is a plugin that does this but I need to accomplish this without a plugin.


Download PHP and CSS from the Wordpress admin page without FTP

Some of my clients don't have CPanel access to their WordPress, so I have to copy and paste from the built-in editor to pull out the PHP. Is there a way within that admin interface to grab all the PHP files? I don't have FTP acces.. gr...


How to create posts or pages with the names in wordpress?

When you develop a site on wordpress you may want to create posts/pages with the same name, something that wordpress does not allow by default. Use cases:                example.com/en/contact      example.com/fr/contact      example.com/en/support/contact      I am currently using WPML plugin in order to create multilanguage sites and I encountered this limitation in wordpress. How can I solve this problem? Do you know any tricks or plugins that would allow me to deal with this problem.


How to use code sample into WordPress post?

I am using WordPress, and when I post some post data into my WordPress post, including some html code, as follows:

      I want the code to be displayed, but the code is not displayed. How can I make it work?


Adding a div class or id inside the_content()

I'm trying to create an advertisement block to be placed on a single post (single.php) such that the div class or id is left aligned and the post content wrapped around it. I checked the single.php and this is the only piece of code I notice is what displays the post.
                     <?php the_content(); ?>                     <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'themejunkie' ), 'after' => '
' ) ); ?>      I tried adding the code both above the 'entry-content' div and also after the_content, but with both methods it either displays the div either at the beginning or at the end of the post content. Can someone tell me which files to look into in order to add this?


Custom Post Types and independent Categories - complex Taxonomy

Input data:   1. There is a Custom Post Type, with `Companies` posts that relates to `Company` category;   2. There is a Custom Post Type, with `Products` posts that tied to `Items -> Item-type` category;   3. There is a Custom Post Type, with `Articles` posts that tied to `Articles` category; Summarizing, structure looks like this:               + Companies (cat)        |- Company-1 (post)        `- Company-2     + Items (cat)        `- Item-type-1 (cat)        |   |- Product-1-1 (post)        |   `- Product-1-2        `- Item-type-2 (cat)            |- Product-2-1 (post)            `- Product-2-2     + Articles (cat)        |- Article-1 (post)        `- Article-2      The Problem: I'll be appreciate for a way to implement the structure that can be accessed like this:               http://example.com/company-1/items/item-type-1/product-1      http://examplecom/company-2/items/item-type-1/product-1 //(note that both company 1 and 2 can produce a similar product)     http://example.com/company-1/articles/article-1-1     http://example.com/company-2/articles/article-2-1      Both Products and Articles posts have got a custom fields that stores post-IDs of companies they're tied to. UPDATE: I was thinking about developing it with custom taxonomies:               http://example.com/post-type-company/taxonomy-item/term-item-type/product      Can you advice more suitable way?


when saveing $meta_box i get Undefined index error

I need help to fix these Notices:               PHP Notice: Undefined index: person-name in testimonials.php on line 112     PHP Notice: Undefined index: position in testimonials.php on line 112     PHP Notice: Undefined index: company in testimonials.php on line 112     PHP Notice: Undefined index: link in testimonials.php on line 112     PHP Notice: Undefined index: testimonial_wpnonce in /testimonials.php on line 116     PHP Notice: Uninitialized string offset: 0 in testimonials.php on line 97      I tried the following:               if ( isset($_POST['name']) && !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(FILE) ) ) return $post_id;       but still got Undefined index. Here is the code from line 95 - 124
                 <label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?>                 <input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo htmlspecialchars( $data[ $meta_box[ 'name' ] ] ); ?>" />
<?php echo $meta_box[ 'description' ]; ?>

                  <?php } ?>
         <?php     }          function wpb_save_meta_box( $post_id ) {         global $post, $meta_boxes, $key;              foreach( $meta_boxes as $meta_box ) {             $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ];         }              if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) )             return $post_id;              if ( !current_user_can( 'edit_post', $post_id ))             return $post_id;              update_post_meta( $post_id, $key, $data );     }          add_action( 'admin_menu', 'wpb_create_meta_box' );     add_action( 'save_post', 'wpb_save_meta_box' );


Apply the_content filter, but prevent other hooked actions

I have a plugin that displays some content onto the front end of the site after applying the_content filter to the block of text. I do this for formatting and maintaining links and images etc. When I display my content on the front end of the site, other plugins that are hooked into the_content cause conflicts. For example, sharedaddy by jetpack hooks into the_content and displays share buttons wherever the_content is being used. I can manually disable it by removing the filter, but this is less than ideal as I'm sure not all of my users are using sharedaddy. So rather than adding the remove_filter for sharedaddy, is there a way I can just simply remove all filters hooked into the_content for my specific plugin? I am displaying my content like so: ` <?php echo apply_filters('the_content' , $this->optionVal['custom- message']); ?> `


trouble with page_id & highlighting current page

I'm using the below code to highlight the page name/gallery shown when the corresponding link is clicked on. My challenge is that regardless of what link I click, only the very first link(`page_id=24`/Haagen-Dazs) is highlighted. Any ideas what's causing the issue? Thanks. live site CSS `.active { border: 1px solid #ff893b; }` HTML/PHP/JAVA `
         <a href="?page_id=24" <?php if ($page_id=='24'){echo 'class="active"';} ?>> Häagen Dazs
         <a href="?page_id=26" <?php if ($page_id=='26'){echo 'class="active"';} ?>> Hugo Boss Rodeo Drive
         <a href="?page_id=28" <?php if ($page_id=='28'){echo 'class="active"';} ?>> Ford
         <a href="?page_id=30" <?php if ($page_id=='30'){echo 'class="active"';} ?>> MOCA Contemporaries
         <a href="?page_id=32" <?php if ($page_id=='32'){echo 'class="active"';} ?>> XBOX 360 Halo 3 Sneak Preview
         <a href="?page_id=34" <?php if ($page_id=='34'){echo 'class="active"';} ?>> Saddlerock Smith & Basso Weddings
         <a href="?page_id=36" <?php if ($page_id=='36'){echo 'class="active"';} ?>> Christie's
         <a href="?page_id=42" <?php if ($page_id=='42'){echo 'class="active"';} ?>> Instyle Magazine + Ming by Mango

`


Why can't I load JS script in a plugin?

I have this at the bottom of my plugin file, but while I can access the plugin, I can't see any reference in the code to **jquery.chained.min.js** in the source:               add_action( 'wp_enqueue_scripts', 'my_plugin_enqueue' );              function my_plugin_enqueue() {           wp_enqueue_script( 'jquery.chained.min', plugins_url('/js/jquery.chained.min.js',__FILE__), array('jquery'));         }      I have confirmed in the plugin folder that jquery.chained.min.js is in the js folder.


custom theme: english .mo file not working

I'm having an issue with a `.mo` file. I have a fully functioning localized custom theme that's running in four languages for the moment: Dutch, English, French and Spanish. There is one problem: the English localization doesn't work. The other languages work just fine. The translation plugin is polylang. The plugin for creating `.po` and `.mo` files is CodeStyling Localization. The `.po` and `.mo` files are situated in the folder `/language/` inside my theme. The theme is localized and works just fine in Dutch (default language), French and Spanish. When I'm in the English version of the website however, the default Dutch words appear on localized strings. I've tried deleting the English `.mo` and `.po` files and recreating them anew but this didn't help. It isn't a problem with the `en_US.po` or `en_US.mo` files. I just copied them from the site's server and tried them on another WP install. Worked just fine. I'm out of ideas. Does anybody have suggestions? Is there a way to test the call to the English `.mo` file and get some PHP feedback. Any ideas are welcome.


Count number of post in Taxonomy?

wp_count_terms() counts the number of terms in a taxonomy but not the number of post that have those terms and I've found that wp_count_post() does not accept a taxonomy. So whats a guy gotta do to count the number of post in a taxonomy term? Example: Term: Apples Post: 89 (this is what I want to get, the number of post with the 'Apples' taxonomy) Thanks!


Custom taxonomy no data

Ladies and Gentleman, i have a problem. I habe created a taxonomy like this in my functions.php               function drivers_init() {         // create a new taxonomy         register_taxonomy(             'tax_drivers',             'post',             array(                 'label' => __( 'Drivers' ),                 'rewrite' => array( 'slug' => 'tax_drivers' )             )         );     }     add_action( 'init', 'drivers_init' );      I'm able to view my taxonomy under 'post' and also can add some terms to idd (records in term_taxonomy and terms are created and correct). Now the problem: I can't get the data (to show) in my front-end. If i use get_terms('category'), i'll get all default categories, but if i change to get_terms('tax_drivers') i won't get data at all? Did i do sth wrong?


WooCommerce - Want to show multiple currency for a single product

Am using woocommerce - and want to show multiple currency for a single product. I know there is a currency converter widget extension. But am not able to buy it for now. So if can some one assist me to write a function where I can show multiple currency for a single product - But will pay the base currency which is set in woocommerce settings. Its just to show how much it costs if you are in different country. Something like this - http://haet.at/wp-e-commerce-currency-helper/ Please assist. Regards, Raghav,


Fatal error: require() [function.require]: Failed opening required in wordpress

My blog has been working fine for months. Today when I tried to open it I got the following errors:               Warning: require(/home/dhabitat/public_html/blog/wp-includes/functions.php) [function.require]: failed to open stream: Permission denied in /home/dhabitat/public_html/blog/wp-settings.php on line 69     Fatal error: require() [function.require]: Failed opening required '/home/dhabitat/public_html/blog/wp-includes/functions.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dhabitat/public_html/blog/wp-settings.php on line 69      Does anybody know how it can be fixed. thanks


Plugin: database creation

Can someone tell me what's wrong with this function?               function xattachments_db_install() {        global $wpdb;        $xattachments_db_version = "1.0";        $table_name = $wpdb->prefix ."xattachments";             $sql = "CREATE TABLE IF NOT EXISTS ".$table_name. " (             'xattachments_id' int(10) unsigned NOT NULL,             'xattachments_name'  varchar(200) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,             'xattachments_title' varchar(200) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,             'post_id' int(10) unsigned NOT NULL,             'xattachments_data_id' int(11) NOT NULL,             PRIMARY KEY ('xattachments_id')         ) ENGINE=MyISAM DEFAULT CHARSET=CHARSET=utf8 COLLATE utf8_bin ;";             require_once(ABSPATH.'wp-admin/includes/upgrade.php');        dbDelta($sql);        add_option("xattachments_db_version", $xattachments_db_version);          }     register_activation_hook(__FILE__,'xattachments_db_install');      It doesn't generate any error message when I activate the plugin but the table is not created in the database. This function is located at the very beginning of the plugin file. Thank you.