Custom menus not showing

As a follow on from my last unresolved query regarding menus, the problem has extended even further. My menus are not printing anywhere in the code. I am registering the menu functions.php:               add_action( 'after_setup_theme', 'your_newtheme_setup' );          if ( ! function_exists( 'your_newtheme_setup' ) ) :              function your_newtheme_setup() {                  if (function_exists('register_nav_menu')) {                 register_nav_menus(                     array(                         'main-menu' => 'Main Menu',                         'footer-menu' => 'Footer Menu',                         'products-menu' => 'Products Menu',                         'legal-menu' => 'Legal Menu'                 ));             }         }          endif;      I then call the menu in header.php:               wp_nav_menu( array( 'theme_location' => 'main-menu' ) );       This results in nothing being printed! I am also trying to include the menu in the sidebar_footer.php where I have created a widget using the 'Custom Menu' widget and I've created 3 custom menus: footer-menu, products-menu & legal-menu and again, none of the menus are being printed! The widget at least prints the heading of the widget but the menu itself produces nothing! This is clearly an issue with all menus in my theme that I cannot seem to resolve! IMPORTANT NOTE: I have built the main-menu manually using the following code which I found in the wordpress docs:                           $menu_name = 'main-menu';                      if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {                          $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );                          $menu_items = wp_get_nav_menu_items($menu->term_id);                          $menu_list = '
';                          foreach ( (array) $menu_items as $key => $menu_item ) {                         $title = $menu_item->title;                         $url = $menu_item->url;                         $menu_list .= '
' . $title . '
';                     }                     $menu_list .= '
';                 } else {                     $menu_list = '

No Menu

';                 }                 echo $menu_list;             ?>      ADDITIONAL INFO: I've done some debugging in the function wp_nav_menu() and found that the menu items disappear during this call:               $items = apply_filters( 'wp_nav_menu_items', $items, $args );      in line: 223 (or thereabouts) in the file: nav-menu-template.php


Second Custom Post Type Archive

I've got an `event` custom post type, and using filters, I've configured the archive page to show only event in the future, and in chronological order based on a meta value (start date). I want to make a second archive page to show events in the past, complete with pagination, ordered reverse chronologically on the same meta value. My first thought is to use a shortcode inside a normal page, but I'm not sure how to get the pagination working. Alternatively, is there a way to create a "generic" archive page? Do I need to get into rewrite rules?


Wordpress/Buddypress login theme function

Hey i installed buddypress and wanted to know if there is a theme function o can add so that on my theme it says > Login • Sign Up and when they login it says > My Profile • Sign Out


is there a way to show the the post title after the image?

Trying to show the post title after the image in the main blog page and single page, I have tried to edit the content.php but unable to achive the result I need, which is basiscally               IMAGE     TITLE     META      CONTENT      I have tried to change the code in content.php but only managed to get the title to show below the image but also below the content               <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>         <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
             <?php _e( 'Featured post', 'twentytwelve' ); ?>
         <?php endif; ?>                           <?php the_post_thumbnail(); ?>             <?php if ( is_single() ) : ?>
<?php the_title(); ?>
             <?php else : ?>
                 <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>
             <?php endif; // is_single() ?>             <?php if ( comments_open() ) : ?>
                     <?php comments_popup_link( '' . __( 'Leave a reply', 'twentytwelve' ) . '', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
             <?php endif; // comments_open() ?>                                         <?php twentytwelve_entry_meta(); ?>             <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '', '' ); ?>             <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>

                         <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>

<?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?>

<?php the_author_meta( 'description' ); ?>

                             <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">                                 <?php printf( __( 'View all posts by %s →', 'twentytwelve' ), get_the_author() ); ?>

             <?php endif; ?>


Altering images inserted into Posts for lazyloading with PHP Simple HTML DOM Parser

I want to find a robust solution to make lazyloading possible for images inserted into a post. There are many lazyload solutions out there. I'm not looking to cater any one of them specifically, but rather just a method to edit the dom with PHP without regex. The Simple HTML DOM Parser seems perfect for that, I'm just not sure what I'm doing here. I can find all images and edit the attributes to suit a lazyload script:               // Add the PHP Dom parser     require "assets/simple_html_dom.php";          function add_image_placeholders( $content ) {              $html = str_get_html($content);              // Find all images         foreach($html->find('img') as $element) {                  $img_src     = $element->src;             $placeholder = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';             $img_class   = $element->class . " lazy";             $img_width   = $element->width;             $img_height  = $element->height;             $img_id      = $element->id;             $img_alt     = $element->alt;             $img_title   = $element->title;                  echo '
';         }              return $html;          }          add_filter( 'the_content', 'add_image_placeholders', 99 );      That of course just clumps them in the beginning of the post. I would need to loop the whole content somehow... Here's little bit about how to customise the parsing behavious, but I could't get it work. Thanks.


WP Query get posts by specific author IDs if one of several logged in authors

I have a custom template page where posts are shown from authors 1,2 and 3.               <?php $the_query = new WP_Query( 'posts_per_page=-5&author=1,2,3' ); ?>      How can I use **get current user** in this so that the posts are only visible to an author with one of those ID's (1,2 or 3) and are logged in? In other words: Author 4 will not see any posts. Authors 1,2,3 will see each others posts if they are currently logged in. Thanks very much in advance-


Display post details by post ID

I need to display post details by ID on front page template (`front- page.php`). On the front page I want to display the post’s title, excerpt & featured image. I have tried to do that but no idea on how I should be doing that. Is there any function in WordPress that can be used to do it?


qTranslate 2.5.28 and WordPress 3.3.1 issues

Anybody knows how to solve the issues in qTranslate 2.5.28 with WordPress 3.3.1?   * http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3045   * http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=2841   * http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3004   * http://wordpress.org/support/topic/plugin-qtranslate-formatting-missing-in-editor   * http://wordpress.org/support/topic/qtranslate-breaks-the-way-wordpress-handles-paragraphs   * http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3016 Any help is greatly appreciated.


How to get permalink and title from post ID?

I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if condition, which means I somehow have to replace $id with the permalink and title. At the moment the code merely lists the post ID numbers.               <?php       if(count($related)){         echo "
Read More
";         foreach($related as $id){            echo "
$id
";         }         echo "

";       }     ?>


Beginner Resources for Roots Theme Framework

I'm building a WordPress theme, using Roots as a starter theme. Are there any tutorials telling me how to build a theme off of Roots? I've worked with starter themes before, but this one is a whole new monster. I don't know what I'm supposed to edit, and what I'm not supposed to edit.


Adavnced custom fields relationship query plus query inside

I am currently developing a site, I have three custom post types (speakers, events, videos). Each event has a relationship with speakers so when a event is created they select what speakers spoke at that event. my event page works fine and I can call the speakers fine. The problem I am having in my videos custom post type when creating a video the user has 2 relationships which they select which event it was recorded at and what speaker it is for. So on my events page under each speaker. I want it to get their video for that event. i have tried using meta query's but I cannot get it to work. I have posted on ACF forum with no reply. Any help would really be appreciated I have tried everything I can think of. http://support.advancedcustomfields.com/forums/topic/nesting-relationship- querys/ Above is the post on advanced custom field support forum. Here is a paste bin of my events.php http://pastebin.com/LB8bdyKj Here is the section of code ,               <?php     $posts = get_field('speakers');     if( $posts ) :     foreach( $posts as $post) :       setup_postdata($post);     ?>

         <img src="<?php the_field('speakers_image'); ?>" />

<?php the_title();?>
       <?php       $videos = get_posts( array(         'post_type' => 'videos',         'meta_query' => array(           'relation' => 'AND',           array(            'key' => 'speaker',            'value' => get_the_ID()           ),           array(            'key' => 'events',            'value' => $eventid           )         )       ) );       $videoquerys = new WP_Query($videos);       ?>       View Profile

      Above is what i have tried the information between event and speaker i can get fine its querying the speaker and event and getting the video that matches i am having trouble with.


Dynamically determine URI to scripts and styles included with a class which could be added from plugin/theme/child theme/mu plugin

I'm working on a settings API class which I'd like to be able to drop into a plugin, wpmu plugin, theme, or child theme directory, and have it just work. My issue is that I'm having trouble figuring out how to determine the URIs for including scripts and styles on the fly. I'd like this to work no matter how the site's WP install is set up, so it should work where ever the wp-content, plugins, mu-plugins, and themes directories are located. I found this post which involves something similar, but it's not quite the same, since it's dealing with paths and not URIs. Also, (frankly), I'm finding it a little challenging to wrap my head around, and I'd like to avoid going down that rabbit hole if my carrot isn't going to be there. Any advice on how to approach this?


Wordpress Ajax Data problem

I couldn't add selected data to a div using ajax. Here is my code:               <?php     function master_ajaxurl() {             $myOpt = $_POST['option'];             bringDetails($myOpt);      }                               function bringDetails($opt)     {             global $wpdb;             $sql ="SELECT * from mst_urun_liste WHERE kod like '$opt'";             $rows = $wpdb->get_row($sql );             return $rows;     }     add_action('wp_ajax_master_ajaxurl', 'master_ajaxurl');     add_action('wp_ajax_nopriv_master_ajaxurl', 'master_ajaxurl');     ?>     <script>     $(document).ready(function () {             var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';         $('#combobox').change(function(){             $.ajax({                             url:ajaxurl,                 action:'master_ajaxurl',                 type: "post",                 data: {option: $(this).find("option:selected").val()},                 success: function(data){                     //adds the echoed response to our container                          $("#details").html(data);                 }             });         });     });          </script>      I have a selectbox, and want to change values related to selected element, but ajax populates my div with whole html code of site. And here is a test page I prepared. I want to populate values from database (Kod, Parça No, Parça Adı, Fiyat, Adet, Tutar) of selected values I realized that, If i don't set url:ajaxurl, it returns the whole page, if i use it returns 0


Do Not Display Parent Page if No Subpages

This is the code from the codex most commonly used for sidebar menus. It displays the child pages of the top level ancestor and the ancestor itself. There is one thing about this code I would like to change - I don't want the top level ancestor displayed if it has no children! It doesn't make much sense to have a one link menu which points to itself. How can I edit this code to achieve this? I've previously asked a similar question, but was never given the correct answer. All the answers given also listed children of the parent's child (the second level child page). In functions.php               // Sub-pages menu     if(!function_exists('get_post_top_ancestor_id')){     /**      * Gets the id of the topmost ancestor of the current page. Returns the current      * page's id if there is no parent.      *       * @uses object $post      * @return int       */     function get_post_top_ancestor_id(){         global $post;              if($post->post_parent){             $ancestors = array_reverse(get_post_ancestors($post->ID));             return $ancestors[0];         }              return $post->ID;     }}      Calling it:               <ul class="subpages">         <?php wp_list_pages( array('title_li'=>'','include'=>get_post_top_ancestor_id()) ); ?>         <?php wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>get_post_top_ancestor_id()) ); ?>     </ul>      This code checks if a page has children, I'm curious if this could be merged with the codes above to create the correct code:               $children = get_pages('child_of='.$post->ID);?>     if( count( $children ) != 0 ) { show list as normal }     else { show "no parent" text }


Error updating WordPress, does not ask for FTP password, just error

I started to update a WordPress blog and ran into a permissions problem. I fixed the permissions problem and started the update again and at some point (been a few days now), I received the following error. I tried again this morning and updating plugins or the program itself yields the same error. Update WordPress Downloading update from http://wordpress.org/wordpress-3.7.1-new-bundled.zip… Download failed.: Destination directory for file streaming does not exist or is not writable. Installation Failed I have a couple of blogs on the same web hosting account and neither of the other ones have issues, just this blog.


Add custom css to menu while using custom nav_menu_tag

I created a custom menu to replace my li with td markers. However, I need to be able to add some custom tags through the wordpress menu. How do I do so? Is there something I can add to my mytag_nav_menu section to allow me to add custom csstags from the wordpress menu? My functions code located inside functions.php:               function mytag_nav_menu($args = '', $mytag = 'td') {             $defaults = array(                 'echo' => 1             );                  $r = wp_parse_args($args, $defaults);             $args = $args.'&echo=0';             $oldtags = Array('<li','
');             $newtags = Array('<'.$mytag.' class="center"','</'.$mytag.'>');             $mynav = str_replace($oldtags, $newtags, wp_nav_menu($args));             $output= preg_replace('/<a/', '<a class="nav"', $mynav, 12);             if ( $r['echo'] )                 echo $output;             else                 return $output;         }      My function call in the header located in header.php:               <?php mytag_nav_menu(array('theme_location' => 'header-menu',     'items_wrap' => '
%3$2
',     'fallback_cb'=>'wp_page_menu'));?>      Explanation of what I want to do:   1. Go into Wordpress admin   2. Go to Appearance/Menus   3. Click on a menu item, click on the drop down arrow   4. Add to CSSClasses (Optional)   5. Save the menu 6 Have the classes show up Result should be:                    News     	      Can anyone explain to me what I can add to my mytag_nav_menu to let those custom classes show up but still edit the tags as below? If this is not clear, please let me know.


Function to execute when a post is moved to trash .

Hi is there an action which can be performed while a post is moved to trash .... I tried delete_post and deleted_post. It works but twice for each action ( before and after the action as written in codex ) and the output is shown only when the post is deleted from trash. Example i want to send an email to the author stating that his post has been moved to trash because of some reason, and update some user_meta. if i use               add_action('deleted_post', 'emailUser');      or               add_action('delete_post', 'emailUser');      it works only when the post is deleted from trash . . . **Update :** got it to work for trash posts using               add_action('trash_post', 'emailUser');      but the problem for double execution of function is still there. . .


Add data-icon input to Wordpress custom menu links

I need to add a `data-icon=""` input to my Wordpress Custom Menu input box thing. This is so I can use an icon font and type the code in for a specific icon and in the CSS use pseudo elements to match it up and display the icon. I've found loads of tutorials which show how to extend the `Walker_Nav_Menu` class so I can add an attribute, but none of them extend this into adding a new input box on the Wordpress Custom Menu screen (http://cl.ly/Sn0C) and then having the value of this displayed in the HTML. I've used this code to add a data-icon input box on the Custom Menu admin screen (http://cl.ly/SmqM) but I'm not good enough at PHP to link it up to the `Walker_Nav_Menu` extension class to show the data-icon value in the HTML. Can anyone help me out? Thanks :) I would prefer if this could be done in functions.php and/or without the use of a plugin. Thanks! Btw, here is my `Walker_Nav_Menu` extension class code:               class data_type_walker extends Walker_Nav_Menu {           function start_el(&$output, $item, $depth, $args) {                global $wp_query;                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                     $class_names = $value = '';                     $classes = empty( $item->classes ) ? array() : (array) $item->classes;                     $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );                $class_names = ' class="'. esc_attr( $class_names ) . '"';                     $output .= $indent . '
ID . '"' . $value . $class_names .'>';                     $attributes  = ! empty( $item->attr_title ) ? ' title="'     . esc_attr( $item->attr_title       ) .'"' : '';                $attributes .= ! empty( $item->target )     ? ' target="'    . esc_attr( $item->target           ) .'"' : '';                $attributes .= ! empty( $item->xfn )        ? ' rel="'       . esc_attr( $item->xfn              ) .'"' : '';                $attributes .= ! empty( $item->url )        ? ' href="'      . esc_attr( $item->url              ) .'"' : '';                $attributes .= ! empty( $item->data_icon )  ? ' data-icon="' . esc_attr( $item->data_icon        ) .'"' : '';                     $prepend = '';                $append = '';                     if($depth != 0) {                      $description = $append = $prepend = "";                }                      $item_output = $args->before;                 $item_output .= '';                 $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;                 $item_output .= $description.$args->link_after;                 $item_output .= '';                 $item_output .= $args->after;                      $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );             }     }      EDIT: Chittaranjan asked me for some more info so here goes: I'm calling this new extension (`data_type_walker`) on the class `Walker_Nav_Menu` in my header.php file where my nav menu is located. Calling it as follows:               <?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false, 'menu_class'=> 'nav-menu', 'walker' => new data_type_walker() ) ); ?>      The output should be something like this:
navigation text link


way to make all pages with certain tags public?

I want a way to make all pages with certain tags public. I don't care if a solution is programatic or via GUI (though I prefer programatic), I just want to be able to make all pages with a certain tag public with just one "click-of-the-button" so to speak. EDIT: Oops. I thought pages could have tags just like posts. My intention is to make a bunch of static pages, show them to someone to approve them, and if they approve of the pages, then make them public all at once for the world to see. Is there a way to do this?


wp_option table error while importing

I am importing a huge database manually and i have a problem.The error it very vague to me, as i am not much familiar with mysql.The error says the following ![enter image description here](http://i.stack.imgur.com/RD1Xt.png) Its such data that i am unable to comprehend,where to find the error.It cannot be option_id, as its auto_increment. what is the problem? when it says 'Duplicate entry 1 for key primary'?


Wp_Mail and Contact Form 7

I have a problem. I've used               add_filter('wp_mail_from', 'new_mail_from');     add_filter('wp_mail_from_name', 'new_mail_from_name');          function new_mail_from($old) {      return 'contact@mysite.hk';     }          function new_mail_from_name($old) {       return 'MySite.com';     }      To overwrite default From email WordPress (wordpress@mysite.com) And this is Ok, But Contact Form 7 Form was overwritten by the same function too. I want CF7 to send `[your-name] [your-surname] <[your-email]>` to email. Not MySite.com (contact@mysite.hk) Is there a way to get rid of this bug?


wordpress not able to open theme-editor.php

I am having a site radhanath-swami.info. I logged as admin using "radhanath- swami.info/wp-admin". then i tried "radhanath-swami.info/wp-admin/theme-editor.php"                 You do not have sufficient permissions to access this page.      I dont know what to do. I googled a lot but not much help. I dont have access to the server not the ftp. Whatever i can do is only from admin dashboard. I was using theme esplanade, due to some reasons i have changed to another theme. THen i have deleted the esplande theme. Later I have decided to use esplanade, so installed it again and activated it. From then the theme-editor.php is not working. Before this theme-editor.php was working. I also checked with changing to other theme. It also now shows the same permission thing when i open theme-editor.php I have also tried removing all the plugins still same message. I feel there are some bugs in the wordpress


wpalchemy insert bottom missing in media uploader with custom post type

I have used wpalchemy class with custom post type, and added a meta box for file upload. But i found that Insert button is missing in media uploader popup window. Same code is working fine when used on posts or pages. I tried to copy and paste code directly from following page to make sure i am not making any mistake in my code. http://www.farinspace.com/wordpress-media- uploader-integration/ I found that this issue is only with custom post types, working fine with default posts and pages.


How to filter posts that belong to a specific category only if that is the only category

I need to filter posts that belong to a category only if that is the only category. For example if my post A belongs to cat1 and I don't want to display posts that belong to cat1, post A won't be displayed. But if post A belongs to cat1 and cat2 it will be displayed as I don't want to filter cat2. I tried to do something like this:               <?php while (have_posts()) : the_post(); ?>          $category_to_exclude = 11;     while ( have_posts() ) : the_post();     $categories = get_the_category();     if( in_array($category_to_exclude, $categories) && count($categories) > 1 ) {         the_title();         the_content();     }     endwhile;      but of course it doesn't work properly as "cut off" posts only. It should filtered directly from the query used to get the posts but I don't know how to write this query. Any idea?


How Can I Center the Logo in the Navigation Menu?

I'd like to center the logo in the navigation menu. I understand how to do it if it were not PHP based. Does anyone have any insight on this? You can view the test site here Any help is greatly appreciated.


Show Meta Box On Specific Page Template

Is there a way to show custom page settings on specific page templates ONLY? For instance I have a settings field: "Custom Settings". I don't want this to show on the "Default Page Template". I only want it to display if we select the "Custom Page Settings Page Template". Here's my meta box code:               function cd_meta_box_add()       {       add_meta_box( 'icon-class-meta-box', 'Icon Class', 'ic_meta_box_cb', 'page', 'side', 'default' );       }       add_action( 'add_meta_boxes', 'cd_meta_box_add' );           function ic_meta_box_cb( $post)       {       $values = get_post_meta( $post->ID );        $selected = isset( $values['ic_meta_box_select'] ) ? esc_attr( $values['ic_meta_box_select'][0] ) : ”;            wp_nonce_field( 'ic_meta_box_nonce', 'meta_box_nonce' );      ?>       <p>           <label for="ic_meta_box_select">Class</label>           <select name="ic_meta_box_select" id="ic_meta_box_select">             <option value=" " <?php selected( $selected, ' ' ); ?>> </option>              <option value="red" <?php selected( $selected, 'red' ); ?>>red</option>               <option value="blue" <?php selected( $selected, 'blue' ); ?>>blue</option>             <option value="green" <?php selected( $selected, 'green' ); ?>>green</option>             <option value="pink" <?php selected( $selected, 'pink' ); ?>>pink</option>             <option value="orange" <?php selected( $selected, 'orange' ); ?>>orange</option>             <option value="black" <?php selected( $selected, 'black' ); ?>>black</option>         </select>       </p>     <?php         }


WP_Query For Custom Author and Single CPT Search?

I have created a search page where users can search the site with these options: (1) Keyword   (2) Keyword in/from 12 different Custom Post Types (CPT's)   (3) Keyword in/by a single Author's posts across all CPT's   (4) Keyword in/across all Categories   But I need one more search option that I am missing, and which is very important to me: (5) Author + CPT, where a user can select any Author and any single CPT from among the 12. For example, if Jane is an Author and she has CPT posts in Audio, Video, or Blogs, etc., I need a user to be able to search for all Jane's Video, where the search results only display the CPT Video and no other, by Jane. I have seen other similar, but ultimately different questions, about how to display all CPT's by an Author. But I already have this. Now I need to add the narrower option of searching for one Author and one CPT. My research leads me to believe that I would have to write a custom WP_Query to alter my search parameters. Is this correct? If so, does anyone have tips for how to do so? I have not written one before, I have read the Codex on it, but this is pushing me into new territory and is a bit over my head -- if I am even on the right track. Thank you.


Can I use the same Folder name as a Multisite Blog?

I have a Wordpress Network site 3.8+ where one of my sites is domain.com/media/. On the root of domain.com, I am wanting to create a folder named "media" to store all uploads. Currently I have this folder as set up as above "media" with the site domain.com/media/ and nothing significant has happened. However it might clash when I start adding content. Does anyone know if I can have the same foldername as a site name?


custom page url slug needs illegal ?id=1 for javascript

I have created portfolio page which contains a image-slid-menu for navigation. For an menu item to appear as open, javascript gets instruction like ?id=0 appended to the url. for instance portfolio/art.php?id=0. However wordpress does not allow url slug containing ? or = for pages. What should I do now? I already setup the slider with these pages working: www.gransar.net/portfolio/ www.gransar.net/portfolio/design did I complete screw up thinking this could be easily implemented? I'm using the following: http://www.ajaxblender.com/demos/menu/imagemenu/


How to change option recently_edited?

WP recently_edited option can be very useful - it tracks last 5 files that you've made changes to. Only problem is - well, that's all, 5 files. What if I've been made numerous changes to Wordpress theme files by using default WP admin editor? It would be helpfull if I had list of, say last 20 files edited and time when that happened. **Do anyone know where is stored function or some else mechanism that allow only 5 item to reside into array of recently_edited WP option?** I've tried with wp-admin/includes/schema.php and wp-includes/option.php where it, as I tohught, should be - no results.


How to create a page template using custom plugin

I am building a plugin. I just want to create page template whenever i install plugin. Page template like full-width template. I have used codes after searching but not able to get success. So please help me. Thanks in advance


add after content don't work

I am using this code to put some functions after content, but this one don't work. It appear before the content and not after.               function add_wb_posts_pagination ($content) {             $content .= wb_posts_pagination();             return $content;          }     add_filter('the_content',  'add_wb_posts_pagination' );      is the same code i use to add others functions, but this don't work... what can be the problem?


Adding Category/Tag/Taxonomy Support to Images/Media

I've been trying to add category, tag, or custom taxonomy support to images (or all media, though I'm only concerned with Images). I've got it part-way figured out with:               add_action('init', 'create_image_taxonomies');          function create_image_taxonomies() {     $labels = array(         'name' => 'Media Category'     );          $args = array(         'labels' => $labels,         'public' => true     );          register_taxonomy('imagetype', 'attachment', $args);     }      This properly adds a Media Category field to the media screen. I've also confirmed this can be accessed with `get_the_terms($my_attachment_id, 'imagetype')`. Where I'm running into trouble is getting this information to show anywhere in the admin/dashboard except when viewing the media directly -- I want it either in a sub-menu or as a custom column, or both, as can be done for Posts and Pages. I've tried using `manage_posts_custom_column` along with `manage_edit- attachment_columns`, but nothing at all is showing up. I've tried to use `add_media_page` to display something like the page automatically generated for Page and Post categories, but here I'm having trouble pulling the images to which I've given categories. You can see both attempts here: http://pastebin.com/S8KYTKRM Thanks in advance for any assistance!


Why write markup for index.php?

As I understand, index.php (a required template) is used when a more specific template is unavailable---according to the template hierarchy. My question is, if I create all the specific templates that my theme uses (e.g., home.php, single.php, page.php, search.php, archive.php, 404.php, etc...), then why bother writing any markup in index.php at all? I might as well just leave it blank? Is there a reason to fill out index.php?


Website page structure

How can a get my website link structure like this: mywebsite.com/products/vegetables/carrot Where vegetables is the taxonomy term and carrot is the post slug from the custom post type products. mywebsite.com/products/vegetables - is the taxonomy page, where all products that has this taxonomy will be shown. Is it possible to structure the link like this ? Thanks in advance


Custom post type pagination, single page issue

After having problems getting pagination working at all for custom post types, I've read that the custom post type name and the page name cannot be the same. So I set out from scratch: I've created a custom post type of 'news-articles' (original I called it 'news' but got 404s on pagination) using the Custom Post Type UI plugin. Next I created a template called `template-news.php` with the following content:               <?php     /**      * Template Name: News      *      * Print posts of a Custom Post Type.      */          get_header();      get_template_part( 'include/content', 'head' );          $type = 'news-articles';          if ( get_query_var('paged') ) {        $paged = get_query_var('paged');     } else if ( get_query_var('page') ) {        $paged = get_query_var('page');     } else {        $paged = 1;     }          $args=array(        'post_type' => $type,        'post_status' => 'publish',        'paged' => $paged,        'posts_per_page' => 1,        'caller_get_posts'=> 1     );          $temp = $wp_query;  // assign original query to temp variable for later use     $wp_query = null;     $wp_query = new WP_Query();     $wp_query->query($args);     ?>          <div class="postcontent nobottommargin<?php if( semi_option( 'blog_sidebar' ) == 'left' ) { echo ' col_last'; } ?> clearfix">          <?php             if ( $wp_query->have_posts() ) :             ?>
             <?php                 while ( $wp_query->have_posts() ) : $wp_query->the_post();                 ?>                                      <div id="post-<?php $wp_query->ID; ?>" <?php post_class('entry clearfix'); ?>>                                     <?php                                     get_template_part( 'include/blog/news/post', 'standard' );                                     ?>
                 <?php                                 endwhile;                 get_template_part( 'include/blog/navigation' );                 ?>
<?php             else :                 get_template_part( 'include/blog/error' );             endif;             $wp_query = $temp;             ?>
     <?php if( semi_option( 'blog_sidebar' ) == 'left' ) { get_sidebar( 'left' ); } else { echo get_sidebar('news'); } ?>     <?php get_template_part( 'include/content', 'foot' ); ?>        <?php get_footer(); ?>      Next I created a page called 'News' and assigned the template as 'News'. At this point, if I view the news page, everything looks good. I get pagination and it works. However post title links are `/news-article/post- title` instead of `/news/post-title`. If I try going to `/news/post-title` it just redirects to `/news-article/post- title`. I tried setting 'Rewrite' to 'True' and 'Custom Rewrite Slug' to 'news' in CPT UI. At first glance this appears to have cured it, but it breaks pagination - I get a 404 on page 2. I've tried refreshing the permalinks but still get the 404.


Different functions file for each site in multisite installation?

I'm trying to create two (for now) sites in multisite WP installation that use same theme, but require somewhat different functionality i.e homepage has a bit different layout and there will be some CSS changes. Is there a way that I could use to override functions.php and other theme files for each site?


Remove Title, Editor and Meta Box Support Based on Post Formats

Been looking around and can't find this. Is it possible to remove, let's say, the title area on post format: "quote"? Or the editor on post format: "image"? I noticed this page in the Codex: http://codex.wordpress.org/Function_Reference/remove_meta_box Seems you could pull it off if you created a custom post type for images, for example, then removed support for that type, but that defeats the purpose of formats and also would break new themes, which I don't want to do.


Can NOT search my custom post type?

I have added a new custom post type named: **website_bookmarks** I plan on using it as my bookmarks manager (going to export all my bookmarks from Google Chrome into my custom post type) for the following reasons   * Can search bookmarks easily   * Can add tags (php, web design, etc...)   * Can add descriptions to explain the bookmark better   * Can view and sort however I choose   * Can access from anywhere online   * Can share my bookmarks with my readers ( will have option to mark a bookmark as Private or Public so I can be the only one to view the Private ones)   * Sure there are other reasons to make this a good idea Now my only problem so far is the search part. I cannot get my wordpress (latest release) to search the **website_bookmarks** post type for anything. I have modified my search form with a hidden field               <input type="hidden" name="post_type" value="website_bookmarks" />       So on my search page in the URI I will see...               www.mydomain.com/?s=mysearchterm&post_type=website_bookmarks      The problem is it **ONLY** shows search results for my regular blog post and no results from my custom post type. If I remove the `s=mysearchterm` from the URI so it is now               www.mydomain.com/?post_type=website_bookmarks      then it will show ALL the post from my custom post type. This shows that the **website_bookmarks** is the proper name for my post type, just the search part is not working correctly. It will retunr search results from regular post with no problem, just none from my website_bookmarks post type It should not be showing any results for my blog post and ONLY results for my custom post type **website_bookmarks** Can someone help me? I can not figure out why it will not work, the code I show above for modifying the search form, I found online from others saying that it worked for there blogs simply by changing the search form to what I did above. Below is my whole search.php file as well               <?php get_header(); ?>     <?php if (have_posts()) : ?>
<?php printf( __("Search results for %s", "vigilance"), get_search_query()); ?>
         <img class="archive-comment"src="<?php echo get_template_directory_uri(); ?>/images/comments-bubble-archive.gif" width="17" height="14" alt="Comments"/>

             <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php esc_attr( sprintf( __( 'Permanent Link to %s', 'vigilance' ), the_title_attribute( 'echo=false' ) ) ); ?>"><?php comments_number( '0', '1', '%', '' ); ?><?php the_time( __( 'M.j.y', 'vigilance' )); ?><?php the_title(); ?>
             <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>

<?php next_posts_link( __( '« Older Entries', 'vigilance' )); ?>

<?php previous_posts_link( __( 'Newer Entries »', 'vigilance' )); ?>

     <?php else : ?>
<?php printf( __("Search results for '%s'", "vigilance"), get_search_query()); ?>

<?php printf( __( 'Sorry your search for "%s" did not turn up any results. Please try again.', 'vigilance' ), get_search_query());?>
             <?php get_search_form(); ?>
     <?php endif; ?>
     <?php get_sidebar(); ?>     <?php get_footer(); ?>      I have even tried using this code below in my functions.php file with no luck...               function mySearchFilter($query) {         $post_type = $_GET['post_type'];         if (!$post_type) {             $post_type = 'any';         }         if ($query->is_search) {             $query->set('post_type', $post_type);         };         return $query;     };     add_filter('pre_get_posts','mySearchFilter');      Below is my code used to create the website_bookmarks post type, you can see that I have enabled query_var and publicly_queryable and have set exclude_from_search to true and false to test it both ways, with no luck               $bookmark_args = array(             'labels' => $bookmark_labels,             'public' => true,             'publicly_queryable' => true,             'exclude_from_search' => true,             'show_ui' => true,             'show_in_menu' => true,             'query_var' => true,             'rewrite' => array(                 'slug' => 'bookmark',                 'with_front' => false),             'taxonomies' => array('bookmark_tags'),             'capability_type' => 'post',             'has_archive' => true,             'hierarchical' => false,             'menu_position' => 4,             'can_export' => true,             'supports' => array(                 'thumbnail', //website thumbnail                 'excerpt', //website description                 'title', //website title                 'custom-fields',                 'comments'             )         );            register_post_type('website_bookmarks', $bookmark_args);


wp_insert_post another database with custom field

wp_insert_post with the command you want to transfer the contents to another database, I use the following command               <?php          require('wp-config.php');     $conn = mysql_connect($dbHost, $dbUser, $dbPass);     mysql_select_db($dbName, $conn);     mysql_query('set names utf8');     mysql_query("SET character_set_connection = 'UTF8'");     mysql_query("SET character_set_client = 'UTF8'");     mysql_query("SET character_set_results = 'UTF8'");     $results = mysql_query("SELECT * FROM idx_link LIMIT 0,100", $conn);          function permayap($deger) {              $turkce = array("ş", "Ş", "ı", "(", ")", "'", "ü", "Ü", "ö", "Ö", "ç", "Ç", " ", "/", "*", "?", "ş", "Ş", "ı", "ğ", "Ğ", "İ", "ö", "Ö", "Ç", "ç", "ü", "Ü");              $duzgun = array("s", "s", "i", "", "", "", "u", "u", "o", "o", "c", "c", "-", "-", "-", "", "s", "s", "i", "g", "g", "i", "o", "o", "c", "c", "u", "u");              $deger = str_replace($turkce, $duzgun, $deger);              $deger = preg_replace("@[^A-Za-z0-9-_]+@i", "", $deger);              return $deger;     }          $i = 0;     while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) {         $post = array();         $post['ID'] = $row['link_id'];         $post['post_name'] = permayap($row['title']);         $post['post_title'] = $row['title'];         $post['post_status'] = 'publish';         $post['post_type'] = 'post';         $post['post_author'] = '1';         $post['ping_status'] = 'open';         $post['post_excerpt'] = '';         $post['comment_status'] = 'open';         $post['post_category'] = array($row['category_id']);         $post['tags_input'] = $row['keywords'];         $post['tax_input'] = array("sehir" => $row['sehir']);         add_post_meta($post_id, 'telefon', '' . $row['telefon'] . '', true);         $posts[$i] = $post;         $i++;     }          mysql_free_result($results);     mysql_close($conn);          require('wp-load.php');          foreach ($posts as $post) {         wp_insert_post($post);     }     ?>      command is working correctly, but does not add to the wordpress database, can you help me with this thank you.


Change Permalinks Structure to a Sequential Number for Each Post?

I've just created a draft on my blog, and it's post ID is 1. After creating another draft, the post id for this last post is 3! I was hoping to see them in sequential order, so in the future I'll have a nice auto-incremented numbering like               ../archives/1       ../archives/2         some months later...               ../archives/154     ../archives/155      I have no problem diving into code, but I was wondering if someone happens to know a simple solution to achieve this. Thank you.


Exporting and Importing WordPress Media Libraries and Galleries

I'm trying to migrate a series of blogs from one place to another, both running 3.0.1, and I am unable to get media libraries and galleries to come across in the export/import process. Any ideas on how to do this? The gallery shortcode comes across in the post content, but it doesn't display anything because the actual gallery does not come across. Thanks, Dave


Start WP Pagination From Number 1 in URL

I am using this code to paginate gallery post type images:               $images = get_posts(array(     'post_type' => 'attachment',     'post_status' => 'inherit',     'post__in' => $image_ids,     'orderby' => 'post__in',     'posts_per_page' => 1     ));      then display them in the loop, it puts page links on the page like: 1.......15 Each link button has its corresponding link truly like this: domain.com/post1/ domain.com/post1/2 domain.com/post1/3 domain.com/post1/4 And what I need is to make the first one get the "1" in front of the link like: domain.com/post1/1 So how do I do it?


mod_rewrite enabled but Permalinks show index.php

I just installed a friends blog on my LAMP stack, which has mod_rewrite enabled (I'm using it for clean URLs on my Drupal installs on the same server). For some reason, WordPress (3.0.3) isn't recognizing that mod_rewrite is enabled. In the Permalinks menu it's displaying options for PATHINFO permalinks (with index.php preceding the url string). My fix for now was to just use the Custom Structure field and input what I wanted less the index.php part WordPress seems intent on inserting, which works but I'd like to get an actual fix for this in place. Is this a 3.0.3 anomaly? I haven't had much time to investigate my server configuration, but any guidance would be much appreciated.


Recommendations for a LaTeX Plugin?

I need mathematics on a WordPress site and I'm having trouble finding a suitable LaTeX plug-in. I've tried several solutions including MathJax (which is slow and renders inconsistently) and the WP QuickLaTeX plugin which works well but does not allow displayed equations (only inline equations) and stores all images on an external site. I'd like a plugin that allows inline and displayed equations, stores images locally and does not take an age to render the maths on a page. Does it exist?


Is there a simple way to manage capabilities per user?

I have a WordPress-Site where some people (non-expert clients) need to create/manage users. The site uses multiple custom post types and each user is assigned permissions for one or several of those cpt's. At the moment i see two ways to handle this and i'm not very happy with any of them. **(1) User roles** : If i have four custom post types (A,B,C,D) then i would need a lot of User Roles to cover all combinations of capabilities. (Role A, Role AB, Role ABD ...). That's not very convenient for the client to manage. **(2) Capability Management Plugin** : If it was me to manage the users i would use a plugin like "User Role Editor". But that is quite complicated to handle for my non-expert clients and the risk of messing up the system is high. What i think of is to have simple checkboxes (at least when creating a new user) where the client can choose the custom post types the new user should be able to access. Like: this user will be able to do everything with cpt A and B and D. Is there a way to do this and is this even something you should do with WordPress? * * * ## UPDATE @RyanLoremIpsum pointed me in the right direction so i was able to write a little plugin that is as simple as i need it to be. Looks something like that: ![choose the cpt's a user should be able to access](http://i.stack.imgur.com/c8OAL.png)


Relative Root Url For Sub domain name

I am really difficulties in using relative root url. I installed my wordpress site /root/mywordpress/tester1 folder and when I installed my wordpress sites with my subdomain like http://mywordpress.mydomain.com/tester1. It doesn't work and all images are broken. Here is my use in wp-config.php file                   define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'].'/tester1/');         define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'].'/tester1/');         define('WP_CONTENT_URL', 'tester1/wp-content');         define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] .'/tester1/');      Is there better solutions for using relative root url for installing wordpress in folder of subdomain


Get only one comment per post with get_comments

Is there a way to limit get_comments results to just the latest comment from every post?


Permalinks for quote authors

**What I have:** A site of quotes with format: "Quote text." -Quote Author   See quotup.com for my test website (my apologies in advance for the testing- profanity). **What I'm after:** Clicking "-Quote Author" should launch a page of all quotes by that quote author with URL: example.com/SteveStevenson, where Steve Stevenson is the Quote Author. **What I've done:** Created a custom table called wp_qauthor that is tied to wp_posts by post_meta (qauthor_id).   Added the following code to functions.php:               add_filter('query_vars', 'add_my_var');         function add_my_var($public_query_vars) {             $public_query_vars[] = 'qaid';             return $public_query_vars;         }      Created a link for the Quote Author's name as such:               Steve Stevenson      Clicking on this link currently loads home.php, but I need it to hit index.php, where I've added this code:               elseif (get_query_var('qaid')) {         $qaid = get_query_var('qaid');         query_posts($query_string . "&meta_key=qauthor_id&meta_value=" . $qaid);}      **The questions:**   * How do I tell WP to call index.php when I click the example.com?qaid=2 href?   * After clicking the link above, how do I get the desired pretty link of example.com/SteveStevenson?    Many Thanks!


Theme Editor Not Showing

I made a custom WordPress theme from scratch for a client, then zipped it up and sent it to them. They installed the theme fine, but for some reason the theme editor does not display. What I mean is there is no link to "Editor" under appearance anymore. Does anyone know why this would happen? We had all plugins disabled at one point and it still wasn't showing. I was able to get to the theme editor on my own test website.


Select min/max meta from query

Kind of lost on what to do here. I have a meta price for each post. I'd like to get the min and max price meta values of this search/query. At the moment its returning the min max values for all posts. Probably a stupid question but how do you query the query? or another solution along these lines.                   // get and display lowest price from search query ?          $query = "SELECT min(cast(meta_value as unsigned)) FROM wp_postmeta WHERE meta_key='_wp_price' AND meta_value IS NOT NULL AND meta_value <> 0";     $the_min = $wpdb->get_var($query);        echo 'Price range: '.ft_currency_conv(of_get_option('ft_currency')).''.$the_min.' to';             // get and display highest price from search query how?         $query = "SELECT max(cast(meta_value as unsigned)) FROM wp_postmeta WHERE meta_key='_wp_price'";     $the_max = $wpdb->get_var($query);        echo ''.ft_currency_conv(of_get_option('ft_currency')).''.$the_max.'';              // the final search query         $querystr = "                 SELECT DISTINCT $wpdb->posts.ID, $wpdb->posts.*                  FROM $wpdb->posts                 LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)                 LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)                 LEFT JOIN $wpdb->terms ON($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id)                  LEFT JOIN $wpdb->postmeta ON($wpdb->postmeta.post_id = $wpdb->posts.ID)                  WHERE $wpdb->posts.post_status = 'publish'                  AND $wpdb->posts.post_type = 'showroom'                  ORDER BY $wpdb->posts.post_title ASC                 ";          // get results from the search query     $searchresults = $wpdb->get_results($querystr, OBJECT);      Update: The posts are already sorted, I'm trying to pull the lowest and highest meta value (price) of the search results, so I can display the price range. So how do I pull a min/ max meta value out of a final search query and display it. Something along these lines.                  $query = "         SELECT DISTINCT {$wpdb->posts}.ID,          {$wpdb->posts}.*,         (SELECT min(cast(meta_value as unsigned))                FROM {$wpdb->postmeta}                WHERE meta_key='_wp_price'                AND meta_value IS NOT NULL                AND meta_value <> 0               AND {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID         ) as min_price,         FROM {$wpdb->posts}         LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)         LEFT JOIN {$wpdb->term_taxonomy} ON({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id)         LEFT JOIN {$wpdb->terms} ON ({$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id)          LEFT JOIN {$wpdb->postmeta} ON ({$wpdb->postmeta}.post_id = {$wpdb->posts}.ID)          WHERE {$wpdb->posts}.post_status = 'publish'          AND {$wpdb->posts}.post_type = 'showroom'";              $the_min = $wpdb->get_var($query); // get the min price of search          echo 'Price range: '.ft_currency_conv(of_get_option('ft_currency')).''.$the_min.' to'; // display the min price of search above post results.


Create separate template for shared custom taxonomy with shared terms

![enter image description here](http://i.stack.imgur.com/KEJuR.jpg)I have created custom taxonomy called "product_category", it has been shared with post type "books" and "movies" . So I need to create a different template for both post types. Both the templates' design will be different, so its important that both the post_type shared taxonomy (even their terms will be shared in both the post_type.) should have different template . Path should be like :- > site/books/product_category/horror/ > > site/movies/product_category/horror/


Create /archive page in Wordpress Theme

I'm trying to create a Wordpress theme, and I'm having a little difficulty with creating an easily accessible archives page. First off, I'm not referring just to the standard archive.php in the template hierarchy. What I'm trying to do is make a separate page on the site that lists _all_ posts (not sorted by tag/category/year) in a single, easily- accessible portion of the site by just going to /archive (e.g. www.example.com/archive) I've read up on the Wordpress Codex that you can create a wordpress page using templates from PHP files, but I would really rather not go that route. If I could, I'd rather make a theme that already has the feature built in without the user having to manually do the work to create the page. Also, for some reason I never had a "template" dropdown section appear; go figure. Does anyone have any ideas or suggestions for how to implement? Searching for an answer has been hard because most questions are about the template hierarchy or just using the page method. I'm thinking that I should be looking into the add_rewrite_rule() function and rewriting the year with 'archive/'; the only issue with that is that it would limit by year.


How to organize and cache additional data associated with terms?

I'm updating a plugin of mine and am have a hard time figuring out the "best way" to build in a specific bit of functionality. The plugin allows users to associate images from their media library to any term of any taxonomy. I'm currently working on creating functions that users can add to their themes and plugins to get the data stored by the plugin. The code I have so far can be viewed here: https://github.com/mfields/Taxonomy-Images/blob/master/public- filters.php The functionality presented in this file enables users to get the image of the term currently being queried (for taxonomy archive views) and another function is basically a wrapper for core function `get_terms()` which will return all terms of a given taxonomy while adding the image id to each term object. I would like to add a third function to the file before release. This would be a wrapper for `get_the_terms()` and would return all terms associated with the global post object that have images. I was thinking about modeling the `get_the_terms()` function after the `get_terms()` function which has built in caching for the image files. But I'm a bit afraid of what would happen when this function was used in the loop in any archive template. Basically the workflow would go something like this:   1. Get all image/term associations (0 queries).   2. Get terms associated with the global post: `get_the_terms()` (0 queries).   3. Query for all images associated with the terms (3 queries). This is done by creating a list of all image ID's and passing them to `get_posts()` via the `include` parameter. IMHO this is fine to do in single views (single.php, page.php, etc.) but what would happen if a user was to use this function in the loop in an archive views? You will need to multiply 3 queries (produced by `get_posts()`) by the value of the posts-per-page setting (10 in a default WordPress installation). So now we're at 30 total queries. It gets kinda ugly fast! Especially if users want images from more than one taxonomy displayed. 2 taxonomies per post would add 60 to what WordPress needs to do! Basically there are a few paths to take moving forward and I would like to know what you would do in a situation like this.   1. Do not build the functionality at all.   2. Build the function and educate users that a caching plugin should be installed if they use get_the_terms() in archive views.   3. Build the function + create another function that will cache all images before an archive template is loaded. This process would involve something like: After the `$posts` array has been generated (but before the template has been loaded), loop over all posts in the array calling get_the_terms() each iteration for every public taxonomy. The output of all term objects would be stored in a new array. Then, I could determine which images are associated with each term of every taxonomy and pass the image IDs to `get_posts()` in one shot. This would allow all image info to be cached for use in the template in 3 queries instead of 30, 60 or 90. IMHO 3 seems like a logical way to go, but I'm not really sure if it would be an anti optimization or not. Please let me know your thoughts about this!


Change Category Slug Redirection

Hi if I change the category slug of one of my categories, does WordPress automatically handle redirects from the old category slug to the new one?


WordPress comment count to include attachment comments

How can I make the comment count on a post on my index page include comments that have been made on, in my case, individual gallery pictures that are included in the post? It seems that comments made on attachments like this aren't counted using the standard WordPress comments functions.


How to list custom post types?

Here's what I'd like to do: a) Create a custom post type and write panel for a menu item called "My Stuff." b) "My Stuff" will behave like a category -- but the content will not appear in the main blog. It will only appear under "My Stuff." So, what do I need to do? Create another loop? If so, where would I put the second loop, and how would I create a link to "My Stuff"? Or should I add "My Stuff" to the loop in index.php, create a "My Stuff" category (or taxonomy) and filter "My Stuff" somehow so it only displays when certain fields are present? Apologies for the complicated question, but I find this all very confusing. None of the scattered tutorials available on the topic clearly explain how to display custom post type content anywhere other than on a page or through the loop. I'd appreciate any assistance. Thanks.


use child theme for mobile version

I have never used the child theme function. so I am curious if it is possible to use this function to create a mobile version or no? I know that there are mobile plugins for this but I was curious if can use a child there for this


Plugins try to install in old location

I just moved my WordPress website to a new domain & server. Everything seems to work fine except for installing new plugins. When I'm trying to install a new plugin, it's still trying to access the upload directory of the old server. The error I get is:               Warning: touch() [function.touch]: Unable to create file /home/oldserver/domains/olddomain.com/public_html/website/wp-content/uploads/search-and-replace.tmp because Permission denied in /home/newserver/domains/newdomain.com/public_html/wp-admin/includes/file.php on line 179          Warning: unlink(/home/oldserver/domains/olddomain.com/public_html/website/wp-content/uploads/search-and-replace.tmp) [function.unlink]: Permission denied in /home/newserver/domains/newdomain.com/public_html/wp-admin/includes/file.php on line 493      I already changed the `WordPress URL`, `Site URL` and `Upload Directory` in the database `wp_options` table. What did I miss?


Easier URL to an image

Currently in development for a client's website and when I type the image source I do not want to type out something similar to this as it can get very messy:                     Is there a template tag or something that'll enable me to just jump into my theme's folder and link from there? The code could look like something similar to this:               <img src="<?php image_source('images/logo.png')?>"/>


Post order by selected tags

Let's say you want to show posts tagged with tags : "HTML, CSS". I want to order posts in tag archive in the following order: Post tagged with only exact two tags - HTML,CSS   Post tagged with only exact two tags - HTML, CSS   Posts tagged with three tags - HTML, CSS, jQuery   Posts tagged with three tags - HTML, CSS, ZEND   Posts tagged with four tags - HTML, CSS, JavaScript, PHP   etc. So first result/s should only output posts with only exact specified tags. After there are no more posts tagged with only those two tags, output posts tagged those 2 tags + only one more tag. And so on. What should I use? Two wpQueryPosts loops? Can it be done with only one loop? How to sort by matched tags?


WordPress 4.0 beta - how to change the link URL in RSS feeds

I am using WP 4 beta and have a site at blah.com/blog but I display the posts on my site at blah.com/articles I want all of the URLs in my RSS feed to use my site URL. Following what was mentioned here: Change the link URL in default RSS feeds I added this filter to the bottom of plugin.php (add_filter doesn't work in functions.php in 4 beta because it's defined in plugin.php which is loaded after functions.php, I found out)               add_filter( 'the_permalink_rss', 'wpse_96602_change_feed_item_url' );          function wpse_96602_change_feed_item_url( $url )     {     return str_replace('/blog/','/article/',$url);     }      But this hasn't worked. What do I need to do? Thanks in advance :)


Wordpress tries to load "next page" after done loading current page

I have a fresh 3.5.1 installation - default theme, no plugins. Running HTTPFox on Firefox shows that after a GET-request of any given page in Wordpress has finished loading, a GET-request is sent for the `rel='next'` page:               <link rel='next' title='Next Page Title' href='http://www.domain.com/next-page/' />      and fails:               00:10:04.992    0.556   698 245 GET (Aborted)   text/html (NS_BINDING_ABORTED)  http://www.domain.com/next-page/      My question - is this on purpose? Is wordpress doing some kind of preloading? I'd like to understand why it is doing this.


Grant access to admin menu?

I'm trying to grant the user role 'editor' to have access to the Users top- level menu, and then control which sub-menus they have access to. The add_action lives in the _construct method.               add_action( 'admin_menu', array( $this, 'action_admin_menu' ) );          public function action_admin_menu() {             $edit_contributor = get_role( 'editor' );             $edit_contributor->add_cap( 'edit_users' );         }      I'm expecting the Users menu to appear for an Editor, but it's not working.


Alternative ways to make ajax requests in wordpress

I'm currently having a problem with working with AJAX. Well not really a problem since I can pretty much do what I want to do. The only problem is my boss saying that the `admin-ajax.php` file is an admin file and he doesn't want any admin file in the public side of the website. So my question is is there any alternative ways without using this method to make ajax requests in Wordpress? Here's what I'm currently doing:               add_action('wp_ajax_nopriv_plug_token', array($this, 'plug_get_token'));          add_action('wp_ajax_plug_token', array($this, 'plug_get_token'));          public function plug_get_token(){       return $token;       die();     }      And under the `wp_enqueue_scripts` action hook I'm loading the file for processing ajax request:               wp_localize_script(          'plug_public_script',          'plug_public',          array(              'ajaxurl' => admin_url('admin-ajax.php')         )     );      So I simply call it in my script like this:               jQuery.post(plug_public.ajaxurl, {'action' : 'plug_token'}, function(token){        //do something with the token     });      My boss said something about moving the admin-ajax.php into a more public location and then call from there. Is there really a security concern when calling admin-ajax.php from its default location?


Remove Site Name from wp_title WITHOUT removing from <title> attribute

I'm using `wp_title()` in the body of my theme to print out the page title name at the top of the page, way before the content. This unfortunately also prints out the site name, which is redundant in my use case. Essentially I'm going for this to be dynamic on each page: `Site Name >> Page Name` instead of `Site Name >> Page NameSite Name` I modified the filter built into my boilerplate theme adjusting this:               // Otherwise, let's start by adding the site name to the end:         $title .= get_bloginfo( 'name', 'display' );              // If we have a site description and we're on the home/front page, add the description:         $site_description = get_bloginfo( 'description', 'display' );         if ( $site_description && ( is_home() || is_front_page() ) )             $title .= " $separator " . $site_description;      But this unfortunately also removed it from the `<title>` attribute in my `<head>` tag. is there a way I can modify this filter to only do a certain action when it's in the body of the page?


Using website header, menu and footer on Wordpress blog

I want to use the header, top menu and footer from my website on my Wordpress blog. The website itself is not a Wordpress site but the blog is and resides in a 'blog' folder on my server. So I guess what I need to do is edit the blog's 'header.php' file to use my website header for starters (then the same for menu and footer) but being relatively new to Wordpress I am finding it difficult to navigate the wordpress 'header.php' file. How do I call a header/menu/footer with direct url's to override the themes header. It seems to be possible but is more of a 'hack' and I can find no definitive answer anywhere. Is it that difficult/tricky to do?? Here is the code for the Wordpress 'header.php' header                   <?php     /*      * Header Section of Iconic One      *      * Displays all of the  section and everything up till
      *      * @package WordPress - Themonic Framework      * @subpackage Iconic_One      * @since Iconic One 1.0     */     ?>          <!DOCTYPE html>                    <html <?php language_attributes(); ?>>               <meta charset="<?php bloginfo( 'charset' ); ?>" />     <meta name="viewport" content="width=device-width" />     <title><?php wp_title( '|', true, 'right' ); ?></title>     <link rel="profile" href="http://gmpg.org/xfn/11" />     <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />     <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in  older IE versions. ?>          <?php wp_head(); ?>     <?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php") ?>          <body <?php body_class(); ?>>
                  <?php if ( get_theme_mod( 'themonic_logo' ) ) : ?>
         <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo  esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="<?php  echo get_theme_mod( 'themonic_logo' ); ?>" alt="<?php echo  esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
     <?php if( get_theme_mod( 'iconic_one_social_activate' ) == '1') { ?>
         <a href="<?php echo get_theme_mod( 'twitter_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/ img/twitter.png" alt="Follow us on Twitter"/> <a href="<?php echo get_theme_mod( 'facebook_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/facebook.png" alt="Follow us on Facebook"/> <a href="<?php echo get_theme_mod( 'plus_url', 'default_value' ); ?>" rel="author" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/gplus.png" alt="Follow us on Google Plus"/><a href="<?php echo get_theme_mod( 'rss_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/rss.png" alt="Subscribe RSS"/>
     <?php } ?>                <?php else : ?>         <hgroup>             <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>
 <?php bloginfo( 'description' ); ?>         </hgroup>     <?php if( get_theme_mod( 'iconic_one_social_activate' ) == '1') { ?>
         <a href="<?php echo get_theme_mod( 'twitter_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/twitter.png" alt="Follow us on Twitter"/> <a href="<?php echo get_theme_mod( 'facebook_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/facebook.png" alt="Follow us on Facebook"/> <a href="<?php echo get_theme_mod( 'plus_url', 'default_value' ); ?>" rel="author" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/gplus.png" alt="Follow us on Google Plus"/><a href="<?php echo get_theme_mod( 'rss_url', 'default_value' ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/img/rss.png" alt="Follow us on rss"/>
     <?php } ?>           <?php endif; ?>                           <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'themonic' ); ?>"><?php _e( 'Skip to content', 'themonic' ); ?>             <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'menu-top', 'menu_class' => 'nav-menu' ) ); ?>                       <?php $header_image = get_header_image();         if ( ! empty( $header_image ) ) : ?>             <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />         <?php endif; ?>


Is it necessary to use esc_url with template tags such as get_permalink?

I have been reading that sanitizing data output is important in theme / plugin development for wordpress. Is it necessary to use functions such as esc_url with template tags like get_permalink, or is the sanitization taken care of by the template tag? Thanks


How to display related posts by subcategory and not parent category

I'm trying to find a way to display related posts that are in a subcategory of a specific parent category based upon the subcategory of the current post. The current post may be assigned to multiple parent categories, but I only want to display related posts of one of the parent category's subcategories. So for example, a post may be assigned to categories A, B and C, but I want to show related posts based upon the current post's B subcategory and not show **all** the posts from either A, B or C. Sorry, this question/problem is hard to explain. I'm using this code to display the category name and posts, but I'm not sure how to exclude parent categories from it, so that only the subcategory posts will display.               More in          <?php $category = get_the_category();              if ( in_category(52) || in_category(56) || in_category(57) || in_category(99) || in_category(28) ) {                 echo $category[1]->cat_name;              } else {echo $category[0]->cat_name;}         ?>          <?php if (have_posts() && !(in_category('32'))) : ?>             <?php $i = 1; while (have_posts() && $i <= 1) : the_post(); ?>             <?php $related = get_posts(array('category__in' => wp_get_post_categories($post->ID), 'numberposts' => 1, 'post__not_in' => array($post->ID)));     if($related) foreach( $related as $post) {             setup_postdata($post); ?>             <?php the_post_thumbnail('medium'); ?>                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                     <a href="<?php the_permalink(); ?>"><?php the_excerpt(''); ?>                     <?php the_author(); ?>
                     <?php } wp_reset_postdata(); ?>         <?php $i++; endwhile; ?>     <?php endif; ?>      Thanks!


Multiple category columns and post counting list in wordpress Homepage

I am decide to make new wordpress website. But my WordPress webdesign structure need home page category navigation bar like directories and it also show only posting counts. Now I am add one sample image,it show how the bar is look like.   * every category needs icons.   * option to change number of rows and columns in category.   * Include exclude specific category   * Auto Update category count when new post published how to modify my wordpress website to add this category list bar in my home page under the header. Sample Image Thank You


IE 6~8 ignoring font, background, and margins on sidebar

I am using the default Twenty Twelve Wordpress theme with my site, and I am trying to customize the sidebar. The CSS I am using is:               .widget-area, #secondary{     float: right;     width: 210px;     font-family: Georgia, "Times New Roman", Times, serif;     padding: 0 15px 0 15px;     border-bottom: 1px solid #cacaca;                border-top: 1px solid #cacaca;     background-color: #efefef;     margin-top: 45px; }      The code for the sidebar is unchanged from the default template, and I am using text widget for the content of the sidebar. The problem page is here: http://www.discusscps.com/gccenter/about-our-organization/ Chrome, Safari, and IE 9 have no problems, but in IE 6~8, font-family, borders, background colors, and the top margin is ignored. I have tried everything I can think of here - any ideas would be greatly appreciated. Thank you.


Display data from a non wordpress database on a page template

I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin.                $rows = $newdb->get_results("SELECT TrainerName FROM trainers");         echo "
";      foreach ($rows as $obj) :      echo "
".$obj->Name."
";      endforeach;      echo "
";      and I added this is my functions.php file `$newdb = new wpdb(); $newdb->show_errors();` I can't get it to work though, I get an error "Warning: Invalid argument supplied for foreach() ..."


Extending search query with additional $sentence value

Next in my quest to extend WordPress is altering how WordPress uses the the `$sentence` variable in `posts_search` to include an additional string, when the `$sentence` variable meets a certain criteria. The specific usecase here is that when someone types in something like `TL123` it should also search for `TL-123`, with `TL%` being the wildcard here. This is to cut-down on search mistakes (for those that do not include the hyphen). I've seen how we can filter into `posts_search` with additional SQL queries (I'm actually using this one with pretty good success so far), but am a little fuzzy on how this could work. Any help would be greatly appreciated. Thanks! _Edit - to include more information about needs thanks to @kaiser_   * Searches are typically done by typing in _TL123_ , when in reality the actual post title is _TL-123_ in most cases - so, the goal here is to intercept when the search query includes _TL_ (NUMBER) and also search _TL-_ (NUMBER). Again, the trick here is that some posts do not include TL- but only TL, so that's why I'm looking for search queries that match that pattern to also search an additional "partial phrase". Thanks! # Update Alright, so based off of kaiser's starter function, I have come up with the following:               function wpse66815_search_query_string( $search, &$wp_query )     {         if (!is_admin() && is_search()) {                  print_r($search);                  global $wp_query;                  // get search term             $search_term = array_shift($wp_query->query_vars['search_terms']);             // specify string we'll use to replace             $replace_var = 'TL';                  // find matches for that string             preg_match_all("/{$replace_var}(?:[^0-9]*)(\d+)/i", $search_term, $out);                  // if there's no matches, return the normal search             if ( empty($out[0]) )                 return $search;                  // find/generate the search term with the replacement             $modified_search_term = preg_replace("/{$replace_var}(?:[^0-9]*)(\d+)/i", "{$replace_var}-$1", $search_term);                  // combine both the regular and modified search term             $new_search[] = $search_term;             $new_search[] = $modified_search_term;                  //var_dump($new_search);                  // generate the new search query             foreach ( $new_search as $keyword )             {                 $new_string_parts[] = $GLOBALS['wpdb']->prepare(                      "                         AND ((%s.post_title LIKE '%%%s%%') OR (%s.post_content LIKE '%%%s%%'))                      "                     ,"{$GLOBALS['wpdb']->prefix}posts"                     ,like_escape( $keyword )                     ,"{$GLOBALS['wpdb']->prefix}posts"                     ,like_escape( $keyword )                 );             }                  // set $search equal to results             $search = implode( " ", $new_string_parts );                  //print_r($search);         }              return $search;     }     add_filter('posts_search', 'wpse66815_search_query_string',500,2);      The part that I can't get past is actually is the actual SQL query -> error below: `WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.post_title LIKE 'tl123') OR ('wp__posts'.post_content LIKE 'tl123')) ' at line 2]` `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (('wp__posts'.post_title LIKE 'tl123') OR ('wp__posts'.post_content LIKE 'tl123')) AND (('wp__posts'.post_title LIKE 'TL-123') OR ('wp__posts'.post_content LIKE 'TL-123')) AND wp_posts.post_type IN ('post', 'page', 'attachment', 'galleries', 'idea_gallery', 'moulding_profiles', 'moulding_collection', 'moulding_combination') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 2 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 80` Any pointers on where I went wrong? Thanks! # Update #2 I've started to see a few issues:   * It was doing `wp__posts` instead of `wp_posts` (I updated that above)   * As `kaiser` mentioned, the `LIKE %s` portion may need to be `LIKE %%s%` but that is not parsing correctly. Error is now: `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (('wp_posts'.post_title LIKE 'tl123') OR ('wp_posts'.post_content LIKE 'tl123')) AND (('wp_posts'.post_title LIKE 'TL-123') OR ('wp_posts'.post_content LIKE 'TL-123')) AND wp_posts.post_type IN ('post', 'page', 'attachment', 'galleries', 'idea_gallery', 'moulding_profiles', 'moulding_collection', 'moulding_combination') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 2 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 80` The error above (from what I can tell) is actually trying to look for a post that is both `tl123` and `TL-123`, but I think `OR` is what I want (as I want to return posts in an either or situation). # Update #3 Updated function to properly escape `%s`, so error is now: `WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.post_title LIKE '%tl123%') OR ('wp_posts'.post_content LIKE '%tl123%')) ' at line 2]` `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (('wp_posts'.post_title LIKE '%tl123%') OR ('wp_posts'.post_content LIKE '%tl123%')) AND (('wp_posts'.post_title LIKE '%TL-123%') OR ('wp_posts'.post_content LIKE '%TL-123%')) AND wp_posts.post_type IN ('post', 'page', 'attachment', 'galleries', 'idea_gallery', 'moulding_profiles', 'moulding_collection', 'moulding_combination') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 2 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 80` # Update #4 Here's what I ended up doing -> the foreach wasn't wrapping correctly (with the AND/OR operator as @kaiser mentioned), so I separated them out into their own array insertions.               function wpse66815_search_query_string( $search, &$wp_query )     {         if (!is_admin() && is_search()) {                  //print_r($search);                  global $wp_query,$wpdb;                  // get search term             $search_term = array_shift($wp_query->query_vars['search_terms']);             // specify string we'll use to replace             $replace_var = 'TL';                  // find matches for that string             preg_match_all("/{$replace_var}(?:[^0-9]*)(\d+)/i", $search_term, $out);                  // if there's no matches, return the normal search             if ( empty($out[0]) )                 return $search;                  // find/generate the search term with the replacement             $modified_search_term = preg_replace("/{$replace_var}(?:[^0-9]*)(\d+)/i", "{$replace_var}-$1", $search_term);                  // combine both the regular and modified search term             $new_search[] = $search_term;             $new_search[] = $modified_search_term;                  var_dump($new_search);                  // generate the new search query             $new_string_parts[] = $wpdb->prepare( "AND ((({$wpdb->posts}.post_title LIKE '%%%s%%') OR ({$wpdb->posts}.post_content LIKE '%%%s%%'))",like_escape( $new_search[0] ),like_escape( $new_search[0] ));             $new_string_parts[] = $wpdb->prepare( "OR (({$wpdb->posts}.post_title LIKE '%%%s%%') OR ({$wpdb->posts}.post_content LIKE '%%%s%%')))",like_escape( $new_search[1] ),like_escape( $new_search[1] ));                  // set $search equal to results             $search = implode( " ", $new_string_parts );                  //print_r($search);         }              return $search;     }     add_filter('posts_search', 'wpse66815_search_query_string',500,2);      It does have some trouble if someone were to type in `tl123 tl456` (two occurences of the `tl` keyword), but I'm working on that portion. Thanks!


Order by meta value

I've a custom post type that has a custom filed called **deck-number** and client wants to sort the result by deck number. FYI, deck numbers are numeric values. So I used query like bellow.               get_posts('post_type=decks&nopaging=true&meta_key=deck-number&orderby=meta_value&order=ASC');      The issue I'm facing is I'm getting result sorting like 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9. I need your advice to solve. Thanks.


PHP-Code inside Href-Tag

I have include PHP-Code inside a href-tag – and it doesn’t work!               <?php $image = get_post_meta($post->ID, 'image_medium', true);         if ( $image != '' ) {?>                       <a href="<?php wp_get_attachment_image($image, 'category-large-thumb' ); ?>"  rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover"><?php echo wp_get_attachment_image($image, 'category-small-thumb'); ?>                      <?php } ?>      The source code shows an empty href (href=““) I checked it with a “direct” pathway (href=”/img.jpg”), like below, and it works               <?php $image = get_post_meta($post->ID, 'image2_medium', true);         if ( $image != '' ) {?>              <a class="fancybox" href="<?php bloginfo('template_directory');?>/1_b.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover"><img src="<?php bloginfo('template_directory');?>/1_s.jpg" />         <?php } ?>      Where is my fault? How can I integrate the (loop-) php-code into the href-tag? Thanks Petra


exec JavaScript using add_action when publish_post

How can I execute some Javascript code when an user publish a post I want to do something like this before publish a post:               add_action ( 'publish_post', 'custom_links' );     function custom_links()     {         echo "<script>Hello world</script>";     }      I want to manually check and edit the permanent link of the future publish post.


Get a post's thumbnail url or display default image in shortcode

I'm trying to get my code to:   * Get a post's thumbnail url   * _or_ (if no thumbnail there) to   * Echo a default url I'm not sure if I am going the easiest way or right way about this. This is the code so far. `$postid` being the attribute for the id of the post I want the url from.               <?php     // Add Shortcode     function friend_pic( $atts , $content = null ) {              // Attributes         extract( shortcode_atts(             array(                 'postid' => '',             ), $atts,                 'f-p'             )         );              $postid = $atts['postid'];               ob_start();          // shortcode contents from here           echo "<img src=\"";          if ( $postid ) {           $thumb_url = wp_get_attachment_url( get_post_thumbnail_id( $postid, 'thumbnail', false) );           $thumb_url = $thumb_url[0];           }else{           echo "http://www.website.com/default.jpeg";          }                                   echo "\">";           // Shortcode edit ends here          $output = ob_get_contents();     ob_end_clean();                 /// FINAL OUTPUT ////         return $output;     }     add_shortcode( 'f-p', 'friend_pic' );       ****Aditional Details*** The point of this is to display the pictures of my friends by using a shortcode in my posts. The pages of my website are about my family and friends, and when I want to reference one I just wanna show the thumb of their page, its their picture, and if there isnt a thumb then show a default picture (a N/A picture).


change text written in english into hindi

i want to change the text written in english into hindi inside my search bar, i am developing a hindi newspaper website by using wordpress cms so when user type in english to search related news in search bar that text should change in hindi because all the news in written in hindi so searching news become easy.please help me if somebody know. here is my wordpress by default search code:

                <form method="get" id="searchform" action="<?php echo home_url(); ?>/">
                           <input type="text" class="form-control search-bar eng my_control" name="s" id="search" placeholder="search....." onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>                                                        <button class="btn my-btn"  id="searchsubmit"  type="button"></button>
                        </form>


Dynamic meta description

I am trying to make the `<meta name="description" content="">` pull the content from single posts, but I am running into a snag. Currently I am using this: `<meta name="description" content="<?php $post_id = the_ID(); $post = get_post($post_id); echo strip_tags(substr($post->post_content,0 , 150)); ?>">` It works well but adds the post id in front of the content. Is there anyway to remove that? Thanks.


Walker nav remove submenu ul from a certain depth

I want to remove `sub-menu` ul and `.menu-item-has-children` class when the menu depth is superior or egal to 2. So, I only want a menu with 3 sub-menu at maximum. Other item children will still displayed in the menu but not in a sub menu. With wp_nav_menu('depth' => 3) it don't append all items. So, I think I need to use a custom walker nav. I don't know how to do it with `start_lvl`. What is the way to count depth and to remove ul and classes... My aim is to change this menu:   * menu-item-has-children      * menu-item-1     * menu-item-2     * menu-item-has-children        * menu-item-3       * menu-item-4       * menu-item-has-children          * menu-item-5         * menu-item-6 to this menu :   * menu-item-has-children      * menu-item-1     * menu-item-2     * menu-item-has-children        * menu-item-3       * menu-item-4       * menu-item-has-children       * menu-item-5       * menu-item-6 And the unwanted behavior provides by wp_nav_menu('depth' => 3) option in wordpress   * menu-item-has-children      * menu-item-1     * menu-item-2     * menu-item-has-children        * menu-item-3       * menu-item-4       * menu-item-has-children I've tried with this:               function start_lvl(&$output, $depth) {          if($depth >= 2) {             $output .=  '';         } else {             $output .= "<ul class='sub-menu'>";         }     }      It near works, but it create a problem with ul inside my navmenu.


WP not recognizing custom post type / template

I've created a custom post type:                  $args = array(         'labels' => array(           'name' => __( 'Prosjekter' ),           'singular_name' => __( 'Prosjekt' ),           'add_new' => __('Nytt prosjekt')         ),         'public' => false,         'show_ui' => true,         'show_in_menu' => true,         'has_archive' => false,         'taxonomies' => array('category'),         'menu_position' => 5,         'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes','post_tag' ),         'rewrite' => array('slug' => 'prosjekter')       );      register_post_type( 'project',$args);      Then I've created this template file:               single-project.php      But when I open a project it's not using the template. What am I missing?


How to solve: An error occured in the upload

![ ](http://i.stack.imgur.com/g0UDP.jpg) This error message appears when I try to upload any picture. Currently I am using WordPress 3.8.


Custom Post Types Archives and daily/monthly joke

I have created a custom post type called joke using custom post types ui plugin. I have enabled archives for that ctp. I would like to have a page that would display the daily (or monthly) joke, and also have a page that would display an archive of all previous jokes. Is it possible, and if so, can you point as to how it can be achieved?


Editing post in admin panel

I have a front end posting form. Everythings work nice, but the custom (meta) fields i added in the form doesn't appear in admin panel post edit? I add them with add_post_meta() function. Any ideas?


Export a blog(not mine) as a PDF document

Is it possible to export the posts of a blog as a PDF? There is a blog with a couple of hundred posts that I'd like to read on my ereader, so I was wondering whether I could extract those posts into a PDF? Thanks for the help!


how to list parent terms only

I have the following code to list all terms, but I need a code where I can list only "parent terms" as they all have child terms too               <?php     // output quick links list of countries     $terms = get_terms('apptypes');     if (count($terms)) {     echo "
Quick links
";     echo "
";     }     $i=0; // counter for printing separator bars     foreach ($terms as $term) {     $wpq = array ('taxonomy'=>'apptypes','term'=>$term->slug);     $query = new WP_Query ($wpq);     $article_count = $query->post_count;     echo "slug."\">".$term->name."";     // output separator bar if not last item in list     if ( $i < count($terms)-1 ) {     echo " | " ;     }     $i++;     }     if (count($terms)) {     echo "
";     }     ?>


Installing plugins on IIS-hosted site

I've got a Windows 2008r2 server with IIS which is hosting a wordpress site. However, I can't get installations of plugins to work with FTP. This is what I've done:   * I've set up a FTP site in IIS which has it's root in the `wordpress/` directory   * I've created a user which has the "Full Access" priviledge on the entire wordpress directory.    * When I log in using a ftp program or browser, it works fine, I can browse the wordpress dirs, upload files etc. But when I try to install a plugin, it takes a _long_ time, and then errors out with "Unable to locate WordPress Content directory (wp-content).". Googling suggests this would be because the ftp root is not in the same directory as the `wp-content` dir, but it is. It does not seem to be a credential problem either, because giving wrong password/username/hostname gives an error quickly. I can also see the ftp session in the IIS manager. What do I need to do?


function to set permalink to /%postname%/ on theme activation

I'm wondering if there is any function to set permalink to `/%postname%/` on theme activation ? Thanks