Is there a way to make custom fields only editable by administrators?

I've found the following code that places custom fields into a user's profile:   function extra_user_profile_fields( $user ) {                ?>
<?php _e("Roof Asset Information", "blank"); ?>

     <?php _e("Facility"); ?>	          <input type="text" name="facility" id="facility" value="<?php echo esc_attr(             get_the_author_meta( 'facility', $user->ID ) ); ?>" class="regular-text" />
     <?php _e("Please enter the facility name."); ?>

     <?php _e("Roof Section"); ?>	          <input type="text" name="roofsection" id="roofsection" value="<?php echo esc_attr(          get_the_author_meta( 'roofsection', $user->ID ) ); ?>" class="regular-text" />
     <?php _e("Please enter the roof section."); ?>

     <?php _e("Sq. Feet"); ?>	          <input type="text" name="footage" id="footage" value="<?php echo esc_attr(         get_the_author_meta( 'footage', $user->ID ) ); ?>" class="regular-text" />
     <?php _e("Please enter the square footage."); ?>

     <?php }          add_action( 'personal_options_update', 'save_extra_user_profile_fields' );     add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );          function save_extra_user_profile_fields( $user_id ) {          if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }          update_user_meta( $user_id, 'facility', $_POST['facility'] );     update_user_meta( $user_id, 'roofsection', $_POST['roofsection'] );     update_user_meta( $user_id, 'footage', $_POST['footage'] );          }          Is there a way to add extra functionality to this code that makes it so only administrators can edit the custom fields?


search.php template not loading results

This is really bizarre - this has never happened before :/    I have a search.php template which consists of this...                   <?php         /**         * @package WordPress         * @subpackage Example 2012         * @since Example 1.0         */              get_header(); ?>                   <?php if (have_posts()) : ?>              <?php while (have_posts()) : the_post(); ?>              <?php the_title(); ?>              <?php endwhile; ?>              <?php endif; wp_reset_query(); ?>                   <?php get_footer(); ?>         this is what is in my functions.php               // SEARCH FORM HEADER     function search_form_header( $form ) {         $form = '<form method="get" id="header-searchform" action="' . home_url( '/' ) . '" >

             <input class="searchform-mid clearit" type="text" name="search" id="search-header" value="Search" />

         </form>';         return $form;     }          add_filter( 'get_search_form', 'search_form_header' );         and this is how I'm calling my form...               <?php get_search_form('search_form_header'); ?>         And this is what my URL looks like when a search is performed (search query hello)...               http://www.example.co.uk/?search=hello         And all I get is the index.php? And ideas would be truly amazing thanks. If you need more info please let me know thanks.


How to avoid wp_nav_menu() ID conflict?

How do I avoid ID conflicts if I use the same menu TWICE on one page. FIRST               wp_nav_menu( array( 'sort_column' => 'menu_order',      'theme_location'=>'menu', 'menu_class'=>'menu', 'menu_id'=>'menu' ) );      SECOND:               wp_nav_menu( array( 'sort_column' => 'menu_order',      'theme_location'=>'menu', 'menu_class'=>'menu2', 'menu_id'=>'menu2' ) );      ID conflicts are like "Duplicate ID menu-item-2456"... Any solutions?


changing parent_id on post

I'm trying to change a post's parent via the wp_insert_post_data filter but I'm not having any luck. In the example below, I'm replacing any "parent" references with the id I want to set.               function my_insert_post_data($data, $postarr){              $data["post_parent"] = 123;         $postarr["parent_id"] = 123;         $postarr["post_parent"] = 123;              error_log(print_r($data,true));         error_log(print_r($postarr,true));          }     add_filter( 'wp_insert_post_data' , 'my_insert_post_data' , '99', 2 );      and when i log the objects, i see the properties have been set but that never gets written to the database.


Custom post type: check permissions and validate nonce

I have a custom post type with the following capabilities:               $capabilities = array(         'read_post' => 'administrator',         'read_private_posts' => 'administrator',         'publish_posts' => 'administrator',         'edit_post' => 'administrator',         'edit_posts' => 'administrator',         'edit_published_posts' => 'administrator',         'edit_others_posts' => 'administrator',         'edit_private_posts' => 'administrator',         'delete_post' => 'administrator',         'delete_posts' => 'administrator',         'delete_published_posts' => 'administrator',         'delete_others_posts' => 'administrator',         'delete_private_posts' => 'administrator'     );      Do I still need to use something like `current_user_can()` when saving (via `save_post`), to validate whether that user has permissions to add or edit a post, or does setting the capabilities take care of that? Since this is not a custom page in Wordpress, but rather a custom post type, do I need to verify the nonce or is this built-in when using a custom post type? I should note that I'm not using any Wordpress fields (such as title, body, etc) in that post type. There is one pair of fields that have been added using `add_meta_box()`.


WordPress Theme Options Import/Export

I already have a theme options page that saves to wp_options > kittens_options. I'm looking for a simple way to incorporate an import/export textarea of those options on my options page. I've searched Google for several hours now and haven't been able to find any useful tutorials. If anyone knows off the top of their head let me know. Thanks **CODE I'M WORKING WITH SO FAR**               <?php     function kittens_transport_page() {     global $themename, $shortname;     $kittens = get_option( 'kittens_options' );     $currentsettings = "";     if ( isset( $_POST['import'] ) && trim($_POST['kittens_import_settings']) != "" ) {     $currentsettings = $_POST['kittens_import_settings'];     } elseif ( isset( $kittens ) && ( $kittens != "" ) ) {     $currentsettings = base64_encode( serialize( $kittens ) );     }     }     ?>

Import & Export Theme Options
     <form method="post" action="#">     Import Options     <textarea rows="8" cols="40" id="kittens_import_settings" name="kittens_import_settings" class="large-text"></textarea>
     <input type="submit" value="Import" id="import" name="import" class="button-primary" onClick="return confirm('Are you sure you want to import these settings?')" /> <?php if ( isset( $_POST['import'] ) && $_POST['kittens_import_settings'] != "" ) { echo "Settings Imported Successfully"; } ?>     </form>

     Export Options     <textarea rows="8" cols="40" id="kittens_export_settings" name="kittens_export_settings" class="large-text" readonly="readonly"><?php echo $currentsettings; ?></textarea>     <?php     function kittens_import_settings(){     global $shortname;     if ( isset( $_POST['import'] ) && trim($_POST['kittens_import_settings']) != "" ) {     if(isset($_POST['kittens_import_settings']) && current_user_can('edit_themes')){     $imported_settings = unserialize(base64_decode($_POST['kittens_import_settings']));     update_option($shortname . '_settings', $imported_settings);     }     }     }     ?>


wp-cli doesn't find and wordpress installation

I wanted to try wp-cli, downloaded the phar and installed it by moving it to ~/bin which is in my path. Then wp --info works, but maybe shows insufficient information. (e.g. no php path, though it is running, so php is there ...) Any other actions I tried so far were unsuccessful, alsways resulting in 'no wordpress installation found' Specifying --path or --url didn't change anything. The result is the same for a multisite or non-multisite installation. Any ideas what could be wrong?               PHP binary:     PHP version:    5.3.27     php.ini used:   /usr/local/lib/php.ini     WP-CLI root dir:        phar://wp-cli.phar     WP-CLI global config:     WP-CLI project config:     WP-CLI version: 0.14.0-alpha      (added `wp --info` output)


Allowing an email as the username?

Is it possible to allow people to utilize their email as their username?


How to include a file using get_template_part() in a plugin?

A very simple question may be, but I'm struggling. In theme development, I worked with `get_template_part()` many times, and I understand its basics. But when I's developing a plugin, I wondered using it showing me some errors: > **Notice: Use of undefined constant STYLESHEETPATH** - assumed > 'STYLESHEETPATH' in `...\wp-includes\template.php` on line 407 and > **Notice: Use of undefined constant TEMPLATEPATH** - assumed 'TEMPLATEPATH' > in `...\wp-includes\template.php` on line 410 Googling the problem showed a support fix:   * Use `get_template_part()` into a plugin - WordPress Support But that seems a huge workaround - I doubt it. I think that shouldn't be much complicated. I checked this WPSE Answer and found this line of code:               if ( '' === locate_template( 'loop-mycustomposttype.php', true, false ) )         include( 'loop-mycustomposttype.php' );      Where there is a PHP `include()` function. As per as my WordPress knowledge I learned to prefer `get_template_part()` over PHP `include()`. Then how exactly I can use a simple `get_template_part()` in my plugin. I'm not using any loop or something, I'm just separating (or you may say organizing) my plugin code into different files so that in some cases, I will simply comment them out to drop where they are not necessary. I tried:               get_template_part( 'my', 'special-admin' );      and then after the error, changed it to:               get_template_part( 'my', 'specialadmin' );      But you know that's not the issue. I'm on local server, using WAMP.


Migrating jQuery gallery to Wordpress

I'm moving my website to Wordpress and I'm trying to migrate my old gallery over. This uses Jquery and picasa. I've tried a few ways of loading the scripts, played with jquery versions, even toyed with an iframe, but seem to be drawing a blank. Literally. I think most likely is that the script that initialises the gallery is incorrect, I just don't know how. This script is below. FYI The new page is here http://www.talesfromthesaddle.com/newmap/photos/ Old page - so you can see the gallery - is here :http://www.talesfromthesaddle.com/picasa/photos.shtml If anyone has some pointers, I've been at it a long time.....Thanks to anyone who can help :)                <script type="text/javascript">            var $viewerSelected = "fancybox";       var $url=document.URL.split("?", 2);       if ($url.length == 2) {         var $queryParams = $url[1].split("&");         for ($queryParam in $queryParams) {           var $split = $queryParams[$queryParam].split("=", 2);           if ($split[0] === "viewer") {             $viewerSelected = $split[1];           }         }       }            jquery(document).ready(function() {              var $viewerShow, $viewerJs, $viewerName;        jquery('#FancyboxCode').hide();         switch($viewerSelected)         {         case "fancybox":           $viewerName = "FancyBox";           $viewerCss  = "js/jquery.fancybox/jquery.fancybox.css";           $viewerJs   = "js/jquery.fancybox/jquery.fancybox.pack.js";           $('#FancyboxCode').show();           break;         case "colorbox":           $viewerName = "ColorBox";           $viewerCss  = "js/jquery.colorbox/colorbox.css";           $viewerJs   = "js/jquery.colorbox/jquery.colorbox-min.js";           break;         default:           alert("Unknown viewer selected");           $viewerName = "unknown";           $viewerCss  = "unknown";           $viewerJs   = "unknown";           break;         }              $("#jqueryVersion").text($().jquery);         $("#viewername").text($viewerName);         $("#viewernameCss").text($viewerCss);         $("#viewernameJs").text($viewerJs);         $("a#inline").fancybox({closeClick: false});         var settings = {         removeAlbumTypes: ["ScrapBook", "ProfilePhotos","Blogger Pictures"],     showAlbumdate:false,         photoSize: 1024,         thumbSize : 144,         albumThumbSize :160,     showPhotoDate:false,         username: '103765176545098072691',         popupPlugin: $viewerSelected,         fancybox_config: {                     config_photos: {                           openSpeed: 500,                 openEffect: 'elastic',   //fade or elastic                 openEasing: 'swing',                      closeSpeed: 500,                     closeEffect: 'elastic',  //fade or elastic                     closeEasing: 'swing',                           nextSpeed  : 500,                 nextEffect : 'elastic', // 'fade' or 'elastic'                 nextEasing:  'swing', // More if easing plugin used                               prevSpeed:500,                     prevEffect: 'elastic',                     prevEasing: 'swing',                     photoSize: 1024                    }                  }           };         $("#pwicontainer").pwi(settings);       });          </script>


How to export 2 week's worth of posts

I need to export the last two week's worth of blog posts from one site into another site, including all meta data and post author info. Is there a good SQL statement to do this, or a plugin that will help me accomplish this?


custom taxonomy listing returns no posts

I had a issue with a custom taxonomy and a custom post type using the same url and that is now fixed but it has created another bug. not showing the posts tagged with the custom taxonomy. my url i am using for my post type is /news and then i have a taxonomy which i need to have /news/cars I can get a all the posts for the custom post type to output on the index template. I also have the single taxonomy page working but my query doesnt show the posts that are tagged with the custom taxonomy for example all posts that are cars. here is my code i have so far :                   function register_custom_post_types() {         $args = array(             'labels' => array(                 'name' => __( 'News' ),                 'singular_name' => __( 'News' )             ),             'menu_position' => 5,             'public' => true,         'query_var' => 'news',             'has_archive' => 'news',             'hierarchical' => true,             'taxonomies' => array('news_categories'),         'publicly_queryable' => true,             'capability_type' => 'post',             'rewrite' => array('with_front' => false, 'slug' => 'news/%news_categories%'),             'supports' => array('title', 'editor', 'thumbnail', 'revisions', 'page-attributes')         );         register_post_type( 'news', $args);          }     add_action( 'init', 'register_custom_post_types' );          add_action( 'init', 'create_my_taxonomies', 0 );              function create_my_taxonomies() {             register_taxonomy(                 'news_categories',                 'news',                 array(                     'labels' => array(                         'name' => 'News Categories',                         'add_new_item' => 'Add New Category',                         'new_item_name' => "New Category"                     ),                     'query_var' => true,                     'show_ui' => true,                     'show_tagcloud' => false,                     'hierarchical' => true,                     'rewrite' => array(                         'with_front' => false,                         'slug' => 'news'                     )                 )             );         }              add_filter('post_type_link', 'news_term_permalink', 10, 4);         function news_term_permalink($post_link, $post, $leavename, $sample) {             if ( false !== strpos( $post_link, '%news_categories%' ) ) {                 $glossary_letter = get_the_terms( $post->ID, 'news_categories' );                 $post_link = str_replace( '%news_categories%', array_pop( $glossary_letter )->slug, $post_link );             }             return $post_link;


create function to call category name and slug

In several theme templates I have code to retrieve the category name and slug for the present post or category page. It is outside the loop. Here is the repeated code:               global $post;     $categories = get_the_category($post->ID);     if ( $categories ) {     foreach ($categories as $category) {         $dw_category_slug = $category->slug;         $dw_category_name = $category->name;     }       }else {         $dw_category_slug = 'utopia';     }       I would like to be able to include this in the functions file instead of writing it in several places. This is what I have tried in my functions file:                 add_action('wp_head', 'dw_get_category');       function dw_get_category() {         global $post;         $categories = get_the_category($post->ID);                if ( $categories ) {                    foreach ($categories as $category) {                    $dw_category_slug = $category->slug;                    $dw_category_name = $category->name;             }             } else {                 $dw_category_slug = 'utopia';             }                  $dw_category[] = array('name' => $dw_category_name, 'slug' =>    $dw_category_slug);         return $dw_category;              }                                                         I would like to be able to write something like `$dw_category['name']` in the template files to call the category name. I know this is the wrong way to do it. Do I need to divide this into 2 functions so there is only one value returned for the function? Or is there some other way to do this? Writing it as a class? If interested the url is http://lenoremalenblog.com Thanks for your time.


Yoast custom feed template as add_feed function?

I'm trying to make Yoast's Custom RSS feeds post display in an add_feed function. Just putting Yoast's snippet inside add_feed results in: > ERROR: feedname is not a valid feed template. I have tried two rewrite functions, but to no avail. What could I be missing? ![enter image description here](http://i.stack.imgur.com/ZgAmz.png) Yoast's function untouched:               <?php     /*     Template Name: Custom Feed     */          $numposts = 5;          function yoast_rss_date( $timestamp = null ) {       $timestamp = ($timestamp==null) ? time() : $timestamp;       echo date(DATE_RSS, $timestamp);     }          function yoast_rss_text_limit($string, $length, $replacer = '...') {       $string = strip_tags($string);       if(strlen($string) > $length)         return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;       return $string;     }          $posts = query_posts('showposts='.$numposts);          $lastpost = $numposts - 1;          header("Content-Type: application/rss+xml; charset=UTF-8");     echo '<?xml version="1.0"?>';     ?><rss version="2.0">     <channel>       <title>Yoast E-mail Update</title>       <link>http://yoast.com/</link>       <description>The latest blog posts from Yoast.com.</description>       <language>en-us</language>       <pubDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubDate>       <lastBuildDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></lastBuildDate>       <managingEditor>joost@yoast.com</managingEditor>     <?php foreach ($posts as $post) { ?>       <item>         <title><?php echo get_the_title($post->ID); ?></title>         <link><?php echo get_permalink($post->ID); ?></link>         <description><?php echo '<![CDATA['.yoast_rss_text_limit($post->post_content, 500).'

Keep on reading: ID).'">'.get_the_title($post->ID).''.']]>';  ?></description>         <pubDate><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate>         <guid><?php echo get_permalink($post->ID); ?></guid>       </item>     <?php } ?>     </channel>     </rss>      Function one:               function myPlugin_add_feed(  ) {       global $wp_rewrite;       add_feed('feedname', 'my_feed');       add_action('generate_rewrite_rules', 'myPlugin_rewrite_rules');       $wp_rewrite->flush_rules();     }     add_action('init', 'myPlugin_add_feed');      and function two:               function custom_feed_rewrite($wp_rewrite) {     $feed_rules = array(     'feed/(.+)' => 'index.php?feed=' . $wp_rewrite->preg_index(1),     '(.+).xml' => 'index.php?feed='. $wp_rewrite->preg_index(1)     );     $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;     }     add_filter('generate_rewrite_rules', 'custom_feed_rewrite');


Wordpress Media URLs?

I just launched a Wordpress site after having done all of the standard procedures: moved the uploads folder, uploaded the database, and did a search and replace on all of the urls in the database. Everything is fine, except for all the media that is uploaded specifically in the content area of the posts. All of these URLs, when you click on the image, say the correct URL, but for some reason on the front end, and inside the post area the images are going to localhost instead. For example, the image URL clearly says http://curioquilt.com/path/to/image, But inside the post and on the front end they aren't being displayed and the server is looking for http://localhost.com/path/to/image. There are no instances of localhost anywhere in the database. If you do go to the site (http://curioquilt.com), you have to go into the archive and click on a deeper post to see this, as I have gone through and manually fixed the first 15-20, but would rather not have to do this for the other hundred. Thanks.


SQL Query to select post thumbnail, post title, post content from a category

I use the db of my wordpress blog to develop a mobile application in Java. For this, I need the SQL query to display the thumbnail of a post, the title and the content in a selected category. I think I have to start from:               SELECT post_title FROM wp_posts p     JOIN wp_term_relationships r ON r.object_id = p.ID     JOIN wp_term_taxonomy t ON r.term_taxonomy_id = t.term_taxonomy_id     JOIN wp_terms terms ON terms.term_id = t.term_id     WHERE t.taxonomy ='category'     AND terms.name = 'politique'     AND p.post_type = 'post'


Two emails being sent on user registration

I'm having a problem where visitors are receiving two emails when they register for an new account. One email has a welcome message that I have set, and one is empty. I want to disable the sending of the second, empty email. I need help in tracing which plugin or mechanism sends out the empty email in order to disable it. Background: When people register for an account, their account is not immediately activated. An admin needs to validate accounts by hand first. I'm using Gravity Forms with User Registration add-on for this. I'm using SB Welcome Email as a plugin to set a custom welcome message to people who have registered for an account. However as mentioned above, there are now two emails being sent to the user. One by SB Welcome Email (good) and one empty (bad). Any suggestions on how I can trace which plugin is sending the second one, and / or any help on disabling the empty email? Also helpful: which hook or action is called when a new user signs up for the site?


Add all products in a category to woocommerce cart

First time using woocommerce, say i have a category called VOLUME ONE with 12 (could be more) products each priced at $10, how would i go about creating a single button like GET VOLUME ONE to add all the 12 products in that in my cart or redirect straight to paypal for checkout.


How can I setup a relationship using categories in WordPress?

I am trying to setup a relationship between a "People" post type and a "Work" post type. For example, I want to have a structure like this               Person 1      - Work        - Work 1         - Work 2     Person 2      - Work        - Work 3         - Work 4      How would I setup a relationship so that when a user is making a "Work" post they can associate the "work" post with a "person"?


cannot drag and drop widgets since wordpress 3.2.1

I recently updated my site to wordpress 3.2.1 automatically. Now I tried to manage my sidebar widgets, and noticed I can no longer drag and drop the widgets around. If I look into my browser-console, I notice that the page is unable to load jQuery. Weird: it appends my root-url to the jquery- url, like so:               <script type="text/javascript" src="http://meanderend.dixis.com//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js?ver=3.2.1"></script>      So it is normal that it is not found. How can I fix this. Is there something wrong in my configuration? Or is this a bug? Then it should be general, for everybody, no?


Multiple templates for custom post type

This is my setup: I have one post type called "products" and a page (page X) where I use wp_query to list all products, the_permalink(); returns the link to single-products.php. The goal is to use wp_query on another page (page Y) and list all products but the permalink should now be linked to another template, single-products2.php for example. Basically I need two templates for the same custom post type.


How do I get a list of popular posts by views?

I am using the Jetpack plugin to get 'site stats' which shows the number of views for blog posts/pages. So I'm no expert or anything but I'm guessing there is a table that stores these views. Is there a way to manipulate this data to create a simple list of the most popular posts by views in the sidebar? Currently, I'm using a plugin for this but I'd prefer to hard code it straight into the theme. Any guidance would be massively appreciated. Thanks for reading!


featured post as div background

Ok I didn't find an answer yet.. because my code is different.. I want to set the featured image as the div's background but I don't know how to do that.. html, php and css collide in one line.. This is the div..               <?php echo '

'; '

'; ?>      and this is the code I want..                <?php $src = wp_get_attachment_image_src ( get_post_thumbnail_id('thumbnail'));     ?>          <div id = "circ" style="background: url(<?php echo $src[0]; ?> ) !important;">test
      I could have inserted it in one line like this               <?php echo '<div id = "circ" style="background: url(<?php echo $src[0];>

'; '

'; ?>      but then they all collide which I don't know the workaround for it.. My apologies in advance.. am new to this community and wordpress too..


add_role() run only once?

I was surprised to discover that add_role() modifies the database and fails if the role already exists. There are two implications here, one first more serious than the other: 1) if you're in development and update your add_role code, you must first remove_role() 2) once you have it right, you should never have to run that code again. So typically I have been putting my add_role() inside a wp_loaded action hook. And since I'm in development, I've also added a remove_role() before my add_role so I can be sure that if I modify my list of caps, it will actually take effect. But clearly this is now being run every time a page of the blog is being accessed. Okay, I could put it in an admin-only action, or I could create a plugin page maybe under Users or Tools where this role can be created once. I guess I'm hoping there's a simpler, more elegant solution out there. I don't imagine there's a run_once kind of action is there? Or is the best practice just to add the role and then use add_cap() a bunch of times? And even then I imagine add_cap is accessing the db. Just thinking in terms of the best way to reduce unncessary db access. What are your best practices?


Search outside of the "loop"

I am creating a blog using only Wordpress's backend. I have found functions to get latest posts (wp_get_recent_posts) and all the required data I need. I do this by including wp-load so I have access to WP's functions. However I cannot find anything that allows me to perform a search outside of Wordpress's theming loops as I have for the rest of the data. I was hoping there was a search function where I can pass it a search query that could be in title, body content or tag name. Am I missing something blindingly obvious in the documentation, there seems to be a function for everything else I need outside of WP's "loop".


Hook for image edit popup

Is there a hook for the popup window which shows up when you click on the edit button on an image in a post?


Select custom post by meta value

Say I've got the custom post type `foo` with a meta box called `bar`. I've posted an entry with `bar` = `pineapple`. Now I want to check if there is a `foo` in the database with a `bar` set to `pineapple`. How would I do that? I've managed to get this working using a `wpdb` query but that doesn't feel right. Is there an elegant, maybe built-in way for me to do this?


PHP Wordpress optimization my loop code

I'm just learning PHP, and I'm using get_terms to get some text descriptions from the CMS, but i want to assign 3 variables to only 3 of my woocommerce tags. My code works well, but I just want to learn if there's a better way to filter by $tag_descrip->name than using if conditions. This is my code:               <?php     $tag_descrip = get_terms( 'product_tag', 'orderby=count&hide_empty=0' );     $count = count($tag_descrip);               if ( $count > 0 ){           foreach ( $tag_descrip as $tag_descrip ) {           if($tag_descrip->name == "parfum_bestof")        {$title_new1 = $tag_descrip->description ;}           if($tag_descrip->name == "tshirt_bestof")        {$title_new2 = $tag_descrip->description ;}           if($tag_descrip->name == "child_bestof")        {$title_new3 = $tag_descrip->description ;}                     }                    }          ?>       Thanks


Slow site initial load time

for some reason my website `www.gcprive.com` takes a very long time to respond initially but then loads all of a sudden. Any ideas why this happens? I am trying to optimize speed in general but this is a profound observation. thanks Andy


Create service similar to wordpress.com

I am looking to build a service for users where they can signup (using an online form such as Gravity or Ninja forms) for a website either as a sub domain or sub directory of the main website similar to wordpress.com. I am using wordpress multisite, but I cannot find anything online on how to accomplish this. Is there a special plugin or script/scripts that I can run?


Custom Post Type archive loop separated by term, in specific term order

I have a custom post type registered (our-team) and I have a taxonomy (team- categories) with multiple terms. Each term has multiple posts assigned to it. On my custom post type archive (archive-our-team.php) I am using the code below to separate my loop by term, which is working great, but defaults to alphabetical ordering by term: A Term Name - all posts in this term B Term Name - all posts in this term C Term Name - all posts in this term I can't figure out how to customize the order of the terms so I can get something like (any order I want): C Term Name - all posts in this term A Term Name - all posts in this term B Term Name - all posts in this term Is there a way to set an order number for each term in a taxonomy, so when I `get_terms` and then output with `foreach` they are in the order I want?               <?php //for a given post type, return all     $post_type = 'our-team';     $tax = 'team-categories';     $tax_terms = get_terms($tax);     if ($tax_terms) {         foreach ($tax_terms  as $tax_term) {             $args=array(               'post_type' => $post_type,               "$tax" => $tax_term->slug,               'post_status' => 'publish',               'posts_per_page' => -1,                       );                  $my_query = null;             $my_query = new WP_Query($args);             if( $my_query->have_posts() ) {                      echo '
'.$tax_term->name.'
';                 while ($my_query->have_posts()) : $my_query->the_post();                   //set vars for custom fields                 $team_location = get_field('team_location');                 $team_position = get_field('team_position');                 $team_email = get_field('team_email');                 $team_name = get_the_title();                 $team_link = get_permalink();                      //get only first name. usage: echo $first_name[0];                 $team_first_name = $team_name;                 $first_name = explode(' ', trim($team_first_name));                 ?>
                         <?php if ( has_post_thumbnail()) { ?>                             <a class="thickbox" href="<?php echo $team_link; ?>"><?php the_post_thumbnail('medium'); ?>                                              <?php } else { ?>                             <img src="<? bloginfo('template_directory' );?>/library/images/no_pic.jpg" alt="no image provide" />                         <?php } ?>

<?php the_title();?>

<a class="thickbox" href="<?php echo $team_link; ?>">More info <?php// echo $first_name[0]; ?>
                             <?php if ($team_email) : ?>
<a href="mailto:<?php echo $team_email;?>">Email <?php echo $first_name[0]; ?>
<?php endif; ?>

 <?php                  endwhile;             }        }     }       ?>


How do I search an array stored in a custom-field using WP_Query?

I have a custom post type called "on-air" that included a custom-field called "daysonair". The form for this has checkboxes for each day of the week. When you add/update a post, the checked items are stored as an array in the custom-field. I can't figure out how to add that custom-field to my WP_Query() search:               array( 'key' => 'daysonair',            'value' => 'Thursday',            'compare' => 'IN' )      I've tried numerous types of comparisons with no luck. The data in the database is:               a:5:{s:6:"Monday";s:6:"Monday";s:7:"Tuesday";s:7:"Tuesday";s:9:"Wednesday";s:9:"Wednesday";s:8:"Thursday";s:8:"Thursday";s:6:"Friday";s:6:"Friday";}      Where all the weekdays have been checked. I'm just looking to see if Thursday is in the array.


Aspx/Rss feed - failed to open stream: Redirection limit reached

I have this issue ive been stuck with now. Its when i load a page that have a feed. I put the feed in wp-admin , this usually work with other feeds but not sure why its not working with this kind of feed. When i load the feed i get this error: [function.file-get-contents]: failed to open stream: Redirection limit reached, aborting in /wp-content/themes/wp-jqm-01-skolledarna/functions.php on line 624. ![enter image description here](http://i.stack.imgur.com/B4Fz4.png) **NOTE:** _The feed work in the browser._ It might be a parser problem and if it is i still cant resolve it. Here is some code of the parser, from function.php :                   class rss_php {          public $document;     public $channel;     public $items;              /****************************     public load methods         ***/     # load RSS by URL         public function load($url=false, $unblock=true) {             if($url) {                 if($unblock) {         $this->loadParser(file_get_contents($url,         false,      $this->randomContext()));                 } else {                     $this->loadParser(file_get_contents($url));                 }             }         }     # load raw RSS data         public function loadRSS($rawxml=false) {             if($rawxml) {                 $this->loadParser($rawxml);             }         }                     /****************************     public load methods         @param $includeAttributes BOOLEAN         return array; ***/          # return full rss array         public function getRSS($includeAttributes=false) {             if($includeAttributes) {                 return $this->document;             }             return $this->valueReturner();         }     # return channel data         public function getChannel($includeAttributes=false) {             if($includeAttributes) {                 return $this->channel;             }             return $this->valueReturner($this->channel);         }     # return rss items         public function getItems($includeAttributes=false) {             if($includeAttributes) {                 return $this->items;             }             return $this->valueReturner($this->items);         }      **What could the problem be ?** **EDIT:** This is my rss function:                    function get_rss($url, $lang, $articles) {     $rss = new rss_php;     $rss->load($url);     $items = $rss->getItems();          // Sets the maximum items to be listed     $max_items = $articles;          $count = 0;          $html = '';     // Translates months to swedish     foreach($items as $index => $item) {     $pubdateForeignString = substr($item['pubDate'], 4);     $pubdateEnglishString = str_replace(array('maj', 'okt'), array('may', 'oct'), $pubdateForeignString);     $pubdate = date("Y-m-d", strtotime($pubdateEnglishString));          $html .= '

'.$item['title'].'

'.$item['description'].'

Läs merPublicerad: '.$pubdate.'

';     $count++; //Increase the value of the count by 1     if($count==$max_items) break; //Break the loop is count is equal to the max_loop     }         echo $html;      }


Is there an easy way of exporting posts with their category already asigned and pictures from localhost?

Every time I export a database using the Export Tool in wp-admin. There are two things left out: The category 'checked' (I have to do that all over again every time I export the posts). Also I can't download the pictures because I usually work in my localhost. How to export absolutely everything (100%) from the database of a Wordpress site?


Comment Form - E-mail Not Required!

I need to know how to make one of the fields on my comment not NOT required. How can I set the e-mail field in the comment field to not be required, but optional?


How to make a pulldown menu display custom meta terms in a theme?

I have a pulldown menu in a custom write box that classification numbers. How can I populate a select box on the front end that will: a) be populated with all the possible values defined in the functions script b) have the value chosen in wp-admin be selected on page load in the pulldown menu? This question piggybacks on my how to add a select menu to a custom meta box that was answered (perfectly) by בניית אתרים. My cpt meta box code:               function inventory_information() {         global $post;              echo '<input type="hidden" name="inventorymeta_noncename" id="inventorymeta_noncename" value="' .         wp_create_nonce( plugin_basename(__FILE__) ) . '" />';              $stocknum = get_post_meta($post->ID, '_dappcf_i_stocknum', true);         $vin = get_post_meta($post->ID, '_dappcf_i_vin', true);         $my_dropdown = get_post_meta($post->ID, '_dappcf_i_dropdown', true);              echo '
Stock #: <input type="text" name="_dappcf_i_stocknum" value="' . $stocknum  . '" class="widefat" style="width:80px" />          VIN: <input type="text" name="_dappcf_i_vin" value="' . $vin  . '" class="widefat"  style="width:200px" />
';              echo '
Inventory class: <select name="_dappcf_i_dropdown" class="widefat">';         echo '<option value="1"'. $my_dropdown == "1" ? ' selected="selected"' : ''. '>' . 'Option 1'. '</option>';         echo '<option value="2"'. $my_dropdown == "2" ? ' selected="selected"' : ''. '>' . 'Option 2'. '</option>';          echo '<option value="3"'. $my_dropdown == "3" ? ' selected="selected"' : ''. '>' . 'Option 3'. '</option>';          echo '<option value="4"'. $my_dropdown == "4" ? ' selected="selected"' : ''. '>' . 'Option 4'. '</option>';          echo '</select>
';     }          function txpbs_save_events_meta($post_id, $post) {         if ( !wp_verify_nonce( $_POST['inventorymeta_noncename'], plugin_basename(__FILE__) )) {         return $post->ID;         }         if ( !current_user_can( 'edit_post', $post->ID ))     return $post->ID;              $station_meta['_dappcf_i_stocknum'] = $_POST['_dappcf_i_stocknum'];         $station_meta['_dappcf_i_vin'] = $_POST['_dappcf_i_vin'];         $station_meta['_dappcf_i_dropdown'] = $_POST['_dappcf_i_dropdown'];              foreach ($station_meta as $key => $value) {     if( $post->post_type == 'revision' ) return;     $value = implode(',', (array)$value);      if(get_post_meta($post->ID, $key, FALSE)) {         update_post_meta($post->ID, $key, $value);     } else {         add_post_meta($post->ID, $key, $value);     }     if(!$value) delete_post_meta($post->ID, $key);         }          }      And I use this code to call my custom fields when displayed in an input field:               <?php echo get_post_meta($post->ID, '_dappcf_i_dropdown', true); ?>      Any direction is greatly appreciated.


Multiple Post Thumbnails plugin and attachment error

This question specifically deals with the Multiple Post Thumbnails plugin, though the problem may have to do with my installation of WP itself as nobody else seems to have had this problem. I am using WP 3.0.5, completely stock with the exception of the plugin. As per the instructions, I am initializing the plugin as such:               $video_thumb_secondary = new MultiPostThumbnails(array(             'label' => 'Thumbnail Image',             'id' => 'video-thumbnail',             'post_type' => 'video'     ));      The code above is called in a function run during the admin_menu hook. When attempting to upload/select an image and then clicking on 'Use as thumbnail image' I get the following error: "Could not set that as the thumbnail image. Try a different attachment." I have also tried initializing the plugin with the default 'post_type' of 'post' and have run into the same error. As I said, I have seen no other documented cases of this error with this plugin, and hardly any at all of this error in general with WP. Hoping somebody can shed some light on it... ** **EDIT** ** Resolved my own issue. The code above must be run outside of any function in your functions.php file. I naturally assumed that it should be defined in one of the admin menu hooks, but that is not the case.


How to get WP Customer Reviews average and aggregated reviews

http://wordpress.org/plugins/wp-customer-reviews/ I am using this plugin but they don't support getting the average and the aggregated reviews at their current version, but probably by their next release 3.0 version. A programmer who studied their code was able to get **it**. The code below shows how he did it, sorry I forgot the name of the programmer. What I did I copy and pasted his code to my post and place it in the HTML editor.               global $wpdb;     $id = get_the_ID();     $pId = $post->$id; //if using in another page, use the ID of the post/page you want to show ratings for.     $row = $wpdb->get_results("SELECT COUNT(*) AS `total`,AVG(review_rating) AS `aggregate_rating`,MAX(review_rating) AS `max_rating` FROM wp_wpcreviews WHERE `page_id`= $pId AND `status`=1");     $max_rating = $row[0]->max_rating;     $aggregate_rating = $row[0]->aggregate_rating;     $total_reviews = $row[0]->total;     $totl = $aggregate_rating * 20;     $wpdb->flush();      This code I got it from my research: `get_the_ID()` where you can get the post's ID dynamically. This is how you display the result above:

<div style="width: <?php echo $totl;?>%">

<?php echo ' ' . $total_reviews;?> Reviews
      I am not sure where did I got wrong with this, having a little knowledge with php and wordpress. What I can see is just the php code being displayed as text inside my post.


Dynamically generated URL and Content page

I am in need of some advice. I have a section on my home page dynamically pulling in a list of terms from a custom table in the WP db. I have made a unique custom URL for each of these terms based on test code:               <a href="<?php bloginfo('url'); ?>/test-directory/test-code/<?php echo      $record->test_code; ?>"        This works fine. My next step is to have these URL's when clicked load the accompanying dynamic content into a template. I tried the code below to create rewrite rules to point to a template but it just isn't working. It doesn't load the template but the default blog template. I am using a child theme but this should work:               function my_add_query_vars( $qvars ) {          $qvars[] = 'test-directory';              $qvars[] = 'test-code';              return $qvars;          }          add_action('query_vars', 'my_add_query_vars');               function my_add_rewrite_rules( $wp_rewrite )    {              $newrules = array();              $new_rules['^test-directory/(.*)/(.*)'] = 'index.php?test-directory=$matches[1]test-code=$matches[2]';              $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;          }          add_action('generate_rewrite_rules', 'my_add_rewrite_rules');                    function my_template_redirect() {              if( get_query_var('test-code') ) {                  include_once(locate_template('template-faq-fullwidth.php', true));                  exit();              }          }          add_action('template_redirect','template_redirect');      Any help is appreciated as always.Thanks.


Terms from current post custom taxonomy -- excluding parent and only from a single parent term

The title sounds complex but this is quite simple. Hopefully the code for it is too. I have this custom taxonomy we'll call "Filters".   * ParentTerm A      * ChildTerm 1A     * ChildTerm 2A   * Parent Term B      * Child Term 1B     * Child Term 2B On a page that has a listing of custom post types, I was easily able to display all the terms selected for the "Filters" taxonomy by putting this in my loop/query:               <?php     $terms = get_the_terms( $post->ID, 'filters' );                      if ( $terms && ! is_wp_error( $terms ) ) :          $listing_filters = array();         foreach ( $terms as $term ) {             $listing_filters[] = $term->name;         }                            $listing_filters = join( ", ", $listing_filters );     ?>
<?php echo $listing_filters; ?>
     <?php endif; ?>      The PROBLEM is for this page I only want to display the terms selected under **_ParentTerm A_**. So _ChildTerm 1A_ and _ChildTerm 2A_ would display if they were checked off. But no other terms would display, not ParentTerm A, nor of course any terms in Parent Term B. However as noted with the above code I of course get any and all selected terms for this custom taxonomy. Any ideas? Thanks!!


Can I change the "Home" text in the menu?

I’m pretty sure this can be done with a filter or some kind of find and replace, but I’m not sure how. I have a page called “Home” like so: ![Screenshot](http://i.stack.imgur.com/GHOmT.jpg) When the link is displayed in my template it says “Home”. I’d like it to say “About Us”. I want the user to know which page the homepage is in the Page Overview panel, but I’d like to be able to name it whatever I like in my template without displaying the word "Home". Any ideas?


Custom bulk actions in WP 3.7.1

So I am trying to get a custom bulk action to work in Wordpress 3.7.1 and so far no luck. The basis I am using is http://www.skyverge.com/blog/add-custom- bulk-action, and it goes wrong here:               $wp_list_table = _get_list_table('WP_Posts_List_Table');     $action = $wp_list_table->current_action();      The action itself is added with jQuery and does show. When I use a prompt to show the `$action` value it is always empty, which means the rest of the script does not fire. Any idea here? The entire code:               <?php     /*     Plugin Name: FoxRunSoftware Custom Bulk Action Demo     Plugin URI: http://www.foxrunsoftware.net/articles/wordpress/add-custom-bulk-action/     Description: A working demonstration of a custom bulk action     Author: Justin Stern     Author URI: http://www.foxrunsoftware.net     Version: 0.1          Copyright: © 2012 Justin Stern (email : justin@foxrunsoftware.net)     License: GNU General Public License v3.0     License URI: http://www.gnu.org/licenses/gpl-3.0.html     */          if (!class_exists('FRS_Custom_Bulk_Action')) {              class FRS_Custom_Bulk_Action {                  public function __construct() {                      if(is_admin()) {                     // admin actions/filters                     add_action('admin_footer-edit.php', array(&$this, 'custom_bulk_admin_footer'));                     add_action('load-edit.php',         array(&$this,     'custom_bulk_action'));                 add_action('admin_notices',         array(&$this, 'custom_bulk_admin_notices'));             }         }                   /**          * Step 1: add the custom Bulk Action to the select menus          */         function custom_bulk_admin_footer() {             global $post_type;                  if($post_type == 'post') {                 ?>                                      <?php             }         }                   /**          * Step 2: handle the custom Bulk Action          *           * Based on the post http://wordpress.stackexchange.com/questions/29822/custom-bulk-action          */         function custom_bulk_action() {             global $typenow;             $post_type = $typenow;                  if($post_type == 'post') {                      // get the action                 $wp_list_table = _get_list_table('WP_Posts_List_Table');  // depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc                 $action = $wp_list_table->current_action();                      $allowed_actions = array("export");                 if(!in_array($action, $allowed_actions)) return;                      // security check                 check_admin_referer('bulk-posts');                      // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'                 if(isset($_REQUEST['post'])) {                     $post_ids = array_map('intval', $_REQUEST['post']);                 }                      if(empty($post_ids)) return;                      // this is based on wp-admin/edit.php                 $sendback = remove_query_arg( array('exported', 'untrashed', 'deleted', 'ids'), wp_get_referer() );                 if ( ! $sendback )                     $sendback = admin_url( "edit.php?post_type=$post_type" );                      $pagenum = $wp_list_table->get_pagenum();                 $sendback = add_query_arg( 'paged', $pagenum, $sendback );                      switch($action) {                     case 'export':                              // if we set up user permissions/capabilities, the code might look like:                         //if ( !current_user_can($post_type_object->cap->export_post, $post_id) )                         //  wp_die( __('You are not allowed to export this post.') );                              $exported = 0;                         foreach( $post_ids as $post_id ) {                                  if ( !$this->perform_export($post_id) )                                 wp_die( __('Error exporting post.') );                                  $exported++;                         }                              $sendback = add_query_arg( array('exported' => $exported, 'ids' => join(',', $post_ids) ), $sendback );                     break;                          default: return;                 }                      $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );                      wp_redirect($sendback);                 exit();             }         }                   /**          * Step 3: display an admin notice on the Posts page after exporting          */         function custom_bulk_admin_notices() {             global $post_type, $pagenow;                  if($pagenow == 'edit.php' && $post_type == 'post' && isset($_REQUEST['exported']) && (int) $_REQUEST['exported']) {                 $message = sprintf( _n( 'Post exported.', '%s posts exported.', $_REQUEST['exported'] ), number_format_i18n( $_REQUEST['exported'] ) );                 echo "

{$message}

";             }         }              function perform_export($post_id) {             // do whatever work needs to be done             return true;         }     }     }          new FRS_Custom_Bulk_Action();      Well there is some more info, it seems to me that WP_List_Table just returns empty values. The following is the content of $wp_list_table, any ideas?:               object(WP_Posts_List_Table)#8848 (10) {          ["hierarchical_display"]=> NULL          ["comment_pending_count"]=> NULL          ["user_posts_count"]=> NULL          ["sticky_posts_count"]=> int(0)          ["items"]=> NULL          ["_args"]=> array(4) {              ["plural"]=> string(5) "posts"              ["singular"]=> string(0) ""              ["ajax"]=> bool(false)              ["screen"]=> object(WP_Screen)#8846 (16) {                  ["action"]=> string(0) ""                  ["base"]=> string(4) "edit"                  ["columns":"WP_Screen":private]=> int(0)                  ["id"]=> string(15) "edit-shop_order"                  ["in_admin":protected]=> string(4) "site"                  ["is_network"]=> bool(false)                  ["is_user"]=> bool(false)                  ["parent_base"]=> NULL                  ["parent_file"]=> NULL                  ["post_type"]=> string(10) "shop_order"                  ["taxonomy"]=> string(0) ""                  ["_help_tabs":"WP_Screen":private]=> array(0) { }                  ["_help_sidebar":"WP_Screen":private]=> string(0) ""                  ["_options":"WP_Screen":private]=> array(0) { }                  ["_show_screen_options":"WP_Screen":private]=> NULL                  ["_screen_settings":"WP_Screen":private]=> NULL              }          }          ["_pagination_args"]=> array(0) { }          ["screen"]=> object(WP_Screen)#8846 (16) {              ["action"]=> string(0) ""              ["base"]=> string(4) "edit"              ["columns":"WP_Screen":private]=> int(0)              ["id"]=> string(15) "edit-shop_order"              ["in_admin":protected]=> string(4) "site"              ["is_network"]=> bool(false)              ["is_user"]=> bool(false)              ["parent_base"]=> NULL              ["parent_file"]=> NULL              ["post_type"]=> string(10) "shop_order"              ["taxonomy"]=> string(0) ""              ["_help_tabs":"WP_Screen":private]=> array(0) { }              ["_help_sidebar":"WP_Screen":private]=> string(0) ""              ["_options":"WP_Screen":private]=> array(0) { }              ["_show_screen_options":"WP_Screen":private]=> NULL              ["_screen_settings":"WP_Screen":private]=> NULL          }          ["_actions"]=> NULL ["_pagination"]=> NULL      }


I need to insert a captcha for all comments in word press

Hi I am new to word press. I need to insert captcha for all the comments wherever seen in word press theme. How can I do it. Please help me.


meta fields for the whole wordpress site

Is there a simple way to store additional information related to the whole website in a meta field? For users, comments or posts, I learned how to use meta fields to store their additional related information, but sometimes I need to have growing arrays that contain additional information about the whole website. Your clarifications are appreciated.


use more than one meta key in query using posts_where

Here I want to add query for more then one meta key as here:               $where .= " AND meta_key='order_assign_delivery_date' AND meta_value LIKE '0000%' And meta_key='order_assign_data' AND meta_value=0";      so now how to do this? above query not working and that's obvious Please guide me how to use more than one meta_key in same query in posts_where filter


Applying OO patterns and principles to plugin development

I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a little uncertain how to structure a plugin using classes. I have a plugin class that takes care of hook registration in its constructor, and some worker classes like a mail queue and mailer, but I have one or two non-class scripts, mostly for forms, that I don't quite know how to neatly fit into classes. What resources are their I can consult for guidance on this aspect of my OO plugin? The plugin is for mass mailing, i.e. mailing to all subscribers, on schedule etc. It registers a custom post type for mail templates, with add new and edit capabilities, and it adds its own menu to the bottom of the admin menu, currently with two submenu pages: 'settings' and 'send mail'. It also adds an 'opt out' option to the user profile page, but that's quite tidy and easy to include the main plugin class.


save radio button selection in post-meta on submit

Right now I'm reading tags from the tag box, and putting them in a form with radio buttons so the user can choose a "main tag" from the tags they just typed in:               function write_tags(){         var rawtags = $j(".tagchecklist").find("span").text();          var stags = rawtags.split("X");         var ftags = stags.slice(1);              document.getElementById('tag_options').innerHTML = '';              $j.each( ftags, function(i, l){             $j("#tag_options").append('<input type="radio" name="mainTagButtons" value="' + i + '" /> '+ l +'<br />');         });          }       Now that I have these displayed and selectable, I have no idea how to save the selection to post meta, or how to check the value there to see if it's saved. First I tried this:               if (!empty($_POST['mainTagButtons'])) {       $this->data['mainTag'] = $_POST['mainTagButtons']; }               if ( isset($this->data) && $this->data != '' )         update_post_meta($id, 'mainTag', $this->data);      But I'm not sure how to test to see if it worked. Any ideas?


How to cause the Wordpress web interface to update via FTP

On some installations of Wordpress, all updates performed through the administrative web interface require the FTP username and password to be entered before they take place. Others update and install themes/plugins just fine without needing FTP information. I'd like to test some permissions hunches by forcing the web administrative interface to update via FTP. Is this possible? ( **Note:** Certainly using a regular FTP client would work, but I'd like to keep the client away from as many additional steps and applications as possible. Keeping them to the web interface would make life... simpler.)


How can I search an FAQ before a contact form is submitted?

I receive many queries via a contact form (Contact Form 7) that are similar in nature. I'm planning to implement an FAQ on my site, so visitors can check for information there. Of course, I still want visitors to be able to contact me, but it would be really useful if I could suggest FAQ articles to visitors before they submit a contact form, based on what they have written. How would I go about implementing something like this for Wordpress 3.x? Could it be done using my existing contact form plugin or must I look at a new approach entirely? I haven't decided on an FAQ plugin yet.


Adding specific post category between posts in loop

I'm building a site built on a masonry theme and would like to add a specific category of post ('Sponsors' in this case) after every 3rd post. An example would go: Post Post Post   Sponsor Post Post   Post Sponsor Post   Post Post Sponsor I've searched quite abit for a similar problem but the closest I can find is for placing an ad such as below. However I'd like to replace the ad with a category post.               <?php     $count=0;     // Begin loop     while ( have_posts() ) : the_post();     $count++;     get_template_part( 'content', get_post_format() );     if ( $count%3==0 ) {     echo 'AD';     }     endwhile; ?>      I'm still a total beginner in programming (especially php and wp) but I have a few ideas of how it could be accomplished. I've tried many different ways but I'm basically shooting in the dark. This is the basic idea of what I've tried ("Sponsors" is cat=22).               <?php $count=0;     while ( have_posts() ) : the_post();     count++;     if ($count%3==0) {        <?php query_posts($query_string . '&cat=22&posts_per_page=1'); ?>        get_template_part( 'content', get_post_format() );     else        <?php query_posts($query_string . '&cat=-22&posts_per_page=1'); ?>        get_template_part( 'content', get_post_format() );     ?>      This obviously doesn't work (query_posts shouldn't be used in a loop?) but I hope it shows some of my thought process. I haven't been able to find a way to exclude a category from a loop already running. Another idea I had would be 2 loops where the first loop excludes the "Sponsor" category and posts 3 times and then a second loop which only posts 1 post from "Sponsor". However when I do this, I don't know how to make this cycle repeat itself (ie. only 4 posts show up). How would I go about doing this? I appreciate the help!


Add code to admin bar only

I am trying to add a QR code to the bar and I can do this but it's my first time to make a WordPress plug-in and I'm having trouble. It ends up showing to everyone even if they are not an admin or even not logged in. Any ideas or guidance would be very grateful.               function selfURL() {         $s = empty($_SERVER["HTTPS"]) ? ''             : ($_SERVER["HTTPS"] == "on") ? "s"             : "";         $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;         $port = ($_SERVER["SERVER_PORT"] == "80") ? ""             : (":".$_SERVER["SERVER_PORT"]);         return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];     }     function strleft($s1, $s2) {         return substr($s1, 0, strpos($s1, $s2));     }          $urlToEncode=(selfURL());          generateQRwithGoogle($urlToEncode);     function generateQRwithGoogle($url,$widthHeight ='30',$EC_level='L',$margin='0') {         $url = urlencode($url);          echo '<img src="http://chart.apis.google.com/chart?chs='.$widthHeight.     'x'.$widthHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.     '&chl='.$url.'" alt="QR code" widthHeight="'.$widthHeight.     '" widthHeight="'.$widthHeight.' "/>';     }


display public excerpt for private post

Thank you in advanced. I know there are plugins that can do this, but I am looking for a simple solution for my function file. I would like to display the excerpt for all posts with the more tag for public visitors, even for private posts.


How to Remove all Instances of edit_post_link

Can someone please assist with how to remove from my theme, whilst in author mode, the edit_post_link (Edit link), throughout all my pages. Which php files in the Twenty Eleven theme (WordPress v3.2) do I need to comment out to no longer display this edit link? I realise that you only see this during author mode but would like to know how to remove altogether. Thanks.


Is it necessary to translate WordPress key terms when localizing a plugin

In translating a plugin, how should "WordPress" key terms be handled? For instance, should the following need translations or should they be left as is:   * Taxonomy   * Custom Post Type   * Taxonomy Term   * Plugin Since these terms all have very specific meanings and are documented within the Codex using these English words, would it make more sense to just leave them in English as opposed to translating them? I almost think of these words as proper nouns that would not be changed when translated.


Need help fixing sql syntax error after WP 3.2 upgrade

I'm using a plugin that failed after upgrade to wp3.2. The error log shows: > 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 '' at line 1 for `query SELECT post_id, meta_value, post_status > FROM bxxoai_postmeta LEFT JOIN bxxoai_posts ON post_id=bxxoai_posts.ID WHERE > post_status='publish' AND meta_key='wpfp_favorites' AND meta_value > 0 ORDER > BY ROUND(meta_value) DESC LIMIT 0, made by require, require_once, include, > get_header, locate_template, load_template, require_once, get_sidebar, > locate_template, load_template, require_once, wpfp_widget_view, > wpfp_list_most_favorited` mysql version I used is 5.0.92-community I'm clueless with database, can anyone please teach or help explain to me what needed to be done to fix this?


Strange bug on post/page save

I have a srtange bug when I try to save/update a post. Every time I got this alert: "Are you sure to live this page?...." I've switched tothe original theme, disabled almost all plugins but nothing work. Any ideas how to fix that?


Wordpress 3.2 has broken my TinyMCE code

My code was working up until the 3.2 update, where I noticed that tinyMCE has been updated too. Does anyone have any ideas why this may not work now? I don't get any console errors but I don't get any tinyMCE editors on the page either! **CLARIFICATION: every instance of the TinyMCE editor has disappeared!** **FURTHER CLARIFICATION: this is only occurring on my custom post type pages where I have custom instances of the TinyMCE editor. I still have the default "theEditor" MCE on the default Posts area.**               function meta_genus_species() {         global $post;              $genus = get_post_custom_values( 'genus', $post->ID );         $species = get_post_custom_values( 'species', $post->ID );         $etymology = get_post_custom_values( 'etymology', $post->ID );         $family = get_post_custom_values( 'family', $post->ID );         $common_names = get_post_custom_values( 'common_names', $post->ID );              if (!isset($id)) { $id = "etymology"; }         if (!isset($temp_min)) { $temp_min = plugins_url('images/temp_max.png' , __FILE__); }         if (!isset($temp_max)) { $temp_max = plugins_url('images/temp_min.png' , __FILE__); }         if (!isset($pH_min)) { $pH_min = plugins_url('images/pH_max.png' , __FILE__); }         if (!isset($pH_max)) { $pH_max = plugins_url('images/pH_max.png' , __FILE__); }          $tinyMCE = <<<EOT              EOT;         echo $tinyMCE;              ?>

Description of taxonomy.

             Genus
                 <input name="genus" class="text" value="<?php if(isset($genus[0])) { echo esc_attr( $genus[0] ); } ?>" />                 Testing...

             Species
                 <input name="species" class="text"  value="<?php if(isset($species[0])) { echo esc_attr( $species[0] ); } ?>" />                 Testing...

             Etymology             <textarea cols="50" rows="5" name="etymology" id="etymology"><?php if(isset($etymology[0])) { echo esc_attr( $etymology[0] ); } ?></textarea>             Description

             Family             <input name="family" class="text"  value="<?php if(isset($family[0])) { echo esc_attr( $family[0] ); } ?>" />             Description

             Common Names             <input name="common_names" class="text"  value="<?php if(isset($common_names[0])) { echo esc_attr( $common_names[0] ); } ?>" />             Description

         <?php          }          function meta_authored() {         global $post;              $species_author = get_post_custom_values( 'species_author', $post->ID );         $year_described = get_post_custom_values( 'year_described', $post->ID );              ?>
         Species Author
             <input name="species_author" class="text" value="<?php if(isset($species_author[0])) { echo esc_attr( $species_author[0] ); } ?>" />
         Year Described
             <input name="year_described" class="text" value="<?php if(isset($year_described[0])) { echo esc_attr( $year_described[0] ); } ?>" />

         <?php     }


Find which Permalink structure is the best

I have the following permalinks structure in mind for a new blog, now instead getting theoretical answers on which is best, i would like to find myself which is best in terms of speed. How can i find this? I tried using get_num_queries() but i find the results varying each time i access the blog. Note: I am running a local XAMPP installation with WordPress on it and i am new to PHP, so any guidance is much appreciated. /%postname%/ /%post_id%//%postname%/ /%post_id%/%postname%/ /%category%/%postname%/ I am expecting 5000 plus posts but pages wont exceed 10. Thought this might also help someone when replying back to my query. Thank You.


Looping Next/Prev Link for custom post type

Strange error with custom post type next/prev. Trying to ge tthe first post if youre on the last one and the last post if youre on the first one. The posts per page is set to 100 but it seems to only grab 10. There are 13 posts, if i'm on the first page, the prev page is number 10. Here is the function im using.               function mod_get_adjacent_post($direction = 'prev', $post_types = 'post') {         global $post, $wpdb;              if(empty($post)) return NULL;         if(!$post_types) return NULL;              if(is_array($post_types)){             $txt = '';             for($i = 0; $i <= count($post_types) - 1; $i++){                 $txt .= "'".$post_types[$i]."'";                 if($i != count($post_types) - 1) $txt .= ', ';             }             $post_types = $txt;         }              $current_post_date = $post->post_date;              $join = '';         $in_same_cat = TRUE;         $excluded_categories = 'post';         $adjacent = $direction == 'prev' ? 'previous' : 'next';         $op = $direction == 'prev' ? '<' : '>';         $order = $direction == 'prev' ? 'ASC' : 'DESC';              $join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories );         $where = apply_filters( "get_{$adjacent}_post_where", "WHERE p.post_status = 'publish'" );         $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.menu_order $order LIMIT 1" );              $query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort";         $query_key = 'adjacent_post_' . md5($query);         $result = wp_cache_get($query_key, 'counts');         if ( false !== $result )             return $result;              $result = $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");         if ( null === $result )             $result = '';              wp_cache_set($query_key, $result, 'counts');         return $result;     }


Remove entry content from homepage index with infinite scroll

I have a WP theme (built on top of Genesis) and I'm having a problem with posts that are loaded on the homepage index with infinite scroll. Essentially, I'm only showing the article title, date, author and category in my main feed. So, the function attached below works perfectly to remove the entry content, but it only does so on the **first** page. How can I adapt this function to prevent pages loaded by the infinite scroll from loading excerpts? My temporary fix is to hide via CSS, but infinite scroll paginates HTML so i have to create a long chain of CSS.I've attached screenshots with the css 'display:none' on and off for illustration of the issue.               add_action('genesis_before','remove_some_actitons');          function remove_some_actitons() {            if ( is_home() )  {           remove_action( 'genesis_entry_content', 'genesis_do_post_content' );         }              }      Here is the sample css I'm using (and so on...) :               #infinite-view-2 .entry-content, #infinite-view-3 .entry-content, #infinite-view-4 .entry-content,#infinite-view-5 .entry-content,#infinite-view-6 .entry-content {         display: none;      }      ![enter image description here](http://i.stack.imgur.com/LdN9V.png) ![enter image description here](http://i.stack.imgur.com/39ohd.png)


Upload unnattached image from frontend

I am using the below function to let users upload files from the front end. It works great except that I would like the file to NOT be attached to any post. Currently, the file is automatically attaching itself to the page that I'm using for uploads (mysite.com/publish). I would like it to just be unattached instead. What should I change below to make that work? Here is the functions:                   // Uploads images from the front-end          function insert_attachment($file_handler,$post_id,$setthumb='false') {          // check to make sure its a successful upload     if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();          require_once(ABSPATH . "wp-admin" . '/includes/image.php');     require_once(ABSPATH . "wp-admin" . '/includes/file.php');     require_once(ABSPATH . "wp-admin" . '/includes/media.php');          $attach_id = media_handle_upload( $file_handler, $post_id );          if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);     return $attach_id;     }


Admin option sidebar count

I need to add a count number to a option menu item in the admin sidebar. How is this done? **I found a similar post:** Modifying admin sidebar contents to show pending posts indicator


How to disable fancybox on small screens

I'm using the plugin "Fancybox for Wordpress" in WP 3.5.1. On small screens, I want to disable the fancybox-script. So, at top of header-file, I include a check for user agent, and sets global variable `$is_mobile` `true` or `false`. This works. However, depending on this, I would like to add something like this to `functions.php` to disable the script on mobile devices.               $is_mobile;     function is_mobile() {     if ($is_mobile==true) {         remove_action('wp_print_scripts', 'mfbfw_load');         remove_action('wp_print_styles', 'mfbfw_css');         remove_action('wp_head', 'mfbfw_init');          } else {$is_mobile = "false"; }          return $is_mobile;     }          add_action('wp_head', 'is_mobile', 1);      This doesn't work, maybe because `functions.php` is loaded before `header.php`. However, it also doesn't work if I include the check for useragent into the function. Anyway, the variable `$is_mobile` is not recognized as a global in `header.php`.


Advanced AND tax_query in sidebar with 2 taxonomies

I have two taxonomy : brand and product. In single sidebar I am displaying the brand and product of the post in the sidebar but I would like to display all the other product of the current taxonomy term brand. This is what I'am going to try but I have no error and it return nothing :               <?php     // get current taxonomy product term     $post_product = get_the_term_list($post->ID, 'product', '', ', ');     echo 'Product : '.$post_marque;          // get current taxonomy brand term     $post_brand = get_the_term_list($post->ID, 'brand', '', ', ');      echo 'Brand : '.$post_brand;          // make the custom query       $do_not_duplicate = $post->ID;                 $taxquery = new WP_Query( $taxquery_args ); while($taxquery->have_posts()) : $taxquery->the_post();                       if( $post->ID == $do_not_duplicate ) continue;                      $taxquery_args = array(                          'post_type'      => 'any',                      'posts_per_page' => 10,                          'tax_query' => array(                              'relation' => 'AND',                         array(                             'taxonomy' => 'brand',                             'field' => 'slug',                             'terms' => $post_marque                         )                         ,                         array(                             'taxonomy' => 'product',                             'field' => 'slug',                             'terms' => $post_product                         )                     )                 );                      the_permalink();                 var_dump($taxquery);                      endwhile;  wp_reset_postdata(); ?>      How to return all taxonomy product terms execpt current post term who have current taxonomy brand term of the post ? Is it possible to return term->name and term-slug ? Screenshot This is a screenshot, for exemple current post will have taxonomy term brand = Antec and taxonomy product term = P280 and I would like to have all product terms with brand term 'Antec' by term->name except 'P280', so the result shoud return this terms : iSO, GX700, etc...


How to change upload dir for custom plugin?

I like to change the media upload directory for my custom plugin. Now i am testing with this in functions.php                function custom_upload_directory( $args ) {         // Check for our plugin pages         if (($_GET['page']=="contender_add") || ($_GET['page']=="contender_edit")){             $args['path'] = plugin_dir_path(__FILE__) . "uploads/test";             $args['url']  = plugin_dir_url(__FILE__) . "uploads/test";             $args['basedir'] = plugin_dir_path(__FILE__) . "uploads/test";             $args['baseurl'] = plugin_dir_url(__FILE__) . "uploads/test";         }         return $args;     }          add_filter( 'upload_dir', 'custom_upload_directory' );      Also how do add my custom upload folder to the media uploader library tab? Regards


How to create category page

Anybody could help me to make a category page only. Thank you.


Weird Parse Error on Uploaded File

so I'm working on this theme on my localhost, and I just uploaded it to see if it'd work and I'm getting a weird parse error for these lines in my functions.php file. It works fine on my localhost though:               $next = isset($_POST['next']) ? $_POST['next'] : false;     $prev = isset($_POST['prev']) ? $_POST['prev'] : false;          $nexp = explode('=', explode('?', $next)[1])[1];     $pexp = explode('=', explode('?', $prev)[1])[1];      It says, unexpected '[' on the line starting with $nexp and $pexp. I'm a bit confused (and tired), and I don't really see what the problem with this line is, and why it would work on localhost but not on the server. Any help would be appreciated.


Can i Use own Facebook App ID with this Social Comment Plugin?

Is it possible to connect the plugin with an own Facebook App ID? In this way it would be entirely clear that this App belongs to the respective blog. Beyond that, if I have other Facebook stuff on the blog, which requires a Facebook Connect, the user only has to authenticate once with one app. So in this way an app could handle all the Facebook stuff that happend on the blog. To Alex an his Team: Just a great piece of work! This plugin is exactly what I was looking for! Thanks for sharing it. http://wordpress.org/extend/plugins/social/


wordpress plugin to add images to main navigation menu

Please advise about wordpress plugin to add multi states images to the main navigation menu I need to be able to add images on top of text for normal, hover and current state. Thanks


How can I replace my primary url globally with a parked one?

Ok so long story short, someone on our team accidentally got the domain we wanted booked on wordpress.com and not with a host for wordpress. ooopssss We've got a slightly inferior domain booked with a host now, and we've got the superior domain parked on that host now. Good, right? you can follow either url to our site and it works. So let's say: Superior domain: example.com Inferior domain: ex-ample.com Get the picture? PROBLEM: all the links in the site still direct to a url with a base of ex- ample.com, even though we want someone visiting the site to only be visiting pages headed with example.com. I hope I'm explaining myself well. once we get to http://ex-ample.com/page/subpage, we can remove the dash and it still works. but aesthetically, it's really unfortunate, and I want clicking the link that leads to /page/subpage to automatically be http://example.com/page/subpage. I feel like we could solve this by changing the home URL. I already followed instructions to change the site URL, but it seems that if we changed the HOME URL to our parked domain, the site breaks and directs to an ad-supported landing page about gardening. I've used FTP a couple times to reset both urls to ex-ample.com and try again, but it turns out it will only let us change the site url and not the home url, which doesn't really help us much anyway. I'm wondering if there's some kind of workaround to make a function that uses an alternate home_url() or something. any ideas? thanks so much Ben


add a menu item to navigation menu to link to external url

I followed this tutorial to add a menu item to navigation menu to link to external site: http://www.natenewz.com/2009/10/07/hardlink-wordpress-navigation/ I copied the snippet of code to my theme's header.php I created a page with the name having the text that I want to appear in the navigation I added a custom field to the page called redirect and placed the link url into the value field. And then tested and the link never appears in the menu.


Using attachment_fields_to_edit filter inside plugin class

I'm writing a plugin using OOP. I realise that filters and action hooks need to be placed inside the constructor method in WordPress like so:               add_action('wp_enqueue_scripts', array($this, 'add_js_css'));      As far as I understand, it should be the same for filters:               add_filter('attachment_fields_to_edit', array($this, 'attachment_fields', 15, 2));      The `attachment_fields()` method should return an array (I've tested it outside of the class and it works), but it seems to return `null` when called inside the class. I'm guessing it's because it's called inside of the class, but I'm not sure what to do about it! If it's useful, the method looks like this:               public function attachment_fields($form_fields) {         global $post;         $file = wp_get_attachment_url($post->ID);         unset($form_fields['post_excerpt']);         unset($form_fields['post_content']);         unset($form_fields['url']['helps']);         $form_fields['url']['label'] = 'URL';         $form_fields['url']['html'] = "<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($file) . "' /><br />";         $form_fields['buttons'] = array(         'label' => '',         'value' => '',         'html' => "<input type='submit' class='button' name='send[$post->ID]' value='" . esc_attr__( 'Add MP3' ) . "' />",         'input' => 'html'         );         return $form_fields;     }      Any advice?


Get date function not working

I have a function to get the date. I have input fields and want the date in this fields. But my code is set a wrong date. I set the date in Wordpress settings and on my server. But it is not working. This is my script:               function get_agenda_item_day() {         global $post;                   $cp_date = get_post_meta($post->ID, 'cp_date_end', true);              $cp_date_arr = explode("-",$cp_date);             $day = $cp_date_arr[2];              return $day;     }      And i use this in my select tag:               <?php $day = get_the_time('j'); ?>      <select name="ad" id="ad" onChange="getNDay()" class="select select-n">                         <option <?php if($day == 1) {echo 'selected="selected"';} ?> value="1">1</option>                         <option <?php if($day == 2) {echo 'selected="selected"';} ?> value="2">2</option>                         <option <?php if($day == 3) {echo 'selected="selected"';} ?> value="3">3</option>                         <option <?php if($day == 4) {echo 'selected="selected"';} ?> value="4">4</option>     etc etc etc     </select>      But, what do i wrong. Always the date is 17 juni in the select box. Because today the date is 5 Juli. Thanks for help


How to rewrite AJAX call URL to admin-ajax.php to match REST style URLs

Let's say I have an AJAX callback setup using admin-ajax.php that fetches WordPress posts when query parameters are passed in the URL. A typical URL for an AJAX call using the GET method would look like: `http://example.com/wp-admin/admin-ajax.php/?action=get_posts&user_id=1` Now I would like to rewrite this to something like: `http://example.com/rest/posts/1` I'm able to rewrite URL for pages using WordPress native `generate_rewrite_rules` hook. But that doesn't work for admin-ajax.php as Wordress hasn't even loaded when admin-ajax.php is called. Any ideas on how to get this setup?


WordPress Cron Schedule the if and else statement

I have a custom php loop/function written that works in the following way               $start = strtotime(date("Y-m-d H:i:s", strtotime("+5 hours")));     $end = get_post_meta( $post->ID, '_limited_dates_to', true );     $remaining = $end - $start;      if ($end > $start) {         wp_set_post_terms( $post->ID, 'not active', 'product_tag', false );     } else {         wp_set_post_terms( $post->ID, 'active', 'product_tag', false );     }      Currently the loop works fine but it is attached with a timer as one can see easily in `$start` and `$end`. Now what I am trying to get here is something of a product expiry thing going on. I need the cron to work this if & else loop and automatically set the active or not active tags. How can this be achieved?   Currently I have to manually refresh the page so that the loop runs.


Moving variables from one page to another

How can I link to another WordPress page but move variables to it as well (preferably not through the address bar)?   For instance, I have on one page a list of shops in which a user should be able to click on a shop, which would then open the shop page with the correct data.   So the shop's id needs to move from the shops list page to the shop page.


Why Jetpack is missing the "Feedbacks" menu item?

Is there a known issue that would prevent the "Feedbacks" menu item from showing? I have two wordpress installs, one has the menu item the other doesn't. They both have the same plugins, theme, and scripts.


Rewrite category slug

I have some categories like so:               /europe/postname     /usa/postname      For various reasons I would like to rewrite these to be:               /news/view/postname      I've tried a few re-direct plugins but not had any success. Is this possible?


How can I added the post's Categories to the site's top menu (like a page)?

Instead of adding pages to the top menu, is there a way to add a dropdown menu with all the categories, or adding individual categories to the top navigation menu? I am using WP 3.9 with Shaken Grid Free theme.


how to return the wordpress path to the new site

Please how do i return to the default path something like this after working on the wordpress installation                 http://fittergroup.com/blog/   to  http://fittergroup.com/


search form leads to 404

I'm using the follow code in my functions.php to add a search box to my primary nav menu -               add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);             function add_search_box_to_menu( $items, $args ) {                 if( $args->theme_location == 'primary' )                     return $items."
<form action='search.php' id='searchform' method='get'><input type='text' name='s' id='s' placeholder='Search'></form>
";                      return $items;             }      The form adds to the nav menu ok, but any search attempt leads to a 404 message. What have I missed?


Custom Post Types strange pagination problem

Have a strange problem with pagination, the query work fine when I'm in homepage, but if click for the next page I get a `404` error. Disabling permalinks settings, I saw that in the query string (when I move on to the next page), then I have `?paged=2` as query argument, but not `post_type=job_listing` (in this case). Here is my code:               global $wp_query, $paged;          if ( get_query_var( 'paged' ) )         $paged = get_query_var( 'paged' );     else         $paged = 1;          if ( get_query_var( 'post_type' ) )         $post_type = get_query_var( 'post_type' );     else         $post_type = 'job_listing';          $args = array(        'post_type' => $post_type,        'paged'     => $paged,     );          query_posts( $args );      And then I have a normal loop cycle and a `wp_reset_query()` at the end. The problem is that when open a pagination link the url look like `www.example.com/?paged=2` and not `www.example.com/?post_type=job_listing&paged=2` which works if I type it manually. I tried everything to make it work but it keeps ignoring the `post_type` var in all pages.


Is there a way to have custom post type and page with the same slug?

I have a custom post type registered as follows:               register_post_type( 'news',         array(             'labels' => $labels,             'public' => true,             'show_ui' => true,             'menu_position' => 5,             'capability_type' => 'post',             'has_archive' => false,             'rewrite' => array('slug' => 'news'),             'hierarchical' => false,             'show_in_menu' => true,             'supports' => array( 'title', 'editor', 'thumbnail' )         )     );      My intent is to have the permalink /news/name-of-the-news-item for the post and a /news/ page listing all the news. I created a page with slug "news" and a template page for that but when I use the pagination to reach /news/page/2/ I get a 404, because it seems I cannot have a page and a custom post type with the same slug. Is there a workaround or a strategy to achieve the permalink structure I need? Note that I cannot use archive-news.php for the listing, bacause I also need a text in the page editable in WP admin. Thanks.


How do I enforce a specific custom post type on the loop

I am developing a blog where the main posts are of a custom post type. Let's assume it is a Book custom post type. I want the /author/admin page to list the books of the author admin, but instead, it goes and searches for Posts of admin, which is the built-in basic post type. How do I make my custom post type Book to be used in all such index queries? (main page, author, search, etc).


Using dividers in menu navigation - where to add code?

I've identified two methods of separating pages in nav menu on my blog (http://reasonandfolly.com) but cannot figure out what php or css file needs to be modified to achieve the result and will admit to not knowing the difference between "span class" and "span divider." Until I get a better handle on basic WP coding, I'd truly appreciate some help. Either of the below examples would fulfill my needs. The question is, how do I implement?   1. http://www.themezilla.com `< span class = " divider " > / < /span >`   2. http://chimpchomp.us `< span id = " divider " > // < /span >` This is the code currently in my header.php file:                  </div><!-- /logo -->                     <nav>                         <?php wp_nav_menu( array( 'menu' =>  __('Main Menu', 'meanthemes'), 'theme_location' => 'primary', 'container' => false, 'menu_id' => false, 'menu_class' => false ) ); ?>                     </nav><!-- /nav -->                 </div>               </header><!-- /header -->


Debug whats going on inside a function called from AJAX

I have a link on my post edit page (admin side) that calls up AJAX and jQuery to run a function inside my `functions.php` page. The link is wired up and calling the jQuery but I can't seem to debug whats going on inside my function thats being called from jQuery. I want the clicked link to delete custom metadata for the post (it is a custom post type) and then delete a file. Here's the code with the delete function at the end:               //Add AJAX functionality to post.php to delete files     add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts');     add_action('wp_ajax_delete_meta', 'delete_pdf_and_metadata');          //Add my custom JS to the header of admin     function my_admin_enqueue_scripts($hook) {         global $current_screen;              if ( 'post.php' != $hook )             return;         wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/my-scripts.js' );         wp_enqueue_script('my-scripts');         wp_localize_script('my-scripts', 'wp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));     }          function delete_pdf_and_metadata() {              global $post;              //delete metadata         $the_id = intval($_POST['the_id'] );         $the_pdf = get_post_meta($post->ID, $the_id);              delete_post_meta($post->ID, $the_id, $the_pdf['name']);              //TODO Delete PDF      }      Here's the jQuery call:               jQuery(document).ready(function($) {         $('.delete_pdf').each(function(i,e) { //grab the class delete-pdf             var id = $(this).attr('id').replace(/delete-/, '');             var li = $(this).closest('li');                  $(this).click(function(){                      $.post(ajaxurl, { action: 'delete_meta', the_id: id }, function(data){                          return id;                     });             });              });          });      Using FireBug all I see is for a response is 0. What is the best way to debug what is happening inside my function `delete_pdf_and_metadata()` being called via jQuery? Thanks!


Creating custom tags

Hi there Best Wordpress Gurus, i've a question about using tags to simplify my HTML. For example if i want to ad a block of content lets say a contact form. I don't want to ad all the time my html code can i use a tag something like: `#contact_form` and that this tag output a contactform for me. If this possible can someone please give me a link to tutorial or gives a example. Tnx in advance.


Using ajax with paging and a custom sub-query

I have a page that uses three queries to retrieve a variety of content. One of those queries grabs posts that are related to the topic of the page. Since these posts can be of all sorts and related through a variety of methods (various magic fields defined values, their category, etc.) I am using a custom query to grab them (something where I build some args and pass them to WP_Query() like so: `$collected_child_posts = new WP_Query($args);` Currently I return 5 results at a time (in my args I have `'posts_per_page' => 5`) and I want to page those results using ajax so that only that block of results updates when you click a `MORE POSTS` link. I implemented this by adding a url to the `MORE POSTS` button that looks like `?paged=n` and then having that retrieved via ajax. Problem is I get the entire page back (including the desired posts) when I only want the posts themselves. Any ideas on the best way to retrieve just those posts from the subquery without returning the entire page? Thanks!


How to Control CSS Class Visiblity From WordPress Admin Panel based on Tax Terms

Can you please let me know if it is possible to control Visibility of some html elements like and which are loading from an specific taxonomy terms meta data? I For Example I have two metadata as "Make" and "Year" for my custom post and I would like to ONLY hide the meta (Make and Year) for my post with specific Custom Taxonomy term = "Hback" (Not for any other terms) Thanks


What's the easiest way to periodically (automatically) read static Markdown content into a WP page?

I'd like to sync my theme's README.markdown into a page on my site and would _love_ to be able to only have to update that text a single time -- namely, when I commit my code up to BitBucket. I have my theme doing `hg pull -u` on a regular basis, so the code stays fresh and the README will get updated every time I make a change to the source, but my WordPress page containing the README then needs to get updated by hand. (I'm using Mark Jaquith's Markdown on Save to do the MD->HTML dance.) Any thoughts?


All Updated Plugins Disappeared

I had 5 plugins with updates. After updating all of them through the Available Updates tool they disappeared from the Network Plugins page. I received errors like this for all plugins:               The plugin custom-post-type-ui/custom-post-type-ui.php has been deactivated due to an error: Plugin file does not exist.      The folders still exist in /wp-content/plugins/ When I deleted the folders and uploaded them through FTP they do not appear on the Plugins page. When I install them through wp-admin I receive this log text:               Downloading install package from http://downloads.wordpress.org/plugin/custom-post-type-ui.zip…     Unpacking the package…     Installing the plugin…     Successfully installed the plugin Custom Post Type UI 0.7.1.     Network Activate | Return to Plugin Installer      But when I click Network Activate, I receive this error:               The plugin does not have a valid header.      This happens for all 5 plugins and only happened beginning today.


I've been out of the loop since 2.8. What did I miss?

I haven't done any serious WP development since version 2.8, although I fiddled a bit with version 3.0. Short of reading the release notes on each version, what are the major things to take note of as 1) a theme/plugin developer and 2) an administrator? I've already identified three things:   * Custom Post Types and Taxonomies   * Custom Menus   * Post Formats (a la Tumbr) What else do I need to take note of?


How to prevent specific plugin files or subfolders from appearing under "plugin files" listing

I have a folder inside my plugin that's used to store cached data for the application. There's no need for the user to edit these files so I'd like to remove this folder's files from appearing in the "Plugin files" listing that appears in the right sidebar when editing the plugin files via "Plugins > Editor". Is this possible?


Site only for users authenticated by different PHP application

I've got custom developed sales system (in PHP, let's say it's domain.com) and I would like to add informational section to it. Instead of developing it from the ground up I thought that it would be better to publish information by Wordpress (for example published on subdomain infos.domain.com). The problem is I would like to make it accessible only for users logged in to domain.com system. So when somebody enters infos.domain.com he sees some text like "Please login to domain.com". When somebody is logged in to domain.com he should be able to read all the pages in infos.domain.com. Commenting them is not necessary (read-only is enough). As I know Wordpress rather from administrator's perspective I tried to find some plugin to solve that, but I failed. Maybe you can advice some ready-made (evan paid) solution? If it does not exist please, advise how it could be solved. Login to domain.com is based on POST form and cookies, passwords in database are hashed with salt. domain.com system can be extended to provide some API.