Wordpress Drag n Drop Uploader - Single File Only

I have a system in place to allow users to upload files, once they have done this they are thrown into a plugin to allow them to perform various cropping (on the main image and the configured thumbnails). My problem is that if I upload multiple files it causes issues as the user can only work on one file at a time. Is there anyway that I can restrict the drag and drop uploader to only accept one file upload at a time? I know that there is the option of the old HTML uploader which does one at a time, but I would prefer to retain the drag and drop option. Thx Richard


How to create dynamic menu from HTML

I tried creating a dynamic menu from HTML, I registered menu in function name is main menu, Here is the HTML code that display the main menu-

             <a class="sprite" href="<?php echo esc_url( home_url( '/' ) ); ?>">              <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <img src="<?php bloginfo('template_directory') ?>/images/home.png" width="57" height="52"  class="home"/>
Home

About Us

Privacy Policy

Disclaimer

SiteMap

Contact Us

Aquaponics

AquaCulture

Hydroponics

Do-It-Yourself Aquaponics

Fish & Plants for Aquaponics


Modified home page query does not yield expected results

Yesterday i asked how it would be best to load all existing pages and their content on front page - to create single page layout. (Single page theme) From the info on that page i created my own pre_get_posts hook in functions.php:               function show_all_pages_on_index( $query ) {         if ( (is_front_page() || is_home()) && $query->is_main_query() ) {             $query->set('post_type', 'page');             $query->set('parent', '0');             $query->set('post_status', 'publish');             $query->set('orderby', 'menu_order');             $query->set('order', 'ASC');         }     }     add_action( 'pre_get_posts', 'show_all_pages_on_index' );      If i put echo in the condition there it gets printed out, so i guess the hook works. but this snippet in index.php still only prints out the initial blogpost that gets created with wordpress install: index.php:               $myposts = get_posts();     foreach( $myposts as $post ) :  setup_postdata($post);              echo "
". the_title()."
";          endforeach;      wp_reset_postdata();      HTML:               http://localhost/hello-world/Hello world!

      Edit - to show what worked in my case as single page layouyt: functions.php:               function show_all_pages_on_index( $query ) {         if ( (is_front_page() || is_home()) && $query->is_main_query() ) {             $query->set('post_type', 'page');             $query->set('post_parent', 0);             $query->set('post_status', 'publish');             $query->set('orderby', 'menu_order');             $query->set('order', 'ASC');         }     }     add_action( 'pre_get_posts', 'show_all_pages_on_index' );      index.php:               while ( have_posts() ) {         the_post();         get_template_part( 'content', 'page' );     }      From there on wordpress'own tempate logic takes over using content-page.php or content.php, which pretty much means you can create different templates for subpages but you need to create them so that they actually fit into single page layout. Thanks to everybody who contributed:)


Display link with current user's username in it in Custom Menu

I'd like to add a link to BuddyPress' My Favourite Topics in a Custom Menu. Is there a way to use the current logged in user's username in the link? I mean like the `%category%` in the permalinks.


get an attachment's media tags or check if it has a media tag?

Is there a way i can get media_tags assigned to an attachment (by id)? And/or check if an attachment has a media_tag? Not sure if i'm missing something but there seems to be very little support for doing this? any help appreciated, Dc


My custom widget won't stay in the widget area after I refresh the widget page

As the title says, i've been developing a simple image rollover widget, now that I'm almost done, the widget won't stay in the sidebar areas after I drag and drop it in and refersh the page, any idea what's going on?               <?php     /**      * Plugin Name: Rollover Widget      * Description: A widget that creates a rollover image effect with a hyperlink.      * Version: 0.1      * Author: Zak Elas      * Author URI: http://dot.com      */               add_action( 'widgets_init', 'my_widget' );               function my_widget() {         register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {              function MY_Widget() {             $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that creates a rollover image effect with a hyperlink. ', 'example') );                  $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'Rollover Widget' );                  $this->WP_Widget( 'example-widget', __('Rollover Widget', 'example'), $widget_ops, $control_ops );         }              function widget( $args, $instance ) {             extract( $args );                  //Our variables from the widget settings.             $link =  $instance['link'] ;             $image = $instance['image'];             $rollover_image = $instance['rollover_image'];                  echo $before_widget;                  // Display the widget link                   echo $before_link . $link . $after_link;                  //Display the name                         echo '

';                        echo $after_widget;         }              //Update the widget               function update( $new_instance, $old_instance ) {             $instance = $old_instance;                  //Strip tags from link and name to remove HTML              $instance['link'] = strip_tags($new_instance['link']);             $instance['image'] =  strip_tags($new_instance['image']);             $instance['rollover_image'] = strip_tags( $new_instance['rollover_image']);                  return $instance;         }                   function form( $instance ) {                  //Set up some default widget settings.             $defaults = array( 'link' => __('Example', 'example'), 'image' => __('/images/editorial.png', 'example') , 'rollover_image' => __('/images/editorial.png', 'example') );             $instance = wp_parse_args( (array) $instance, $defaults ); ?>
                 <label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('link', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $instance['link']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'image' ); ?>"><?php _e('image', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'image' ); ?>" name="<?php echo $this->get_field_name( 'image' ); ?>" value="<?php echo $instance['image']; ?>" style="width:100%;" />

                 <label for="<?php echo $this->get_field_id( 'rollover_image' ); ?>"><?php _e('rollover_image:', 'example'); ?>                 <input id="<?php echo $this->get_field_id( 'rollover_image' ); ?>" name="<?php echo $this->get_field_name( 'rollover_image' ); ?>" value="<?php echo $instance['rollover_image']; ?>" style="width:100%;" />
                        <?php         }     }          ?>


Import Wordpress xml file larger than 8mb

I'm trying to import a xml file (from a previous wordpress theme) into a new wordpress theme. The problem is that the xml file is 46mb much bigger than the wordpress 8mb limit. Anyone have any advice/recommendations on how to import this file? Thanks apagey


wp_redirect does not work

I have a problem with `wp_redirect` which does seem to redirect. It's a full url that is on the current website. I need to put `exit();` after `wp_redirect` for it to redirect. Is this normal? Redirect is in an `init` action btw.


Media attachment date and post date

I have just migrated a massive site (2500+ users, 5000+ posts/images) to Wordpress using custom code. Basically every post has one image and that image is attached to the post as the featured image, and all images show on the Media Library. I have also managed to keep the original submission date for every post (which is the same date each image was uploaded) and to save every image under the corresponding /wp-content/uploads/[year]/[month] folder. So far so good. Hoever... all those image files and all entries on the Media Library, show the migration date (Nov 2011) instead of the original file creation/post creation date (variable from 2003 to 2009). This makes it very difficult to find which image belongs to a certain post, as image creation date information was lost. So I need to update the dates of all Media Library entries and image file creation (same thing?), to the date of the post they are attached to. Any idea what's the best way to go about it? Any help would be truly appreciated.


Cant edit profile from frontend

Hope you can assist. **Background:** I have a multisite config. Users need to be able to update their profile from the frontend, via their profile page, which is something like, `http://example.com/forum/user/fred@example.com` thanks to bbpress. However only Super-Admins can edit their profile. There is a little edit link next to their name but if they are not super-admins then it does not work. How can I fix this? Thanks in advance


Error messages & can't reach admin after upgrading to 3.4.1 WordPress

My hosting company upgraded their php, so my site was getting all sorts of error messages. So, I make a backup of all my content, deleted the wp-admin, wp-includes and loose files in html, then uploaded 3.4.1 of WordPress. I got a bunch of errors at that point, so via FTP I went into my plugins folder and renamed them. That caused most of the messages to go away. Now, I'm left with just two errors. On the front page, I get this error, even though the page loads successfully: Strict Standards: Redefining already defined constructor for class WP_Widget in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/widgets.php on line 93 When I go to wp-admin however, the page does NOT load and I see only this: Strict Standards: Redefining already defined constructor for class WP_Widget in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/widgets.php on line 93 Warning: Cannot modify header information - headers already sent by (output started at /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp- includes/widgets.php:93) in /nfs/c05/h04/mnt/73941/domains/feltbeats.com/html/wp-includes/pluggable.php on line 881 I was actually just on the phone with my hosting company, and he very kindly looked at this for about an hour. He was focusing on it being an actual bug in 3.4.1 - but it seems the fact that the admin doesn't load would have been noticed. =) So I assume it is something in my set up. But since I deleted most files, I can't see what it would be. I had a custom functions.php file in my theme, but I tried deleting it and also the php in it. Any help or just pointing me in the right direction would help. Thank you!


How can one update a theme on a live site without interruption?

So i have a WordPress-based site with a custom Genesis child theme. Once the site goes live, we are obviously going to need to make changes periodically to the child theme's code — modifying CSS and similar. These are the problems i've run into:   1. I don't have shell or FTP access, so i can't just replace the files on the server (they wanted to use one of those dedicated WordPress hosting providers for security and ease of maintenance).   2. It's not possible to upgrade an active theme 'in place' when using the Web-based Upload functionality (you can only do this with themes installed via WordPress's repository thing).   3. To get around the above limitation, i thought maybe i'll just put the git revision hash or whatever in the theme name each time i build the zip file, which will make WordPress see it as a separate theme, and then i can just switch from the old one to the new one. This does work, except that it causes WordPress to reset some of its settings (in particular, which menu is set as the 'Navigation Bar'). To be clear, i am NOT asking how i can test/see changes before making them in production (i have a development server), my issue is specifically with the mechanism of making the change. Given my circumstances, is there any way to do this without causing interruption / having to make configuration changes each time we update?


How do I get WooCommerce to automatically recreate pages?

I had to uninstall WooCommerce plugin (I deleted the tables it created as well) and now I reinstalled the plugin and I doesn't automatically recreate the WooCommerce Pages. Am I stuck having to manually create the pages myself? Is there a way to have it automatically regenerate the pages?


add widgets to dashboard for easy access for clients?

I have a widget created:               if ( function_exists('register_sidebar') )       register_sidebar(array(         'name' => 'Featured Video',         'before_widget' => '',         'after_widget' => '',         'before_title' => '',         'after_title' => '',       ));      All is good, I was just wondering if it was possible to show this widget on the dashboard so the client can easily change the contents when needed. I just want my client to have easier access to it. If it's not possible, no big deal.


Deleting old posts

I have around 30 old posts that I want to delete on my blog. Can I just delete them permanently or should I worry about the "errors" I will get on my google webmasters tools and redirect them somehow?


What is the purpose of this line of code in wp_trim_excerpt?

Can someone please explain what the purpose of this code is:               $text = str_replace(']]>', ']]>', $text);      I'm referring to a line of code inside wp_trim_excerpt(), but I've seen something very similar in some other wp functions as well. On the surface, I would say it's not doing anything at all, but I have to give the wordpress developers more credit than that, so I'm sure there's a reason for this. I've looked into the php manual for str_replace to see if there is some special return value but everything is as I would expect. Is this some sort of ninja data validation technique?


Counting number of identical meta keys

Im looking to count how many meta keys exist within a post, because each time a specific user action happens, a new meta key is created with a date in it. I have this, which does not return anything (I'm looking for a number)...                       ...     $post_title = $row->post_title;             $id = $row->ID;          $post_count = $wpdb->get_var("                     SELECT COUNT(DISTINCT $wpdb->postmeta.meta_key) FROM $wpdb->posts                     LEFT JOIN $wpdb->postmeta                      WHERE $wpdb->posts.post_type = 'things'                     AND $wpdb->postmeta.meta_key = 'dates'                      AND post_id = $id                     ");                  echo $post_title . ' (' . $post_count . ')' . "\n";         }      Similarly, I'd like to count the number of meta keys in total related to a custom post, any help on either of these would be greatly appreciated!


How to disable sidebar only in bbPress and not WordPress?

I am trying to integrate bbPress with WordPress, and the only thing in my way (for now) is the sidebar. How do I disable sidebar in bbPress? I know that one way is to manually remove or comment out `<?php get_sidebar)(); ?>` in all bbPress template files. But I would like to know if there a way that will allow me to quickly allow me to turn it on or off — like adding some code in functions.php etc. Thanks.


CPT archive as home page

I am very new to WP coding. I am working for a University where each faculty has been allocated a CPT. We would like it so that the CPT archive looks the same as the main site. I have created the archive-post-type.php file but am at a total loss from there. From what I have seen in other questions is that the homepage is key? I have this `                                   /*                          * Include the post format-specific template for the content. If you want to                          * use this in a child theme, then include a file called called content-___.php                          * (where ___ is the post format) and that will be used instead.                          */                         get_template_part( 'content-fbe', get_post_format() );                          endwhile;                     // Previous/next page navigation.                     twentyfourteen_paging_nav();                      else :                     // If no content, include the "No posts found" template.                     get_template_part( 'content', 'none' );                      endif;             ?>`      Any help would be really appreciated.


using update_user_meta in form to set and get custom meta

I have a template where a user will set some custom meta values via a form on the front end of my site. I call this form via a function in my functions.php file. Currently when the text inputs are filled out and I hit submit, the values save to the database like expected, however I don't see the values submitted on the page until I hit refresh on my browser. But when I do that I then see the values the user set but the values get stripped from the database, (hitting refresh again on my browser will default back to no values be set). Not sure I have this setup correctly? Here is the code from my template:
Your Values
     Value 1: <?php if(!$new_high) { echo 'Not Set'; } else { echo '$' . $new_high; } ?>     Value 2: <?php if(!$new_medium) { echo 'Not Set'; } else { echo '$' . $new_medium; } ?>     Value 3: <?php if(!$new_low) { echo 'Not Set'; } else { echo '$' . $new_low; } ?>      Then I call the function in the template that has the form: `<?php my_form_function(); ?>` In my functions file I have this which houses the form and updates the user_meta:               function my_form_function() {     global $current_user;     ?>     <form name="setPrices" action="" method="POST">          <fieldset>     Value 3:     <input type="text" id="lowPrice" name="lowPrice" value="<?php echo $_POST['lowPrice']; ?>" />     </fieldset>          <fieldset>     Value 2:     <input type="text" id="mediumPrice" name="mediumPrice" value="<?php echo $_POST['mediumPrice']; ?>" />     </fieldset>          <fieldset>     Value 1:     <input type="text" id="highPrice" name="highPrice" value="<?php echo $_POST['highPrice']; ?>" />     </fieldset>          <button type="submit">Save</button>     </form>          <?php     $low_price = $_POST['lowPrice'];     $medium_price = $_POST['mediumPrice'];     $high_price = $_POST['highPrice'];          update_user_meta( $current_user->ID, '_low_price', $low_price);      update_user_meta( $current_user->ID, '_medium_price', $medium_price);     update_user_meta( $current_user->ID, '_high_price', $high_price);          }      So just to make sure I haven't confused anyone, The above does work (kinda) and when the form is submitted the values save to the database as expected. But I don't see the values in my template until I refresh the page, and once I do that the values reset to nothing. I know my problem is how/where I have update_user_meta


Post sharing email button with post excerpt

How can I have a button by which one can send post link and first 30 words of the article via email. I found some plugins which only send post permalinks not post excerpt. Thanks in advance.


How to have post permalinks redirect to index.php with parameters for loading the content via AJAX?

That question is a bit of a mouthful, so allow me to elaborate: I'm using Wordpress as the CMS for a portfolio (each project is a post in the same category, 'work'). I'm displaying the posts using AJAX. So, when a user comes to the main site (index.php), they can click on a link to the project, and the post content loads in a div on index.php. I'm using the History API to track their progress so they can use the back button. All of that's working. Pretty simple. The part I'm struggling with is how to handle users who navigate directly to a project "page" using a permalink URL. Right now, the permalink URLs are "pretty" (mysite.com/projectname). Her's what I want to happen when a user enters one of these URLs in the address bar: 1) Load index.php. 2) Trigger the javascript which displays the desired post/project. 3) The URL in the address bar remains the same (mysite.com/projectname). Step 2 seems straightforward, I'm just having trouble getting to a state where I have index.php loaded with parameters that tell me which post to load. I've tried a few techniques, but they all involve altering the URL in a way that doesn't match the pretty URL the user entered in the first place. I did try using the History API to alter the URL, but of course this pushes a state to the History, which is no bueno. Does anyone have experience setting up a Wordpress site with similar navigation? Look forward to hearing from you.


Custom Posts and Posts - next_post_link and previous_post_link not working together

I have regular posts and one custom post type ('SS13') pulled in together on the same page. When you click through to the 'single' page for each the next_post_link and previous_post link only work within their post group (regular posts or 'SS13'). I can't find a solution so that next/previous work across all the posts. CPT is used for organisational purposes in the admin section.               <?php /* Start loop */ ?>             <?php while (have_posts()) : the_post(); ?>
                     <article <?php post_class('standard') ?> id="post-<?php the_ID(); ?>">

                                 <?php if(get_field('standard_banner_image')){ ?>                                 <img src="<?php the_field('standard_banner_image'); ?>" alt="Banner Image" />                                 <?php } ?>

<?php next_post_link('%link', 'Next Post: %title', 'FALSE'); ?>&nbsp |  <?php previous_post_link('%link', 'Previous Post: %title',  'FALSE'); ?>

                  <?php endwhile; // End the loop ?>      Any help would be great. Thank You.


Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?

Ok so here's the question how do i stop js from running twice on the widget.php page? I am creating a ajax loaded custom image selector from a domain on the same server as the current site. I want the user to be able to pick an image and populate the fields below with the href to the image description, the title of the image and the image src in it's self, this then posts the results on the front end in the sidebar. I have registered a custom widget inside of my functions.php, the widget has custom js inside it the code is as follows:               /*     *     *Ajax loaded gallery for sidebar     *Note this will not work cross browser.     *     *     */     /**      * Plugin Name: A gallery Widget      * Description: A widget that displays an ajax loaded gallery.      * Version: 0.1      */          add_action( 'widgets_init', 'my_widget' );          function my_widget() {       register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {            function MY_Widget() {         $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }            function widget( $args, $instance ) {         extract( $args );              //Our variables from the widget settings.         $titlewidget = apply_filters('widget_title', $instance['titlewidget'] );         $introtext = $instance['introtext'];         $title = $instance['title'];         $name = $instance['name'];         $img = $instance['img'];         $show_info = isset( $instance['show_info'] ) ? $instance['show_info'] : false;              echo $before_widget;          ?>     <?php     if($titlewidget)       ?>
<?php echo $titlewidget;?>
     <?php     if($introtext)     ?>
 <?php echo $introtext; ?>

     <?php     //display gallery img     if ( $img)       ?>     <a class="columns four" href="<?php echo $name; ?>">          <img class="imggallery" src="<?php echo $img; ?>">                 <?php       // Display the gallery name and link         if ( $title )           ?>          <a class="columns eight imggallery_link" href="<?php echo $name; ?>"><?php echo $title; ?>
          <?php         echo $after_widget;       }            //Update the widget             function update( $new_instance, $old_instance ) {         $instance = $old_instance;              //Strip tags from title and name to remove HTML         $instance['titlewidget'] = strip_tags( $new_instance['titlewidget'] );         $instance['introtext'] = strip_tags( $new_instance['introtext'] );         $instance['title'] = strip_tags( $new_instance['title'] );         $instance['name'] = strip_tags( $new_instance['name'] );         $instance['show_info'] = $new_instance['show_info'];         $instance['img'] = $new_instance['img'];              return $instance;       }            function form( $instance ) {              //Set up some default widget settings.         $defaults = array( 'title' => __('Example', 'example'), 'introtext' => __('introtext', 'example'), 'titlewidget' => __('Reference Project', 'example'), 'img' => __('img', 'example'), 'name' => __('link goes here', 'example'), 'show_info' => true );         $instance = wp_parse_args( (array) $instance, $defaults ); ?>
Gallery selector for Lundhs

         <label for="<?php echo $this->get_field_id( 'titlewidget' ); ?>"><?php _e('Widget Title:', 'example'); ?>           <input type="text" class="titlewidget" name="<?php echo $this->get_field_name( 'titlewidget' ); ?>" value="<?php echo $instance['titlewidget']; ?>" style="width:100%;" />

         <label for="<?php echo $this->get_field_id( 'introtext' ); ?>"><?php _e('Intro text:', 'example'); ?>           <input type="text" class="introtext" name="<?php echo $this->get_field_name( 'introtext' ); ?>" value="<?php echo $instance['introtext']; ?>" style="width:100%;" />

First Pick your images

Your current front end projects

Reference project one

         <img class="gallery_one" src="<?php echo $instance['img']; ?>" />

           <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'example'); ?>           <input type="text" class="title" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

           <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('The link:', 'example'); ?>           <input type="text" class="link" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />
              //img Input.
           <label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('The Link to the image:', 'example'); ?>           <input type="text" class="img" id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php echo $instance['img']; ?>" style="width:100%;" />

     Add new project

       <?php       }     }      the problem arises because this js runs twice adding the additional input boxes twice when '.addNew' is clicked.                   (function($) {             var addDiv = jQuery('.addinput');             var i = jQuery('.addinput p').size() + 1;              jQuery('.addNew').live('click', function() {             jQuery.append('
<input type="text" class="p_new' + i +'" size="40" name="p_new_' + i +'" value="" placeholder="I am New" />Remove
');             i + 1;                  return false;         });              jQuery('.remNew').live('click', function() {               if( i > 1 ) {               jQuery(this).parents('p').remove();               i - 1;               }         return false;         });     }(jQuery));      the latter code runs twice once in the inactive widgets on the left and once in the active widget in the sidebar. How do i go about forcing the JS to run only in the currently active widget. Moving the js to a separate .js file and enqueing really isn't an option for me because i am going to have to use php values inside the php to populate and retrive the values in the next step of this build. Any help is appreciated. Chris // **UPDATE** // Right i think the function i'm looking for is `is_active_widget()` (codex) but I just can't seem to get it to work it still runs the js twice even if i set $skip_inactive to true.   so far I've tried this:                   //start gallery widget          add_action( 'widgets_init', 'my_widget' );          function my_widget() {       register_widget( 'MY_Widget' );     }          class MY_Widget extends WP_Widget {            function MY_Widget() {              $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }                 function widget( $args, $instance ) {              extract( $args );              //Our variables from the widget settings.         $titlewidget = apply_filters('widget_title', $instance['titlewidget'] );         $introtext = $instance['introtext'];         $title = $instance['title'];         $name = $instance['name'];         $img = $instance['img'];         $show_info = isset( $instance['show_info'] ) ? $instance['show_info'] : false;              echo $before_widget;          ?>     <?php      if($titlewidget)       ?>
<?php echo $titlewidget;?>
     <?php      if($introtext)     ?>
 <?php echo $introtext; ?>

     <?php      //display gallery img     if ( $img)       ?>     <a class="columns four" href="<?php echo $name; ?>">          <img class="imggallery" src="<?php echo $img; ?>">                 <?php       // Display the gallery name and link          if ( $title )           ?>          <a class="columns eight imggallery_link" href="<?php echo $name; ?>"><?php echo $title; ?>
          <?php             echo $after_widget;       }            //Update the widget             function update( $new_instance, $old_instance ) {         $instance = $old_instance;              //Strip tags from title and name to remove HTML          $instance['titlewidget'] = strip_tags( $new_instance['titlewidget'] );         $instance['introtext'] = strip_tags( $new_instance['introtext'] );         $instance['title'] = strip_tags( $new_instance['title'] );         $instance['name'] = strip_tags( $new_instance['name'] );         $instance['show_info'] = $new_instance['show_info'];         $instance['img'] = $new_instance['img'];                   return $instance;       }                 function form( $instance ) {      if ( is_active_widget( false, false, $this->id_base, true ) ) {?>                      <?php     }             else {          ?>                   <?php       }              //Set up some default widget settings.         $defaults = array( 'title' => __('Example', 'example'), 'introtext' => __('introtext', 'example'), 'titlewidget' => __('Reference Project', 'example'), 'img' => __('img', 'example'), 'name' => __('link goes here', 'example'), 'show_info' => true );         $instance = wp_parse_args( (array) $instance, $defaults );          wp_localize_script( 'some_handle', 'object_name', $instance );         ?>
Gallery selector for Lundhs

         <label for="<?php echo $this->get_field_id( 'titlewidget' ); ?>"><?php _e('Widget Title:', 'example'); ?>           <input type="text" class="titlewidget" name="<?php echo $this->get_field_name( 'titlewidget' ); ?>" value="<?php echo $instance['titlewidget']; ?>" style="width:100%;" />

         <label for="<?php echo $this->get_field_id( 'introtext' ); ?>"><?php _e('Intro text:', 'example'); ?>           <input type="text" class="introtext" name="<?php echo $this->get_field_name( 'introtext' ); ?>" value="<?php echo $instance['introtext']; ?>" style="width:100%;" />

First Pick your images

Your current front end projects

Reference project 1

         <img class="gallery_one" src="<?php echo $instance['img']; ?>" />

           <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'example'); ?>           <input type="text" class="title" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />

           <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('The link:', 'example'); ?>           <input type="text" class="link" id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" />
              //img Input.
           <label for="<?php echo $this->get_field_id( 'img' ); ?>"><?php _e('The Link to the image:', 'example'); ?>           <input type="text" class="img" id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php echo $instance['img']; ?>" style="width:100%;" />

     Add new project

       <?php       }     }      I have also tried moving it into the `class MY_Widget extends WP_Widget { }` then adding the `add_action`. Like so:                   class MY_Widget extends WP_Widget {            function MY_Widget() {         $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays the chosen gallery images and link from lundhs ', 'example') );              $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );              $this->WP_Widget( 'example-widget', __('Reference Projects', 'example'), $widget_ops, $control_ops );       }       add_action('widgets_init', 'jsadd');       function jsadd(){           if ( is_active_widget( false, false, 'MY_Widget', true ) ) {?>                          <?php     }             else {          ?>                   <?php       }            }      but still no luck. DOes anybody know what i'm doing wrong here?


How do I write this shortcode?

I have this shortcode, I would like to write in a better and clean way:               function webhosting_products_shortcode( $atts, $content = null) {         $content='
Eburnie Hosting vous offre:
'                 . '

'                 . '
Hébergement Web
'                 . '

'                 . '
Hébergement Web

'                 . '

Hébergement Email
'                 . '

'                 . '
Hébergement Email

'                 . '

Conception de Sites
'                 . '

'                 . '
Conception de Sites

'                 . '

Certificat SSL
'                 . '

'                 . '
Certificat SSL

'                 . '

Programme Revendeur
'                 . '

'                 . '
Programme Revendeur
'                 . '

';              return $content;            }     add_shortcode('webhosting', 'webhosting_products_shortcode');      The shortcode [webhosting] is working, but I don´t think it´s the right way to achieve it. Thanks.


Wordpress: How to use post_class() in an echo

I am working on a foreach loop in Wordpress and want to add 'post_class()' to a div within it. Currently the code looks like this:               if ( is_array( $posts ) && !empty( $posts ) ) {              echo '
';         foreach ( $posts as $post ) {             echo '
';                 echo '
';                     echo   '
';                      echo        '
'. tribe_get_event_taxonomy() .'
';                     echo    '
';                 echo '
';             echo '
';         }         echo '
';     }      The 'post_class()' function is breaking the div it is in and calling the classes as if they were content in the page. Any ideas?


How to sync with plugins update after I have done manual optimizations?

I have several WordPress running plugins on my site and as per suggestions of wordpress performance optimizations I am planning to do the optimizations on plugins myself. However, that will mean that I will have to modify existing plugins codes. Now, as WordPress plugins release frequent updates, the updates will wipe out my manual changes. How can I keep sync between these? That means, how can I get updated plugin and keep my manual changes as well?


Custom query to get post names beginning with a digit

I'm implementing an A-Z index for a custom post type. I've got my links printing out the page and the query working for the letters. However, the numbers are tripping me up because I don't want them to work quite the same. I want the first link to read '0-9' and clicking it to show all posts that start with a number. I think a wildcard is the answer, but it's not working the way I expect. Here's my function from my `functions.php`:               function test_first_letter( $sql ){       global $wpdb;       $first_letter = get_query_var( 'first_letter' );       if( $first_letter ){        if( $first_letter == 'num') :          $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", '5%');        else:          $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", $first_letter.'%' );        endif;       }       return $sql;     }     add_action( 'posts_where', 'test_first_letter' );      If the `$first_letter` query param is equal to 'num', then I want the query to look for all `post_names` starting with numbers `0-9`. However, this doesn't work:               $sql .= $wpdb->prepare( " AND $wpdb->posts.post_name LIKE %s ", '[0-9]*');      How can I get all posts where the post_name starts with any digit, 0-9?


Appengine - Wordpress authentication through google ID?

I am planning to migrate my website to Google appengine. I wanted to know that if I do migrate then will my users necessarily need to login using the googleID/openID or can I maintain the default wordpress login. An additional linked quesiton: I would prefer to force users to login using google account only. I am currently using social login plugin to implement the same. Does appengine provide other options to force wordpress authentication only through google IDs? Thanks


Displaying ACF image from within another plugin

I'm trying to call an image from a custom field made with Advanced Custom Fields but can't seem to get it working. The code below is in a PHP file within another plugin. The idea is that clicking on the title (H3) it will show the 'zoom' image in a pop-up lightbox.               if( 'show' == $values['title'] ){         $item .= '
';         $feat_img = wp_get_attachment_image_src(get_field('zoom'), 'full');         $item .= '';         $item .= apply_filters('the_title',$thepost['post_title']);         $item .= '';         $item .= '
';     }      The href tag shows empty on the front end and selecting between `image object`, `image url` and `image ID` doesn't make a difference. Perhaps I need to try and call ACF scripts before this plugins script? If so, how do I go about doing that?


How to make comments work for a post loaded per Ajax?

I am currently loading a single post using ajax. While the post loading works ok, I cannot get the comments to load. Here is my code: My javascript to load the post:                     The javascript goes through functions.php this way:               function implement_posts()     {         //<?php         get_template_part( 'loop', 'single' );         die();     }      Now here is the code where I actually load my post content:               <?php         $linkid = "p=".$_POST["postid"];         $posti = new WP_Query($linkid);         $posti->the_post();         echo "Time: ";         the_time('F jS, Y');         echo "
";         the_category(', ');         echo "
";         the_title();         echo "
";         the_content();         echo "
";         comment_form();         ?>
         <?php if (have_comments()) {         echo "Comments ok";         }         else         {             echo "No comments";         }         ?>      Now, even for posts having comments I am getting "No comments" displayed. Everything else works correctly. Can anyone help me out? Thank you.


Unable to override pluggable function wp_mail

A couple of days ago, my wordpress blog hosted on openshift suddenly stopped sending me mails and notifications. Until now I'd never bothered how wordpress handled mail sending since they always worked. Now, after going through codex, etc I came to know that wordpress handles this by calling the wp_mail(), then @mail() php function which ultimately calls the unix sendmail. Since I don't want to depend on sendmail/openshift, I decided to override the wp_mail pluggable function in my custom plugin, so that it calls my own sendgrid function instead of using the core one. Here is my code for plugin:               <?php     /**      * Plugin Name: Sendgrid Plugin      * Plugin URI:  http://www.prahladyeri.com      * Description: Mail sending using Sendgrid Web API      * Version:     0.1      * Author:      Prahlad Yeri      * Author URI:  http://www.prahladyeri.com      * Text Domain:      * Domain Path:      * Network:      * License:     GPLv2      */          namespace MailDemo;     require_once('sendgrid.php');          add_action( 'init', __NAMESPACE__ . '\plugin_init' );          /**      * Plugin Name: Prahlad's mail      * Description: Alternative way to send a mail      */     if (!function_exists('wp_mail'))      {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwill_Override');            function wp_mail($to, $subject, $message, $headers = '', $attachments = array())         {             sendgridmail($to, $subject, $message, $headers);         }         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwas_Overridden');       }     else      {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Iwas_Not_Overridden');       }          function plugin_init()     {         file("http://".$_SERVER['SERVER_NAME']."/logme.php?" . 'Maildemo_Plugin_Init');      }          //echo __NAMESPACE__ . "\n";      And here is the include file sendgrid.php (I tested it individually on CLI and it works fine):               <?php     function sendgridmail($to, $subject, $message, $headers)     {     $url = 'https://api.sendgrid.com/';     $user='myapikey';     $pass='myapipassword';          $params = array(         'api_user'  => $user,         'api_key'   => $pass,         'to'        => $to,         'subject'   => $subject,         'html'      => '',         'text'      => $message,         'from'      => 'myself@yahoo.com',       );                   $request =  $url.'api/mail.send.json';              // Generate curl request         $session = curl_init($request);         // Tell curl to use HTTP POST         curl_setopt ($session, CURLOPT_POST, true);         // Tell curl that this is the body of the POST         curl_setopt ($session, CURLOPT_POSTFIELDS, $params);         // Tell curl not to return headers, but do return the response         curl_setopt($session, CURLOPT_HEADER, false);         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);              // obtain response         $response = curl_exec($session);         curl_close($session);     }          //only for testing:     /*$to      = 'myself@yahoo.com';     $subject = 'Testemail';     $message = 'It works!!';     echo 'To is: ' + $to;     //wp_mail( $to, $subject, $message, array() );     sendgridmail($to, $subject, $message, $headers);     print_r('Just sent!');*/      Trouble is that this doesn't seem to be getting called by wordpress. It did work once or twice when I initially tested it yesterday, but after that its no longer working. Looks like wordpress is still calling the core wp_mail function instead of calling this one. Any idea folks ?


Rewrite the Wordpress URL from custom plugin

I have created a plugin in wordpress. I am making a cURL request to the server and server response is coming to new index.php. Which is in my_plugin/newfolder/newfolder/index.php. Now from the server side it post the response to my_plugin/newfolder/newfolder/ but it makes problem to other workflows in my application. So I have to handle the post response URL to my_plugin/newfolder/newfolder with out slash from my plugin. How can I do this? I have checked flush_rewrite_rules but it is not helping me. Please help me into this.. Your Help is appreciated.


HM CMB: Role Select

I'm using human made's custom meta boxes framework (https://github.com/humanmade/Custom-Meta-Boxes). I want to add a select drop down in my metabox wich is populated from the roles on my WP site. How would i populate a select field with the current roles on my site? I was trying to us a post_select field and WP_Query the roles, but not sure if that's possible:               array(              'id'       => $prefix . 'role',              'name'     => 'Role',              'type'     => 'post_select',              'use_ajax' => false,             'query' => array( 'wp_roles' => array('get_names') )           ),         );


Stripping shortcode from custom excerpt function

I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom "read more". However, I have captions shortcode showing up in my excerpt. > **Example:** > > [caption id="attachment_4656" align="aligncenter" width="450"] Crispy > Vegetable Tacos[/caption] Do you sometimes feel overwhelmed when trying to > decide what to make for dinner? What I’ve learned from my years as a family > dinner planning expert ... continue reading I tried adding line 5 to strip out the actual shortcode code but it isn't working. Am I on the right track? I'd prefer the shortcodes not to show at all and I've used the function I've seen on the 'net but it isn't working (I'm guessing cause I'm using a custom excerpt function). Anyone want to help me out, please?               function get_excerpt($count){        $permalink = get_permalink($post->ID);        $excerpt = get_the_content();        $excerpt = strip_tags($excerpt);        $excerpt = str_replace(']]>', ']]>', $excerpt);        $excerpt = substr($excerpt, 0, $count);        $excerpt = substr($excerpt, 0, strripos($excerpt, " "));        $excerpt = $excerpt.' ... continue reading ';        return $excerpt;     }      The fifth line I attempted to convert from this:               $content = str_replace(']]>', ']]>', $content);      TIA!


customize urls displayed by previous_post_link and next_post_link

I am using the below code to display my next and previous links in single.php:
<?php previous_post_link( '%link', '' ); ?>

<?php next_post_link( '%link', '' ); ?>
      Everything is working well except that I am defining some rewrite rules in my websites so I am not using the default links like:               http://local-host/enc/?aya-bi-aya=aya-143      but instead               http://local-host/enc/aya-bi-aya/aya-143/      I managed to change the structures of my links for all the website except for the next and previous links, since it requires maybe change of core code!! How can I customize the urls returned by these two Wordpress functions? Thanks for your time and consideration. **Edit:** I am using custom post type(=aya-bi-aya).My permalink structure is set to default. It then displays my permalinks like:               http://local-host/enc/?aya-bi-aya=aya-143      But inside my website, I dont need such urls, but instead I am using urls like:               http://local-host/enc/?aya-bi-aya=aya-143&assurah=al-baqarah&attab=attakhrij      The additional parameters fulfill my needs, especially in my jquery code. Plus, I am using the mod_rewrite to tranform my links to:               http://local-host/enc/aya-bi-aya/al-baqarah/aya-143/attakhrij/      The only remaining thing is to change the links in previous and next, so that they respect this last shape. Thanks Milo for triggering the real issue.


Passing $this->get_field_name() to javascript

## I've tried doing this one of two ways:   1. In the `form` method of my `Widget` class (which extends `WP_Widget`), I have the following snippet, which sets a global javascript variable:              if( $instance ) :     ?>         <script type="text/javascript">             window.widget_order_name = "<?php echo $this->get_field_name( 'order' ) ?>";         </script>     <?php     endif;        2. In the widget admin markup, I also tried to create the following html structure:              <div       field_name='<?php echo $this->get_field_name( 'order' ) ?>'       id='order_field_name'       class='hidden'>     </div>      In my widget admin javascript file, I grab the value of this field_name in one of two ways (as seen below) and then attached that widget name to that of a hidden input field (which contains a value I want to store).   1. The first way, using `window.widget_order_name`:              var widget_field_name = window.widget_order_name;        2. The second way, using `jQuery` to grab the `field_name`:              var widget_field_name = $( '#order_field_name' ).attr( 'field_name' );      ## My problem: Whenever I first move the widget from the Available Widgets container to my sidebar, I don't get the actual field name, I get instead a sort of _placeholder_ for the field name. So, instead of getting something like this:               <input        type="hidden"        name="widget-hours-widget[2][order][]"       value="L48">      I get this:               <input        type="hidden"        name="widget-hours-widget[__i__][order][]"        value="L26">      After the save button is clicked, the `field_name` gives me the correct name of the widget, `widget-hours-widget[2]` rather than the placeholder `widget- hours-widget[__i__]`. Has anybody run into a similar problem or know how to go about fixing it? Thanks.


Get url of thumbnail from the media uploader

I want to select image from the WordPress 3.5 media uploader. I can get the image URL with the following code, but it gets the full size image. I want to get the thumbnail image url,how can I get that?                var custom_uploader;      $('.upload-image').click(function(e) {             e.preventDefault();                  if (custom_uploader) {                 custom_uploader.open();                 return;             }                  custom_uploader = wp.media.frames.file_frame = wp.media({                 title: 'Choose Image',                 button: {                     text: 'Choose Image'                 },                 multiple: false             });                  //When a file is selected, grab the URL             custom_uploader.on('select', function() {                 attachment = custom_uploader.state().get('selection').first().toJSON();                 var abc = attachment.url;    //this is full image url.                  alert (abc);             });                  custom_uploader.open();          });


Custom Tiny MCE button to bring up a custom php popup

I have a tiny MCE button but I'd like to make it open a modal window(like for the spellcheck). How do I go about doing this?               tinymce.create('tinymce.plugins.tinyplugin', {                  init : function(ed, url){                 ed.addButton('tinyplugin', {                 title : 'map',                     onclick : function() {                        // make my pop up window?                     },                     image: url + "/icon.png"                 });             }         });


Deactivate plugin upon deactivation of another plugin

Wondering if its possible to deactivate a plugin in the deactivation code of another plugin? IE. i have a widget that i'm adding via its own plugin that won't function if the 'master' plugin isn't activated...


Workflow and best practice for documentation

We have been creating a bunch of templates that are very custom and change from time to time but also have a bunch of similar parts from theme to theme. I am looking to streamline the way we create our documentation to pass off to users and was looking to the WPA community to see what they use for creating docs. I was thinking of creating sometype of Wiki to pass along to clients that we would build upon as we go but is not completely clear to me yet on how to do so. Can anyone share their experiences, trials, tribulations? Thanks in advance! JN


Collecting email addresses via a "beta" sign up form

I'm making a landing page using WordPress coupled with a theme I bought from WooThemes. I'd like to create a page that allows people to sign up for news of when a beta account is available. Ideally, this page will only have some text + a box to input their email address. I'm looking for a simple solution which will collect the addresses, then give me a quick way to see all the list and export it. I'm not looking for something to help me send the emails themselves, just collect the addresses. Is there any good WordPress plugin to use for this? If not, what is the "usual" way of doing this? Thanks!


Is there a way to send HTML formatted emails with Wordpress' wp_mail function?

Is there an action_hook or something similar that could help me achieve this? I tried adding markup in a PHP string variable and just fired off an email with the wp_mail function like so:               $email_to = 'someaddress@gmail.com';     $email_subject = 'Email subject';     $email_body = "
Hello World!
";     $send_mail = wp_mail($email_to, $email_subject, $email_body);      But it showed up as plaintext? Any ideas?


Automatically Import Image into Posts from URLs on the Web?

Is there a way for me to add an `<img>` tag in a Post, but then have a plugin download that image, and put it on the server for me instead of me needing to manually download the file from online to my computer and then upload it to the server? Thanks


Creating a Static Website based on a WordPress Website?

I am taking on a project where I need to build a static website (due to hosting restrictions). I thought of trying to do this by building a WP site on my computer, then creating a sitemap, and then ripping that site, and finally uploading the files to the host. Any better suggestions on how to do this? (or any good reason why I shouldn't even try)


Why I am getting double jquery?

I was doing page analysis from http://www.gtricks.com/google-chrome- tricks/extensions-to-block-sites-in-chrome/">Pingdom and GTmetrix, and I notices that I am getting jquery versions 1.7.2 and 1.8.3 in the page. I have deregister jquery from functions.php and manually included(v. 1.8.3) in HTML code, which is also been shown at source code. I can't understand from where v1.7.2 it is coming?


Trying to get variables in hacked category dropdown

I've discovered a workaround to get wp_category_dropdown to display as a multiple select field. My code is as follows:               <?php     $sponsors = wp_dropdown_categories( array(         'child_of' => 0,         'class' => 'postform',         'depth' => 0,         'echo' => 0,         'exclude' => '',         'hide_empty' => false,         'hide_if_empty' => false,         'hierarchical' => true,         'order' => 'ASC',         'orderby' => 'name',         'selected' => 0,         'show_count' => 0,         'show_option_all' => '',         'show_option_none' => __(''),         'tab_index' => 0,         'taxonomy' => 'sponsors', )         );          $sponsors = str_replace(         "name='cat' id=",         "name='cat[]' multiple='multiple' size='19' id=",         $sponsors     );     ?>      So far, so good. Problem is, the above outputs the input name as 'cat' which is fine and dandy unless I need to loop through the above several times and with a more defining name. As such, I need to have the name of the input be in the following format:               name="scrape[<?php echo $inpCnt; ?>][sponsors]"      However, doing this doesn't work:               $sponsors = str_replace(         "name='scrape['.$inpCnt.'][sponsors]' id=",         "name='scrape['.$inpCnt.'][sponsors][]' multiple='multiple' size='19' id=",         $sponsors     );      So what can I do?


How to produce a sub-page-system in Wordpress

I am currently new to Wordpress development and I am developing a custom theme with a few custom post types and custom functionality. For the most part, it was pretty easy to find the information I need on the Internet and the codex. I am importing an older outdated system (proprietary) into Wordpress and I would like to be able to keep all the sub-pages of this older system in Wordpress to take advantage of some powerful features and plugins. I have almost everything complete but I am a little confused on how to produce a hierarchical order for custom post types. I have Wordpress installed in a sub folder (wordpress) from the domain root. I have a front-page setup to show the themes front page which aggregates data from other systems. I was able to use `add_rewrite_rule` to get some pages working properly with clean URIs. My problem is: I have a few systems that are auto generated from a separate database. For simplicity I will call these systems `services`. I currently have 2 `services` and there will eventually be more. The issue I am having is that each service will need to have it's own page with it's own sub-pages. i.e.: (main page): domain.com/services/aims domain.com/services/rcm (sub-pages): domain.com/services/aims/list domain.com/services/aims/profile domain.com/services/rcm/list domain.com/services/rcm/profile Each system will be built using the same functionality. The list page will list vendors for each service while the profile page will show detailed information for each vendor. I also want to be able to post articles in each system as well. ie: domain.com/services/aims/articles/?(.+)? domain.com/services/rcm/articles/?(.+)? My question is this: Is this functionality possible in Wordpress? I tried using custom post types to get the URI to work but I was not sure of how to implement the articles. I know I can use `query_vars` to show different page content and this will emulate what I am trying to do with list and profile but I cannot figure out how to allow for articles to be posted to each service. I would like to use the same files for the services instead of having to make new files every time a service is added. The desired effect I am going for is that each service has the ability to post content to itself to keep it organized, list vendors in a list page, and show the vendor details. I know I will need to have custom navigation added to the pages and I am sure this is the easy part. Does anyone know if this is possible? If so, which approach would be the most efficient? Thanks for any help you can shed on this subject. Also, sorry if the title is not good enough... I couldn't figure out how to explain it simply.


What does "Use BalanceTags" Do?

I have a multisite installation, and I was changing the settings of one of my sites from the mu administration panel when I came across a setting called `Use BalanceTags`. Out of curiosity, what does that setting do?


Posts in loop displaying all taxonomies

I have a loop set up to display projects with two types of taxonomies attached to each. My issue is that within the loop I have set up a function to select specific posts to attach different imagery/styling to them and for some reason these posts are printing every taxonomy, not just the taxonomies specifically related to them. The rest of the posts in the loop are displaying their correct taxonomies. Any clues? Full loop code below:               <?php $loop = new WP_Query( array( 'post_type' => 'projects', 'orderby' => 'menu_order', 'order' => 'ASC', 'showposts' => 19 ) ); ?>                 <?php                  $c = 0;                 while ( $loop->have_posts() ) : $loop->the_post();                 $c++;             ?>             <?php if( $c == 5 || $c == 15 || $c == 25 || $c == 35) : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('feature_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                     $terms = get_terms('client');                     $count = count($terms);                     if ( $count > 0 ){                         echo "
Client: ";                         foreach ( $terms as $term ) {                         echo "";                         echo $term->name;                         echo "";                     }                 echo "
";                 }                 ?>                 <?php                     $terms = get_terms('type');                     $count = count($terms);                     if ( $count > 0 ){                         echo "
Type: ";                         foreach ( $terms as $term ) {                         echo "";                         echo $term->name;                         echo "";                     }                 echo "
";                 }                 ?>
             <?php elseif( $c == 10 || $c == 20 || $c == 30 || $c == 40) : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('feature_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                 $terms = get_terms('client');                 $count = count($terms);                     if ( $count > 0 ){                         echo "
Client: ";                         foreach ( $terms as $term ) {                             echo "";                             echo $term->name;                             echo "";                         }                     echo "
";                     }                 ?>                 <?php                 $terms = get_terms('type');                 $count = count($terms);                     if ( $count > 0 ){                         echo "
Type: ";                         foreach ( $terms as $term ) {                             echo "";                             echo $term->name;                             echo "";                         }                         echo "
";                     }                 ?>
             <?php else : ?>
                                  <a href="<?php the_permalink(); ?>" title="Learn more about <?php the_title(); ?>" rel="bookmark">                     <?php                         $rows = get_field('thumbnail_image');                         if($rows)                         {                             foreach($rows as $row)                             {                                 echo '';                             }                         }                     ?>
<?php the_title(); ?>
                 <?php                 $terms = get_the_terms($post->ID, 'client');                 echo '
Client: ';                 foreach ($terms as $taxindex => $taxitem) {                     echo "";                     echo $taxitem->name;                     echo "";                 }                 echo '
'                 ?>                 <?php                 $terms = get_the_terms($post->ID, 'type');                 echo '
Type: ';                 foreach ($terms as $taxindex => $taxitem) {                     echo "";                     echo $taxitem->name;                     echo "";                 }                 echo '
'                 ?>
         <?php endif; endwhile; wp_reset_query(); ?>


Custom menu linking to page not found

I have built a series of pages and sub pages in wordpress. Then, using custom menus with 5 x top level menus and then sub-menus under 3 of these top level menus:               Menu 1     Menu 2     - Sub Menu 1     - Sub Menu 2     Menu 3     Menu 4     - Sub Menu 1     - Sub Menu 2     - Sub Menu 3     - Sub Menu 4     Menu 5     - Sub Menu 1     - Sub Menu 2      Whenever I click on Menu 5 -> Sub Menu 1 OR Sub Menu 2 I get "Nothing Found for: Sub Menu 1" I've just gone back into the page editor and clicked "View Page" and I get the same error. The pages I've created cannot be viewed. I can view all other Sub Menu Pages in all other menus except the last menu. I thought the url might be too long but it is no longer than any other URL in any other sub menu? ANy Ideas?


WordPress Custom Field Should be Unique. Is it possible?

I have a custom field called "website_url". It should be unique. Ex: If a author set "http://wordpress.stackexchange.com/questions/ask" as the custom field value as a post, "http://wordpress.stackexchange.com/questions/ask" can't be used any other post. How to do it?


How to use WP-FirePHP extension?

http://wordpress.org/extend/plugins/wp-firephp/ I'm simply supposed to call `fb('Error message','Lable')` but it doesn't work all the time. I can't figure out when and where the relevant files are being included and classes defined in order to make the call to the said method/function. For example it doesn't work even when I call `fb()` from `wp- content\plugins\wp-firephp\FirePHPCore\fb.php` itself and open up `http://localhost/wordpress` (maybe because the file never gets included) but it works on `http://localhost/wordpress/wp-admin`. Does that mean `wp-firephp` plugin only works for `/wp-admin` and related pages? Because I wanted to use its functionality on non-admin related pages like `/footer.php` and such. Am I doing it wrong?


Taxonomy dropdown metabox in the back-end

I've created custom taxonomy called `Brands` and made it hierarchical so I can add Car brands and models there and keep their relations, like this:   * Ford      * Mustang     * Mondeo     * Focus Problem is, this list might get pretty long and only one _brand_ and one _model_ is needed per post, so checkboxes are misleading. I'm thinking to split that metabox in to two (one for brand and one for model) and make them dropdowns. So when brand is selected in the first dropdown, second dropdown would show only models related to that brand. But i have no idea how to code it. Maybe anyone could show me an example?


Best way to add some custom javascript using jquery to a child theme

I use the default TwentyTen theme and I have made a child theme with some CSS adjustments, and that's pretty much it. Now I'd like to do two things   * Make the theme load the latest jQuery, and to load it using the Google CDN.   * Add a javascript file which would be loaded on every page. What's the best way to do that? I'm a total WordPress newb, so don't really know my way around.


Multisite - sub-subfolders for certain blogs

Consolidating several blogs into a single multisite instance - we have 2 sets of blogs - active and archived. What's the best way of adding `/archive/` to the URLs of the archived blogs? So, as an example:   * An active blog would be accessed via `www.domain.com/blogname`   * An archived blog would be accessed via `www.domain.com/archived/blogname` I've taken a look at a couple of domain mapping plugins (including the WPMU Dev) one, but I don't think they do what I need.


breadcrumbs & rel="nofollow"

Should a breadcrumbs navigation have links set to rel="nofollow"?


Theme Activation, Create Database Tables

I have been tasked with creating a theme that will be a base to list the site owners ebay store products. I have fleshed most of the project out in plain old php to get everything working as regards to adding the listings via the ebay api, right now im integrating the code into functions.php of the custom theme. What i need to do is create database tables in WP to hold the ebay xml file values from various xml files, following the codex i can see how it is done via plugin activation, My question is how can i do it directly via the themes functions.php on theme activation following the codex it does not work which im guessing is down to require_once ABSPATH


Make W3 Total Cache "Empty All Caches" function purge varnish

Right now, when I perform "Empty All Caches" it doesn't send a PURGE request to varnish. The result is that varnish isn't being refreshed. Is there a way that I can make varnish purge it's cache when choosing "Empty All Caches"? Is there a way that I can hook into W3 Total Cache "Empty All Caches"?


How to create an iPhone app base on the content from a Wordpress site? (Just like the one by Mashable)

I have a WP site. Now wanna create an iPhone app base on the content from my site so that the visitors can read my site easier. I wanna create one just like the iPhone app by Mashable (the Mashable should be based on WP) http://itunes.apple.com/us/app/mashable/id356202138?mt=8 Anyone can advise me how should I start? Or any template of such?


Need help making Gallery slideshow with lightbox work correctly

I am adding pictures to a page, and would like them to be in a series of slideshows. f'rinstance, I have 4 picture series that should be on the page and I would like the visitor to click on a thumbnail to open a lightbox. Each picture series would be represented by a single thumbnail, so there should be four thumbnails on the page only. I installed Simbox2 plug-in it works and serves my needs nicely, but I have two problems:   1. all the pictures in the gallery show up on the page - thumbnail form - in a column. You can click on any one of them to open the lightbox, it shows that picture of the series, and then you can move forward or backward as well.   2. when I try to add another gallery to the page, all the pictures I upload end up being appended to the first gallery. And, they appear in the bottom of the column of thumbnails Obvisously, I don't understand the gallery function and could use some enlightenment. I know it can be done, because I've seen it on some of the lightbox plug-in sites. I just can't figger it out. Thanks!   * a -


previous_post_link() and next_post_link() with a custom post type?

I'm on `single-work.php` for a custom post type called `work`, inside the loop. Trying to make two links to the previous and next post. Using this code:               <?php previous_post_link(); ?>      and               <?php next_post_link(); ?>      But nothing shows up. Am I missing something Here is my code, very straightforward:               <?php get_header(); ?>     <div class="full" >          <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>              <?php next_post_link('%link', 'Next post »'); ?>     <?php next_post_link('%link', 'Next post »'); ?>          <?php endwhile; // end of the loop. ?>          </div><!--/full-->       <?php get_footer(); ?>


why doesn't my rewrite rule work? (is there something weird with wordpress htaccess?)

My ht access includes:               Options +FollowSymLinks     RewriteEngine on     RewriteCond %{REQUEST_URI} ^/preview/(.*)\-[0-9]+$     RewriteRule ^/preview/(.*)\-[0-9]+$ /$1 [R=301,L]      but still when I try to access something such as: http://sg.wyli.co.uk/preview/coronation-street-the-mystery-of-the-missing- hotpot-recipe-1806 it doesn't redirect (where http://sg.wyli.co.uk/coronation-street-the-mystery- of-the-missing-hotpot-recipe will work...) im using a plugin: Wp htaccess Control to add the rule, so it's definitely being added to the wordpress rewrite rule system, but it's not having any effect? are there any more wordpress quirks I need to avoid? Is there a basic error I'm missing?


Foliopress WYSIWYG editor does not display images

I use the Foliopress WYSIWYG editor. I inserted overview-1.png via the 'Quick Insert Image' option. This added the following mark-up:               <img width="166" height="263" alt="overview 1" src="images/2012/01/overview-1.png" />      The width and height attributes are correct yet the editor can't find the src. But on the FE the img gets displayed. How do I display the img in the WYSIWYG as well?


Loop info in jquery Tabs - loop into a variable?

I've got three loops set up via jQuery UI tabs as seen in my code below. All works good but i'd like to be able to display the "count" of each loop in the tab label. I obviously can't just echo it because it's before the loop is even called and outside of it. Any suggestions? Maybe call the loops before and put each one into a variable or something? Not even sure if that can be done... Thanks

loop 1 (loopcount)

loop 2 (loopcount)

loop 3 (loopcount)

                      <?php include (TEMPLATEPATH . '/include/loop1.php'); ?>

                      <?php include (TEMPLATEPATH . '/include/loop2.php'); ?>

                      <?php include (TEMPLATEPATH . '/include/loop3.php'); ?>


Don't display a sidebar widget when on a specific page

I am trying to stop latest blog items from displaying in the blog section of my site. I have used the following code:                   <?php  if ( is_page('blog') ) { ?>
Don't display anything
         <?php } /* for all other pages */          else { ?>
Display blog
         <?php } ?>      However, whenever I am on the blog page it displays "Display Blog", completely ignoring the if statement. Is there something I'm missing from getting this working?


Why do my custom post types show up in the dashboard, but not on my site?

I added the following code to my functions.php file to create a custom post type.                 function create_post_type() {           register_post_type( 'mysite_reviews',               array(                     'labels' => array(                         'name' => __( 'Reviews' ),                       'singular_name' => __( 'Review' )                   ),                 'public' => true,                 'menu_position' => 5,                 'rewrite' => array('slug' => 'reviews')               )             );         }            add_action( 'init', 'create_post_type' );      I then created a copy of my single.php file named single-mysite_reviews.php. I went to my Wordpress dashboard and the custom post type was showing up in my menu. I created a new post from the new menu and published it. When I tried to view this new post all I could get was an error. Or more specifically, this page: http://gointrigue.com/vanilla/reviews/my-site-reviews-custom-post-type/ What am I doing wrong?


Show for a particular page ID only title and short summary

$id = 25;      $post = get_page($id);      $title = apply_filters('the_title', $post->post_title);     $content = apply_filters('the_content', $post->post_content);      echo $title, $content;        The above code shows title and full content, but I want to show the short summary only. How can I do this?


Using conditional statements in place of custom Page templates

How do I use if/ else statements instead of custom Page templates? For example, I create content for static Pages that I want to look different from other static Pages. So instead of using `page-sample.php`, `page-sample2.php`, etc, could I use conditional statements? Is there a tutorial that would demonstrate how to do this? It seems that it would save time but I am not familiar enough with using them in WP.


Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 **PO** - is prefix that is always the same **CO** - first 2 letters of the site name - if site name is "Coca Cola" - CO will appear (if I change the name of the site, this will change too) **S** - always the same **2013** - current year **0051** - number that increase by 1 when hit Add New Order. Must have 4 characters. If number is 1 then 0001 will appear. Now.... I need this as a hook that will auto generate and auto populate my purchase_order custom filed. PO number must be generated as a unique record. Function has to count "published and drafted" **Order** post types and then to increase that number by one, so last part of PO number can be generated (0051). For the reference, please take a look how this guy solved something similar http://www.codeproject.com/Articles/491733/Auto-generated-sequence-number-in- SQL-Server Thanks.


How to load a stylesheet into wp_head from a custom widget?

The code below is part of a widget that goes with my theme. I'm trying to include a stylesheet that the widget needs by placing an add_action call to wp_head. However, the function never fires in this context. What am I missing?                  function widget( $args, $instance ) {             if(!get_option('my_slider')) return;             add_action('wp_head', 'my_sliderCSS');             extract($args);             $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );             $text = apply_filters( 'widget_text', $instance['text'], $instance );             $hide_title = isset( $instance['hide_title'] ) ? $instance['hide_title'] : false;             echo $before_widget;             if ( $title && !$hide_title )echo $before_title . $title . $after_title;             if ( $text )?>

<?php echo $instance['filter'] ? wpautop($text) : $text; ?>

             <?php echo $after_widget;         }


How can i display in themplate file only a few post

How guys , i my archive themplate i have 3 tipe of themes: -poster -complex -simple How can i display a certain number of post for arhive themes: Ex: for my poster i want to display 24 posts(only the poster and title), for complex i want to display 12 posts(full with excerpt..), for simple i eant to display 30 ( only titles) I have tree themes for the archive.php Archive.php
         <?php if(function_exists('bcn_display'))         {             bcn_display();         }?>

      <?php     $view = 'poster';     $mode = stripslashes( $_GET["afisare"] );     $modes = array('complex', 'simple', 'poster');     if(in_array($mode, $modes)) $view = $mode;     get_template_part('persoane', $view);     ?>

      <?php include (TEMPLATEPATH . '/sidebar/actors.php'); ?>     <?php include (TEMPLATEPATH . '/publicitate/ad300.php'); ?>
      persoane-poster.php

     <?php is_tag(); ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>
     <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Film %s'), the_title_attribute('echo=0')); ?>">     <img src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=120&w=90&zc=1" alt="" title="<?php the_title(); ?>" />
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">     <?php the_title(); ?>

     <?php endwhile; ?>

     <?php if(function_exists('wp_paginate')) {wp_paginate();} ?>
     <?php if ($prev_link || $next_link): ?>          <?php endif; ?>          <?php else : ?>

          <?php         if ( is_category() ) { // If this is a category archive             printf("
".__("Sorry, but there aren't any posts in the %s category yet.", "kubrick").'
', single_cat_title('',false));         } else if ( is_date() ) { // If this is a date archive             echo('
'.__("Sorry, but there aren't any posts with this date.", "kubrick").'
');         } else if ( is_author() ) { // If this is a category archive             $userdata = get_userdatabylogin(get_query_var('author_name'));             printf("
".__("Sorry, but there aren't any posts by %s yet.", "kubrick")."
", $userdata->display_name);         } else {             echo("
".__('No posts found.', 'kubrick').'
');         }         if(function_exists('get_search_form')) get_search_form();     ?>

          <?php endif; ?>


How make get_next_post() return first post when viewing last one

I need a way to link to the first and the last post (CPT) created. For example, I'm in the last post and if I click in "next" I should go to the first. Now i have this               <?php     $next_post = get_next_post();          if ( ! empty( $next_post ) ) : ?>
         <a href="<?php echo get_permalink( $next_post->ID ); ?>">                                      <?php next_post_link( '%link', __( 'Next project', 'twentyeleven' ) ); ?>
     <?php endif; ?>      I need something like `else: go to first post`.   I would do the same thing when I'm in the first post and when clicking on "previous" i go to the last. # EDIT:   I found a snippet of code that set the order of the navigation through single- post like the `menu_order`, so maybe the solution now is different.   Here the code of what I'm talking about                 function square_adjacent_post_where($sql) {       if ( !is_main_query() || !is_singular() )         return $sql;            $the_post = get_post( get_the_ID() );       $patterns = array();       $patterns[] = '/post_date/';       $patterns[] = '/\'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\'/';       $replacements = array();       $replacements[] = 'menu_order';       $replacements[] = $the_post->menu_order;       return preg_replace( $patterns, $replacements, $sql );     }     add_filter( 'get_next_post_where', 'square_adjacent_post_where' );     add_filter( 'get_previous_post_where', 'square_adjacent_post_where' );          function square_adjacent_post_sort($sql) {       if ( !is_main_query() || !is_singular() )         return $sql;            $pattern = '/post_date/';       $replacement = 'menu_order';       return preg_replace( $pattern, $replacement, $sql );     }     add_filter( 'get_next_post_sort', 'square_adjacent_post_sort' );     add_filter( 'get_previous_post_sort', 'square_adjacent_post_sort' );


Massive Tags Remove Using MySQL

I am using **WordPress 3.4.2** for one of my site and currently it has **38,251** tags![enter image description here](http://i.stack.imgur.com/Bmih3.jpg)   Now i want to remove all Tags from my site, so which way will be more safe to truncate every tags my site has.


wordpress plugin JSON API search within specific category

From the JSON API plugin doc I notice that I can get the post within some category               http://abc.com/?json=get_category_posts&id=9      And I can also search the post               http://abc.com/?json=get_search_results&search=keywords      However, are there anyway to implement search within some category? Thanks


Excerpt all post content Content Same Size without word cutting off

On my category page there are list of 24 posts with title and excerpt content. To display specific lengths of content, I am using **substr** function. Now the issue is that each post excerpt content are displaying in different lengths. To display specific lengths of content I am using substr to cut string of specific length.                 $content = strip_tags(get_the_content());            $content = substr($content, 0, 100);            echo $content . '[..]';      for example:                     post title one          post content size post content size post content size post content           size post content size[..]             post title two        post content 1'50" 0 size post content 55 size post content th[..]             post title three        post content size post "content 55" size checkk post content s[..]      Here in example you can see each post has different content lenght. Now what I am looking for is each post display specific lenght of content. Second and third post content lengths should be same as **first post.** Also spelling should not cut. For that I've tried                    $words = explode(' ', $string, ($word_limit + 1));              if(count($words) > $word_limit) {             array_pop($words);       //add a ... at last article when more than limit word count       echo implode(' ', $words)."..."; } else {      //otherwise      echo implode(' ', $words); }      but it is not working . I need help to display same length content without word cut off.


Query seems to be duplicated

I'm just hit a development brick wall and can't seem to find a solution to this problem. I've running two WP_Query's the aim is one displays premium stockists and the other one displays the none premium stockists. I've added a tick-box that allow's me to use a conditional to check if its a premium stockist or not.   1. How do I add the correct logic in *if the user is a premium member display the premium stockists. These must appear at the top of the page above the other stockists due to them been premium.   2. I'm using a plugin called Advanced custom fields to generate the premium true/false field. website is enter link description here Code I've got.               <?php          $args = array(         'orderby' => 'title',         'order' => 'ASC',         'posts_per_page' => 5,         'paged' => get_query_var('paged'),         'tax_query' => array(             array(                 'taxonomy' => 'store-category',                 'field' => 'id',                 'terms' => array($_POST['region'])                 )             )         );          $query = new WP_Query($args);          if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();          $mapurl = get_post_meta($post->ID, 'lj_mapurl', true); ?>

             <?php the_title(); ?>             <?php the_content(); ?>

             <?php   if ( has_post_thumbnail() ) {                 $postthumnail_count++;                 the_post_thumbnail('stock');             }             ?>

     <a class="viewMap" href="<?php echo $mapurl; ?>" title="Find <?php the_title(); ?> on a map (opens in a new window)" target="_blank">View Map

     <?php endwhile; ?>     <?php else: ?>
Sorry, content not found
          <?php endif; ?>     <?php wp_reset_query(); ?>          <?php          $args = array(         'orderby' => 'title',         'order' => 'ASC',         'posts_per_page' => 5,         'paged' => get_query_var('paged'),         'tax_query' => array(             array(                 'taxonomy' => 'store-category',                 'field' => 'id',                 'terms' => array($_POST['region'])                 )             )         );          $query = new WP_Query($args);          if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();          $mapurl = get_post_meta($post->ID, 'lj_mapurl', true);      $premium = get_field('premium_stock_supplier');     if ( ! $premium ) { // this is basically short for $premium == false         ?>

                 <?php the_title(); ?>                 <?php the_content(); ?>

                           <a class="viewMap" href="<?php echo $mapurl; ?>" title="Find <?php the_title(); ?> on a map (opens in a new window)" target="_blank">View Map

                 <?php  } ?>                            <?php endwhile; ?>         <?php else: ?>
Sorry, content not found
          <?php endif; ?>      updated code for displaying premium stockists (doesn't work)               <?php                   $args = array(         'orderby' => 'title',         'order' => 'ASC',         'meta_query' => array(             array(                 'meta_key' => 'premium',                 'meta_value' => '0',                 )             ),         'posts_per_page' => 5,         'paged' => get_query_var('paged'),         'tax_query' => array(             array(                 'taxonomy' => 'store-category',                 'field' => 'id',                 'terms' => array($_POST['region'])                 )             )         );      code for displaying none premium stockists (doesn't work)               $args = array(         'orderby' => 'title',         'order' => 'ASC',         'meta_query' => array(             array(                 'meta_key' => 'premium',                 'meta_value' => '0',                 )             ),         'posts_per_page' => 5,         'paged' => get_query_var('paged'),         'tax_query' => array(             array(                 'taxonomy' => 'store-category',                 'field' => 'id',                 'terms' => array($_POST['region'])                 )             )         );


WordPress Custom URL Rewrites

I am trying to add a custom rewrite rule with a single variable to a specific page. The 'ugly' version is `http://example.com/used-cars/car/?carname=name- of-car` and the 'pretty' version I'm going for is `http://example.com/used- cars/car/name-of-car`. `http://example.com/used-cars/car/` is a page with a custom template that doesn't display anything if the `carname` variable is not set. This is the code I have so far:               add_filter('query_vars', 'ip_add_rewrite_query_vars');     function ip_add_rewrite_query_vars($query_vars) {         $query_vars[] = 'carname';         return $query_vars;     }          add_action('init', 'ip_add_rewrite_rules');     function ip_add_rewrite_rules() {         add_rewrite_rule(             'used-cars/car/([^/]+)/?$',             'index.php?p=403&carname=$matches[1]',             'top'         );     }      With this, when I go to `http://example.com/used-cars/car/name-of-car` it just redirects to `http://example.com/used-cars/car` and `get_query_var('carname')` returns `null`. I have tried a couple of different variations on ways to do this (like modifying `$wp_rewrite` directly, using `add_rewrite_tag()`), but I either get the same result or a 404 error. I flush the rewrite rules and my browser's cache every time I try to test the page again. I installed the rewrite analyzer plugin and my rewrite appears there and looks correct compared to the default ones. As far as I can see from all the examples on the web the code I have should work - it's pretty much the same example from the codex page - and I have no idea why it doesn't. This is a multisite setup (each site on a different subdomain) - I'm not really familiar with multisite but I don't think there's anything in that that would affect custom rewrites?


Caption and title in img alt tag are the same?

I'm currently on WP 3.6 and noticed an unpredictable behaviour with the alt attributes generated by WP. If I have an image title, the title appears in the alt. If I have a caption, the caption replaces the alt. What can I do to prevent the image title from appearing in the alt field? I want to keep it empty if there are no image captions.


Get title of post image is attached to

So I found this post: Find the post an attachment is attached to and implemented Chip's suggestion but having a weird outcome. I am trying to pull the title of the post that the specific image is attached to. This is my query:               <?php         $args = array(             'post_type' => 'attachment',             'posts_per_page' => -1,             'post_status' => 'any',             'post_parent' => null,             'tax_query' => array(                 array(                     'taxonomy' => 'post_tag',                     'field' => 'slug',                     'terms' => 'logo'                 )             )         );              $attachments = get_posts( $args );         foreach ( $attachments as $image ) {             // Get the parent post ID             $parent_id = $image->post_parent;             // Get the parent post Title             $parent_title = get_the_title( $parent_id );             // Get the parent post permalink             $parent_permalink = get_permalink( $parent_id );         }                   if ( $attachments ) {             foreach ( $attachments as $post ) {                      $logoimg = wp_get_attachment_image($post->ID, 'Work Gallery');      This is the line where I am calling the title: `echo ' ' . $parent_title . ' ';` This kind of works but it is outputting 1 post title in particular and for all the images on the page. Any thoughts as to why its not dynamically picking up each images associated post title? Thanks!


how to implement a site like this in wordpress?

I want to develop a site like http://www.webpresent.biz/ Should I develop in wordpress? How much effort is required? Plugins available? Help would be appreciated.


Changing domain

I set my domain in the WordPress without www i.e xyz.com but realised after setting that xyz.com wasn't redirecting to www.xyz.com. Now I am unable to login into the admin panel. I grepped through the code but saw that the domain is not set as a value to any variable. Is it saved in the DB? How can I change it?


Displaying errors with settings api

I'm not using the full settings api, just this code:               register_setting( 'my_options', 'my_options', 'my_options_validate' );      Then my validation:                 $options = get_option('my_options');            if(error_found){              add_settings_error( 'my_options', 'settings_updated', 'error_message_here', 'error');            }            return $options;      But on postback no errors are displayed. So my questions are: does simply setting an error message result in its display? do I have to use the full settings api to have errors displayed? do I have do anything to disable the "settings updated" message on postback? I've tried using settings_errors but no errors show.


How can I change my meta_query to SQL wpdb query?

I want to extract post related to 3 meta_data fields called bed_value, bath_value, rob_value the variable data is $bedrooms, $bathrooms, &rob, I got some confused with join and like structure. The unworking metaquery is this               $args = array(         'meta_query' => array(         'relation' => 'OR',                  array(             'key' => 'beds_value',             'value' => $bedrooms,             'compare' => '=',                             ),             array(             'key' => 'baths_value',             'value' => $bathrooms,             'compare' => '=',                             ),             array(             'key' => 'rob_value',             'value' => $rob,             'compare' => '=',                             ),                   ),     );          $args = array_merge( $args , $wp_query->query );      query_posts( $args );      So it is better and easier to do a SQL wpdb query I will change the code. prior wpdb query with $wpdb->get_results($query, OBJECT); does not allow to paginate the results, thats why I tried to change to meta_query I need more knowledge!


Filter Posts by current Month

Ok, I have a client that wants to only display posts by the current month. I've tried a few different variations but none have worked. Here's where I'm at now. Any help is appreciated!                   <?php         $current_year = date('Y');         $current_month = date('m');         $args = array(             'year'     => $current_year,             'monthnum' => $current_month         );           $custom_query = new WP_Query('$args');                  if ($custom_query->have_posts()) : while ($custom_query->have_posts()) : $custom_query->the_post();                           // The following determines what the post format is and shows the correct file accordingly                     $format = get_post_format();                     get_template_part( 'includes/post-formats/'.$format );                          if($format == '')                     get_template_part( 'includes/post-formats/standard' );                   endwhile; else:                   ?>


Multiple loops in same page, without duplicate content

I'm trying to make a page with multiple loops, I need every loop to display a predefined number of posts from the same category (every loop displays X number of posts from Category CATS). But I also need the second loop, the third loop and so on to display the posts from where the last loop stopped, without duplicating content (example: loop 1 from post 1 to 5. loop 2 from post 6 to 10. loop 3 from post 11 to 15 etc.). Here's what I've tried so far (I also gave a try to the code in the wordpress codex, but nothing seems to work) Can you help me? here's my code so far;               <?php   if (have_posts()) : ?>     <?php   $mosaics = new WP_Query('category_name=mosaics&posts_per_page=5'); ?>     <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>     <?php   if( $post->ID == $do_not_duplicate ) continue; ?>          <?php   echo get_the_content(); ?>     <?php   endwhile; ?>     <?php   endif; ?>     <?php   wp_reset_query(); ?>
          <?php   if (have_posts()) : ?>     <?php   $mosaics = new WP_Query('category_name=mosaics&posts_per_page=4'); ?>     <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>     <?php   if( $post->ID == $do_not_duplicate ) continue; ?>          <?php   echo get_the_content(); ?>     <?php   endwhile; ?>     <?php   endif; ?>     <?php   wp_reset_query(); ?>
          <?php   if (have_posts()) : ?>     <?php   $mosaics = new WP_Query('category_name=mosaics&posts_per_page=3'); ?>     <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>     <?php   if( $post->ID == $do_not_duplicate ) continue; ?>          <?php   echo get_the_content(); ?>     <?php   endwhile; ?>     <?php   endif; ?>     <?php   wp_reset_query(); ?>
          <?php   if (have_posts()) : ?>     <?php   $mosaics = new WP_Query('category_name=mosaics&posts_per_page=2'); ?>     <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>     <?php   if( $post->ID == $do_not_duplicate ) continue; ?>          <?php   echo get_the_content(); ?>     <?php   endwhile; ?>     <?php   endif; ?>     <?php   wp_reset_query(); ?>


How to use first tag in permalinks

i have tried `%tag%` in permalinks but it dont showing tag name in the permalinks... What i wanna do is to use the first tag name in the permalinks. So, how to do it? Thanks