Trouble with archive-posttype.php and single-posttype.php

I cant seen to get a single page for a custom post type to work. Ive tried both archive-transaction.php (transaction is the post type) and single- transaction.php and both give me a 404 when I try to look at the individual post in the post type (and both with an 's' on the end of transaction as well didnt work). Here is the function to make the Transactions post-type:               // Register Custom Post Type     function transactionsPost() {          $labels = array(         'name'                => _x( 'Transactions', 'Post Type General Name', 'text_domain' ),         'singular_name'       => _x( 'Transaction', 'Post Type Singular Name', 'text_domain' ),         'menu_name'           => __( 'Transactions', 'text_domain' ),         'parent_item_colon'   => __( 'Parent Transaction:', 'text_domain' ),         'all_items'           => __( 'All Transactions', 'text_domain' ),         'view_item'           => __( 'View Transaction', 'text_domain' ),         'add_new_item'        => __( 'Add New Transaction', 'text_domain' ),         'add_new'             => __( 'Add New', 'text_domain' ),         'edit_item'           => __( 'Edit Transaction', 'text_domain' ),         'update_item'         => __( 'Update Transaction', 'text_domain' ),         'search_items'        => __( 'Search Transactions', 'text_domain' ),         'not_found'           => __( 'Not found', 'text_domain' ),         'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),     );     $rewrite = array(         'slug'                => 'transaction',         'with_front'          => true,         'pages'               => true,         'feeds'               => true,     );     $args = array(         'label'               => __( 'transaction', 'text_domain' ),         'description'         => __( 'Transactions', 'text_domain' ),         'labels'              => $labels,         'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'custom-fields', ),         'taxonomies'          => array( 'category', 'post_tag' ),         'hierarchical'        => false,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 5,         'menu_icon'           => '',         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'query_var'           => '',         'rewrite'             => $rewrite,         'capability_type'     => 'page',     );     register_post_type( 'transaction', $args );          }          // Hook into the 'init' action     add_action( 'init', 'transactionsPost', 0 );


uploading images to specified directories

I am hoping that you can help me. I've tried finding plugins to do what I want to do but none of them really simplify the problem that I am trying to fix. I am trying to build a site for my photography business. So as you can imagine, I am going be uploading many images for review and public viewing. Sorting through these many photos in the standard media structure is a pain in the butt. I am attempting to learn how to code this myself, but I'm not sure which direction I need to take or how to accomplish my goal within wordpress. So I have two possible options I am thinking.   1. on my photo album custom post type I will have a custom taxonomy called client that will be selected. I will also be naming the album. So when I upload images to the directory I would like to see them placed in "uploads/client/%client_name%/%Post_name%/"   2. If it would be possible to simply upload all my albums already organized in their appropriate folder structure via ftp, and run a script that automatically creates the pages to display these albums, that could be a little easier. Though I would have to go back and insert the other gallery data.  you may notice that i have uploads/ client Client images obviously go here, but I will also have a folder for non-portraits and instead of %client_name% this would be %img_category%/%Post_name%/ This allows for a Image_type/Album/Gallery/image relationship let me know if anyone has a way to tackle this. I'm going try to use the "advance custom fields" plugin, or "Types" Plugin for the custom fields, but I may need to hand code something to get this functionality. I am still trying to get a handle on hooks and all in custom coding, so I'm not sure what file or function I would need to alter to accomplish this goal. Also, I dont mind if the other site files maintain the media folder structure, but they could also be altered perhaps to store files such as product images, logos, ect. They just won't be loaded in a gallery format A simple version of the loop that I think needs to happen is as follows: I know the actual code syntax is not there, but this should give a general idea what I'm thinking to make this work. Define $image_type Define $client or img_category Define $Post title $Img_directory= "uploads/$image_type./.$client./.$post_title./ For each image in $img_directory wrap in Div add buttons to comment, favorite, purchase, and social sharing Display each div in a gallery format1


WordPress post type "event" query string fix?

What am I doing wrong in this query? I want to select events from a custom post type called events and order by the event date and only show ones after the current date. It doesn't seem to work...               $querystr = "          SELECT $wpdb->posts.*      FROM $wpdb->posts, $wpdb->postmeta     WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id      AND $wpdb->postmeta.meta_key = 'wpcf-start-date'     AND $wpdb->postmeta.meta_value >= CURDATE()      AND $wpdb->posts.post_status = 'publish'     AND $wpdb->posts.post_type = 'events'     ORDER BY $wpdb->postmeta.meta_value ASC          ";


How to change a specific character in a theme option value - replace a space with a plus sign

I'm writing a theme where I'd like to give users the ability, via a theme option, to specify a typeface for their site with Google Web Fonts. If a user wants to embed a font like, say, News Cycle, then the code needs to specify this in two places, in a `<link>` tag within the `<head>`, and in the site's CSS. In the `<link>` tag, the font is specified with a `+` (plus sign) in the name:               <link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet' type='text/css'>      However, in the CSS, there is no plus sign:               h1 { font-family: 'News Cycle', arial, serif; }      Ideally I'd like users to just write or paste the name of the font into a form field, and then, in the code, to replace spaces with plus signs where needed. From googling around, I think this can be done with `str_replace` or another similar bit of PHP, but I'm a PHP novice. Can anyone shed some light on the best way to do this? At the moment the relevant PHP in my header.php looks a bit like this:               <?php           $options = get_option('mytheme_theme_options');          if( isset( $options['webfont'] ) && ( !empty( $options['webfont'] ) ) )        printf( "WEBFONT LINK", $options['webfont'] );          ?>      Thanks.


Being notified when some YouTube video in some post becomes unavailable

Is there a plugin or some PHP code that notifies you whenever a YouTube videos becomes unavailable in some post of a WordPress website ?


Recommende e commerce plugin for simple needs

I want to create a small ecommerce functionality for my site. Namely 4 products, payment via a Bank portal gateway. Nothing more. Which plugin do you recommend for such simple needs? Thanks


How to use a dedicated template for the Custom Post Type from a plugin?

I'm working through this tutorial on Custom Post Types (in a plugin) wherein the author demonstrates how to **force the use of a dedicated template for the Custom Post Type**. The author states thus: > The code (below) searches for the template `single-movie-reviews.php` in the > current theme directory. If it is not found then it looks into the plugin > directory for the template, which we supply as a part of the plugin. The > template_include hook was used to change the default behavior and enforce a > specific template. **Step 1: Added this code to my`plugin-name.php` file**               add_filter( 'template_include', 'include_reviews_template', 1 );     function include_reviews_template(){         if ( get_post_type() == 'reviews' ) {             if ( is_single() ) {                 // checks if the file exists in the theme first,                 // otherwise serve the file from the plugin                 if ( $theme_file = locate_template( array( 'single-movie-reviews.php' ) ) ) {                         $template_path = $theme_file;                     } else {                         $template_path = plugin_dir_path( __FILE__ ) . '/templates/single-movie-reviews.php';                 }             }         }         return $template_path;     }      **Step 2: Create the single-{custom-post-type}.php file.** Next, I created the requisite `single-movie-reviews.php` file and added it to `'/my-plugin/templates/'` directory. The author adds the following: > **Note:** You need to create a new page **from the dashboard** using the > newly created template. **The Problems**   1. The Page template does NOT show in the dashboard   2. When I visited the post I created using the Custom Post Type, it **does show** the post using the page template from the plugin. **_However_**... every other page _(i.e. pages **NOT** using the CPT)_ now show **a blank white screen** (as though it cannot find the proper template to use).  So what am I doing wrong? Please advise


Create placeholder text for wordpress search box

I need to create a search box in my default searchform.php file that has similar behaviour as the default ability in HTML5 with the "placeholder" attribute. This is what I have in my searchform.php at the moment:                <input type="submit" id="searchsubmit" value="text" />      <input placeholder="<?php _e( 'Search here..' ); ?>">      The text 'Search here..' appears in the input and it dissapeard when I start typeing in the input. I need it to dissapear when I click the input. Thx


Perform function on publish AND save (not just save)

I am using this function to auto-set a post title based on a couple of custom fields:               function set_event_title( $data , $postarr ) {       if($data['post_type'] == 'event') {         $getdate = get_post_meta($postarr['ID'],'event_datestart',true);         $dateformat = new DateTime($getdate);         $date = $dateformat->format( 'm-d-Y' );         $event_venue = get_post_meta($postarr['ID'],'venue_name',true);         $event_title = $event_venue . ' - ' . $date;         $post_slug = sanitize_title_with_dashes ($event_title,'','save');         $post_slugsan = sanitize_title($post_slug);         $data['post_title'] = $event_title;         $data['post_name'] = $post_slugsan;       }       return $data;     }     add_filter( 'wp_insert_post_data' , 'set_event_title' , '99', 2 );      But I can only get it to work on post update and not on the initial publishing of the post. Is there a way to make this work both the FIRST time as well as the rest of the times when the post is saved?


Hook to return true when the_post() is used in a custom while loop

I fetch external data like this, but I also added the_post();               while($slice = mysql_fetch_assoc($result)){         the_post();         rest of my stuff     }      I need a hook to tell me if the_post() returns true, something like this:               while($slice = mysql_fetch_assoc($result)){         the_post();         if(the post returs true){ do something;         else { rest of my stuff }     }      Any ideas?


How can I highlight syntax like it appears on stackoverflow?

Suppose I am writing a post and want to highlight only a couple of characters: `like this`. How can I achieve this?


Can I turn off further comments on a single page?

I have a blog post with comments on. I want to stop all people posting any further comments but keep the ones that are currently there. How do I do that? Using Wordpress 3.5.1


Auto Log In Users after registration and send confirmation email

I'm using this function in functions.php to auto log in users after the sign up in the front-end               function auto_login_new_user( $user_id ) {        wp_set_current_user($user_id);        wp_set_auth_cookie($user_id);         wp_redirect('http://mydomain.com/confirmation/');        exit;     }     add_action( 'user_register', 'auto_login_new_user' );      This works great for auto login in users but for some reason this also causes the automatic confirmation email not being sent to users anymore. I have no idea why though, any suggestions would be really helpful. Thanks


file compressed the content on single line after upload in wordpress

I don't have any idea what going wrong with my wordpress file, When i tried to open a file after downloading, the downloaded file got compressed in single like like:               <?php/** * The Header for our theme. * * Displays all of the  section and everything up till
 *      and the actual file is like:               <?php     /**      * The Header for our theme.      *      * Displays all of the  section and everything up till
      *      the problem with this, when i tried to upload new files then also compressed and not working properly. I have installed WP Super Cache plugin to cache the pages for increasing the page load speed with cache, I am not sure if this plugin is behind all this. Instead of wp super cache i have added some code in my htaccess file:               RewriteEngine On     RewriteBase /blog/          # here are few rewrite rules for 301 permanent redirect          RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /blog/index.php [L]               Header unset ETag       FileETag None          <filesMatch "\.(jpg|jpeg|png|gif|swf)$">     Header set Cache-Control "max-age=2592000, private"     Header set Expires "Sun, 23 October 2011 20:00:00 GMT"     </filesMatch>     <filesMatch "\.(css|css.gz)$">     Header set Cache-Control "max-age=604800, private"     </filesMatch>     <filesMatch "\.(js|js.gz)$">     Header set Cache-Control "max-age=604800, private"     </filesMatch>     <filesMatch "\.(xml|txt)$">     Header set Cache-Control "max-age=216000, private, must-revalidate"     </filesMatch>     <filesMatch "\.(html|htm)$">     Header set Cache-Control "max-age=7200, private, must-revalidate"     </filesMatch>          AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript     # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /blog/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /blog/index.php [L]     </IfModule>          # END WordPress      Can anyone please help me what wrong i have done.. **UPDATE:** ![enter image description here](http://i.stack.imgur.com/4cbgR.png)


how to show only particular category post in archive widgets

i want to display blog category month list in archive widgets. but i i can't figure out yet how. i have more category like review, gallery etc. normally show all month list in archive widgets but i want only BLOG show in archive widgets. i already figure our how to show only blog post in archive page but now problem is widgets. any idea guys how ?


To CSS Style on the image uploaded on a Post under Content Section

I have uploaded a media picture to a post the HTML I saw as such                     How do I css style on this image? I can't use class="alignnone size-full wp- image-204" because on the next new post, that class name could be different. All my post will have exactly one image and will be in the same location.


Using chunk theme from wordpress.com on my own host

I am new to wordpress so please excuse this question if it is obvious, but I was not able to find a good answer here or via the more general internet. I want to use the Chunk theme from wordpress.com but:   * I can't find it via the theme admin area of my local wordpress installation    * I can't find a way to download a `.zip` file Is there a way to do this? If any further information is required I can provide as needed.


How to use get_post_custom_values to return the value of an array

I have a custom post type called `albums` and a custom field therein called `tracklist` which is an array containing `song_title` and `duration`. I would like to print a list of the songs on each album. It's helpful for me to think of the array hierarchy like so:               albumlist       album         tracklist           track             song_title             duration So far I figured out how to drill down to the tracklist array, but not how to display the values of the song titles within it.               $albums = get_posts(array(       'post_type' => 'album',       'meta_key'  => 'tracklist'     ));          if($albums) {       foreach($albums as $album) {         echo get_the_title($album->ID) . "
"; // Displays album's title         $tracklist = get_post_custom_values('tracklist', $album->ID);              foreach($tracklist as $track) {           echo $track . "
"; // Displays "12" (there are 12 tracks on this album)         }       }     }      Anyway, I've been working at this for a couple hours trying to solve it myself, but it's getting late! Once I get to the `tracklist` array, how do I drill inside the track and get the song title? Thanks for any help you can proffer.


How to limit the number of terms (terms acts like categories)

Hello i have created taxonomy in custom post type that act like category. then i have created terms that acts like categories. i have create widget that show all terms from taxonomy. all works great. but i can"t understand how to limit the number of terms to show. i have created input in my widget. so if i put some number i want the widget will limit to show only this number of terms. thanks for help! the code to show all terms is:               $terms = get_terms('new_category');     echo '
';     foreach ($terms as $term) {         $term_link = get_term_link( $term, 'new_category' );         echo '

' . $term->name . '

';          }     echo '
';


How to setcookie if is_page('page') ? should I use add_action('init') or there is another action?

I want to setcookie if is_page('arabic') or is_page('english') then redirect to home_url() only if the page name/slug `arabic` or `english`, I think that init action happen before the code determine the current page, how to do that Also after fixing that problem , how can I be sure that setcookie will happen before the redirect so the cookie which Has just set will be shown (because cookie needs refresh) Below is my code               function site_set_user_language() {         if(!isset($_COOKIE['site_language'])){             setcookie('site_language', 'ar', time()+3600*24*365*3,'/','.site.com');         }elseif(is_page('arabic') || is_page('english')){             if($_COOKIE['site_language'] == 'en'){                 setcookie('site_language', 'ar', time()+3600*24*365*3,'/','.site.com');                 wp_redirect( home_url());                 exit();             }elseif($_COOKIE['site_language'] == 'ar'){                 setcookie('site_language', 'en', time()+3600*24*365*3,'/','.site.com');                 wp_redirect( home_url());                 exit();             }            }        }     add_action( 'init', 'site_set_user_language',10,1);     add_action( 'template_redirect', 'site_lang_home_redirect' );


how to do i fix this problem Your backup folder MIGHT be visible to the public

where do I find this wp-content/plugins/wp-dbmanager so that I can move the .htaccess to /home/godel09/public_html/mylesmunroemediavault.com/members/wp- content/backup-db


altering theme - content generated by PAGES not PORTFOLIO

I bought the Hardy theme from Theme Trust thinking that the content below the home page slider would be generated by page content NOT "project" or portfolio content. Turns out, the content below the home page slider is generated by "projects"/portfolio content. I need to make it so that all content below the home page slider is generated by page content; I've contacted Theme Trust support with no luck. How can I make this happen? I've looked for mention of categories or similar in the index.php but didn't see anything... I'm a bit lost. Ideas?               <?php get_header(); ?>          <?php $show_full_post = of_get_option('ttrust_post_show_full'); ?>     <?php $blog_full_width = of_get_option('ttrust_post_full_width'); ?>     <?php $bw = ($blog_full_width) ? "full" : "twoThirds"; ?>          <?php if(!is_front_page()) : ?>

         <?php $blog_page_id = of_get_option('ttrust_blog_page'); ?>         <?php $blog_page = get_page($blog_page_id); ?>
<?php echo $blog_page->post_title; ?>
         <?php $page_description = get_post_meta($blog_page_id, "_ttrust_page_description", true); ?>         <?php if ($page_description) : ?>
<?php echo $page_description; ?>
         <?php endif; ?>

     <?php endif; ?>

     <div id="content" class="<?php echo $bw; ?> clearfix">
                  <?php while (have_posts()) : the_post(); ?>                          <div <?php post_class(); ?>>

<a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?>

                         <?php $post_show_author = of_get_option('ttrust_post_show_author'); ?>                         <?php $post_show_date = of_get_option('ttrust_post_show_date'); ?>                         <?php $post_show_category = of_get_option('ttrust_post_show_category'); ?>                         <?php $post_show_comments = of_get_option('ttrust_post_show_comments'); ?>                              <?php if($post_show_author || $post_show_date || $post_show_category){ _e('Posted ', 'themetrust'); } ?>                                             <?php if($post_show_author) { _e('by ', 'themetrust'); the_author_posts_link(); }?>                         <?php if($post_show_date) { _e('on', 'themetrust'); ?> <?php the_time( 'M j, Y' ); } ?>                         <?php if($post_show_category) { _e('in', 'themetrust'); ?> <?php the_category(', '); } ?>                         <?php if(($post_show_author || $post_show_date || $post_show_category) && $post_show_comments){ echo " | "; } ?>                              <?php if($post_show_comments) : ?>                             <a href="<?php comments_link(); ?>"><?php comments_number(__('No Comments', 'themetrust'), __('One Comment', 'themetrust'), __('% Comments', 'themetrust')); ?>                         <?php endif; ?>
                                                <?php if($show_full_post) : ?>                         <?php the_content(); ?>                     <?php else: ?>                              <?php if(has_post_thumbnail()) : ?>                             <?php if(of_get_option('ttrust_post_featured_img_size')=="large") : ?>                                                                           <a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_post_thumbnail('ttrust_post_thumb_big', array('class' => 'postThumb', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?>                                            <?php else: ?>                                 <a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_post_thumbnail('ttrust_post_thumb_small', array('class' => 'postThumb alignleft', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?>                             <?php endif; ?>                         <?php endif; ?>                                  <?php the_excerpt(); ?>                         <?php more_link(); ?>                                             <?php endif; ?>

                            <?php endwhile; ?>
         <?php global $total_pages; $total_pages = ceil($wp_query->found_posts/get_option('posts_per_page')); ?>         <?php $paged = get_query_var('paged'); ?>         <?php get_template_part( 'part-pagination'); ?>
               <?php if($bw == "twoThirds") get_sidebar(); ?>

          <?php get_footer(); ?>


Pass parameters to static home page brings up index.php latest posts

i have a Wordpress site that has the main page set to a specific template. www.mydomain.com -> main_page_template I am trying to pass in some params to my main URL as follows www.mydomain.com/?name=test&id=100 The issue is when passing in such parameters it always shows the list of current posts (it calls my index.php file which lists all posts) as opposed to the main page. When i dont pass parameters, it shows fine. For all other pages, the above is fine (i.e. www.mydomain.com/page1/?name=test&id=100). Any ideas on how i can pass parameters in yet still have it show the homepage? Finally, i know the permalink settings cause some form of rewriting, how can i get the raw unrwitten query to the page, i.e. www.mydomain.com?p=100. This would help for debugging. Thanks in advance, Chris


Upgrade DB Loop - WordPress DB Version Conflict

So I did an auto update to WP 3.3 and got a screen telling me there was a DB upgrade needed. I hit continue and it said the upgrade was a success. I hit continue again and the same screen popped up telling me the DB needed upgrading... repeat cycle. Then I changed the DB version in version.php (18226) to match what was in the database under the options table for DB version (19470). This allows me to access the backend, but nothing will update. Can't update any post or pages. It says the page is updated, but it never actually does... I have read and tried all of these solutions: Site stuck in "Database Update Required" loop http://blog.nexcess.net/2011/11/15/how-to-fix-the-wordpress-admin-upgrade- loop/ http://www.clickonf5.org/2247/solution-database-upgrade-required/ Any suggestions? Thanks


NextGen Plugin: on finding images tags

I'm trying to understand (and find) where nextgen save images tags. I tried in ngg_picture table without any result ... Do u know where they are? Are they some kind of standard wordpress tags?


jquery-ui-autocomplete is not loaded with wp_enqueue_script

when I load the default jquery-ui-autocomplete script from wordpress via               wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.8.6' );      it is embedded, and all works fine, except the annoying notice message in debug mode: > Notice: wp_enqueue_script was called incorrectly. Scripts and styles should > not be registered or enqueued until the wp_enqueue_scripts, > admin_enqueue_scripts, or init hooks ... The solution therefore is quite easy, only wrap the `wp_enqueue_script` call:               function add_scripts(){       wp_enqueue_script( 'jquery-ui-autocomplete', '', array( 'jquery-ui-widget', 'jquery-ui-position' ), '1.8.6' ); //don't loads the autocomplete       wp_enqueue_script( 'jquery-ui-autocomplete'); //same as above     }     add_action('wp_enqueue_scripts', 'add_scripts');       BUT these technique doesn't embeds the `jquery-ui-autocomplete script`, only the annoying message disappear. The only way the `jquery-ui-autocomplete` script is embed, is without wrapping it ... Where is my error? According to the documentation in the codex it should be done by wrapping the call and simply call `wp_enqueue_script( 'jquery-ui- autocomplete');` inside. BR, mybecks


Show Excerpts In Twenty Eleven Theme

I just need to create a blog I have done everything i guess, its showing posts but they are supposed to be kind of summary first and after click the whole post. I already selected the "For each article in a feed, show summary" from reading option from dashboard I already activated the hidden option of enabling excerpt, and typed some words to check but no luck.. I have replaced the `<?php the_content();?>` to `<?php the_excerpt();?>` Might be i am missing something, it was simple every site I followed for the solution they told me so but i am not getting output theme i am using is Twentyeleven and I dont want to use any plugin coz they(You and all word-press masters)say its simple.


Plugin admin list pages as submenu

I am creating a plugin for a custom admin menu based in the admin area. My wordpress template is consisted of 5 pages with different templates and some custom variables that the end user would be allowed to edit with a custom role I have assigned to him, eg. grunt. The reason I am doing this is so that the user could have the minimum knowledge of interacting with the page admin. For example, I have a page with 6 custom fields that define how the template should be shown, while in another page these field variables change to alter the display effect. So in my admin menu I would have:               Site Management     - Page 1 Admin -> This makes a carousel with 2 items max     - Page 2 Admin -> This is a plain text page     - Page 3 Admin     - Page 4 Admin -> This is a carousel with 4 items max     - Page 5 Admin      And so on. Since my menu is the same as the pages shown + Homepage link, I have used `wp_get_nav_menu_items()` function to get those menus. But now I am in a dilemma, trying to access every page's post to edit. Here is how I list the pages on my admin menu:               $options = get_nav_menu_locations();     $menu_items = wp_get_nav_menu_items($options['main_nav']);     $i = 0;     foreach ((array) $menu_items as $key => $v):         $post = get_post($v->object_id);         setup_postdata($post);         add_submenu_page('theme_admin2', 'Administration', $v->title, 'edit_posts', 'theme_admin_'.$v->object_id, array(&$this, 'display_page_test'));     endforeach;      Each menu item is a submenu page at the moment. How can I pass the $v->object_id variable to the display_page_test function of my plugin class so that I would differentiate my output as well? _**UPDATE_**   I am referring to creating an admin menu using the public menu items as subitems (to the admin). Once a user clicks the subitem it will be an edit screen for the page: title, body and image. This is the only view that the customer will see + profile. I've created that page, but I cannot send the object id of each menu to the callback function that creates the submenu pages.


calling jquery function on plugin page

I am trying to call the following script on a plugin admin page:               <?php     function add_match_attendance_scripts() {          $output = '<script type="text/javascript">                      jQuery(function () {     $("#seatt_start").datepicker({dateFormat: "dd-mm-yy"});     $("#seatt_expire").datepicker({         dateFormat: "dd-mm-yy",         firstDay: 1,         onSelect: function (prev_date) {             prev = prev_date.split("-");             var date = new Date(prev[2], prev[1] - 1, prev[0]);             var d = date.getDate();             var m = date.getMonth();             var y = date.getFullYear();             var new_date = new Date(y, m, d - 7);             $("#seatt_start").removeAttr("disabled").datepicker("setDate", new_date);          }        });     });          </script>';                          echo $output;             }                  add_action('admin_head','add_match_attendance_scripts');     ?>      I already have enqueued `jquery-ui-datepicker` for all admin pages and it works correctly on all admin pages using a similar function:               add_action('admin_head','add_report_custom_scripts');          function add_report_custom_scripts() {     global $report_custom_meta_fields, $post;          $output = '<script type="text/javascript">                 jQuery(function() {';          foreach ($report_custom_meta_fields as $field) { // loop through the fields looking for certain types         // date         if($field['type'] == 'date')             $output .= 'jQuery(".datepicker").datepicker({ dateFormat: "dd-mm-yy", firstDay: 1 });';          }          $output .= '});         </script>';          echo $output;     }      but apparently this script runs on my plugin page and not the one I wanted. So how can I specify which script goes where seeing as they are both admin pages?


Wordpress multiple forms

I have a question on how to approach the following situation. When you have a website like:               www.green.com/page1     www.green.com/page2     www.green.com/page3     www.green.com/page4      With on every page a different form:               Page 1 = form 1      Page 2 = form 2     Page 3 = form 3     Page 4 = form 4     Page 5 = form 5      Now there are 5 users::               user1@hotmail.com     user2@hotmail.com     user3@hotmail.com     user4@hotmail.com     user5@hotmail.com      Each user has an account on the wordpress website. Every user should be able to login and only see their attached form.               user1@hotmail.com can see only the submissions from form 1     user2@hotmail.com can see only the submissions from form 2     user3@hotmail.com can see only the submissions from form 3     user4@hotmail.com can see only the submissions from form 4     user5@hotmail.com can see only the submissions from form 5      What is the best way to approach this in the back-end? How can I let users only see the forms they are allowed to? Thanks a lot!


select a main navigation menu per user type from multiple main navigation menus

GOAL: I want to use custom menus for two different kinds of users. For instance, I want to Merchant users to be able to use Merchant menu, and Owner for Owner menu. I do not have enough reputation, this image is in the admin menu panel which has theme location with custom menu selection. http://dl.dropbox.com/u/6520543/custom%20menu.jpg   1. wp_terms holds names of custom menus with term_id.   2. wp_term_taxonomy holds term_id from wp_terms with taxonomy as "nav_menu" and number of menu items saved under each custom menu as count column. "function register_custom_nav" and "register_nav_menus" work, but I can't find a clue how it selects which custom menu is selected for users. If I can find where it's loading the selected custom menu somewhere in the code or db, I can just change upon user's login. I think it's definitely in the DB where it selects the custom menu id, but I can't find. Does anyone know how????


Adding Post Counts to Menu (Nav) Programmatically?

I'm fairly stumped on this. Without getting too query-heavy, I was wondering what path one might take to produce a menu that links to a category of posts, and displays in parenthesis how many new posts there are. Example: **News (5 new)   Articles (8 new)** ...and so forth. What is the most efficient way to achieve this without running a million queries?


Change height of Add New Post input box

The textarea box on the Add New Post page is too high for my application. I'd like to change it to 260px high. However the style is embedded. What's the best way to change it, without altering the original file?


users and usermeta table

Is it mandatory for each user to have entries in usermeta table as well or it's optional? Recently, I came across a wordpress database which has thousands of users in user table however only a few of them have entries in usermeta table. I am wondering in what scenario this could have happened as it doesn't look like those entries were manually removed from database.


After installing this videozoom theme i'm getting this error: Parse error: syntax error, unexpected T_ENDWHILE in /home/moviesa1/public_html/test99 dot info/wp- content/themes/videozoom/wpzoom_featured_posts.php on line 1 my site: http://test99.info/               <?php        $args = array('showposts' => $wpzoom_featured_posts_posts, 'orderby' => 'date', 'order' => 'DESC');        $featType = $wpzoom_featured_type;        if ($featType == 'Tag') {            $args['tag'] = "$wpzoom_featured_slug";            // Breaking tag slug          }          elseif ($featType == 'Category')          {            $args['cat'] = "$wpzoom_featured_slug";  // Breaking tag slug          }     ?>

                      <?php            query_posts($args);            $i = 0;            if (have_posts())                :     ?><?php                $AE = new AutoEmbed();            // loading the AutoEmbed PHP Class      ?>
            <?php            while (have_posts())                : the_post();            update_post_caches($posts);            $i++;            unset($videocode);            $videocode = get_post_meta($post->ID, 'wpzoom_post_embed_code', true);     ?>
            <?php            if ($videocode && $AE->parseUrl($videocode)) {                $AE->setParam('wmode', 'transparent');                $AE->setParam('autoplay', 'false');                $AE->setHeight(260);                $AE->setWidth(450);     ?>
<?php                echo $AE->getEmbedCode();     ?>
<?php                } else                {     ?>        <?php                    unset($img);                    if (current_theme_supports('post-thumbnails') && has_post_thumbnail()) {                        $thumbURL = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '');                        $img = $thumbURL[0];                    } else {                        unset($img);                        if ($wpzoom_cf_use == 'Yes') {                            $img = get_post_meta($post->ID, $wpzoom_cf_photo, true);                        } else {                            if (!$img) {                                $img = catch_that_image($post->ID);                            }                        }                    }                    if ($img) {     ?>
<a href="<?php                        the_permalink();     ?>" rel="bookmark" title="<?php                        the_title();     ?>"><img src="<?php                        bloginfo('template_directory');     ?>/scripts/timthumb.php?src=<?php                        echo $img      ?>&h=275&w=450&zc=1" alt="<?php                        the_title();     ?>" width="450" height="275" />
        <?php                        } // if an image exists        } // if a video does not exist      ?>

<?php                        the_time("$dateformat");     ?> / <?php                        the_category(', ');     ?> / <?php                        the_author_posts_link();     ?>

<a href="<?php                        the_permalink()     ?>" title="<?php                        the_title();     ?>"><?php                        the_title();     ?>
          <?php                        the_excerpt();     ?>
<a href="<?php                        the_permalink()     ?>" title="<?php                        the_title();     ?>" rel="nofollow">Continue reading » <?php                        edit_post_link(__('Edit this post'), ' | ', '');     ?>

        <?php                        endwhile;     ?>
        <?php                        endif;     ?>

                    <?php                        query_posts($args);                        $i = 0;                        if (have_posts())                            :     ?>

          <?php                            while (have_posts())                                : the_post();                        update_post_caches($posts);                        $i++;     ?>          <li<?php                        if ($i == 6) {                            $i = 0;                            echo " class=\"last\"";                        }     ?>><?php                        unset($img);                        if (current_theme_supports('post-thumbnails') && has_post_thumbnail()) {                            $thumbURL = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '');                            $img = $thumbURL[0];                        } else {                            unset($img);                            if ($wpzoom_cf_use == 'Yes') {                                $img = get_post_meta($post->ID, $wpzoom_cf_photo, true);                            } else {                                if (!$img) {                                    $img = catch_that_image($post->ID);                                }                            }                        }                        if ($img) {     ?><img src="<?php                            bloginfo('template_directory');     ?>/scripts/timthumb.php?src=<?php                            echo $img      ?>&h=98&w=135&zc=1" alt="<?php                            the_title();     ?>" width="135" height="98" />
<?php                        }     ?>          <?php                        endwhile;     ?>

      <?php                        endif;     ?>      Prev    Next
      <?php                        wp_reset_query();     ?>      sorry for posting the code in one line like that, how do i post in in a block?


Identify which loop you are hooking into; primary or secondary?

What is the most efficient way to determine which loop I'm in? I have a few plugins that alter the query by hooking into various parts of `WP_Query::get_posts()`, through the usual suspects, ie `posts_where`, `posts_join`, etc. I don't want to effect every loop on every page though, so right now I'm running a `debug_backtrace()` and checking for the existence of `the main()` or `query_posts()` function as necessary. There has to be a more efficient way to identify the primary loop and sub- loops on each page. Something I keep missing when I pore over the query vars and other aspects of the request, something that's unique to each one. How would you go about doing this?


How does a mobile WordPress theme differ from a simple theme?

1. What should be taken care of while coding a mobile theme as compared to a simple one?   2. Is there any tutorial available that teaches how to develop a **mobile** theme from scratch?


Custom Post Type Template - Archive

I have a custom post type, called 'job', and I have the following templates in my theme:   * single-job.php (works fine, displays single job as expected)   * archives-job.php (is not recognized?)   * archives-current.php (also not recognized)    * archives.php (is not recognized either?)    * index.php (archives page uses this page) Here is how I've registered my custom content type in functions.php:               add_action( 'init', 'create_jobs' );     function create_jobs() {       $labels = array(         'name' => _x('Jobs', 'post type general name'),         'singular_name' => _x('Job', 'post type singular name'),         'add_new' => _x('Add New', 'Job'),         'add_new_item' => __('Add New Job'),         'edit_item' => __('Edit Job'),         'new_item' => __('New Job'),         'view_item' => __('View Job'),         'search_items' => __('Search Jobs'),         'not_found' =>  __('No Jobs found'),         'not_found_in_trash' => __('No Jobs found in Trash'),         'parent_item_colon' => ''       );            $supports = array('title', 'editor', 'custom-fields', 'revisions', 'excerpt');            register_post_type( 'Job',         array(           'labels' => $labels,           'public' => true,           'has_archive' => 'current',            'supports' => $supports         )       );     }      When i go to the url http://mywebsite/wordpress/current/, it displays all of my jobs as expected-- but it is not using ANY of the archive templates, and instead uses index.php. My understanding of the wordpress documentation was that it would look for archives-(special archive for post type name).php, then archives-(post type).php, then archives.php, then index.php... but it just goes straight to index.php? I did visit the permalinks settings page and clicked save to refresh everything, so I'm not getting 404's, it's just not outputting to the correct templates... did I name them incorrectly? Is there a registration setting I missed when I created my custom post type?


Custom post type routing with hierarchy

I've been playing around with a lot of custom post types lately and I am pretty anal about my URL structure / routing. An issue I ran in to a with a site that I just developed was this:   * I had many custom post types, for example: `videos`   * The URL structure to 'view' the video list (ie: archive of sorts) was `/media/videos/`   * This 'view' was basically a custom `WP_Query` displaying things properly from a custom .php template.   * When an individual 'video' link is clicked you are taken to the post type URL structure, ie: `www.site.com/videos/{slug}`   * This causes all loss of URL structure/parental relationship to structure. I would love to solve this problem:   * When you navigate to `/media/videos/` you get the custom loaded template file   * When you click a video `permalink()`, you will be linked to `/media/videos/{slug}`   * Ideally this would perserve hierarchy of URL structure (so if something like Breadcrumb NavXT it would still have a relationship). I made a teacher/student/etc module one time where I did custom routing via `add_rewrite_rule` to handle these problems, but I would rather figure out how to handle hierarchy appropriately in this situation. Can someone please point me in to the right direction? Thanks! Tre


Using Images in Wordpress - Best Practices

I'm not a novice to Wordpress Theme Design & Development. I've actually been doing it for a few years now and in recent years, it has become more than a hobby and is slowing shaping into a career choice. However, I have a somewhat simple yet puzzling question to ask here... Forever, I've been uploading the images I use through my custom themes into their own "img" or "images" directory under the themes directory under wp- content. Of course, for posts I just used the Media Uploader built within Wordpress itself. But, now that I'm trying to be more professional and produce grade-A work consistently I recently thought about how I handle my images. You see, using my old method I also did NOT use Wordpress template tags for the image paths. I was doing the old fashion HTML method with it's relative path and if I encountered a problem, I just put the WHOLE path in there to save time. That is a huge no, no. I'm well aware but this wasn't client work... Anyway, to get to my point - what IS the best practice for using images in Wordpress? I'm now beginning to think more inline with this process: **For theme development I now have a "inc" directory within my theme's directory that then has a "imgs" and "js" directories, etc. When designing the theme, I'm now using Wordpress template tags for my paths to work properly throughout the theme. For my posts, I'm still using the Media Uploader and the normal /upload directory.** Is my new method the best practice? Thank you!! Again, I'm just trying to clean up my workflow and methods so I'm more in-line with the Codex and other top tier Wordpress projects out there. Thanks!


How to define a custom font family for a wordpress blog that will not affect the entire site

While my related question on Stack Overflow _should_ explain the basic CSS for this once it gets answered, how would I define a custom font family for a wordpress blog that will _only_ apply to a <span> and will not affect the site-wide font families being used by the theme on my wordpress site? > Related: Creating Useable Custom Font Family


Course listing with multiple dates

I'm trying to build a course listing (custom post type) - each course has multiple dates assigned to it, but I'm failing miserably (mainly due to my poor PHP skills!). I'm trying to use standard WordPress custom fields with a key called date and values of the dates (until I get it working, then moving onto custom metaboxes). What I need to do is output the courses multiple times - once for each date value, so I need to display for example (Category and location are custom taxonomies): 25/09/2013 - Course 3 - Category - Location   26/09/2013 - Course 1 - Category - Location   28/09/2013 - Course 1 - Category - Location   29/09/2013 - Course 2 - Category - Location   01/01/2014 - Course 1 - Category - Location   06/01/2014 - Course 2 - Category - Location Dates will be stored as YYMMDD for sorting purposes as I'm sure I read this is the best format? As for what I need to output - the plan was a page template in the above format. I also need to order them by date, and not show any dates prior to today's date. I can't for the life of me work out how to do this - specifically outputting the post info once per date. I will also need to filter the results shown using a few select dropdowns, but I should be able to figure this out later.


403 forbidden due to .htaccess?

I have this 403 forbidden issue that i can't tell what's causing it. At this moment, i've already talked with theme support, wich advised me to talk with host support, wich i've done it already, they identified the issue after following the steps i told. They suggested then to check either with cloudflare support or w3tc, cause after running Firebug's "NET" the following info was:               HTTP/1.1 403 Forbidden     Server: cloudflare-nginx     Date: Wed, 25 Sep 2013 10:46:34 GMT     Content-Type: text/html; charset=UTF-8     Transfer-Encoding: chunked     Connection: keep-alive     X-Pingback: http://findout-macau.com/xmlrpc.php     Expires: Wed, 11 Jan 1984 05:00:00 GMT     Cache-Control: no-cache, must-revalidate, max-age=0     Pragma: no-cache     X-Powered-By: W3 Total Cache/0.9.3     X-W3TC-Minify: On     Link: <http://wp.me/3UMOt>; rel=shortlink     Vary: Accept-Encoding,User-Agent     CF-RAY: b3721978b0506dc     Content-Encoding: gzip      I've checked with cloudflare, and they let me know that usually this kinda of issue has to do with:               1. Permission rules you have set or an error in the .htaccess rules you have set.     2. Mod_security rules.     3. IP Deny rules      Nevertheless i've my .htaccess content below:               RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://images.findout-macau.com/$1          # BEGIN W3TC Browser Cache     <IfModule mod_mime.c>     AddType text/css .css     AddType text/x-component .htc     AddType application/x-javascript .js     AddType application/javascript .js2     AddType text/javascript .js3     AddType text/x-js .js4     AddType text/html .html .htm     AddType text/richtext .rtf .rtx     AddType image/svg+xml .svg .svgz     AddType text/plain .txt     AddType text/xsd .xsd     AddType text/xsl .xsl     AddType text/xml .xml     AddType video/asf .asf .asx .wax .wmv .wmx     AddType video/avi .avi     AddType image/bmp .bmp     AddType application/java .class     AddType video/divx .divx     AddType application/msword .doc .docx     AddType application/vnd.ms-fontobject .eot     AddType application/x-msdownload .exe     AddType image/gif .gif     AddType application/x-gzip .gz .gzip     AddType image/x-icon .ico     AddType image/jpeg .jpg .jpeg .jpe     AddType application/json .json     AddType application/vnd.ms-access .mdb     AddType audio/midi .mid .midi     AddType video/quicktime .mov .qt     AddType audio/mpeg .mp3 .m4a     AddType video/mp4 .mp4 .m4v     AddType video/mpeg .mpeg .mpg .mpe     AddType application/vnd.ms-project .mpp     AddType application/x-font-otf .otf     AddType application/vnd.oasis.opendocument.database .odb     AddType application/vnd.oasis.opendocument.chart .odc     AddType application/vnd.oasis.opendocument.formula .odf     AddType application/vnd.oasis.opendocument.graphics .odg     AddType application/vnd.oasis.opendocument.presentation .odp     AddType application/vnd.oasis.opendocument.spreadsheet .ods     AddType application/vnd.oasis.opendocument.text .odt     AddType audio/ogg .ogg     AddType application/pdf .pdf     AddType image/png .png     AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx     AddType audio/x-realaudio .ra .ram     AddType application/x-shockwave-flash .swf     AddType application/x-tar .tar     AddType image/tiff .tif .tiff     AddType application/x-font-ttf .ttf .ttc     AddType audio/wav .wav     AddType audio/wma .wma     AddType application/vnd.ms-write .wri     AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw     AddType application/zip .zip     </IfModule>     <IfModule mod_expires.c>     ExpiresActive On     ExpiresByType text/css A31536000     ExpiresByType text/x-component A31536000     ExpiresByType application/x-javascript A31536000     ExpiresByType application/javascript A31536000     ExpiresByType text/javascript A31536000     ExpiresByType text/x-js A31536000     ExpiresByType text/html A3600     ExpiresByType text/richtext A3600     ExpiresByType image/svg+xml A3600     ExpiresByType text/plain A3600     ExpiresByType text/xsd A3600     ExpiresByType text/xsl A3600     ExpiresByType text/xml A3600     ExpiresByType video/asf A31536000     ExpiresByType video/avi A31536000     ExpiresByType image/bmp A31536000     ExpiresByType application/java A31536000     ExpiresByType video/divx A31536000     ExpiresByType application/msword A31536000     ExpiresByType application/vnd.ms-fontobject A31536000     ExpiresByType application/x-msdownload A31536000     ExpiresByType image/gif A31536000     ExpiresByType application/x-gzip A31536000     ExpiresByType image/x-icon A31536000     ExpiresByType image/jpeg A31536000     ExpiresByType application/json A31536000     ExpiresByType application/vnd.ms-access A31536000     ExpiresByType audio/midi A31536000     ExpiresByType video/quicktime A31536000     ExpiresByType audio/mpeg A31536000     ExpiresByType video/mp4 A31536000     ExpiresByType video/mpeg A31536000     ExpiresByType application/vnd.ms-project A31536000     ExpiresByType application/x-font-otf A31536000     ExpiresByType application/vnd.oasis.opendocument.database A31536000     ExpiresByType application/vnd.oasis.opendocument.chart A31536000     ExpiresByType application/vnd.oasis.opendocument.formula A31536000     ExpiresByType application/vnd.oasis.opendocument.graphics A31536000     ExpiresByType application/vnd.oasis.opendocument.presentation A31536000     ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000     ExpiresByType application/vnd.oasis.opendocument.text A31536000     ExpiresByType audio/ogg A31536000     ExpiresByType application/pdf A31536000     ExpiresByType image/png A31536000     ExpiresByType application/vnd.ms-powerpoint A31536000     ExpiresByType audio/x-realaudio A31536000     ExpiresByType image/svg+xml A31536000     ExpiresByType application/x-shockwave-flash A31536000     ExpiresByType application/x-tar A31536000     ExpiresByType image/tiff A31536000     ExpiresByType application/x-font-ttf A31536000     ExpiresByType audio/wav A31536000     ExpiresByType audio/wma A31536000     ExpiresByType application/vnd.ms-write A31536000     ExpiresByType application/vnd.ms-excel A31536000     ExpiresByType application/zip A31536000     </IfModule>     <IfModule mod_deflate.c>     <IfModule mod_headers.c>         Header append Vary User-Agent env=!dont-vary     </IfModule>         AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json     <IfModule mod_mime.c>         # DEFLATE by extension         AddOutputFilter DEFLATE js css htm html xml     </IfModule>     </IfModule>     <FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">     <IfModule mod_headers.c>         Header set Pragma "public"         Header append Cache-Control "public"          Header unset Set-Cookie          Header set X-Powered-By "W3 Total Cache/0.9.3"      </IfModule>      </FilesMatch>      <FilesMatch  "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">     <IfModule mod_headers.c>         Header set Pragma "public"         Header append Cache-Control "public"          Header set X-Powered-By "W3 Total Cache/0.9.3"      </IfModule>      </FilesMatch>      <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">     <IfModule mod_headers.c>         Header set Pragma "public"         Header append Cache-Control "public"          Header unset Set-Cookie          Header set X-Powered-By "W3 Total Cache/0.9.3"      </IfModule>      </FilesMatch>      # END W3TC Browser Cache      # BEGIN W3TC Page Cache core      <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteCond %{HTTPS} =on     RewriteRule .* - [E=W3TC_SSL:_ssl]     RewriteCond %{SERVER_PORT} =443     RewriteRule .* - [E=W3TC_SSL:_ssl]     RewriteCond %{HTTP:Accept-Encoding} gzip     RewriteRule .* - [E=W3TC_ENC:_gzip]     RewriteCond %{REQUEST_METHOD} !=POST     RewriteCond %{QUERY_STRING} =""     RewriteCond %{REQUEST_URI} \/$     RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]     RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -f     RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]     </IfModule>     # END W3TC Page Cache core     # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      What i'ld like to know is some tip on how to solve this? Does someone believes to know how to get through this?


Remove category link

I want to use categories but I also want to remove the category pages.               http://www.example.com/categories/foo/      Assumed that this category exists this URL should return a 301 and redirect to               http://example.com/index.php      I've tried to add a `category.php` to my theme but this won't work for me. I don't want to hide posts with a specific category or remove the category base or something like that. I'm using WordPress 3.6.1.


How to set up htaccess to redirect a particular post type or subdirectory to HTTPS?

I have a post type with the slug 'open-tour', so all its pages are under www.domain.com/open-tour/. **I need all the pages under this "directory" to go to HTTPS (for credit card payments).** I can redirect a single URL okay, but the dynamic stuff goes a bit over my head. Maybe it's also because I don't know how/where to write the redirect in relation to Wordpress's htaccess block. Anyway here's the latest iteration of my fail code:               RewriteEngine on     RewriteCond %{HTTPS} off     RewriteCond %{http_host} ^www.domain.com/open-tour/(.*) [nc]     RewriteRule ^(.*)$ https://www.domain.com/open-tour/$1 [r=301,nc]       Can anyone tell me what I'm doing wrong here? EDIT: Thanks JMa and Pothi! Now, is there a way to make another rule that is the reverse of this? That is, if the user is viewing a page that's NOT in the open-tour directory, then redirect to HTTP? I tried the following code, but it didn't work. Is says "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."               RewriteEngine On     RewriteBase /      RewriteCond %{HTTPS} on      RewriteRule !^open-tour/(.*) https://%{SERVER_NAME}/open-tour/$1 [R,L]      I figured it would be a simple matter of adding the exclamation point, but I guess not. Sorry I wrote this in a comment below, but it wasn't formatted very nice :P This whole thing wouldn't be an issue, but unfortunately once you get to the HTTPS page and go elsewhere on the site, the HTTPS sticks. I have a Constant Contact plugin that pulls up a warning for trying to pull unencrypted data to an encrypted https protocol.


What action to use for when a post is saved / published, with a caveat

I'm trying to do some stuff when a post has been saved, I'm currently using the `save_post` action, of which generally works. However, the problem I'm having is when a post is scheduled it fires the `save_post` action, of which changes some data I don't want it to. Is there an action of which fires **only** when the user clicks publish / save in the post edit screen, and **not** when a post changes schedule status.


Exclude the category of the current post

I have a simple site that shows one random post when you reach it. This post then has a link below it that, when clicked, will pull in another random post to that homepage, excluding all posts from the category that the current post is in. Eg. A post from category 'Bikes' is shown. Below it is a link that needs to replace that post with another random post from all the categories excluding the posts in 'Bikes' I am finding it easy to find code for excluding a set category but i can't find a way to read what post category is shown on the page and exclude only that. I would greatly appreciate any advice. WordPress Version 3.1


Unable to Change "Pages:" Before WP_LINK_PAGES

Below is a functions.php code for wp_link_pages which allows pagination and previous/next links to be displayed. It also wraps each pagination link in a span class called "classlinks". I need to change the default "Pages:" before the pagination while maintaining the rest of the code. My attempts removed the ability to show both next/previous links and pagination. Any help?               // WP_LINK_PAGES: Add prev and next links to a numbered link list     add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add');              function wp_link_pages_args_prevnext_add($args)     {         global $page, $numpages, $more, $pagenow;              if($page-1) # there is a previous page             $args['before'] .= ' '. _wp_link_page($page-1)                  . $args['link_before'] . $args['previouspagelink']  . '' . ' '             ;              if ($page<$numpages) # there is a next page             $args['after'] = ' '. _wp_link_page($page+1)                . $args['link_before'] . $args['nextpagelink']  . ''             ;              $args['link_before'] = '';         $args['link_after'] = '';              return $args;     }


Set order of returned items in the WP_Query() class/function

I have this function which gives me `IDs` and `titles` of all `child pages` of a given `parent ID`.               function getPageChildren($page_id) {            $my_wp_query = new WP_Query();       $all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));            $page_children = get_page_children($page_id, $all_wp_pages);            foreach ($page_children as $p) {             $tmp['id'] = $p->ID;         $tmp['title'] = $p->post_title;             $pages[] = $tmp;       }            return $pages;         }      I want some way of ordering them in the backend, which I'd presume is done in the page attributes box of the edit page in the `Order` field? I have amended my the second statement in the above with the following:               $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'sort_order' => 'ASC', 'sort_column' => 'menu_order'));      hoping this would tell the function to talke into account the order I specify, but this doesn't seem to work. Can anyone tell me how I am supposed to order the results of my function from the backend please? Thanks


Add an attachment feature to comments

Is there a way to allow attachments with wordpress comments? I know of a paid plugin that allows this but I was hoping for someone to point me in the correct direction that's future proof and doesn't rely on plugins. Ideally I would want the attachment to be connected to the post itself so we could query all the attachments if needed. Thanks!


Custom Attachment Type

I want to create a "photography" custom post type which uses attachment's same edit/upload panel. Exact same panels usage for "attachment" post type but with "photography" name. Is it possible?


WP_Query and two custom fields returns no posts

Having trouble with WP_Query returning no posts when filtering on two custom fields, although testing for each custom field individually works perfectly. After reviewing documentation for custom field parameters I'm obviously still missing something. Thank you in advance for any assistance or ideas. Query that produces no posts:               $query = new WP_Query(array(     'post_type'=>'games',     'orderby'=>'menu_order',     'order'=>'asc',     'posts_per_page' => 1,     'meta_query'=> array(         'relation'=>'AND',         array(             'key'=>'game_date_time',             'value'=>$nowtoday,             'compare' =>'>'         ),         array(             'key'=>'home_team',             'value'=>'Allen',             'compare'=>'LIKE'           )     )     ));          SQL produced:                `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) WHERE 1=1 AND wp_posts.post_type = 'games' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'game_date_time' AND CAST(wp_postmeta.meta_value AS CHAR) > '3/5/2014 23:12') AND (mt1.meta_key = 'home_team' AND CAST(mt1.meta_value AS CHAR) LIKE '%Allen%') ) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order asc LIMIT 0, 1`      The var `$nowtoday` is a formatted timestamp for comparing against the custom field `game_date_time`. Querying only on `game_date_time` yields the expected result. Here is that query and it returns the next chronological game (home or away) as intended.               $query = new WP_Query(array(     'post_type'=>'games',     'orderby'=>'menu_order',     'order'=>'asc',     'posts_per_page' => 1,     'meta_query'=> array(         'relation'=>'AND',         array(             'key'=>'game_date_time',             'value'=>$nowtoday,             'compare' =>'>'         ),         array(            /* 'key'=>'home_team',             'value'=>'Allen',             'compare'=>'LIKE'  */         )     )     ));      SQL produced:               `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'games' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'game_date_time' AND CAST(wp_postmeta.meta_value AS CHAR) > '3/5/2014 23:11') ) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order asc LIMIT 0, 1`      Similarly, the modified query to return only home games, that is to say, where home_game is LIKE 'Allen', returns the expected result.               $query = new WP_Query(array(     'post_type'=>'games',     'orderby'=>'menu_order',     'order'=>'asc',     'posts_per_page' => 1,     'meta_query'=> array(         'relation'=>'AND',         array(            /*  'key'=>'game_date_time',             'value'=>$nowtoday,             'compare' =>'>'  */         ),         array(            'key'=>'home_team',             'value'=>'Allen',             'compare'=>'LIKE'           )     )     ));      SQL produced:               `SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'games' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = 'home_team' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Allen%') ) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order asc LIMIT 0, 1`      The puzzle is why the two filters together produce no result, when there are numerous posts that meet both conditions, `game_date_time > $nowtoday AND home_team LIKE 'Allen'`. Thank you for your time and any suggestions toward a solution!


Advanced Custom Fields - Query Efficiency

For testing purposes I have edited page.php to have nothing other than:               <?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
     <?php $site_options = get_fields('options'); ?>     <?php endwhile; ?>      I removed get_header, get_footer and only have ACF plugins enabled because I am still early in development and doing some initial testing. When I view the page without calling get_fields it reports 9 queries but if I visit the page with get_fields it jumps to 72 queries. It seems like that should only bump by 1 or 2 queries...not 63. Queries are reported using:               get_num_queries();      Results from get_options call:               Array(     [main_ad_-_image] => Array         (             [id] => 25             [alt] => TEST             [title] => lg-social_media             [caption] =>              [description] =>              [mime_type] => image/png             [url] => {urlhere}             [width] => 460             [height] => 260             [sizes] => Array                 (                     [thumbnail] => {urlhere}/wp-content/uploads/lg-social_media-150x150.png                     [thumbnail-width] => 150                     [thumbnail-height] => 150                     [medium] => {urlhere}/wp-content/uploads/lg-social_media-220x124.png                     [medium-width] => 220                     [medium-height] => 124                     [large] => {urlhere}/wp-content/uploads/lg-social_media.png                     [large-width] => 460                     [large-height] => 260                 )              )          [main_ad_-_url_type] => ext     [main_ad_-_url] => www.google.com     [small_ad_1_-_image] => Array         (             [id] => 28             [alt] => Fake Text             [title] => fake-text             [caption] =>              [description] =>              [mime_type] => image/png             [url] => {urlhere}/wp-content/uploads/fake-text.png             [width] => 220             [height] => 120             [sizes] => Array                 (                     [thumbnail] => {urlhere}/wp-content/uploads/sm-fake-text-150x120.png                     [thumbnail-width] => 150                     [thumbnail-height] => 120                     [medium] => {urlhere}/wp-content/uploads/sm-fake-text.png                     [medium-width] => 220                     [medium-height] => 120                     [large] => {urlhere}/wp-content/uploads/sm-fake-text.png                     [large-width] => 220                     [large-height] => 120                 )              )          [small_ad_1_-_url_type] => ext     [small_ad_2_-_image] => Array         (             [id] => 30             [alt] => Fake Text 2             [title] => fake-text2             [caption] =>              [description] =>              [mime_type] => image/png             [url] => {urlhere}/wp-content/uploads/fake-text2.png             [width] => 220             [height] => 120             [sizes] => Array                 (                     [thumbnail] => {urlhere}/wp-content/uploads/fake-text2-150x120.png                     [thumbnail-width] => 150                     [thumbnail-height] => 120                     [medium] => {urlhere}/wp-content/uploads/fake-text2.png                     [medium-width] => 220                     [medium-height] => 120                     [large] => {urlhere}/wp-content/uploads/fake-text2.png                     [large-width] => 220                     [large-height] => 120                 )              )          [small_ad_1_-_url] => www.google.com     [main_ad_-_page] => {urlhere}     [small_ad_2_-_url_type] => ext     [small_ad_2_-_url] => www.google.com     [small_ad_3_-_image] => Array         (             [id] => 27             [alt] => Fake Text 3             [title] => fake-text3             [caption] =>              [description] =>              [mime_type] => image/png             [url] => {urlhere}/wp-content/uploads/fake-text3.png             [width] => 220             [height] => 120             [sizes] => Array                 (                     [thumbnail] => {urlhere}/wp-content/uploads/fake-text3-150x120.png                     [thumbnail-width] => 150                     [thumbnail-height] => 120                     [medium] => {urlhere}/wp-content/uploads/fake-text3.png                     [medium-width] => 220                     [medium-height] => 120                     [large] => {urlhere}/wp-content/uploads/fake-text3.png                     [large-width] => 220                     [large-height] => 120                 )              )          [small_ad_3_-_url_type] => ext     [small_ad_3_-_url] => www.google.com     [small_ad_4_-_image] => Array         (             [id] => 29             [alt] => Fake Text 4             [title] => fake-text4             [caption] =>              [description] =>              [mime_type] => image/png             [url] => {urlhere}/wp-content/uploads/fake-text4.png             [width] => 220             [height] => 120             [sizes] => Array                 (                     [thumbnail] => {urlhere}/wp-content/uploads/fake-text4-150x120.png                     [thumbnail-width] => 150                     [thumbnail-height] => 120                     [medium] => {urlhere}/wp-content/uploads/fake-text4.png                     [medium-width] => 220                     [medium-height] => 120                     [large] => {urlhere}/wp-content/uploads/fake-text4.png                     [large-width] => 220                     [large-height] => 120                 )              )          [small_ad_4_-_url_type] => ext     [small_ad_4_-_url] => www.google.com     [facebook] => www.facebook.com     [twitter] => twitter.com     [youtube] => www.youtube.com     [office_address] => text     [office_address_-_google_url] => test     [office_-_phone] => 1234567890     [office_-_800_#] => 8001234567     [office_-_email] => email@email.com)      Should I be concerned about this?


How / where is the  wp_query object created for RSS feeds?

Looking at the code in feed-rss2.php and feeds-rss2-comments.php, after the header preamble, we have a Loop - eg in feeds-rss2-comments.php:               if ( have_comments() ) : while ( have_comments() ) : the_comment();     $comment_post = get_post($comment->comment_post_ID);     get_post_custom($comment_post->ID);      Where is the wp_comment_query object being created for this loop? What I'm doing (following my question yesterday), is creating 2 new RSS feeds - one showing posts that have been trashed, the other showing comments that have been trashed. It's easy enough to add a new query_posts / get_comments call, but is there a more efficient way of doing it?


Strip <p> on get_the_content_limit

I would like to remove the paragraph tags < p > it generates, i tried adding strip tags but it doesn't seem to work.               function the_content_limit( $max_characters, $more_link_text = '(more...)', $stripteaser = false ) {          $content = get_the_content_limit( $max_characters, $more_link_text, $stripteaser );         echo apply_filters( 'the_content_limit', $content );    }


Settings API Multiple Checkbox in General Settings

I am trying to add a custom setting at General Settings page with checkboxes. My plan to this is for users to select appropriate categories for their blog based on a list of categories through checkboxes. I use the code below.               $new_general_setting = new new_general_setting();          class new_general_setting {         function new_general_setting( ) {             add_filter( 'admin_init' , array( &$this , 'register_fields' ) );         }         function register_fields() {             register_setting( 'general', 'mystore_categories', 'esc_attr' );             add_settings_field('mystore_categories', ''.__('Store Category' , 'favorite_color' ).'' , array(&$this, 'mystore_categories_func') , 'general' );         }         function mystore_categories_func() {         $options = get_option('mystore_categories');         $portfolio_cats = ( is_array( $options['mystore_categories'] ) ) ? array_map( 'absint', $options['mystore_categories'] ) : array();         $blog_id = 1;         switch_to_blog($blog_id);         $hiterms = get_terms( 'product_category', array( 'hide_empty' => 0, 'parent' => 0) );              foreach ($hiterms as $hiterm) {           // $checked = $options[mystore_categories][$loterm->term_id] ? ' checked="checked"' : '';           echo '<input type="checkbox" name="mystore_categories[]" value="' . $hiterm->term_id . '" ' . checked( in_array( absint( $hiterm->term_id ),$portfolio_cats ),true ) . '> ' . $hiterm->name . '
';           $loterms = get_terms('product_category', array('orderby' => 'slug', 'parent' => $hiterm->term_id, 'hide_empty' => 0));           if($loterms) {             foreach($loterms as $loterm) {               echo '<input type="checkbox" name="mystore_categories[]" value="' . $loterm->term_id . '" style="margin-left:25px;" ' . checked( in_array( absint( $loterm->term_id ),$portfolio_cats ),true ) . '> ' . $loterm->name . '
';             }           }         }              restore_current_blog();         echo '
Select the category or categories that suits what you sell.';         }     }      However, when submitting the page, the checked ones are not getting checked. Also, when I echo the $options[mystore_categories] its empty. Please help


Is it possible to add post specific info in head of worpress post for OG use

Im trying to implement this OG features on my site. http://www.jwplayer.com/blog/publish-your-videos-to-facebook-with-a-jw-player/ Is it possible to get post title, thumbnail url, and place it in the head section of a wordpress single post page? Thanks


WP_Query using OR arguments e.g. posts in Category OR has Tag

I'm wondering if it's possible to use WP_Query() to filter posts by multiple OR arguments. I'd like to retrieve all posts that are in a category OR have a tag. If this is not possible using WP_Query(), what would be the easiest way to achieve this? The code below filters posts that are in cat 1 AND have tag 2. I need posts that are in cat 1 OR have tag 2.               $args = array(       'cat' => '1',       'tag' => '2',       'post_type' => 'post',       'posts_per_page' => -1     );          $the_query = new WP_Query( $args );


Customise Wordpress Update Notice in wp-admin backend area

Is there any way to customise the wordpress update notice in the backend admin area? ![wordpress 3.9 update notice](http://i.stack.imgur.com/9y6Hx.png) I want to make it so that I can change the **Please update now** to **Please contact now** and link to a different URL. So the person running the website doesn't update the website, since they don't know how to back up the website. I have found ways to hide the notice online, but no way to actually edit it.


Check if user registered more than a month ago

How would I go about checking if current user registered more than, say, 30 days ago? I would like to display certain content only to that group of users. Thanks very much in advance for your help.


sql query to put quotes around numbers in img tag

I have quite a few old posts that contain an img tag with height and width with no double quotes around the numbers. For example:               <img height=319 alt="" src="http://www.example.com/images/myexample.jpg" width=496>      I am not sure how to write a MySQL query that can find the height and width numbers, and surround them with double quotes. Although a MySQL query is preferred, if this is not possible then perhaps someone could suggest a regular expression I could use with a PHP script that might solve this issue.


Setting admin edit panels & metaboxes positions and visibility for ALL users and admins

My WP 3.3 setup involves several post types and customized edit panels with Advanced Custom Fields plugin (which creates many metaboxes) and other plugins such as SEO metabox panel, Scribu's Posts2Posts connections and more. The problem is, the appearance order of these panels is often quite random (even if Adavanced Custom Fields offers some sort of ordering, but it doesn't always work, since other plugins don't have it and furthermore I might want to change metabox positions according to post types). Now, Wordpress allows each administrator / user with proper rights to arrange the metaboxes in edit panels the way he/she wants. However... every admin has to arrange their own!! Isn't there a way to prepare a default/fixed ordering or let superadmin or one admin in particular to set the panels position for EVERYBODY? I have at least 4 admins and few editors/authors... it doesn't make sense I have to set up their panels logging in with EACH of their accounts... it's stupid and time consuming, and confusing for non wordpress savvy users. Is there any plugin or code snippet that could help my case? thank you


Set Default User Role

I'm using WordPress 3.3.1. When a user registers, I want to be able to set the new user to an author. How would I do this?


Target Post Type from array Query

I have the following query to extract posts from two different types. However, how can I then target them in the actual content display conditional code? The if ($my_query->post_type == 'featured' ) does not work. I also tried if (post_type == 'featured' ).                   <?php      // query posts     $my_query = new WP_Query             ( array(             'post_status' => 'publish',             'post_type'   => array('featured', 'wpsc-product'),             'orderby'     => 'menu_order',             'order'       => 'ASC',             'showposts'   => 50 ));           while( $my_query->have_posts() ) : $my_query->the_post();     $fitemlink = get_post_meta($post->ID,'new_fitemlink',true);                // display the content           if ($my_query->post_type == 'featured' ) {      echo get_image_path(get_post_meta($post->ID, 'slideimage_src', true));          } else if ($my_query->post_type == 'wpsc-product' ) {      echo wpsc_the_product_image(); }           endwhile; ?>


Automatic Shortcode Creation with Custom Fields

This is basically a php issue as I'm fairly new to it and can't figure out how to code things the way I want. I am basically trying to pull information from custom fields (grid reference) and post titles etc to then write out a (long) shortcode. This shortcode creates a map (OS OpenSpace Maps Plugin) Currently I have successfully got code to print out (echo) the shortcode, and then I have to edit it slightly, removing spaces and a few obsolete characters, then manually paste this back into template using 'do_shortcode' The correct format of the shortcode is:               [osmap markers="HU123456;Link 1|HU123456;Link 2...etc"]      My current code to print on the screen is:               <?php     echo '[osmap width="800" height="600" markers="';     $args=array(       'post_type' => 'sport-crag',       'post_status' => 'publish',       'posts_per_page' => -1,       'caller_get_posts'=> 1       );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {       while ($my_query->have_posts()) : $my_query->the_post(); ?>       <?php echo get_post_meta($post->ID,'gridref', true);?>;<a href=\'<?php the_permalink() ?>\'><?php the_title(); ?>|       <?php       endwhile;     }     wp_reset_query();  // Restore global post data stomped by the_post().     echo '"]';     ?>      What I really want to do is put all this inside the 'do_shortcode' function. There are also a few issues with my solution so far that I can't figure out how to sort.   1. Grid references often have spaces in them (e.g. HU 123 456), but this will not work in the shortcode so they need the spaces taking out (HU123456).   2. My code puts a final '|' after the last entry which needs to be removed. Not sure how to do this though as its part of the while loop. Any help to get this an automatic process all inside the php would be much appreciated! It only takes 5 mins at the moment, but the issue is that if any other posts are added, the process has to be redone before they appear on the map, so it will get annoying. I also have 4 maps for different post types so it will get very irritating!


Getting a specific "title for a section" only on Startpage?

I have a website which shows alle posts from my wordpress on the startpage. thanks to Stephen Harris who helped me with this code I put in the functions.php:               add_action('pre_get_posts','wpse57309_alter_front_page_query');     function wpse57309_alter_front_page_query( $query ){          if( $query->is_main_query() && is_front_page() ){              if( !$query->get('post_type') ){                  //post type is not set, the default will be an array of them:                  $query->set('post_type',array( 'movies', 'music', 'featued'));              }          }     }      Now I have another problem: I am getting the titles for each section by using this code here:               <?php wp_reset_query(); ?>     <?php echo $post->post_type; ?>      in between h2 tags - but now on Startpage I get different names of the post type - but I'd like to have just: "Home" as Title... I tried it with is_home() and with is_front_page() but I had no luck. Also the "post_type" is set to one specific on this page. I have built in a filter which filters on click the posts using a `&style=soul` but on startpage its now always one specific post_type. I guess its the last post's post_type... Maybe someone has a hint?


Advice for Beginner in Wordpress

I am very new to the wordpress. My simple objective is i want to create one website with database. I have donwloaded wordpress. After this how should i start installing and configuring my local setup before uploading my site into a webserver. Please help. Regards Dinesh.


problem with has_post_thumpnail in foreach loop

I have a code that display the post if has_post_thumpnail the problem is it shows all the posts wheather it has thumpnail or not                   <?php      global $post;     $args = array( 'numberposts' => 5 );      $postQuery = get_posts($args);      $num  = 0;      foreach( $postQuery as $post ) : setup_postdata($post);                  if ( has_post_thumbnail() ) { ?>
                          <a href="<?php echo get_permalink(); ?>" title="Go to <?php echo the_title(); ?>" rel="bookmark">                         <?php the_post_thumbnail('medium'); ?>

                     <?php the_title('
','
'); ?>                              <?php the_content();  ?>
             <?php              }         endforeach; ?>


Applying if (get_post_meta) to new shortcode

It's my first time here so here goes :) I've created a custom image field which allows me to upload new images, or have images added via a form from the frontend. I want these to display. I'm creating a shortcode like so:                   function display_ad() {         global $post;         return do_shortcode( '' . 'ID , "wpcf-display-ad" , true ) . '"/>' . '' );         }         add_shortcode('display-ad', 'display_ad');      This works fine - images are displayed and link to their respective post, but for posts that don't contain a display image, the src tag still returns (and any css, for example a border, too). I'm struggling to figure out how to apply the if statement to the above code, i.e:                   if ( get_post_meta( $post->ID , "wpcf-display-ad" , true ) ) :      ... so that if an image doesn't exist then nothing is returned. * * * Hi Abdussamad Thanks for your suggestions. I've just spent the last hour trying to wrap my head around them and them to work, but no joy. I must warn you I'm very much at the early stages of PHP :) Here's what I've done based on your comments:               function display_ad() {     global $post;     $content = get_permalink($id);     $ad_image = get_post_meta( $post->ID , "wpcf-display-ad" , true );     if( empty( get_post_meta( $post->ID, 'wpcf-display-ad', true ) ) ) {     return $content;     } else {     return $content . $ad_image;     }     }     add_shortcode('display-ad', 'display_ad');      However, this just returns a white screen. I have two posts up at the moment on my development site (one with a display ad, the other not), and if I remove the if statement bit, and just `return $content;` then the posts and their permalinks display. If I just `return $ad_image;` again the posts display together, one showing the path to the image, the other blank (but present in Chrome's Developer Tools panel). However, with the if statement I get the white screen. Evidently I'm doing something wrong. Thanks for your help. Gavin.


Why is jQuery not working properly?

I've enqueue'd jQuery from Google and it's displaying in the source code but no matter where I put my scripts they don't seem to work. Here is the site in question - http://www.deanelliott.me/handh/ Near the bottom of the page, there are a couple of testimonials, these should appear one at a time in a slideshow, but, as you can see that's not happening. I'm not a jQuery master by any means but I can hold my own and I've never had any issues before... Any help would be greatly appreciated


update_option onclick

I'm trying to add a update_option value when I click a text link. I came up with the following code, but I don't know how to make it "clickable", like                   <?php          function toggle_chat_front_end()          {                update_option("show_chat","true");          }          add_action("show_chat", "toggle_chat_front_end");     ?>      ### It should work as "Enable/Disable Chat" <\-- Clickable link Also, that would change the value to true, right? How can I make a "toggle" out of it? On and off ### show_chat code:                 if (get_option( 'show_chat' ) != "") {               if(!is_plugin_active('online-chat/online-chat.php'))            activate_plugins('online-chat/online-chat.php');               } else {              if(is_plugin_active('online-chat/online-chat.php'))            deactivate_plugins('online-chat/online-chat.php');                }          }      Thanks for your time!


Template for page with overridden Theme

I think I've got a somewhat uncommon issue. My wordpress site uses a custom theme, but I wanted to add a blog alongside that, without using multisite because my host charges 3x the amount for such a feature. What I found was the ability to override an individual page's theme using a plugin, called Page Theme (Click for theme home page). This worked great - until I tried to load posts of a specific category. I have a new category with slug blog-posts, cat=14, which are the only ones I want to show up on the page. I set my site's default theme back to my Custom Theme, then overrode the Blog page to be the twentytwelve theme. I then set the page template to a php file that queries for my blog posts (following instructions similar to these) However, all of the formatting is lost. If I go to my site's settings, Reading > Static Page > and then select the Blog page for Posts, the formatting is back, but its showing EVERY post. I realized the templates I can select, because I have my Custom Theme set to default, are only those in my /themes/CustomTheme/.. folder. I also learned that when you select the static posts page, it will look up the index.php for that theme (in this case, twentytwelves index, which looks great!)... But I'm not sure how to QUERY for the posts I would like, while maintaining the TwentyTwelve theme format. Any guidance is very much appreciated. 4 hours spent on this and I'm just where I started :( Charlie


Shopping plugin with user groups

We need to implement different user groups on our new WP-site so every group has it's own price for every product. For example: "retail customers" and "wholesale customers". Is there an appropriate solution that works out of the box? If not, what approach should you recommend to achieve this? Maybe some combination of plugins will do? We really don't want to create separate domains or to have duplicate items in our shop. Thanks!


mobile vs responsive sites

A web company for a medical clinic in the US is telling me that it is cheaper for them to build regular WP site and a separate WP mobile site than a single WP responsive site. What is the conventional wisdom which is better. Is responsive just for those who can't afford a regular and a mobile site or does it handle more devices than a mobile site?


How to use wildcards in $wpdb queries using $wpdb->get_results & $wpdb->prepare?

I am attempting to make a custom search for BuddyPress groups. Here is my method:               public function search_groups($string){         global $wpdb;         $results = $wpdb->get_results($wpdb->prepare(             "             SELECT *              FROM {$wpdb->prefix}bp_groups              WHERE `name` LIKE '%%s%'             AND `description` LIKE '%%s%'              AND `status` = 'public'             ORDER BY `name` ASC             ",             $string,             $string         ));         if(!empty($results)){             $return = $results;         } else{             $return = false;             }         return $return;     }      However, I am receiving a WordPress database error. I'm pretty sure it's due to the fact that I'm using `$wpdb->prepare();`, since it uses % signs for replacing variables. Let's take a look at this portion of my query:               WHERE `name` LIKE '%%s%'     AND `description` LIKE '%%s%'      That just looks like trouble. Is there any way that I can accomplish something along the lines of...               WHERE `name` LIKE '%{$string}%'     AND `description` LIKE '%{$string}%'      and still use the `$wpdb->prepare();` method?


using wp_redirect to redirect to a permalink

I'm using wp_redirect to change the URL of my 404 page:               function show_404($message = 'page not found'){        wp_redirect(home_url() . '/error/404?m=' . urlencode($message));        exit();     }      I have created a wordpress page that has a `/error/` permalink. It works fine on my local WAMP environment (properly showing my themed 404 page when navigating to `localhost/wordpress/pageThatDNE`), but when I test it to a real server, I get a `The requested URL /error/404 was not found on this server.` message. Navigating to `mysite.com/error/` gives me a `You don't have permission to access /error/ on this server.` message. My other pages/permalinks work fine. Any ideas how to resolve this?


How to restricted a page [without plugin]

How to restricted a page in wordpress. For example : user [ _without login_ ] can see 5 of game list. [example.com/game/] and after click 'view more', **user must login/register** and after that, user **can access full/100 game list**. [example.com/game/] Anyone know to make it without plugin? thank you


How to add options to the plugin page?

I can't find a more or less clear example on how to create additional fields, so may be someone can help me here? Here is my code:               function __construct(){         add_action('admin_init', array($this, 'plugin_admin_init'));     }          public function create_fields(){         register_setting('dleToWp_options', 'database_name');         register_setting('dleToWp_options', 'database_prefix');         register_setting('dleToWp_options', 'version');         //Stuck here         // add_settings_section('dleToWp_options', __('Settings', 'dleToWp'), NULL, 'dleToWp');         // add_settings_field('plugin_text_string', 'Plugin Text Input', 'plugin_setting_string', 'plugin', 'dleToWp');     }          public function settings_page(){              echo '

'.__('Database converter', 'dleToWp').'
             <form action="options.php" method="post">';         settings_fields('dleToWp_options');         do_settings_sections('dleToWp');         echo '</form>
';     }      I nee create 3 fields: Database name, database prefix and select box of versions.


How to link a custom post type to a page that uses a template that is a child page?

I only have 4 links on my navigation. One of those links is "Neighborhoods". I have created a custom post type so that client can enter new neighborhoods as a menu item on a another page and so that they can enter a custom URL for that menu item. Then i create the Neighborhood page from a template (lets call it Adams Morgan) and the default URL to the site once created is domain/adams-morgan and now i'll present two possible options for why i can't properly link the menu item to the page. On custom post type "Neighborhoods" in the custom field URL box i enter "adams-morgan" assuming it should link to that postname permalink. Instead what it does is change the URL to domain/neighborhoods/adams-morgan and doesn't take me to the actual page which is at domain/adams-morgan. I then tried to make Adams Morgan a child of the Neighborhoods page but all that did was change the URL to domain/neighborhoods/adams-morgan. I know what you're thinking that should've worked because it now matches the one i mention a couple of lines up but the reality is that this page that is created looks like a single blog post page without any content and just uses the "Adams Morgan" name as a title to its content-less page instead of taking me to the actual Adams Morgan page that has styled content? In a perfect world i would like my URL to read domain/neighborhoods/adams- morgan but that page only takes me to a single post looking page. The other URL of domain/adams-morgan takes me to the styled page (when i remove Neighborhoods as the parent to this page) i can actually see the page but when i tried to make the Adams Morgan page a child of the Neighborhoods page the URL domain/adams-morgan ceased to exist and now would forward straight to domain/neighborhoods/adams-morgan. Any suggestions why it does this? What's strange to