PageNav Not working on Custom Post - function built into theme

The Pagenav will not appear on this page, I've got the wp-pagenav function built into the theme so calling it works on all the other pages. It appears on the blog template I'm using but just not the "Stockists One"               $includes = get_template_directory() . '/includes/';      require_once ($includes . 'pagenavi.php');      I've included the Pagenavi functionality within a file named pagenavi.php                 <?php         /*           Template Name: Stockists          *          */         ?>              <?php get_header(); ?>

<?php the_title();?>

<?php the_breadcrumb(); ?>

<a href="<?php echo home_url(); ?>">

Store Locator
                                     <form name="locator" action="" method="post" id="locator">                                         <input type="hidden" name="keyword[eq:instance_type:yes]" value="56:Document"/>                                         <input type="hidden" name="storelocator" value="1"/>                                         <fieldset>
Please search for a xxx® dealer near you.

Area                                             <?php                                             $args = array(                                                 'order' => 'asc',                                                 'show_option_none' => 'Select area',                                                 'show_count' => 0,                                                 'hide_empty' => 0,                                                 'echo' => 1,                                                 'selected' => 0,                                                 'hierarchical' => 0,                                                 'name' => 'region',                                                 'id' => 'region',                                                 'class' => 'region',                                                 'depth' => 3,                                                 'tab_index' => 0,                                                 'taxonomy' => 'store-category',                                                 'hide_if_empty' => false);                                              wp_dropdown_categories($args); ?>                                             <input type="button" class="image" value="Search" title="search" alt="search" onclick="this.form.submit();"/>
                                          </fieldset>                                 </form>              <?php if (isset($_POST['region'])) {          ?>                              <?php                              $args = array(                             'orderby' => 'name',                             '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                                          $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 } else { // code for the stockists not marked as premium ?>

                                                     <?php the_content(); ?>

                                                     <?php   if ( has_post_thumbnail() ) {                                                     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 } ?>                                          <?php endwhile; ?>                                     <?php else: ?>
Sorry, content not found
                                          <?php endif; ?>              <?php } ?>
If you cannot find a retailer near your location email xxx.co.uk for help.

                                                     <?php   if ( has_post_thumbnail() ) {                                                     the_post_thumbnail('stock');                                                     } ?>                    <?php      get_template_part('includes/wp-pagenavi');      if(function_exists('wp_pagenavi')) {      wp_pagenavi( array( 'query' => $query ) );      }     wp_reset_postdata();    // avoid errors further down the page     ?>

         <?php get_footer(); ?>      Here is the page_template where the pagenav does appear.               <?php     /*     Template Name: Sorting blog page     */     ?>          <?php get_header();           ?>

<?php the_title();?>

<?php the_breadcrumb(); ?>

<a href="<?php echo home_url(); ?>">

Show All               <?php $categories = get_terms("category");             foreach ($categories as $category) {                 $entrycategory = str_replace(' ', '-', $category->name);                 echo ''.$category->name.' ';             }             ?>

                      <?php portfolio('port4',4,'post'); ?>
                  <?php             get_template_part('includes/wp-pagenavi');             if(function_exists('wp_pagenavi')) { wp_pagenavi(); }             ?>

                    <?php get_footer(); ?>      Now I've tried using both the documentations recommended function callback and the way I've done it for the blog page neither work.                <?php             get_template_part('includes/wp-pagenavi');             if(function_exists('wp_pagenavi')) { wp_pagenavi(); }      ?>      Any suggestions I'm very grateful for :)


show the meta values to visitors that collected via coment form

in stackoverflow (here) there is a solution for collecting extra information from visitors, and i want to ask that, is it possible to show the collected information to other visitors in his/her comment section? Thanks...


Additional, optional fee on Woocommerce Checkout

I'm building a shop based on WooCommerce. I need to add an extra checkbox on the checkout page called Shipping Insurance. Once the field is checked, i need to add an extra $3 to the Order Total. I was able to add a fixed fee this way:               function woo_add_cart_fee() {       global $woocommerce;       $woocommerce->cart->add_fee( __('Shipping Insurance', 'woocommerce'), 3 );          }     add_action( 'woocommerce_before_calculate_totals', 'woo_add_cart_fee' );      The problem is that this will add a fixed $3 to the order total, so its not optional. Any idea how to proceed with this issue?


How to retrieve "custom url" from image attachment in wordpress

I have uploaded a bunch of images to a post and set the 'custom url' for each of them in the media uploader. How can I retrieve the custom URL assigned to each image into $caption_text= at the bottom?                   $images =& get_children( array(                                  'post_parent' => $featured_page,                                 'post_status' => 'inherit',                                 'post_type' => 'attachment',                                 'post_mime_type' => 'image',                                 'order' => 'ASC',                                 'numberposts' => $thelimit,                                 'orderby' => 'menu_order' )                                 );          // Loop through the images     foreach ( $images as $id => $image ) {         $attatchmentID = $image->ID;              $imagearray = wp_get_attachment_image_src( $attatchmentID , 'fullsize', false);         $imageURI = $imagearray[0];         $imageID = get_post($attatchmentID);              $thumb_imagearray = wp_get_attachment_image_src( $attatchmentID , 'fullscreen-thumbnails', false);         $thumb_imageURI = $thumb_imagearray[0];              $imageTitle = $image->post_title;         $imageDesc = $image->post_content;         $postlink = get_permalink($image->post_parent);         // If linking is On         if ($featured_linked == 1 || $featured_linked == true) {             $attatchmentURL = get_attachment_link($image->ID);         }         // Count         $count++;         if ($count>1) { echo ","; }              $slideshow_title="";         $slideshow_caption="";              //Find and replace all new lines to BR tags         $find   = array("\r\n", "\n", "\r");         $replace = '
';         $imageDesc = str_replace($find, $replace , $imageDesc);         $image_post_link = get_permalink();                   if ($imageTitle) $slideshow_title='
'. esc_attr($imageTitle) .'
';         if ($imageDesc) $slideshow_caption='
'. $imageDesc .'
';                   $caption_text= '
' . $slideshow_title . $slideshow_caption . '> Preview Article
';                   echo "{image : '".$imageURI."', title : '". $caption_text . "', thumb : '".$thumb_imageURI."', url : ''}";     }


Using a Cron Job to dynamically populate a field ONCE, and then making the field blank the next time someone visits page

I'm probably going to butcher explaining what I'm trying to do, so bare with me. Essentially I'm working on a custom Contest type of solution for a client. I'm using Gravity Forms for the users to sign up, and then I have a hidden field that is able to be populated dynamically through GF. I have a Cron Job set up to where once a day it will populate that field with a value of "winner". However it only needs to be populated for the first user that hits the site after the scheduled job runs, then for the next person it should be blank again. I've looked into using a session variable, but unless I can pull the session id, I can't exactly make that work correctly. I can't use a query string, as I don't want the user to know if they've won until after they fill out the form, which then it will use the value to show a winner or loser section with javascript. I'm about 99% sure this is not the best way to go about it, but being somewhat of a PHP newb, this is what the last few days of research has gotten me. Any help would be greatly appreciated.


Change CSS for logged in users

In my css i have a hidden `div id`:               #example {display:none;}      How can I set this to `display:block` for logged in users only? I am assuming using Jquery would be the best option here for best performance? Or is it better to use a function in functions.php ?


WP Multisite URL rewrite static content folder

I have a WP multisite installation on the root folder. one of the sites have a subdomain               subdomain.mysite.com      in the root folder there is a sub directory called               /subdomain-static      folder structure looks like something like below               www     |     |- static-content     |    |....     |     |-wp-content     |-wp-admin     |...       I want to rewrite urls for the content in subdomain-static so it would look like               subdomain.mysite.com/demo/static/subdomain-static/....      I've tried the following               RewriteRule ^/subdomain-static/(.*)$ http://subdomain.mysite.com/demo/static/$1 [R=301,L]      also few simillar things without no luck any help is appreciates


Settings API: Two update notices after saving settings?

I've used the settings API to create a very simple page for plugin settings. This is my first time using the API, and through various tutorials online and answers here, I think I've figured it out. This is backed up by the fact that the page even works!! However, something weird is happening: ![two notices regarding the saving of settings](http://i.stack.imgur.com/dSv88.png) As you can see above, there are two div.update messages being displayed on the screen. I've checked and there's only one call to the `settings_errors()` function so and that function isn't called in a loop or anything that I can find, but I'm still getting two notices. Here's the code:               public function __construct() {         /* more stuff */              add_action("admin_menu", array($this, "plugin_settings_menu_add");         if($pagenow == "options.php" || $pagenow == "options-general.php") {             add_action("admin_init", array($this, "plugin_settings_initialize");         }     }          public function plugin_settings_menu_add() {         add_options_page("Gallery Settings", "Galleries", "manage_options", "galleries-settings-page", array($this, "plugin_settings_menu_display"));     }          public function plugin_settings_menu_display() {         require(plugin_dir_path(__FILE__) . "views/plugin-settings.php");     }          public function plugin_settings_permissions_to_use_default() {         return apply_filters(             "plugin_settings_permissions_to_use_default",             array(                 "galleries-settings-permission-to-use-url" => ""             )         );     }          public function plugin_settings_initialize() {         if(get_option("galleries-settings-permission-to-use") == false) {             add_option("galleries-settings-permission-to-use", $this->plugin_settings_permissions_to_use_default());         }              add_settings_section(             "galleries-settings-permission-to-use-section",                    // DOM ID for the section             "Permission to Use Gallery Items",                                        // on-screen title for it             array($this, "plugin_settings_permissions_to_use_header_display"),        // callback to display its header             "galleries-settings-page"                                            // the menu page on which to show it         );              add_settings_field(             "galleries-settings-permission-to-use-url",             'Webtools Form (required)',             array($this, "plugin_settings_permissions_to_use_url_display"),             "galleries-settings-page",             "galleries-settings-permission-to-use-section"         );              register_setting(             "galleries-settings-page",             "galleries-settings-permission-to-use",             array($this, "plugin_settings_permissions_to_use_sanitize")         );     }          public function plugin_settings_permissions_to_use_header_display() {         echo "
......
";     }          public function plugin_settings_permissions_to_use_url_display() {         $settings = get_option("galleries-settings-permission-to-use");         $value = isset($settings["galleries-settings-permission-to-use-url"])             ? $settings["galleries-settings-permission-to-use-url"]             : ""; ?>              <input type="url" id="galleries-settings-permission-to-use-url"             name="galleries-settings-permission-to-use[galleries-settings-permission-to-use-url]"             value="<?=esc_url($value)?>" class="regular-text" required aria-required="true">
              Enter the full URL but without any query string parameters.         <? }          public function plugin_settings_permissions_to_use_sanitize($input) {         $output = array();         foreach($input as $key => $value) {             // even though we have only one field here at the moment, we'll use a loop and a switch             // to santize.  that way we're ready to go with respect to additional data that might one             // day be sent here.                    switch($key) {             case "galleries-settings-permission-to-use-url":                 if(empty($value) || !filter_var($value, FILTER_VALIDATE_URL)) {                     add_setting_error("galleries-settings-permission-to-use-url",                         "galleries-settings-permission-to-use-url-invalid",                         "You must enter a valid web address."                     );                 } elseif(($qloc = strpos($value, "?"))!==false) $value = substr($value, 0, $qloc);                 break;             }                  $output[$key] = $value;         }              return apply_filters("galleries_plugin_settings_permissions_to_use_sanitize", $output, $input);     }      The following is the contents of the `plugin-settings.php` page that's included in the code above:

Gallery Settings
              <? settings_errors(); ?>              <form method="post" action="options.php">                 <? settings_fields("galleries-settings-page"); ?>                 <? do_settings_sections("galleries-settings-page"); ?>                 <? submit_button(); ?>         </form>
      And, yes, as you can probably tell, this is Yet Another Image Gallery Plugin. I did do a search and replace to hide some of the information about for whom I'm doing the plugin. Hopefully doing so didn't introduce any errors.


Duplicate posts being displayed when querying Custom Fields

I have created a small segment within WordPress that records match information for League of Legends. Using up to 30 different custom fields I can store information of 30 champions picked from 3 games (10 different champions are picked each game) I want to query all games the champion 'Shen' has played in but the issue have come across is, if 'shen' was Picked in two of the three games played, that individual match is displayed twice in the loop. Is it possible to prevent any duplicates if a custom field has duplication information? Code I am using currently:               <?php          $querystr = "     SELECT $wpdb->posts.*      FROM $wpdb->posts, $wpdb->postmeta     WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id      AND $wpdb->postmeta.meta_value = 'Shen'      AND $wpdb->posts.post_status = 'publish'      AND $wpdb->posts.post_type = 'matches'     AND $wpdb->posts.post_date < NOW()     ORDER BY $wpdb->posts.post_date DESC     ";          $pageposts = $wpdb->get_results($querystr, OBJECT);          ?>     <?php if ($pageposts): ?>     <?php global $post; ?>     <?php foreach ($pageposts as $post): ?>          <?php setup_postdata($post); ?>

vs

<a href="<?php the_permalink(); ?>">view match information

<?php echo get_post_meta($post->ID, 'dbt_tournamentname', true) ?>

<img src="<?php echo get_post_meta($post->ID, 'dbt_team1logo', true) ?>" />

<img src="<?php echo get_post_meta($post->ID, 'dbt_team2logo', true) ?>" />

     <?php endforeach; ?>          <?php else : ?>
No matches found featuring 'Shen'.

Sorry, no team composition featured the selected champion.
          <?php endif; ?>      Any help will be greatly appreciated! Cheers Dan


Different size video display for category page (smaller) & detail page (larger)

I have a 'media' category page that pumps in videos / image galleries. I'm looking to have a smaller size video display (vimeo / youtube) on the category page, and the full size video on the single page. How do I change the size of the video embed on the fly for the both scenarios? Here's the loop for selecting anything in the "videos" category.                   <?php $videos = new WP_Query('category_name=video'); ?>         <?php while ( $videos->have_posts() ) : $videos->the_post(); ?>         <?php the_content(); ?>         <?php endwhile; ?>      Videos are entered into the post's main tinymce content editor. Am I being to vague?


Linking together two different custom post types

I hope someone can help out with this as it is very frustrating... I am trying to build a property site in Wordpress and would like to link two custom post types together - One would be development areas and the other would be individual properties within that development area I understand that I can create a CPT called 'Developments' and another called 'Properties' but how would I go about linking them together?.. for example if I created a property and tried to attach it to a development how would this work if they are separate custom post types? I read a similar question - How to connect different CPTs together? and the answer by Scuba Kay was almost what I needed but I don't know how you would query a certain property which belongs to a certain Development Thanks in advance!


Retrieve post data via WPDB class

I'm trying to figure out doing a custom query using the $wpdb Object. I have custom type posts, event_posts, that have meta data, images, as well as event dates which are input in the post with the FT Calendar plugin. I can get posts that have event dates (dates pulled from the ftcalendar_events table), but my first issue is that when I query the post type it comes back as "revision" and not "event_posts". My second issue is that I don't know how to retrieve the metadata and images for the post. Here's what I am using below. Why am I doing it this way you might ask? Because I need to order the posts based on the event date, which is pulled from the ftcalendar_events table, and even though the standard wp query methods retrieve the post with all of that information, there isn't a way to order them by the event date. Any ideas how to retrieve all of that?               global $wpdb;     $poos = $wpdb->get_results("         SELECT         p.post_title AS title,         p.post_type AS type,         p.post_content AS content,         ev.start_datetime AS start         FROM         " . $wpdb->prefix . "posts AS p,         " . $wpdb->prefix . "ftcalendar_events AS ev         WHERE         p.post_parent = ev.post_parent         AND         p.post_type='event_posts'         ORDER BY         ev.start_datetime         ASC     ");          //print_r($poos);     //echo '

';          foreach($poos as $poo){         echo $poo->type.'
';         echo $poo->title.'
';         echo $poo->content.'
';         echo $poo->start.'

';         }      That outputs:               revision (should be "event_posts")     Home Town Celebration     Historic 'Home Town' Celebration in Ridgefield WA. An '0ld town' holiday celebration artisans fair and market. December 2013     2013-12-07 11:00:00


Cannot update a file for my theme

I have a theme that automatically adds some widgets. I don't want them and so I tried to edit the Sidebar.php but it just fails and sends me to a page with message 404. Here's the code block I am trying to delete from Sidebar.php:
     <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('south_sidebar') ) : ?>

Archives
             <?php if(function_exists('wp_easyarchives_widget')) : ?>                 <?php wp_easyarchives_widget("mode=none&limit=6"); ?>             <?php else : ?>
                     <?php wp_get_archives('type=monthly'); ?>
             <?php endif; ?>

Meta

                 <?php wp_register(); ?>
<?php wp_loginout(); ?>

          <?php endif; ?>
           EDIT: So for now what I have done is I modified the css to hide southsidebar. But actually I want to use that div by adding other widgets.


Problem with shortcodes in external file

I have simple post with a shortcode:               [xx]http://harrix.org/1.txt[xx]      And an external file which has the content containing a WordPress shortcode:               [strong] g[/strong]      I try add my own tag to load the external file:               <?     add_filter('the_content', 'WorkWithTags');     function WorkWithTags($content){     $Tag ="xx";          if (preg_match_all('~\['.$Tag.'\](.*?)\[/'.$Tag.'\]~is', $content, $arr))      {         foreach ($arr[1] as $value)         {           $newvalue = @file_get_contents($value);//Main String                $content=str_replace($value, $newvalue, $content);        }             //Delete tags        $tr=array('['.$Tag.']'=>'','[/'.$Tag.']'=>'',);         $content=strtr($content,$tr);     }     return $content;     }     ?>      Adding file works good. But the external file contains shortcodes of WordPress. How can I get WordPress to execute all of the shortcodes from this external file? **Update.** I try use code by s_ha_dum in **functions.php** :               function WorkWithTags($atts,$content){       $atts = shortcode_atts(         array(           'tag' => 'xx'         ),         $atts       );       $fo = $atts['tag'];       $content = file_get_contents($fo);//Main String       return do_shortcode($content);     }     add_shortcode('wwt','WorkWithTags');      ![enter image description here](http://i.stack.imgur.com/TxMw6.png) Then I add this shortcode in post:               Text. Text. Text. Text. Text. Text. Text. Text.           [wwt tag="http://harrix.org/1.txt" /]          Text. Text. Text. Text. Text. Text. Text. Text.      ![enter image description here](http://i.stack.imgur.com/rj2Xh.png) And I see that in preview of post: ![enter image description here](http://i.stack.imgur.com/nugUC.png) I can not run shortcodes in an external file.


Scaling an image in a WordPress post

I am currently building a WordPress theme and when I add an image using the add media button, I'm able to choose a scaling percentage to allow the image to get bigger or smaller within the modal pop up box. It seems that the standard themes that ship with WordPress allow the user to do this, so there must be some functionality that is included with these themes. It seems when I inspect the code that there is an alternative width and height attribute added to the image when percentage scaling is added to an image within the context of a theme like Twenty Eleven. Is it straightforward to add this functionality to themes built from scratch as I am doing?


One Child Functions.php for Multiple Child Themes

I have a wordpress setup that I use for clients with around 30 or so child themes that they can choose from. Each child theme has it's own functions.php file currently. Is it possible to setup just one child functions.php and call it from all the separate child themes? My reason for wanting this functionality is I find myself continually making changes to the functions.php and I have to do it to all 30+ themes every time.


Single page site with history.js

I'm developing a single page site that shows each page on the front page, like so:                                               *-----------------*                                     | Home            |                                     |                 |                                     |                 |                                     |                 |                                     *-----------------*                                     | About           |                                     |                 |                                     |                 |                                     |                 |                                     *-----------------*                                     | Work            |                                     |                 |                                     |                 |                                     |                 |                                     *-----------------*      And I'm using history.js to alter the URL structure based on which section is visible in the viewport. Everything controlling this output is in my theme's `index.php`, and mirrored in the `pages.php` file. Which I'm sure there's a better way to do that, but I've no idea what it might be. I want all pages that aren't /, /about or /work to redirect to the homepage (client doesn't want to use 404), another thing I don't know how to go about setting up. I know I could put a PHP redirect in the `single.php` file and an `include()` in the `pages.php` but that doesn't strike me like the best option.


Is it to possible to insert a page in the post depending on the category ofthe post

I am making a website about world countries and cities.Every Post will be a city name and will have a category of a country. In the beggining of the post I want to have a brief description of the country instead of writing the same description to 20 or more cities. Is it possible that wordpress would see the category is Europe > Germany and inside the post put brief description which I would have in a page called Germany ? * * * **edit:** I found a piece of code which can add a page inside a post http://css-tricks.com/snippets/wordpress/embed-a-page-inside-a-page/ Still I need a way to do that the page would be added only if post is in certain category * * * **edit2:** I've done what I wanted.Half-manually though, but it works. Soluton: This in single.php               <?php get_template_part( 'countries' ); ?>      I created countries.php in index and there put the code:               <?php     if(in_category('category-2')) {          $recent = new WP_Query("page_id=15"); while($recent->have_posts()) : $recent->the_post();?>
<?php the_title(); ?>
            <?php the_content(); ?>     <?php endwhile;          } else {     echo "Error";     }     ?>      Despite that I will have to add every country manually it's the best solution I could find.


WordPress 3.3.1 single post template

Does anybody have any idea why on single posts there are no template dropdowns for template selections in WP 3.3.1? I did not find that either in the page administrative area. Thank you


Gallery Shortcode Function Help

Okay, so I found this code online that allows you to add the option of how many thumbnails you want to show in the gallery shortcode. The code below is what they say to add to the functions.php file                     function get_random_gallery_images(){       global $wpdb,$post;           $ids = "";           $counter = 0;           $number_of_posts = 4;           $args = array(           'post_type' => 'attachment',           'numberposts' => 4,           'post_status' => null,           'orderby' => 'rand',           'post_parent' => $post->ID           );           $attachments = get_posts($args);           if ($attachments) {               foreach ($attachments as $attachment) {                        if ($counter != 0) {                       $ids .= ','.$attachment->ID;                   }                   else {                       $ids .= $attachment->ID;                   }                   $counter++;               }           }          return $ids;  }        Then they say add this code below to the loop                      $attachment_ids = get_random_gallery_images();              echo do_shortcode('[ gallery columns="4" include="'.$attachment_ids.'" link="file" ]');      But my problem is, they didn't say where in the loop to add the code. Does anyone know where I can add this code? Also if you have a better solution to achieve what I am asking, please share :)


show custom post's post in two different divs

I have created a custom post type. For that I have used this code               add_action( 'init', 'broker_post_type' );     function broker_post_type() {       register_post_type( 'new_broker',         array(           'labels' => array(             'name' => __( 'Brands' ),             'singular_name' => __( 'Brand' )           ),         'public' => true,         'has_archive' => true,         'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),         )       );     }      Now to show all the featured image of the post type Brands in a single page I have used this code               function display_broker_posts() {       $args = array(         'post_type' => 'new_broker',         'orderby' => 'title',         'order' => 'ASC',         'posts_per_page'=> -1,       );            $dee_bios = new WP_Query( $args );       if( $dee_bios->have_posts() ):         $dee_output = '
';         $dee_output .= '
';         $dee_output .= '
';         $dee_output .= '
';         while ( $dee_bios->have_posts() ) : $dee_bios->the_post();           if( $dee_bios->current_post == 0 || ( $dee_bios->current_post % 2 ) == 0 ) {             $dee_output .= '
';             }           else {             $dee_output .= '
';             }                $dee_output .= get_the_post_thumbnail( $dee_bios->post->ID,'small', 'bios', array( 'class' => 'alignleft' ) );           $dee_output .= '';         //  $dee_output .= '
' . get_the_title() . ', ' . get_the_content() . '
';           $dee_output .= '
';         endwhile;         $dee_output .= '

';         $dee_output .= '
';       endif;            wp_reset_postdata();       return $dee_output;     }      Now this one is giving the result. But here in result I want something different. I want that lets say I have `16 posts in the Post`. So it will show `first 10 posts in a different div and the rest 6 posts in a different div`. So can someone kindly tell me how to do this? Any help will be really appreciable. Thanks


Hiding the media-new.php File URL option via jQuery

As the title says I'm currently having some difficulties hiding the File URL option via jQuery. I've been trying this:               // add_action( 'admin_footer-media.php', 'cor_remove_tr_file_url' );     add_action( 'admin_footer-media-new.php', 'cor_remove_tr_file_url' );     /**      * Removes the 'File URL' row      */     function cor_remove_tr_file_url() {     ?>     <script>     jQuery(document).ready(function($){       $('tr.image_url').remove()     });     </script>     <?php     }      which works great on `media.php`, but somehow it isn't working on `media- new.php`. Would someone perhaps know what I might be overlooking here? ![enter image description here](http://i.stack.imgur.com/QjFaL.png)


Is it possible to embed github gists in wordpress comments?

Is it possible to embed github gists in wordpress comments, I have seen a few plugins which allow embedding gists in posts, but not yet seen any plugins that allow embedding gists in comments.


query posts and custom post type with meta key

I'm trying to query all-in-one-event-calendar's custom post type ai1ec_event and normal wordpress posts in a slider on my home page. That works pretty well. Now I want to query only the posts with the custom field value "teaser", but that returns just normal posts, not the events.               <?php     query_posts( array(     'post_type'=>array('post','ai1ec_event'),        'posts_per_page' => 50,     'meta_query' => array(         array(             'key' => 'teaser',             'value' => 'on'                 )     )     );     ?>      Even if I leave out the post type query:               <?php     query_posts( array(     'meta_query' => array(         array(             'key' => 'teaser',             'value' => 'on'                 )     )     );     ?>      it only returns posts, no events.


Changing my permalink structure - will new layout conflict with existing page?

My site has a blog page at `/blog/`, with links to blog posts. A post will have a URL starting at the root of the site, which is a bit jarring. I'd like to have the posts URLs appear as if they are within the blog section of the site. My site currently has a permalink structure like the following: `/2010/09/11/sample-post/` I'd like to modify it to include a `blog` prefix: `/blog/2010/09/11/sample-post/` As I understand, WordPress should be able to handle the appropriate redirects. My issue is the fact that I have the blog **page** at `/blog/` If I change my post permalink structure, is there going to be any conflict with a page having a similar URL?


Theme files and imagesnot loading on a mobile device

I am just setting up my site but I have run in to a weird issue where the site seems to load perfectly fine on my computer but when I view it on a mobile device (iPhone/iPad) it appears to have none of the template files and none of the images are attached to posts etc. Any thoughts what could be wrong? I might add incase it helps I built this on a local set up and it's my first time using this process so there may be something in that I did wrong. But I checked the uploads folder and themes folder and they both have '755' permissions. This is the site: http://www.phoebeschoppingblock.com


Getting a List of Currently Available Roles on a WordPress Site?

When writing WordPress plugins there is often a need to set up options for which roles on the site have access to certain functionality or content. To do this a plugin dev needs to fetch the list of roles that exist on the site to use in the option. Because custom roles can be created we cannot assume the default roles are the only ones available. What is the best way to fetch the list?


Why does WP_DEBUG only work after wp_debug_mode() is called?

With debugging set to on,               define('WP_DEBUG', true);      my instance of WordPress doesn't show any debugging info. After a lot of searching I figured that after I call `wp_debug_mode()` debug info shows correctly. Can anyone tell me why calling `wp_debug_mode()` is necessary, since the debugging documentation page doesn't even mention this function? Is there something in my environment that is causing this?


Why can't I add this feed to the RSS widget?

I wish to use the following RSS in my widget, but it seems to not pick it up: http://www.tapuz.co.il/blog/rssBlog.asp?FolderName=TickTack I imagine there is a problem in the feed. So:   * What is it?   * And can it be fixed? Thanks.


Ordering links in List Tables don't include page number

I'm working on a WordPress plugin that requires the use of some WP_List_Table[s]. Everything is working fine but the ordering links for the table records do not include the "paged" GET parameter and thus whenever I click them the current page is lost and I'm returned to the first page. The pagination buttons don't seem to have this problem. They contain all the relevant GET parameters, such as "paged", "orderby" and "order" so unlike the ordering links they don't reset any parameter when clicked. Is this normal WordPress behavior or have I missed something?


Show only first children level of current category?

I wish to display only first level of subcategories on current category page (if any). I tried this code:               <?php             $args=array(                 'child_of' => $cat-id,                 'hide_empty' => 0,                 'orderby' => 'name',                 'order' => 'ASC',                 'depth' => '1' //NOT WORKING                  );             $categories=get_categories($args);             foreach($categories as $category) {                 echo 'term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'';  }             ?>      But, it shows all children, and children's children (grandchildren). I tried with "'depth' => '1'" but it is ignored. How to show only first level of children (if exist) on category page?


Translation of plugin Upload button

I want to translate "Upload an image" by using `_()`, `_e()`. It does not work for me. I tried `value= _e( 'Upload an image')` but did not work out.               function logo_image() {      $options = get_option('plugin_options');           echo"<input type='text'  class='regular-text text-upload' name='plugin_options[logo_image]' value='{$options['logo_image']}'/>";           echo "<input type='button' class='button button-upload' value='Upload an image'/>";           echo"<img style='max-width: 200px; display: block;' src='{$options['logo_image']}' class='preview-upload'/>";      }


Blog Not Loading, Can't Access Admin Page, No Trace of WordPress on Server

I recently took over as the webmaster for a small company, and I was asked to figure out what's going on with the company's blog, which uses WordPress. Essentially, the blog won't load, and this prevents me from accessing the admin page. I've checked to make sure the blog is down for everyone, and not just me. I wasn't left with much information about the site, so I assumed that WordPress had been installed to the company server. After a lengthy period of combing the server's files, I wasn't able to find anything related to WordPress. Although I have little knowledge of WordPress, I am aware that the presence of WordPress content in an SQL database is necessary for any page published with WP. How would I find the WP database? I suppose my question is: is there anything I could have overlooked? Are there any default WP files or keywords that would allow me to find any trace of WP or WP published content on the server? If I could find something to fix, I could potentially start looking for solutions to the problem. Thanks, and I apologize if my limited knowledge of WordPress prevented me from effectively expressing my questions.


Strange URL alternative behavior. site.com/a redirects to a page like site.com/an-article

Today, I saw that the link `site.com/b` doesn't show a 404 page. It goes to `site.com/blog/1393/03/05/built-in-power-supply/` (Maybe because of `built-in-power-supply` at the end) `site.com/c` goes to `site.com/products/sick/proximity-sensor/capacitive/` (Probably because of the last `capacitive`) `site.com/d` is redirected to `site.com/products/danfoss/`. `site.com/en` goes to `site.com/products/sick/encoder/` and `site.com/de` show the page `site.com/detection-and-ranging-solutions/` **BUT** `site.com/fr` shows a **Page Not Found** error, because there is not a page beginning with `fr`. * * * All of the URLS above should show a simple 404 Not Found error. Does anyone have the experience to resolve the strange problem?! Note that we have installed Swifty Page Manager.


Is there a way to dump all registered sidebar/widget?

I need to know the properties of sidebar and widgets I've added, is there a way to dump those? Thanks.


Garbage code showing up in search result post descriptions

I don't know why this is showing up on all my post descriptions in Google:                       _// _ // ]]> //      It is driving me crazy. I am new to this but feel this is the reason my posts are not posting alone in Google. They are only tied to my home page in Google.


Multiple Installs using the same database AND tables

I've been looking for a solution to this problem for actually a few months. Before I get started I would like to inform that I have NO INTEREST in using wordpresses multisite. Here is the issue for my website. I have a:     * Live Web Server/Database Server - **we'll call is mysite.com/news**   * Development Webserver/Database Server - **We'll call it dev.mysite.com/news**   * LOCAL(My Mac) Server that uses the DEVELOPMENT database. (Local changes are committed via SVN to the development server once completed)So the dev and the local stay mirrored for the most part. **we'll call it local.mysite.com/news** The only part of my site that uses Wordpress is our news section, and it's'great! The only issue is when working on the news, I can't work locally, and see my changes until it's committed to the development server and then viewed there. The reason for this is because of the wp_options table that points to the development server. I want to be able to make changes and actually be able to view them on local.mysite.com/news. But when going to local.mysite.com/news it redirects to dev.mysite.com/news because of the options set in the wp_options table. I'm okay with modifying core files, I have no plans to update. Is it possible to make a second wp_options table and specify somewhere in the configuration which wp_option table to use?


Correct Method to run scripts with dependencies without enqueue?

With enqueue you would change `$deps` to your script or array of scripts that are needed to run first for your script to work.               <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>      For example:               function script_that_requires_jquery() {         wp_register_script( 'script-with-dependency', 'http://www.example.com/script-with-dependency.js', array( 'jquery' ), '1.0.0', true );         wp_enqueue_script( 'script-with-dependency' );     }     add_action( 'wp_enqueue_scripts', 'script_that_requires_jquery' );      I usually do this but it doesn't always seem to work:               function script_that_requires_jquery(){         if ( wp_script_is( 'jquery', 'done' ) ) { ?>             <script type="text/javascript">             (function($) {                 // jquery function goes here                 })( jQuery );             </script>         <?php }     }     add_action('wp_footer', 'script_that_requires_jquery');      Maybe this is it?               function script_that_requires_jquery(){         wp_enqueue_script( 'jquery' );         ?>             <script type="text/javascript">             (function($) {                 // jquery function goes here                 })( jQuery );             </script>         <?php      }     add_action('wp_footer', 'script_that_requires_jquery');


prevent HTML output if custom field is empty

I am using the ACF plugin for custom fields. I am using this to add a second content area to my website. I have a peice of JS that says if this div is present then add a class to the page-content div to increase it's size. js:                     HTML:

                         <?php wp_nav_menu( array('top-menu' => 'Top Menu' )); ?>

                         <?php                     // TO SHOW THE PAGE CONTENTS                     while ( have_posts() ) : the_post(); ?>

                 <?php the_field('first_title'); ?>

                      <?php                 $first_comment = get_field('first_content_block');                 echo do_shortcode("[vr_jsp] $first_comment [/vr_jsp]");                     ?>                           <?php                     endwhile; //resetting the page loop                     wp_reset_query(); //resetting the page query                     ?>
                      <?php                     // TO SHOW THE PAGE CONTENTS                     while ( have_posts() ) : the_post(); ?>

                 <?php the_field('second_title'); ?>

                 <?php                 $second_comment = get_field('second_content_block');                 echo do_shortcode("[vr_jsp] $second_comment [/vr_jsp]");                        ?>
                     <?php                     endwhile; //resetting the page loop                     wp_reset_query(); //resetting the page query                     ?>
<a href="<?php echo home_url(); ?>">Return to home page X

      My css works but because the div page-content-text-additional renders with or without content the JS puts the double class on regardless. is there a way I am able to only render the page-content-text-additional if there is content in the ACF query?


Infinite blog loop

I can't figure out why I'm getting an infinite blog post. When I comment out loop code in content.php, it no longer loops. I'm trying to post items based on post format and failing so far. Let me know if I need to provide anymore info! I appreciate it. content.php:               <?php     /**      * The default template for displaying content. Used for both single and index/archive/search.      *      * @subpackage FoundationPress      * @since FoundationPress 1.0      */     ?>          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
             <?php FoundationPress_entry_meta(); ?>
             <?php the_content(__('Continue reading...', 'FoundationPress')); ?>
                  <?php if ( have_posts() ) : ?>                  <?php do_action('foundationPress_before_content'); ?>                  <?php while ( have_posts() ) : the_post(); ?>                 <?php get_template_part( 'content', get_post_format() ); ?>             <?php endwhile; ?>                  <?php else : ?>                      <?php get_template_part( 'content', 'none' ); ?>                  <?php do_action('foundationPress_before_pagination'); ?>         <?php endif;?>                           <?php $tag = get_the_tags(); if (!$tag) { } else { ?>
<?php the_tags(); ?>
<?php } ?>


how to get wordpress categories list with thumbnails?

i am trying to get thumbnails list with their thumbnails images .i tried code below but it only gives categories list . i know there a could do using feed_image but i can't figure out how to do it .please help me i am just a beginner in wordpress               $args = array(     'show_option_all'    => '',     'orderby'            => 'name',     'order'              => 'ASC',     'style'              => 'list',     'show_count'         => 0,     'hide_empty'         => 1,     'use_desc_for_title' => 1,     'child_of'           => 0,     'feed'               => '',     'feed_type'          => '',     'feed_image'         => '',     'exclude'            => '',     'exclude_tree'       => '',     'include'            => '',     'hierarchical'       => 1,     'title_li'           => __( 'Categories' ),     'show_option_none'   => __( 'No categories' ),     'number'             => null,     'echo'               => 1,     'depth'              => 0,     'current_category'   => 0,     'pad_counts'         => 0,     'taxonomy'           => 'category',     'walker'             => null        );            echo wp_list_categories( $args );


Using widgets on an options page?

hopefully someone more experienced can help me out with this idea I've got... I'm working on a new theme, and I'd like this to be widgetised. I've done this before using the regular widgets/sidebar setup in the admin area, but this time I'd like the home page sidebar (the drag and drop part) to feature on my theme options page. Can anyone tell me how tough this would be? I would like access to the same set of widgets, but a drag and drop sidebar area which is laid out horizontally rather than vertically, so the user could choose widgets for , say, 3 columns. I think this would make a cool interface for the administrator - if only I knew more..! Many thanks, Dan.


List of contents of entire blog

There is a widget categories which prints categories as tree, for example:               category1       subcategory1       subcategory2     category2       subcategory1      I would like to print whole content of blog together with articles not as widget but on main page as normal text like:               category1       subcategory1         news1         news2       subcategory2         news1     category2       subcategory1            news1         news2      What is the way to do this?


Need help with add_rewrite_rule

**SOLUTION** * * * **I've gone with Update 3 and have got it working. What I had misunderstood, was that I believed that a rewrite rule would change`designers/?designer=some- designer&bid=9` to `/designers/some-designer`. But it is of course the other way around.** * * * I've been doing some research, but I don't quite get how to use add_rewrite_rule(). This post is pretty close to what I need, but do I really need that much code? My current link is this:   http://www.norwegianfashion.no/designers/?designer=Batlak-og-Selvig&bid=9   What I want is this   http://www.norwegianfashion.no/designers/Batlak-og-Selvig/   1. How do I use `add_rewrite_rule()`?    2. I need to pass the designer ID (bid). How can I do that when using re.write rules with out it showing in the URL? **Update 1** I found this which is a bit more explainatory. But it's not working:               function add_rewrite_rules( $wp_rewrite )      {         $new_rules = array(             '('.$template_page_name.')/designers/(.*?)/?([0-9]{1,})/?$' => 'designers.php?designer='.             $wp_rewrite->preg_index(1).'&bid='.             $wp_rewrite->preg_index(2)         );            // Always add your rules to the top, to make sure your rules have priority         $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;     }     add_action('generate_rewrite_rules', 'add_rewrite_rules');          function query_vars($public_query_vars) {              $public_query_vars[] = "designer";         $public_query_vars[] = "bid";         return $public_query_vars;     }     add_filter('query_vars', 'query_vars')      **Update 2** Here is another solution I've tried, that Jan Fabry suggesten in another thread. I put this in my functions.php, but it has no effect.               add_action('generate_rewrite_rules', 'add_rewrite_rules');     add_filter('query_vars', 'query_vars');          /* Custom re-write rules for desigenrs     ------------------------------------------------------------------------------*/     function add_rewrite_rules( $wp_rewrite )      {         add_rewrite_rule('^designers/([^/]*)/([^/]*)$ /designers/?designer=$1&bid=$2 [L]', 'top');         flush_rewrite_rules(false);     }               function query_vars($public_query_vars) {              $public_query_vars[] = "designer";         $public_query_vars[] = "bid";         return $public_query_vars;     }      **Update 3**   I found a few examples here as well. But this is not working either :(               add_filter('rewrite_rules_array','wp_insertMyRewriteRules');     add_filter('query_vars','wp_insertMyRewriteQueryVars');     add_filter('init','flushRules');            // Remember to flush_rules() when adding rules     function flushRules(){         global $wp_rewrite;         $wp_rewrite->flush_rules();     }          // Adding a new rule     function wp_insertMyRewriteRules($rules)     {         $newrules = array();         $newrules['(designers)/(\d*)$'] = 'index.php?pagename=designers&designer=$matches[1]';         return $newrules + $rules;     }          // Adding the bid var so that WP recognizes it     function wp_insertMyRewriteQueryVars($vars)     {         array_push($vars, 'designer');         return $vars;     }      **Update 4** I also tried this solution, but still no sucess.               add_filter('search_rewrite_rules', 'designers_createRewriteRules');          function designers_createRewriteRules($rewrite) {     global $wp_rewrite;          // add rewrite tokens     $designer_token = '%designers%';     $wp_rewrite->add_rewrite_tag($designer_token, '(.+)', 'designers=');          $bid_token = '%bid%';     $wp_rewrite->add_rewrite_tag($bid_token, '(.+)', 'bid=');          $keywords_structure = $wp_rewrite->root . "designers/$designer_token/$bid_token";     $keywords_rewrite = $wp_rewrite->generate_rewrite_rules($keywords_structure);          return ( $rewrite + $keywords_rewrite );      } **Update 5**   It seems that my rewrite rules are not added. Executing the follwoing afte radding new rules: `print_r($wp_rewrite)`, does not include my new rewrite rules. **Update 6**   I tested Jan's solution. But URL does not change :(               /* Initiation script for NF template     ------------------------------------------------------------------------------*/        add_action('after_setup_theme','norwegianfashion_setup');          if ( ! function_exists( 'norwegianfashion_setup' ) ):            function norwegianfashion_setup() {          /* Here I do a lot of stuff */              // SEO friendly URL for desigenrs         add_action( 'init', 'wpa5413_init' );         add_filter( 'query_vars', 'wpa5413_query_vars' );       }          endif;               /* Custom re-write rules for desigenrs     ------------------------------------------------------------------------------*/     function wpa5413_init()     {         // Remember to flush the rules once manually after you added this code!         add_rewrite_rule(             'designers/([^/]+)/?',             'index.php?pagename=designers&designer=$matches[1]',             'top' );     }          function wpa5413_query_vars( $query_vars )     {         $query_vars[] = 'designer';         return $query_vars;     }      I would **really** appreciate it if someone were able to help me solve this issue.


Where to place PHP code that inserts (or doesn't insert) menu item?

Where do I place the PHP code to insert or not insert a menu item based upon some condition, i.e. value of another PHP variable like so:               $listItem = '';          <?php if ($condition)     {         $listItem = '
Blog
';     }          ?>          /* html for menu list */          <?php echo $listItem; ?>          /* more html for menu list */


Customise Comment form

I am trying to customise the comment form so I can clearly edit the labels and style them.               <?php comment_form( $args = array(                   'id_form'           => 'commentform',  // that's the wordpress default value! delete it or edit it ;)                   'id_submit'         => 'commentsubmit',                   'title_reply'       => __( 'Leave a Reply' ),  // that's the wordpress default value! delete it or edit it ;)                   'title_reply_to'    => __( 'Leave a Reply to %s' ),  // that's the wordpress default value! delete it or edit it ;)                   'cancel_reply_link' => __( 'Cancel Reply' ),  // that's the wordpress default value! delete it or edit it ;)                   'label_submit'      => __( 'Post Comment' ),  // that's the wordpress default value! delete it or edit it ;)                        'comment_field' =>  '
<textarea placeholder="Start typing..." id="comment" class="form-control" name="comment" cols="45" rows="8" aria-required="true"></textarea>
',                         'comment_notes_after' => '
' .                     __( 'You may use these HTML tags and attributes:' ) .                     '

' . allowed_tags() . '
'               ));          ?>      How can I change it so I can target the appropriate field such as `Name`, `Email` and `Website`? I can't find a good tutorial to do so. Any help or direction will be appreciated.


Linking a PDF as a downloadable document

How do I add a link to a PDF in the content, so that it downloads rather than opens in the browser windows? (I've uploaded the PDF to the media library and can insert the link but can't find an option to prevent it opening in the browser window). Thanks, Lucy


Is there a way to add Reattach and Unattach links in image gallery?

For some reason the Reattach and Unattach links in Media library is gone. Is there a way to add these from functions.php?


Question about how do wordpress filters/actions work

I have a question that I'm curious. In WordPress we can add a filter or action like this code:               add_filter($filter_Name, $function_will_be_hook);     add_action($action_Name, $function_will_be_hook);      We can pass some parameters into **function_will_be_hook()**. But how does WordPress know that these parameters are related to its filters/actions. Example:               function my_the_content_filter($content) {         $content .= "I added some additon content";         return $content;     }           add_filter( 'the_content', 'my_the_content_filter' );      **How does WordPress know`$content` is the content of Post/Page (even when we change name of this param to some other name)?**


nginx varnish w3 total cache issues

I converted a few sites from Apache to nginx and it was running well for a while. I recently updated the nginx configuration regarding the new changes to W3 Total Cache rules. I also tried to clean up my config. I am having really odd issues. One or two sites on this server will give me a 404 error and not load until. I verified the sites-available configuration file is exactly like the other sites. Most of the sites work fine, and as I was editing the WordPress sections of the conf, I noticed some sites would do this or 403 error but not all sites. I find this really confusing as if there is a problem with the config, it should be all sites. I went through the files for the sites that have the problems over and over and I can't see any typos or variance from the other sites. If I disable W3TC completely, everything works fine. One site I had a lot of problems with, the only way to fix it was to delete all traces of W3TC manually, and reinstall it. This is my configuration file, it is all one file here, but it is split up in multiple files on the server (drop.conf, wordpress.conf, php.conf), I just pasted them all into one file.               server {     listen       8080;     server_name  domain.com www.domain.com;     root         /srv/www/domain.com/public;     access_log   /srv/www/domain.com/log/access.log;     error_log    /srv/www/domain.com/log/error.log;          location = /robots.txt  { access_log off; log_not_found off; }     location = /favicon.ico { access_log off; log_not_found off; }       location ~ /\.          { access_log off; log_not_found off; deny all; }     location ~ ~$           { access_log off; log_not_found off; deny all; }              location / {              index index.html index.php;             try_files $uri $uri/ /index.php?$args;      }          location /search {             limit_req zone=wpsearch burst=3 nodelay;             try_files $uri /index.php;     }          location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {             expires max;             add_header Pragma public;             add_header Cache-Control "public, must-revalidate, proxy-revalidate";     }          # Prohibit php files from executing in wp-uploads     location ~* ^/wp-content/uploads/.*.php$ {             return 403;     }          location ~ /nginx.conf { deny all; }                      include /srv/www/domain.com/public/nginx.conf;              location ~ \.php {             fastcgi_intercept_errors off;             client_max_body_size 25M;             try_files      $uri =404;             limit_conn phplimit 5;             fastcgi_index  index.php;                  fastcgi_param   QUERY_STRING            $query_string;             fastcgi_param   REQUEST_METHOD          $request_method;             fastcgi_param   CONTENT_TYPE            $content_type;             fastcgi_param   CONTENT_LENGTH          $content_length;                  fastcgi_param   SCRIPT_FILENAME         $request_filename;             fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;             fastcgi_param   REQUEST_URI             $request_uri;             fastcgi_param   DOCUMENT_URI            $document_uri;             fastcgi_param   DOCUMENT_ROOT           $document_root;             fastcgi_param   SERVER_PROTOCOL         $server_protocol;                  fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;             fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;                  fastcgi_param   REMOTE_ADDR             $remote_addr;             fastcgi_param   REMOTE_PORT             $remote_port;             fastcgi_param   SERVER_ADDR             $server_addr;             fastcgi_param   SERVER_PORT             $server_port;             fastcgi_param   SERVER_NAME             $server_name;                  fastcgi_param   HTTPS                   $https;                  # PHP only, required if PHP was built with --enable-force-cgi-redirect             fastcgi_param   REDIRECT_STATUS         200;                  fastcgi_pass   unix:/var/run/php5-fpm.sock;     }     }


Wordpress wp_update_attachment_metadata image width and height = 1?

Hello Friends I used to set post thumbnail programetically. this is my code.               foreach ($csv as $key => $value) {     $filename = "wp-content/uploads/images/".$value[8].".jpg";     $wp_filetype = wp_check_filetype(basename($filename), null );     $attachment = array(     'post_mime_type' => $wp_filetype['type'],     'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),     'post_content' => 'this is the first project file.',     'post_status' => 'Published'     );     $my_post = array(       'post_title'    => $value[0],       'post_content'  => $value[2],       'post_status'   => 'publish',       'post_author'   => 1,       'post_type'   => 'post_staff'     );     $post_id = wp_insert_post( $my_post );          $attach_id = wp_insert_attachment( $attachment, $filename,$post_id);     $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );     wp_update_attachment_metadata( $attach_id, $attach_data );                     add_post_meta($post_id, '_thumbnail_id', $attach_id);     update_post_meta( $post_id, '_staff_name', $value[1] );         update_post_meta( $post_id, '_staff_city', $value[3] );         update_post_meta( $post_id, '_staff_postal_code', $value[4] );          update_post_meta( $post_id, '_staff_direct_line', $value[5] );          update_post_meta( $post_id, '_staff_fax', $value[6] );          update_post_meta( $post_id, '_staff_email', $value[7] );         $tagd = array( 9 );     wp_set_post_terms( $post_id, $tagd, 'department' );        if($value[3] == "St. John's, NL"){         $tagl = array( 8 );     }else if($value[3] == "Corner Brook"){         $tagl = array( 7 );     }     wp_set_post_terms( $post_id, $tagl, 'location' );        if(set_post_thumbnail( $post_id, $attach_id )){         echo "image set";     }      } This is working fine but the imported feature image with size 1x1 width = 1 and height = 1 why it takes width and height is 1 autometically please help. when i trying to get image using get_the_post_thumbnail the return image. image is found but bydefault the image width = 1 and height = 1 take. this is my code.               get_the_post_thumbnail( get_the_ID(), array(250,165));      Thank you.


Get author ID with attachment ID

I have a page, outside the loop, that display a media attachment with some basic info about it (title, uploaded date, etc). I have the attachment ID available to me via a form submitted before the page loads. What I need to do is secure the page by making sure that only users who have uploaded that file have access to the page with that file one it. In order to do that, I assumed the easiest way would be to compare the ID of the current, logged-in user with the ID of the user who created the attachment. But there doesn't seems to be a way that I can find to get the ID of the author of a post outside of the loop using only the attachment ID. I'm stumped, how should I do this?


Move specific javascript to the footer

I have noticed if I move all of my javascript to the footer, some plugins do not function properly, or at all. Is there some code I can add to my functions.php to move specific plugin javascript to the footer? Or is there a way to exclude certain js from going from the footer if I add it all? This is the code I used:               remove_action('wp_head', 'wp_print_scripts');     remove_action('wp_head', 'wp_print_head_scripts', 9);     remove_action('wp_head', 'wp_enqueue_scripts', 1);          function my_remove_thematic_scripts() {     remove_action('wp_head','thematic_head_scripts');     }          add_action('init', 'my_remove_thematic_scripts'); //wait for init          //Add the actions to the footer          add_action('wp_footer', 'wp_print_scripts', 5);     add_action('wp_footer', 'wp_enqueue_scripts', 5);     add_action('wp_footer','thematic_head_scripts');     add_action('wp_footer', 'wp_print_head_scripts', 5);      The plugins that don't work properly are simplemap, gravity forms (mainly not loading properly) and a background slider for my homepage.


Can you have multiple wordpress sites under the same domain?

Any issues with having multiple wordpress sites under the same domain. Example:   * domain.com/programs   * domain.com/sales   * domain.com/learning Each would have its own templates, functionality, menus and whatever. Any issues you can see? One of the issues I am worried about is if I have:   * domain.com/programs - which might be a hub site for programs and then I have another person who is the "golf" program admin... \- domain.com/programs/golf two totally different sites - may use multisite but not sure yet. So what if the domain.com/programs admin adds "golf" as a category? **NEW INFO:** To those who said, this is normal for WP and no issues please see Why did installing wordpress in url root jack up underlying WP sites?. I had 10 sites installed and after installing a "root" site all are having MAJOR permalink issues.


Is it better to use filter for the_content in archive pages?

I'm using advancd-custom-fields plugin and I'm about to modifiy my acrhive content page that is shown frontend. I use the file **personnel-archive.php** (because the custom post type used is personnel) in my theme in that works ok: Beginning of this file looks like:               <?php get_header(); ?>              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                  <div class="post" id="post-<?php the_ID(); ?>">
<?php the_title(); ?>

                       <?php echo image_personnel(get_the_ID());?>                      <?php the_content('
Läs resten »
'); ?>                          <?php wp_link_pages(array('before' => '
Sidor: ', 'after' => '
', 'next_or_number' => 'number')); ?>      I my functions.php I have made this function:               function image_personnel($post_ID) {         $post_type = get_post_type( $post_ID );         $content = '';              //If custom type for shown post is personnel, then show image first         if ($post_type == 'personnel') {                  $picture_personnel = get_post_custom_values('picture_personnel', $post_ID);             if ($picture_personnel) {                 $image_fields = get_field('picture_personnel');                                                 $url_image = $image_fields['url'];                 $alt_image = $image_fields['alt'];                 $title_image = $image_fields['title'];                 if (strlen($alt_image)>0) {                     $title_image = $alt_image;                 }                 else {                     $alt_image = $title_image;                 }                 $content = '';                }                                         }              return $content;     }                 I've basically just added a field "picture_personnel" to each personnel post and I want to show it in the content. Is it better to use filter for the_content? Or is it just a matter of taste?


attach one post from one post type to another post from another post type

I have 2 custom post types: agenda and doel. At each agenda post, I want to choose a doel post to attach it to, and the same with normal posts. So I want a connection between posts, agenda, en doel. I found this plugin called posts2posts from scribu, it does attach the posts types to each other, but I can not find out how and if it is possible to connect certain posts from one post type to certain posts from an other post type. The ideal solution would be to have a dropdown in one post type, that shows all the posts from an other one, and you can select one. In example, when editing a post from agenda, I can choose a post from doel to attach it to. And later on I want to loop that. Does someone know how this can be done easily, or recommend a good plugin? Sorry for my bad explanation, hope it is kind of clear.


is_active_sidebar() not working

why the is_active_sidebar() function return always false? Function.php code:               if ( function_exists('register_sidebar') ) {        register_sidebar(array(          'name' => 'Footer Column 2',         'id' => 'footer-column-2', // I also added the ID but doesn't work          'before_widget' => '
',             'after_widget' => '
',          'before_title' => '
',            'after_title' => '
'        ));     }      footer.php code:               <?php if ( is_active_sidebar( 'footer-column-2' ) ) : ?>
                        <?php dynamic_sidebar( 'Footer Column 2' ); ?>
          <?php endif; ?>      I tried with the name or id but not working. Any idea? Thanks EDITED: I have more dynamic sidebars and I use this code to register these:               //register custom sidebars     add_action( 'widgets_init', 'register_theme_sidebars_dynamic' );          // and this function...I think the problem is here:          function register_theme_sidebars_dynamic(){         global $wpdb;         //post and pages sidebars         $widgetized_pages = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'omc_page_sidebar'", ''));              if($widgetized_pages){             foreach($widgetized_pages as $w_page){                 $widget_id = strtolower(str_replace(' ', '_', $w_page));                 register_sidebar(array(                     'name' => $w_page,                     'id'   => 'jw_widgetsection_'.$widget_id,                     'description'   => '',                     'before_widget' => '',                     'after_widget' => '     ',                     'before_title' => '',                     'after_title' => ''                 ));              }// For each         }//End If                  }


Site migration from Localhost to Server - 404 errors

I'm migrating another site from localhost to remote web server and am experiencing an issue. Here are the steps I took: 1.) Downloaded Wordpress locally, and began editing the twentytwelve theme. 2.) Created 8 custom template pages using something like this:               <?php     /*     Template Name: My Custom Page     */      3.) I went to Wordpress dashboard/admin and created 8 pages from the templates I made, then added those pages to the menu bar. 4.) I changed the DB credentials in the wp-config then FTP'd the entire site from localhost to remote host. 5.) I exported the database and successfully imported onto remote server. 6.) I downloaded the search & replace script and uploaded it to the live server, then ran it and replaced the URLs across the site. I can now navigate to the home page on the remote host: fairchildwebsolutions.com/evo/eco_designs/ However, 404 error displays when I go to any of the other pages I created. Did I do something wrong? Note that all of the pages display just fine on the localhost. Thanks


Customize wp-admin form custom fields

I would like to customize some form elements in my WP admin area: starting from this example (http://api.jquery.com/val/ the one with the select) what I would liko to do, is to update a via a select field. In order to do so I started including this function:               function my_enqueue() {              wp_enqueue_script( 'my_custom_script', get_template_directory_uri() . '/js/admin.js' );     }     add_action( 'admin_enqueue_scripts', 'my_enqueue' );      Inside "admin.js" I placed:               alert("It works!");      And it does work. But whenever I try to include anything related to jQuery nothing happens: the code is being included inside the page and I get no errors in Firebug. For example a script as simple as the one you can find at http://www.w3schools.com/jquery/event_keyup.asp               $("input").keyup(function(){         $("input").css("background-color","pink");     });       Doesn't work. Nothing happens. So I wonder, what am i missing or doing wrong? Thansk a lot!


Prevent stripping MathML tags on post save

I am trying to add MathML markups in wordpress custom post. But, it is stripping all MathML tags when I hit the publish button :( I have disabled "wpautop" and "Visual Editor". These are not helping at all. Can you please suggest what I can do?


Settings API with arrays example

I'm using the Wrox WordPress plugin development book as a primary reference for getting started with a new plugin and I understand all settings can be saved as 1 array but the book does't give an example of this and all the stuff I'm finding on the web seems so different from one example to another. The second half of a post by Konstantin gets me close but I'd really like to see a more complete example with multiple fields.


Two settings field in one form

is it possible to have two settings fields in one form?               <?php         echo '<form method="post" action="options.php">';         settings_fields( 'my-plugin-settings-group-1' );         settings_fields( 'my-plugin-settings-group-2' );     ?>      I tried it but it doesn't work, only one settings_fields is saved. any ideas or other solutions?


how to use register_setting array

register_setting( 'tema-settings-group', 'option' ); I send more than 1 value but when ı display get_option('option') ı can only see value that ı sent last. So I think ı need make array to display all values ı send.But if there is another way to display all valuo by using register_setting() pls tell me. I search but ı couldnt find. why dont you give me link


Comments_template doesn't work

If I use               comments_template();      it does not work at all. But if I change it to               global $withcomments;     $withcomments = 1;     comments_template( 'comments.php', true );      it displays the comments template but I need to setup the Disqus plugin, and the plugin does not work. I don't understand, getting comments to display is being incredibly difficult for some reason.. dev link * * * _(tried to truncate non-pertinent code to keep it short)_ **index.php**               if ( have_posts() ) {         while ( have_posts() ) {             the_post();             get_template_part( 'content' );         }     } ?>      * * * **content.php**                         <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">              <?php get_template_part( 'content', 'header' ); ?>
                  <?php             $entrycontent = $lithograph_theme_options['excerpt_content'];                  if ( $entrycontent != '' ) {                 switch ( $entrycontent ) {                     case 'excerpt':                         if ( $lithograph_theme_options['slideout_content'] == 0 ) the_excerpt();                         else : ?>                                                              <?php                                     if(!empty($post->post_excerpt)) the_excerpt();                                     else : echo get_first_paragraph(); ?>                                 + more                                                                                <?php echo get_the_post(); ?>                                 - close                                 <?php                                      get_template_part( 'content', 'footer' );                                     comments_template( 'comments.php', true );                                 ?>                                                      <?php }                         break;                     case 'content':                         the_content();                         global $withcomments;                         $withcomments = 1;                         comments_template( 'comments.php', true );                         break;                 }             } ?>

      * * * _(generic comments template)_ **comments.php**               <?php if($comments) { ?>
             <?php foreach($comments as $comment) { ?>                 <li id="comment-<?php comment_ID(); ?>">                     <?php if ($comment->comment_approved == '0') { ?>
Your comment is awaiting approval
                     <?php }                     comment_text(); ?>                     <?php comment_type(); ?> by <?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?>
             <?php } ?>
     <?php } else { ?>
No comments yet
     <?php } ?>


Missing items on page

I'm missing items on my web page and I think it is due to some jQuery problems. But I'm not sure and I am unable to find the bug. On this site, on the upper-right corner there is a shopping bag 'widget', and on my site there is none but the white space indicates that it's trying to be there. Now I made a gist of the differences of both sites (https://gist.github.com/mvaneijgen/d5784918e202ac19070f/revisions), but still cant find a bug maybe a more experienced WordPress developer sees it in a second. I have tried disabling all the plugins, flushing the cache and ask for theme support on GetBowTiedSupport - Ticksy, but there's no response from the developer so I hope to fix it through this channel.


How to add order in goods catalog plugin in wordpress?

https://wordpress.org/plugins/goods-catalog/ I'm using Goods Catalog Plugin to add the products.Now i waht to order it. But there is no option for it. Kindly Help me to add the order in this plugin


approve,spam,trash etc. options are not coming on comments in admin panel

I made some changes in **comment-template.php** , **wp-comment-post.php** so now I am storing the comments withot attaching with any post or page (I am setting the comment_post_id to 0). But now the problem is When I go on admin panel and see all comments the comments with 0 comment_post_id are not having option of spam , trash , approve etc. how to resolve it? Actually I want to store comments separately from post or page but with complete functionality as in comments of any post or page like whether logged in or not otherwise fields for name, email etc. and in admin panel options for approval,trash,spam etc.. Can I achieve this with any other plugin that performs same as comment form.


Extending WC_Cart in woocommerce

I am trying to extend WC_Cart in woocommerce, from what i understand my code should be correct. However when I load the cart I get the following message.               Fatal error: Call to undefined method WC_Cart::get_prediscount_total() in ...      Code in my plugin:               class My_WC_Cart extends WC_Cart {          public function get_prediscount_total() {             return apply_filters( 'woocommerce_cart_total', woocommerce_price( $this->total * 5 ) );          }      }      The output code is                echo $woocommerce->cart->get_prediscount_total();      This works when the codes in `/wp-content/plugins/woocommerce/classes/class- wc-cart.php` but the moment I try to extend it it fails.


Multi-part form and wp_redirect()

For starters, it's a plugin (with a shortcode) or at least I would prefer it to be. I've got two issues both related to wp_direct. If form 1 validates I want to redirect to form 2, and continue the process. If the visitor tries to start at form 2 without first having filled out form 1, then I want to redirect them back to form 1. I've tried a number of different things and I continue to get "Cannot modify header". Even when the __construct() uses add_action ''send_headers' I still get the header error. How do I validate a form, redirect and then display a second form. This hardly seems like an advance need. Yet I've spend a good part of the day looking for answers and here I am begging for help :) Thanks in advance. p.s. wp_safe_redirect() doesn't show up in the tags list.


List of all existing Wordpress plugins

Is there a place from where I can get a list of all existing Wordpress plugins located in http://wordpress.org/extend/plugins/ I am trying to test my website for vulnerabilities and need such list. Thanks


Remove a menu item created by a plugin

I'm trying to remove a menu item and tried several approaches, but have not had any luck. It was created from a FAQ plugin. If I use this line:               remove_menu_page( 'edit.php?post_type=question' );      It will remove the main menu, however I only want to remove two sub-menu items contained inside that `edit.php?post_type=question` URL address. For the item I want to remove, the path in the URL bar gives me the following:   `edit-tags.php?taxonomy=faq-topic&post_type=question`   and   `edit-tags.php?taxonomy=faq-tags&post_type=question` I have tried several solutions including `remove_menu_page` and `remove_submenu_page` to no avail. What has failed so far:               remove_submenu_page( 'edit.php?post_type=question', 'edit-tags.php?taxonomy=faq-topic&post_type=question');     remove_menu_page( 'edit-tags.php?taxonomy=faq-tags') ;     remove_menu_page( 'edit-tags.php?taxonomy=faq-tags&post_type=question') ;     remove_submenu_page( 'edit.php?post_type=question', 'edit-tags.php?taxonomy=faq-topic&post_type=question');     remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&post_type=question');     remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic');     remove_submenu_page( 'edit.php', 'edit-tags.php');


Custom fields with square brackets in the name

I have some custom fields which I need to have square brackets inside. This would not be a problem apart from the fact that I need the end user to be able to reselect the custom field on another post but it is not visible. Any custom fields with a name with a square bracket is missing from the drop down list. Is there any one that can help me to show the custom fields in the dropdown with a square bracket in it?


How to filter categories of a post

Is there any way to filter the categories of a post? I am using `wp_get_post_categories( $post -> ID );` i want to filter this listing i.e. `if(post_name or post_id == "some id or some name") {it should not be displayed}`


Multisite Independent User Base

I run a multisite blog farms with all blogs having a consistent functionalities (theme and plugins and some basic content), but independent from each other in terms of user database. I would like to prevent user signup at one site being able to sign in through all other sites. Likewise, if a user is deleted from a site, s/he can't access other network sites. I'm actually registering user through a plugin, so I have total control over the registration process. Any input is appreciated :)


Static posts page is not working

I've found other questions asking the same thing but I think I followed the method correctly. I created a page called "Splash" (page-splash.php) and another empty page called "Blog" But when I change the settings in "Reading" the main page is working (WP loads page-splash.php correctly) but the the loop in my index.php is NOT returning any posts. ! http://i.imgur.com/ZLVlp.png This is my index.php               <?php get_header(); ?>
          <?php query_posts($query_string . '&cat=-3'); ?>     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<?php the_title(); ?>
                <?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>
<?php the_content(); ?>

            <?php endwhile; else: ?>
Sorry, no posts matched your criteria.
      <?php endif; ?>
     <?php get_footer(); ?>      The thing that confuses me if I remove the whole use a static front page feature and just return to the normal settings. The loop in index.php is working... Update: here's the site I'm working on. http://www.christiegrahamphotography.com/2012/wordpress/ Click into blog will return zero posts (I have 3 published posts)


Using wp_dropdown_users and selected() function?

I have a custom meta box with a dropdown displaying all the WP users via wp_dropdown_users. It saves which WP user is chosen with the post, so that all works. However, is there a way to make it show the selected user in the dropdown when going back to edit, rather than the first in the list? I've used the selected() function for another dropdown but I've created that dynamically. I've tried to implement selected() with wp_dropdown_users, but it hasn't worked so I'm not sure if it's even possible? Thanks!


How do I “replace a function via plugins” in WordPress?

I'm new to WordPress and am not understanding their docs. What I'd like to do is to replace the `wp_hash_password` (and a few other password related functions) with my own. I've already written the functions and had them tested outside WordPress to ensure functionality. > "wp_hash_password function can be replaced via plugins. If plugins do not > redefine these functions, then this will be used instead." > > According to WordPress docs Unfortunately I can't find any place that tells me HOW to do it. I tried creating a PHP file in the `../wp-content/plugins/myfirstplugin/myplugin.php`. In my `myplugin.php` file I have an "overriding" function:               function wp_hash_password( $password ) {           // my code is here          }      I also tried renaming my php file to functions.php and even used the `add_action` & `add_filter` but again the docs are less than supportive. I have the code I just need to know how to put it in a "plugin", where the plugin goes, and how to activate the plugin (is this done in the wordpress admin's menu?) Cheers!


Listing all posts from current category on page

I'm trying to list all posts from a certain category, in a list, on the category page that already lists the posts out in blog form. I'm trying to do it in the header area so that you can get an overall look at the posts on the page. I found this:
     <?php     global $post;     $category = get_the_category($post->ID);     $category = $category[0]->cat_ID;     $myposts = get_posts(array('numberposts' => 5, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish'));     foreach($myposts as $post) :     setup_postdata($post);     ?>
     <a href="<?php the_permalink(); ?>">     <?php the_title(); ?>
     <?php endforeach; ?>     <?php wp_reset_query(); ?>
      But it always seems to cut one of the posts out of the list. Is there an easier way to do this, without a plugin? Thanks


Add a .last class to the last <li> in each ul.sub-menu

I've seen a lot of code on how to add a `first` and `last` class to a WordPress menu, but in my instance I would like to add a `last` class to the last li in the sub-menu that WP generates. Here's what I would like to achieve in it's simplest form.

Menu item one

Menu item two

Sub menu item one

Sub menu item two

Sub menu item three

Menu item three

      And here is what I currently have, that adds first and last classes to only the parent menu items. Could this be adapted?               function add_first_and_last($items) {         $items[1]->classes[] = 'first';         $items[count($items)]->classes[] = 'last';         return $items;     }          add_filter('wp_nav_menu_objects', 'add_first_and_last');      I would like to stick with php for this and not use either `:last-child` (want it to work in ie7 & 8) or jQuery.


Page not found error when adding text `2 = 2 ^ 1` to the page

Adding the following text to a page in the Text editor and clicking `Update` results in "Error 404 - Page Not Found":               2 = 2^1      Replacing this text with anything else makes the Update succeed. Any ideas what might be causing the error? **Update:** After some experimentation I've discovered a more general form of input leading to errors:               <number> = <number> ^      with the same number on both sides of the equal sign. For example, `100 = 100 ^` gives an error while `100 = 101 ^` doesn't.


How pass a 0 in $atts?

I need to pass an attribute (tabindex="0") into my navigation link. I use this filter:               /**      * Add tabindex attribute to menu links      *      * Brings keyboard accessibility for opera browser.      */     add_filter( 'nav_menu_link_attributes', 'atts_menu_tabindex' );     function atts_menu_tabindex( $atts, $item, $args )     {         $atts['tabindex'] = 0;         return $atts;     }      This filter works fine with all values unless with **_0_** (zero). What can i do, to pass the "0"?


Multisite install on subdomain w/ subdomains change siteURL

I have a multisite installed on a subdomain and I am trying to make the process of duplicating sites more straight forward. Currently when it is duplicated you must delve into the settings to manually change the siteURL for that particular site from `xxx.xxx.example.com` to `xxx.example.com`. Is there a way this can be done hooking into `wpmu_create_blog` at all? If it helps I am currently using NS Cloner Pro to duplicate sites, but I don't think it should matter.


How to call one custom field value if another custom field value is equal to today's date

I'm building a website for a school division in Canada, they help organize their days by assigning a school day to each day of the week. There are 5 school days, and so they do not always end up on the same day of the week, as on a day off the school day doesn't roll over. I have used a custom post type and entered in custom fields to allow setting a date value, and a School Day Value by the staff of the school, however on the front page I have created a widget that I'd like to run a php string that will find an event with the date value the same as today's date, and then display that day's date or that custom field value in the sidebar for that day. Can anyone think of how to do this? Thanks! EDIT* So from what I can see I think I'd need something like "               $query = new WP_Query( array( 'meta_key' => 'color', 'meta_value' => '**insert something that would show today's date in the  correct format**' ) );      does it seem like I'm headed in the right direction? Sorry guys I know I'm way below the skill set needed for this but I'm not sure how else to learn.


How to Delete all Unused photos Function

I have the current problem : I run a WordPress website with Woo Commerce and every few days I refresh the product list deleting and importing over 8000 products at a time . Now, every single time I get +/- 3500 products deleted from the database so I have to remove the photos and the thumbnails for each one .. so i have to delete more then 12.000 photos . Using any plugin is not an option, they all freeze / stop working so I need to build my own / function or plugin and I need a starting point . I have a list with the old products and I delete them like this :               foreach($old_product_list as $oldproduct){              $wpdb->show_errors();         $delq = $wpdb->get_results(                          "  DELETE a,b,c                             FROM wp_posts a                             LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )                              LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )                              LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )                              LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )                                                 WHERE a.post_title='".$mysqli->real_escape_string($oldproduct['name'])."' " );        [.....]


making a glossary with wordpress

I know that there are glossary plugins in the wordpress repository. This plugins normally searches glossary terms in post content and adds a link to it. But i have not found one, that search and replace terms in custom post types. Because of this i am trying to make my own glossary plugin. if you know about a plugin that make this, please tell me. My code search custom post type posts titles in the post content and replace it with a link. The problem is that it make the replace in all the text, including a title atributte of a links, and i dont want to replace it by a link in this cases. what can i do to it doesn`t replace when is link atributte text? This is my code:               function reemplazar($cadena){              //get glossary posts type posts         $args = array(             'showposts'   => -1,             'category_name' => 'glosario',             'post_type' => 'glosario',         );          $posts_array = get_posts( $args );              //Create an array with post title in keys and post link in a value         $reemplaza = array();         foreach ($posts_array as $posts) {             $reemplaza[get_the_title($posts->ID)] = 'ID) . '" title="' . $posts->post_content .'">' . get_the_title($posts->ID) . '';         }              //create an array with array keys and add a regex for search terms that are before a dot, coma o white spaces         $patterns = array_keys($reemplaza);         $pattern_final = array();         foreach ($patterns as $pattern) {             $pattern_final[] = '/(?<=\s|^)' . $pattern . '(?=\s|\.|\,|$)/i';         }              //replace in the post content words that are a glossary term by a link to glossary         $cadena = preg_replace($pattern_final, $reemplaza, $cadena, 1);         return $cadena;     }          //do reemplazar function when post content display     add_filter('the_content', 'reemplazar');


One Click demo content installation feature in WordPress theme options panel

I've been seeing a feature of one click demo content installation option on some powerful WordPress themes now a days. Mostly on Themeforest themes. I'd like to know if anyone have any idea about the best way to implement this. Or any other resources to do this. Some hints, idea or keyword would be suffice. I'm not asking you to write me the codes or something. I'm wondering if you know the right way to do this. Thanks in advance.


How to get the custom header image's alt text?

I'm using a custom header in my theme. My aim is to add an `alt` attribute to my custom header `img` element. My `img` element so far looks like this:               <img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />      How can I get the alt text of the custom header image?


Add id to menu items in wp_nav_menu

I'm using wp_nav_menu in Wordpress to create my navigation The output is similar to this(I have removed href links)

Home

About

Services

Work

Contact

                        I need to style each link separately. How can I add an id to each (li) or (a) in the menu so I can style it.


How to create shortcode to show the 2 latest posts

I would like to create a shortcode that displays the last 3 posts to any page.... It should be laid out like this > Title > > Excerpt...Read more I've added this code in function.php               function my_recent_post()      {       global $post;            $html = "";            $my_query = new WP_Query( array(            'post_type' => 'post',            'posts_per_page' => 2       ));            if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();                 $html .= "
" . get_the_title() . "
";            $html .= "
" . get_the_excerpt() . "
";            $html .= "Read more";            endwhile; endif;            return $html;      }      add_shortcode( 'recent', 'my_recent_post' );      and it works, except now my homepage shows the 2 posts as desired in a division, but the problem is below the content, ie, below the division with the shortcode, it shows the entire 2nd article (see image). Any suggestions? ![the problem](http://i.stack.imgur.com/NkxlG.jpg)


How do write this type shortcode?

How do I write this shortcode or any alternative?               echo do_shortcode ('[gviewer file="$att_url"]');      Any suggestions someone?