Change admin startpage to Pages-page?

When you login to the admin you see the Welcome page by default. A client of mine requested to see the "Pages" page by default, he had seen it somewhere else. Is this possible, and if so, how? Tried searching but found nothing relevant, didn't find it in the settings either.


Display trackbacks separately from comments in twentyeleven

How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop? The function below is from the twentyeleven functions.php file. I'm using the standard comments.php file from twentyeleven, and the trackbacks are shown under the comments when using `<?php comments_template( '', true ); ?>` in a template file. I can delete that, **but while keeping the normal comments display, how do I display pings in other areas of a template file all by themselves?** _(Yes, I'm using a child theme.)_               if ( ! function_exists( 'twentyeleven_comment' ) ) :     /**      * Template for comments and pingbacks.      */     function twentyeleven_comment( $comment, $args, $depth ) {         $GLOBALS['comment'] = $comment;         switch ( $comment->comment_type ) :             case 'pingback' :             case 'trackback' :         ?>

<?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '', '' ); ?>
         <?php                 break;             default :         ?>


Adding default post content for category

I'm trying to add some default content to my posts using this code in my functions.php:               add_filter( 'default_content', 'my_editor_content' );     function my_editor_content( $content ) {     $content = "My html content.";     return $content;     }      It works fine, but I would like to add the content to some categories only. This is tricky because the default content gets added while creating a new post, (so it is without a category). I followed this thread: Force category choice before creating new post? and the author came up with a way of forcing you to choose a category before wp creates the new post, but I don't know how to edit the default content code so it is only applies to some categories?


Get Order of Meta Box in a Page/Post

I'm using the Posts 2 Posts plugin specifically, but I think this applies to any meta box. I have three Posts 2 Posts metaboxes on the side: "Related Case Studies", "Related White Papers" and "Related Videos". I'd like the client to be able to drag these, and have the metabox order correspond to the order they appear on my sidebar. I can do all the backend code to sort properly on the page, I just need to retrieve the value of the metabox order on a per page basis. Meaning if the client dragged the "Related Videos" metabox above the "Related Case Studies" metabox, I'd be able to grab a value to be aware of that on the page itself and output it exactly like it looks. Is this possible? Thanks.


Anonymous Survey

I am wondering if there is a survey plugin that guarantees anonymous answers but has at the same time a function to save the participants e-mail-adresses for a kind of lottery? Or: Is there a (medium-hard^^) way to do this on my own? Thanks for helping!


Redirect users away from Admin breaks ajax

Tried to make a simple redirect for some users I don't want to access the wp- admin/, so I did this code:               function no_admin_access() {         if ( !current_user_can( 'delete_posts' ) ) {             wp_redirect( site_url( '/' ) ); exit;         }     }     add_action('admin_init', 'no_admin_access');      But when I then try to make a ajax request with those users, the that is also redirected so I never get to admin-ajax.php Anybody who has a good work around for this ? Thanks. AJAX Code               $.ajax({         type: 'POST',         url: MyAjax.ajaxurl,         data: {             action: 'mux_ajax_delete_pix',             pid: $this.attr('data-id')         },         success: function(){             $this.parent().fadeOut();         }     });


bbpress change the word forum, topic, reply in the forum to another word I choose

bbpress I would want to customize my Forum in bbpress. by changing/replacing the words that appear on the forum layout. I would like to change the words (everywhere they appear): Forum, topic, reply. To other words of my choice. Does anyone have any way of doing this? I think I will need to make a child theme? anyone have any experience with such a problem? Does anyone know what files name to edit for theme twenty eleven. and where they files are located?


Undefined property: stdClass::$labels in general-template.php post_type_archive_title()

I've got a custom post type with a standard tag taxonomy added to it like so: `'taxonomies' => array('post_tag')`. I've added some tags to some posts of this CPT which are display on the front-end with the template tag `the_tags()` and the links it generates have this format `http://local.mysite.dev/tag/tag1/`. When I click such a link a page without any posts is generated using the `tag.php` template, but if I add `?post_type=seron_mycpt` to the end of the URL like so `http://local.mysite.dev/tag/tag1/?post_type=seron_mycpt` a page with the relevant posts is generated using the same template but this time I also get these lines added to `debug.log`:               PHP Notice:  Undefined property: stdClass::$labels in /...sitepath.../wp-includes/general-template.php on line 665     PHP Notice:  Trying to get property of non-object in /...sitepath.../wp-includes/general-template.php on line 665      These notices are produced when `wp_title()` is called in the `header.php` template. According to the rewrite rules the request is transformed into the query `tag=tag1&post_type=seron_mycpt`. For debugging I put `print_r(get_queried_object());` in `header.php` and got this:               MYSITEstdClass Object     (      [term_id] => 27      [name] => tag1      [slug] => tag1      [term_group] => 0      [term_taxonomy_id] => 27      [taxonomy] => post_tag      [description] =>      [parent] => 0      [count] => 2     )      I think WP expects a CPT object with a `labels` property but gets this object instead which doesn't have that property. If I tag an ordinary `post` with the same tag, the same `header.php` and `tag.php` templates are used and that post is displayed when using the `http://local.mysite.dev/tag/tag1/` URL, and in that case no PHP notices are produced in `debug.log`, although `print_r(get_queried_object())` shows a very similar object. Maybe WP never reaches the notice-producing line in `general- template.php`. I don't understand what this object is and why it is passed instead of a CPT object. Could someone explain?


permalinks with get variables

I'm trying to create my own permalinks with wordpress rewrite API. I have been registering my get variables as it follows               add_filter( 'query_vars','driver_vars' );     function driver_vars( $vars ) {         global $wp_query;         array_push($vars, 'cat_name');         array_push($vars, 'group');         return $vars;     }      and making my own rule as it follows               function drivers_rewrite_rules( $rules ) {         global $wp_rewrite;         $newrules = array(                             'drivers/([^/]+)/([^/]+)/([^/]+)/?$' =>   'index.php?pagename=drivers&cat_name=$matches[1]&group=$matches[2]&product=$matches[3]'                           );         $finalrules = $newrules + $rules;              return $finalrules;     }      my rewrite rule is not getting executed on the second and third variable when I var_dump($wp_query->query_vars) I see just my cat_name variable. if I access with the following url structure than it's okay                ?pagename=drivers&cat_name=Desktops&group=Alienware


Plain-text tag list?

I'm looking for a way to display a plain-text list of tags to use as classes on my post elements, I've been trying               $tags = get_tags();     $tag_list = "";     foreach($tags as $tag){         $tag_list .= $tag->name . " ";     }     echo "<li class=\"$tag_list\">";      in the loop but it seems to output all the tags instead of just the current post's tags, so if I have tags `x`, `y`, and `z`, and I'm viewing a post with tag `x` I still get `<li class="x y z">` anybody have any ideas as to how to show a plain-text list of tags or what I'm doing wrong?


Custom Taxonomy Tag Cloud?

I found that I can do `<?php wp_tag_cloud( array( 'taxonomy' => 'name', 'format' => 'list' ) ); ?>` But I want the list to be seperated by the letter. Alphabeticaly is what I want. So it would display the letter A then all names with that letter and the letter B with all of the b's and so on. Any ideas?


How to output an image or icon for selected check box in a custom post

I have created a custom post type for a property rental site created with WordPress. In it I want to have the input section as checkboxes: ![image one](http://i.stack.imgur.com/leqBP.jpg) and get the output like this: ![image two](http://i.stack.imgur.com/aHNDX.jpg)


Custom post type archive pagination query issue

I'm using the following query to paginate a custom post type archive. The number of posts on the first page is 11 (due to the page layout) and 12 on the following pages. The problem is that while the posts are displayed correctly as set per page, on the second page the query starts from the 13th post skipping the 12th that should normally appear there first, so it gets skipped. This doesn't happen on the next pages, only on page 2. Any ideas?               <?php              if ( get_query_var('paged') ) {                     $paged = get_query_var('paged');                 } else if ( get_query_var('page') ) {                     $paged = get_query_var('page');                 } else {                     $paged = 1;                 }             if (is_paged()) {                 $offset = ( $paged - 1 ) * 12;                 $no = 12;             }             if (!is_paged()) {                 $offset = ( $paged - 1 ) * 11;                 $no = 11;             }                         $args = array(                             'post_type'=> 'myarchive',                             'orderby' => 'date',                             'order'    => 'DESC',                             'posts_per_page' => $no,                             'meta_key' => 'no_photo',                             'meta_value' => 0,                             'paged' => $paged                     );     ?>


Adding SQL source code to comments

I was trying to add the following SQL source code to a comment:               DELETE a,b,c FROM wp_posts a     LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)     LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)     WHERE a.post_type = 'revision'      and tried this approaches:   * posted by using the backoffice   * used Source Code in Comments Plugin with the code brackets   * and the `<code>` tags   * through Postable (www.elliotswan.com/postable) first It always redirect to the homepage. Can anyone help me? Thanks in advance.


How to track post number on the_loop

I have a need to customize some posts from the loop.   Here's the deal: My site is set to 10 posts per page. On post #2,#5, #7 (on every page), I want to display specific background. What's the best solution for this kind of problem?


Custom design calendar archive

I want to create a archive calendar into sidebar exactly like this site http://www.daily-sun.com/ I don't know they are using plugins or custom coding. please anyone give me suggestion how to create this. Thanks in advance, Sujana


How to Show Comment Count on Related Posts?

I am using this code to show related posts without a plugin. Each post shows the title and comment count. The end result is similar to the way Mashable does it: ![alt text](http://i.stack.imgur.com/I3cvI.png) This appears under each post on single.php. My problem is that the comment count shows the same number on each - it shows the number of comments for the current post. I've tried it a couple different ways as you can see below. How can I change it so that it will show the comment number for each post? By the way, this only started happening recently - previously it showed comment count for each. How weird is that?!

You May Also Like ...

          <?php             $this_post = $post;              $total = get_comments_number();             $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;             $posts = get_posts('numberposts=5&offset=0&orderby=post_date&order=DESC&category='.$category);             $count = 0;             foreach ( $posts as $post ) {             if ( $post->ID == $this_post->ID || $count == 4 ) {                  unset($posts[$count]);             }else{             $count ++;             }                  }             ?>          <?php foreach ( $posts as $post ) :          ?>

<?php get_first_image($post->ID);  ?>

<a href="<?php the_permalink(); ?>" class="purpleLink"><?php the_title(); ?>
     <a href="<?php the_permalink(); ?>"> <?php echo $total; ?>
           <?php endforeach // $posts as $post ?>
          <?php             $post = $this_post;             unset($this_post);             ?>

From the Archives...

     <?php          $rand_posts = get_posts('numberposts=4&orderby=rand');          foreach( $rand_posts as $post ) :          ?>

<?php get_first_image($post->ID);  ?>

<a href="<?php the_permalink(); ?>" class="purpleLink">            <?php the_title(); ?>
          <a href="<?php the_permalink(); ?>"><?php comments_number('0','1','%'); ?>
       <?php endforeach; wp_reset_query(); ?>


Sort posts by post views and consider meta key

my code should show popular posts where the meta key "slider" isn't empty. Have anyone an idea why it doesn't work? The problem is that this code only shows posts with a slider image. But it ignores the sorting.               $values = array(       'numberposts' => 10,       'orderby' => 'meta_value_num',       'meta_key' => 'count_views',       'meta_query' => array(           array(             'key'     => 'slider',             'compare' => '!=',             'value'   => ''           )       )     );          $my_posts = get_posts( $values );     global $post;     foreach( $my_posts as $post ) : setup_postdata($post);             the_title();          endforeach;     wp_reset_postdata();


Including jQuery in Wordpress

I am using the code below to include jQuery in my Wordpress installation. I was previous calling the jQuery file using the standard HTML script but this was causing problems with a Wordpress plugin in IE9. When I use the wp_enqueue_script function, it solves the problem but then it breaks my custom Javascript file which I include after wp_head(). What am I doing wrong?               <?php wp_enqueue_script("/wp-content/themes/mytheme/js/jquery-1.5.1.min.js"); ?>     <?php wp_head(); ?>     <script type="text/javascript" src="/wp-content/themes/mytheme/js/custom.js"></script>


how can view all three subcategory in same line(found ex: and code)

i use the code to view subcategory on category page               <?php     if(is_category()) {              $breakpoint = 0;         $thiscat = get_term( get_query_var('cat') , 'category' );         $subcategories = get_terms( 'category' , 'parent='.get_query_var('cat') );              $items='';         if(!empty($subcategories)) {             foreach($subcategories as $subcat) {                 if($thiscat->term_id == $subcat->term_id) $current = ' current-cat'; else $current = '';             $items .= '
             term_id ).'" title="">'.$subcat->name.'
';             }             echo "$items";         }         unset($subcategories,$subcat,$thiscat,$items);     }     ?>      the resut of this code subcategory1 subcategory2 subcategory3 subcategory4 subcategory5 subcategory6 subcategory7 subcategory8 subcategory9 i want the result like this               subcategory1 * subcategory2 * subcategory3 (all three in same line)     subcategory4 * subcategory5 * subcategory6     subcategory3 * subcategory8 * subcategory9      how can i do that thanks


Updating User Meta from Custom Post Field Upon Publish Not Working

I'm trying to get the user_meta to be updated based on the custom post field type. However the information won't transfer if the new post is published by a user through a frontend form. Currently it only works if you update a listing via the front end form, or publish/edit a post via the backend of wordpress.               function update_package_id($post_id) {     $post = get_post($post_id);     $author = get_userdata($post->post_author);     $author_email = $author->user_email;     $package_id = get_post_meta( $post->ID, 'package_pid', true  );     $user_id = $author->ID;     update_user_meta($user_id, 'package_type', $package_id);          if (function_exists( 'AC_OnUpdateUser' )) {     $user = new WP_User( $user_id );     AC_OnUpdateUser( $user->ID, $user, FALSE );     }     }          add_action( 'publish_place', 'update_package_id' );      The second function fires the information into mailchimp. Am I using the wrong action in wordpress?


Update permalinks

I have added custom "folder" named Srpski to my permalink structure as you can see in .htaccess file below. So in WP Dashboard > Settings > Permalinks my custom permalink structure looks like this:               http://webdizajntest.com/poljoprivredni-fakultet/ **Srpski** /%postname%/ This i working great when i add new post or page. It's displaying their permalinks with **Srpski** in url structure and that is what i need because of maintaining PageRank. Problem is with old pages and posts. Their permalinks do not have this "directory" **Srpski** in url structure because they were saved without it. I have a lot of pages and posts and i can't make them from the beginning, so my question is: **How can I update all existing page and posts permalinks in DB to have this structure with Srpski in URL?**               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /poljoprivredni-fakultet/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /poljoprivredni-fakultet/Srpski/index.php [L]     </IfModule>     # END WordPress


Advanced Custom Fields - Storing array value for further usage

This might might be more of a PHP question - but does deal with a WordPress plugin, Advanced Custom Fields I am using a global select option to store a specific Location (custom post type) as the headquarters. I am storing the value as such:               function options_headquarters() {         foreach(get_field('option_headquarters','options') as $post_object) {             $options_headquarters = $post_object->ID;             return $options_headquarters;         }     }      What I am fuzzy on is - since my option is only allowed to grab one value -- is there an alternative to using a foreach statement (to grab just a specific array value) and still applying it to the post_object? That function stores the postID of that Location. I am currently outputting this in my template as:               echo get_field('location_phone',options_headquarters());      which grabs a field called `location_phone` (a meta value within the Location custom post type) and specify a specific postID to grab the value from (the headquarters). Is there a better way of handling passing in this headquarters value? Just pulling this out of you know where, but something like `options_headquarters('location_phone');` would be pretty sweet ;) Thanks!


How to remove a settings section from the Theme Customization API preview pane?

I am currently working on a theme that uses the Wordpress Customization API and I need to remove some pre-existing sections from the customization preview pane. Is there somewhere like a global variable holding an array of the sections perhaps (in true Wordpress style) I can unset the navigation section in particular? Please see attached image for what I am talking about. I've circled it in red. ![enter image description here](http://i.stack.imgur.com/87pbp.png)


Old blog/ and blog/feed/ URLs not working after moving blog to top-level via .htaccess

For a long time I served my blog from http://www.murrayc.com/blog/, with the wordpress installation in /home/murrayc/murrayc.com/blog/. Now I've moved it to http://www.murrayc.com/, without moving the wordpress installation on the filesystem. I did that by:   * Changing the "Site Address (URL)", in Settings->General, to http://www.murrayc.com. I kept the "WordPress Address (URL)" as http://www.murrayc.com/blog   * Adding a RedirectRule in my top-level .htaccess at /home/murrayc/murrayc.com/, so that, for instance, permalink/something could be used instead of blog/permalink/something. The older blog/permalinks still seem to work too. However, some old links are not working. http://www.murrayc.com/blog/ takes you to a page that happens to mention blogs, presumably via Wordpress's attempt to guess what you want. Likewise, http://www.murrayc.com/blog/feed takes you to the comments feed for one old blog post. With the rules added by Wordpress (after changing the "Site Address URL", I think), this is my .htaccess file:               RewriteEngine On     RewriteBase /     RewriteCond %{REQUEST_URI} !^/temp     RewriteRule ^(.*)$ blog/$1 [L]          # 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      I'm using Wordpress 3.5.1, the latest release, via Dreamhost's 1-click install, which updates automatically. This feels like a bug in Wordpress. Maybe it's misinterpreting URLs that it gets at some point that contain blog/blog.


Permalink Settings: optional settings doesn’t apply to editor

In my WordPress 3.8 in my "Permalink Settings" I've chosen the option "Post name". Then I've added "Optional" for "Category" ( `%category%/%postname%` ), the URLs works like I wanted - `http://example.com/categoryname/postname` \- however this rule doesn’t apply to the editor - when I create new post or edit the existing post the URL in editor is still `http://example.com/postname`, so when I click on _View Post_ or _Preview Changes_ it redirects me to this wrong URL which shows Page Not Found. Any help/ideas? what am I doing wrong?


Publish a Silent Post without updating Feed

Is there a way to publish certain posts, silently without updating the feeds and those posts also should not appear in the home page. Appreciate your help.


"GET / HTTP/1.1" 304 186 "-" inside access_log for a WordPress site, but the admin side works

I've been struggling with this problem and I hope I posted this question in the correct place. I have a Wordpress site I installed on a dreamhost host, it's a Linux host. I cloned this site over from another host where it works OK. Now, the /wp-admin side works perfectly, I can navigate around and save settings and the like, but when I go to the front side, all I get is a blank page. When I look at the logs, error_log doesn't get anything, but access_log gets this line: > 123.456.789.012 - - [19/Nov/2013:21:07:34 -0800] "GET / HTTP/1.1" 304 186 > "-" "..." Of course the IP is not the one it shows and the "..." part is just the browser information. My Linux box is... well, I have never seen this before, but when I run `uname -a` it returns this: > Linux boxwood 3.2.45-grsec-2.9.1-r3+ #63 SMP Fri May 24 02:11:07 UTC 2013 > x86_64 GNU/Linux Anyway, I'm also able to go directly to any other page in the site, or at least all the pages I have tried, it looks like this only affects the homepage. Does anybody have ever had an issue like this? If so, can you please share how you fixed it? Or anyone who can help me out troubleshoot this, because I ran out of ideas. Don't know if the GET codes I get are the answer, because I looked up the 304 here and it's just not clear what I need to do, it mentions something about the document not being modified, but I can't figure out what to do to fix it. What I have already done:   1. Used a different .htaccess file - or no .htaccess file at all, and no luck.   2. I enabled WP debug mode, page still blanks out.   3. Reset many settings in Wordpress that I thought might be causing this - still no luck.   4. Googled the 304 response code but didn't understand what to do next :S Thank you guys


Duplicate content with the same URL, google authorship

I have recently added google authorship to my wordpress blog. When I search for specific posts on my blog, they come up with the post with my google+ picture and byline. On the other hand, when I search only for the title of my blog, I get my homepage (with google+ image and byline) and also a few post pages (this time without google+ picture, but with byline). The URL for these posts (with and without googe+ image) is exactly the same, and in any case I have already set my preferred canonical settings using my SEO plugin. I think the problem is that my homepage shows recent posts (full excerpts), and then there is also my individual post pages with the same URL and same content. My guess is that the posts on my homepage are coming up in search results without the google+ picture (but with the author byline in search results). I am not sure how to resolve this issue, without changing the structure of my site. Any ideas?


Deep customization of the comment form?

I've been handed over a design to translate into WordPress plugin & theme. My question is regarding building a custom comment form. The design used some custom scripts on the comment submit button. It handles 'submitting...' button state, animations, and checks. And it uses an anchor tag `<a>` with jQuery's `.bind` to submit the form. I noticed that the `comment_form` function of WordPress did not offer a solution to change the submit button. I only needed to remove it as I'm handling it myself. What made it worse is that WordPress has hard coded `<input name="submit">` into the button, which made it impossible for jQuery to call `.submit` (more details on this issue here: http://stackoverflow.com/questions/12540953/property-submit-of-object- htmlformelement-is-not-a-function). So just hiding this button with CSS won't work. If I prefer not to use the `<input type="submit">` button of WordPress comment form, do I have any options to build my own button? Thanks.


get_header('header2') not working properly in child themes

I am trying to replace header-header2.php of my main theme in my child theme and by adding the file in the child theme, but wordpress is loading the file from the main theme itself. Is the second header not supported in a child theme??? In index.php, I am using get_header('header2') to call the file. Anyone knows how to do this. Please help, its urgent!!!


upload script in plugin development

> **Possible Duplicate:**   >  How can you upload an image from within a settings page? I am developing a plugin. Which has a form. The form contains the following fields.   1. Course Name   2. Course file. The course file field is of type file from where I will upload a file. The name of the file I will store in database and the the uploaded file should save in the wp-content/uploads directory. How will I do this in wordpress. I am new to plugin development so please help me out.


Load more posts with multiple queries

I've been developing a theme which uses the load more ajax plugin, everything is setup and working great with the main query. But, once I setup a new query for popular posts, the load more posts navigation for the popular posts loads the next posts of the main query. Any way to make it load the next posts page of the popular posts instead? Here is the index file:               <?php get_header(); ?>

Recent Posts

               <?php $paged = (get_query_var('paged')) ? (int) get_query_var('paged') : 1;               $my_query = new WP_Query( array( 'posts_per_page' => 2, 'paged' => $paged ) );     while ( $my_query->have_posts() ) : $my_query->the_post(); ?>

                     <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-thumb'); ?>                       <?php the_category(' ') ?>                       <?php comments_popup_link('0', '1', '%'); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                       <?php the_time('d,F,Y'); ?>
<?php echo excerpt(40); ?>
                       <a class="read-more" href="<?php the_permalink(); ?>">Read More

                 <?php endwhile;?>                 <?php include( TEMPLATEPATH . '/load-more.php' );?>

Popular Posts

     <?php      $paged = (get_query_var('paged')) ? (int) get_query_var('paged') : 1;     $popularpost = new WP_Query( array( 'posts_per_page' => 3, 'orderby' => 'comment_count', 'paged' => $paged  ) );     while ( $popularpost->have_posts() ) : $popularpost->the_post();  ?>

                           <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('popular-thumb'); ?>                             <?php the_category(' ') ?>                             <?php comments_popup_link('0', '1', '%'); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                             <?php the_time('d,F,Y'); ?>
<?php echo excerpt(20); ?>
                             <a class="read-more" href="<?php the_permalink(); ?>">Read More

                       <?php endwhile; ?>

         <?php next_posts_link('Older »') ?>

     <?php get_sidebar(); ?>      <?php get_footer(); ?>      And this is the load more posts plugin code:               jQuery(document).ready(function($) {             <?php      $paged = (get_query_var('paged')) ? (int) get_query_var('paged') : 1;     $popularpost = new WP_Query( array( 'posts_per_page' => 3, 'orderby' => 'comment_count', 'paged' => $paged  ) );  ?>     var pbd_alp = {             startPage: "1",             maxPages: "<?php echo $popularpost->max_num_pages; ?>",             nextLink: "<?php bloginfo('url'); ?>/page/2/"     };         var pageNum = parseInt(pbd_alp.startPage) + 1;              // The maximum number of pages the current query can return.         var max = parseInt(pbd_alp.maxPages);              // The link of the next page of posts.         var nextLink = pbd_alp.nextLink;              /**          * Replace the traditional navigation with our own,          * but only if there is at least one page of new posts to load.          */         if(pageNum <= max) {             // Insert the "More Posts" link.             $('.top-home-posts')                 .append('

')                 .append('
Load More Posts
');                  // Remove the traditional navigation.             $('.navigation-top a').remove();         }                   /**          * Load new posts when the link is clicked.          */         $('#load-more-top a').click(function() {                  // Are there more posts to load?             if(pageNum <= max) {                      // Show that we're working.                 $(this).text('Loading posts...');                      $('.more-top-posts-page-'+ pageNum).load(nextLink + ' .post',                     function() {                         // Update page number and nextLink.                         pageNum++;                         nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/'+ pageNum);                              // Add a new placeholder, for when user clicks again.                         $('#load-more-top')                             .before('

')                              // Update the button message.                         if(pageNum <= max) {                             $('#load-more-top a').text('Load More Posts');                         } else {                             $('#load-more-top a').text('No more posts to load.');                         }                     }                 );             } else {                 $('#load-more-top a').append('.');             }                     return false;         });     });      Any help/advice is appreciated, thank you.


How to show an image via shortcode

Can anyone tell me,how to show an image via shortcode.I mean when I use my shortcode,an image will displayed.(shortcode example: [smile] and image location mytemplate directory/images/smile.png)Sorry for my week english.


Image link issues after importing a database backup to my local web server

I am pretty new in WP (I came from Joomla) and I have the following problem trying to import an old WP blog (made using WP 3.5) on my local web server. I have put the old blog foder into my **www** Apache directory and then I have imported the database on my local MySql DB. After, I went into the **wp_options** DB table and I have change the value of the **option_value** field related to the rows **home** and **siteurl** putting in them the correct address (on my localhost web server) Ok, it's seem to work fine: I can see my website and the articles on it but now I have the following problem: if an article contain an immage I can't see this immage and if I open it in the browser appear to me the following error message: **404 Not Found**               Not Found          The requested URL "/it/wp-content/uploads/2012/10/Andrea-Alfieri-chef-bassa3.jpg" was not found on this server.      And in the browser address bar I have the following **wrong URL** :               http://www.myOldWebSite.it/it/wp-content/uploads/2012/10/Andrea-Alfieri-chef-bassa3.jpg      It is wrong because it is related to the old website URL and not to my localhost website. I think that must be some wrong settings on my database and that I have to change it but I don't know what I have to change Can you help me? Some ideas? Tnx Andrea


shortcodes inside shortcode to sum values

I have statistical shortcodes that return values [stat1 val="usa"] [stat2 val="europe"] [stat3 val="china"] [stat4 val="africa"] I struggle to create the shortcode that can sum the shortcode values so if stat1=1 stat2=2 stat2=3 stat2=4 [sumsc][stat1][stat2][stat3][stat4][/sumsc] it would return the value 10


Hook to edit an column on comments screen?

At the moment I'm doing               add_filter("manage_edit-comments_columns", function($columns) {             unset($columns["author"]);             $columns_one = array_slice($columns,0,1);             $columns_two = array_slice($columns,1);             $columns_one["user"] = "User";             $columns = $columns_one + $columns_two;             return $columns;         });          add_filter( 'manage_comments_custom_column', function($column, $column_id) {             echo "Test";         },10, 2 );      Is there a way to just edit the author column instead of removing and creating my own?


How to make tags show up in search results?

Im looking for a way to make tags a searchable object. To clarify, Im NOT trying to make the search engine search posts by looking at its tags, but I want tags to show up in the results just like a post. any help would be much apreciated


Query multiple meta key values?

How to query for mutiple meta key values with the same key               $querystr = "                   SELECT $wpdb->posts.*                  FROM $wpdb->posts, $wpdb->postmeta                 WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id                       AND $wpdb->postmeta.meta_key = 'key1'                    AND $wpdb->postmeta.meta_value = 'value1'                 // why doesn't this work?                 AND $wpdb->postmeta.meta_value = 'value2'                      AND $wpdb->posts.post_status = 'publish'                  AND $wpdb->posts.post_type = 'post'                 ORDER BY $wpdb->posts.post_date DESC                     ";      next code               <?php      $args = array(         'meta_query' => array(             array(                 'key' => 'key1',                 'value' => 'value1',                 'compare' => '='             ),     // this array results in no return for both arrays             array(                 'key' => 'key1',                 'value' => 'value2',                 'compare' => '='             )         )     );     $the_query  = new WP_Query( $args );      ?>                          <?php /* Start the Loop */ ?>     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                              <?php get_template_part( 'content', get_post_format() ); ?>                          <?php endwhile; ?>


How can I change plugin to give access to editor user role?

I want to give my editors access to a settings page to a plugin I've installed on their website. As of now, it's only visible to Administrators. The plugin I'm using is uTubeVideo Gallery, and there is no option to give users other than administrators access. In his admin.php I found these lines, which I know creates the settings page:               public function addMenus()     {         add_menu_page('uTubeVideo', 'uTubeVideo', 'manage_options', 'utubevideo_settings', array($this, 'option_panel'), plugins_url('utubevideo-gallery/i/utubevideo_icon_16x16.png'));         add_submenu_page('utubevideo_settings', 'uTubeVideo Galleries', __('Galleries', 'utvg'), 'manage_options', 'utubevideo_settings_galleries', array($this, 'gallery_panel'));      }      Is there a way for me to tweak his code so I can give access to editors?


Paginated Posts - Social Media Buttons Share First Page URL

I currently have the HTML5 Facebook, Twitter and G+ share buttons inserted into my single.php in WordPress, so it appears on all my post pages. Everything works great until I write a very long article split into multiple pages using the nextpage tag. The problem is if the reader is on page 3, and wanted to share the article, when they click the share button, they are prompted to share the URL of that particular page - nameofsite.com/nameofpost/3 and not of the first/main page of the article - http://www.nameofsite.com/nameofpost, so I am left with many post shares for different pages of the same article! Frown | :-( Is there anyway I can overcome this for all my paginated posts? Thank you, James Edit: I have used the following HTML:

Share This Post

Tweet

<a href="<?php comments_link(); ?>"><?php comments_number('No Comments', 'One Comment', '%' );?>

      I have then entered in the following in .js file called nbzsocial.js:               !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');            (function() {         var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;         po.src = 'https://apis.google.com/js/platform.js';         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);       })();          (function(d, s, id) {       var js, fjs = d.getElementsByTagName(s)[0];       if (d.getElementById(id)) return;       js = d.createElement(s); js.id = id;       js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=225721797619871";       fjs.parentNode.insertBefore(js, fjs);     }(document, 'script', 'facebook-jssdk'));      Which I have placed in a js folder in my child theme and enqueued in my functions PHP with this:               function wpse_load_scripts() {         wp_enqueue_script( 'nbz-social', get_stylesheet_directory_uri() . '/js/nbzsocial.js', array(), '1.0', true );     }          add_action( 'wp_enqueue_scripts', 'wpse_load_scripts' );      Thank you for getting back to me so quickly, I have had no luck on the WordPress forums and Stack Overflow!


You do not have sufficient permissions to access this page while making a plugin

You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page. Wordpress version is 3.8.1 I made a plugin that shows the following display(the index page of my crud plugin) ![enter image description here](http://i.stack.imgur.com/gwxNL.png) I want the Add New link to redirect to other create.php(which is in the same folder as crud.php the index php file).But it says You do not have sufficient permissions to access this page. Is it correct the way i link to create.php file inside my plugin folder? I tried to read abt cross page call in wordpress but no luck. I tried different plugin video tutorial every video ends in the same page. I want to be redirected to the create.php page with the same sidebar and topbar in crud page. And of course i have nicely embeded the html code and php code it's just i did not know the way to show them nicely here. I want a redirect to prevent from inserting data to my table everytime the page is refreshed. And my folder struncture is as follows ![enter image description here](http://i.stack.imgur.com/ZZLeZ.jpg) The code is as follows               add_action('admin_menu','crudindex');     function crudindex(){         add_options_page('Crud Dashboard', 'Crudboard', 'manage_options', 'crud', 'crudboard');     }          function crudboard()     {

                 Motors                 <a class="add_new-h2" href="<?php bloginfo('url');?>/wp-admin/options-general.php?page=create">Add New

     }      I know this is a repeat question.I post it beacause i didn't find the correct answer. Thanks


Plug-in for reserving rooms or equipment via corporate intranet

I'm setting up a corporate intranet for a small organization of about 80 employees. I'm using WordPress running on a Linux server internally. I'd like to give users the ability to reserve conference rooms and audiovisual equipment via the intranet. (I don't want to have them go in through the WP Dashboard.) I recently bought the Premium version of http://onlinebookingcalendar.com/ , but I don't think it'll work for us. There are a few issues with it. First of all, it seems like overkill for what we need. But the _main_ problem is that other users can't see the name of the person who reserved the resource. That information is fairly important for the functionality that we need. I've spent some time Googling, and I just don't see anything that would work for this seemingly simple purpose. I would really rather not pay for something that has a monthly subscription fee. And, as I said, I don't want users to log into the dashboard part of WordPress. Any suggestions?


all tincymce's switch when updating page after changing from html to text in custom metabox

I have a custom metabox which uses wp_editor and when i switch to text editor instead of visual the main content tinymce also changes to text view when i update. I was wondering am i doing something wrong or is that normal behavoir for wordpress when creating a custom metabox and wp_editor? the code i use to set all of this up is:               add_action('add_meta_boxes', 'page_tagline_meta_box');     function page_tagline_meta_box($post) {         global $post;         $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;         $homepage_id = get_option('page_on_front');              $screens = array( 'services', 'page');         if($homepage_id != $post_id) {             foreach ($screens as $screen) {                 add_meta_box('page_tagline_id', 'Tagline text & Telephone number', 'page_tagline_meta_box_cb', $screen, 'normal', 'high');                 add_meta_box('additional_content_id', 'Additional Content', 'additional_content_meta_box_cb', $screen, 'normal', 'high');             }         }     }     function additional_content_meta_box_cb($post) {         global $post;         wp_nonce_field('additional_content_box_nonce', 'additional_content_meta_box_nonce');              $values = get_post_custom($post->ID);              $additionalContent = isset($values['additionalContent']) ? $values['additionalContent'][0]: '';              $settings = array(             'textarea_rows' => 15,             'wpautop' => true         );              wp_editor($additionalContent, 'additionalcontent', $settings);     }      If you would like to see the save function you are welcome to but i know it all saves and i can get the content out in my templates. its just when i switch views on the custom metabox it also switches the view of the main text area for the page when i hit update which i find quite odd. Thanks in advance for your help Alex


Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()

i have add facebook opengraph tag now it showing error like Call to undefined function wp_get_attachment_src() Object at URL 'http://www.website.com' of type 'article' is invalid because the given value ': Call to undefined function wp_get_attachment_src() in on line Fatal error ...... functions.php123 ' for property 'og:image:url' could not be parsed as type 'url'. using this code in header.php               <meta property="og:image" content="<?php echo get_fbimage(); ?>" />      in function.php               <?php     function get_fbimage() {     $src = wp_get_attachment_src( get_post_thumbnail_id($post->ID), '', '' );     if ( has_post_thumbnail($post->ID) ) {     $fbimage = $src[0];     } else {     global $post, $posts;     $fbimage = '';     $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',     $post->post_content, $matches);     $fbimage = $matches [1] [0];     }     if(empty($fbimage)) {     $fbimage = "http://www.gogirlfinance.com/wp-content/uploads/2011/03/logo.jpg";     }     return $fbimage;     }     ?>      Note: I am using same code/ function in other website with no issue


Where to put archive-{post-type}.php

I have a plugin that adds a custom post type for a website I'm building. I am using the_content filters to change how a singular page looks, and it works great, allowing me to keep everything contained in the plugin. However, I want to render a custom archive page using dls and what not, but I have no idea how to do this. This website will probably always use the same theme, but I still want to keep my plugin as separated from the theme as possible.


Save custom field types with this function...?

I found this great article ( **right here**) about creating and saving custom fields for user profiles. The problem is that it only saves text fields. I can't save checkboxes, radio, or any other field types. Here is the code I am using in the functions.php of my theme:               <?php          add_action( 'show_user_profile', 'my_show_extra_profile_fields' );     add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );          function my_show_extra_profile_fields( $user ) { ?>
Extra profile information

                                           <input type="text" name="test" id="test" value="<?php echo esc_attr( get_the_author_meta( 'test', $user->ID ) ); ?>" class="regular-text" />

                                           <input type="checkbox" name="test2" id="test2" value="<?php echo esc_attr( get_the_author_meta( 'test2', $user->ID ) ); ?>" class="regular-text" />

               <?php }           add_action( 'personal_options_update', 'my_save_extra_profile_fields' );     add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );          function my_save_extra_profile_fields( $user_id ) {              if ( !current_user_can( 'edit_user', $user_id ) )             return false;              /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */         update_usermeta( $user_id, 'test', $_POST['test'] );         update_usermeta( $user_id, 'test2', $_POST['test2'] );     }          ?>      In this sample, the "test" field saves, but the "test2" field doesn't. Does anyone know how to save different field types (checkboxes, radio, dropdown, etc.) using this code? Thanks a lot!


Template Tag "template_directory" pulling wrong path

I'm working on a theme index.php and it seems that when I use the "template_directory" it is not actually pulling the url path of the file, but instead is just pulling the main domain name. So instead of                http://example.com/wp-content/themes/theme_name/images/pic.jpg      its pulling the domain url and showing this               http://example.com/images/pic.jpg      I don't understand why it's doing this, since the index.php file is actually in the right directory. (which is inside the theme folder). There is the index.php file that is in the wordpress directory... but I don't understand why it would conflict with the themes index.php file.


Can't Set Featured Image

I have installed the MarketPress plugin from WPMU. I have an ongoing issue with featured images. When I try to set the featured image (in any post) it continually hangs on saving. My problem is that I can't set the product image. In Chrome, when I use the `ctrl` \+ `shift` \+ `J` to bring up the console and then try to set the image, I get a 404 not found for this specific snippet in `admin-ajax.php`:               POST http://www.salonoasis.biz/wp-admin/admin-ajax.php 404 (Not Found) jquery.min.js:4     send jquery.min.js:4     f.extend.ajax jquery.min.js:4     f.(anonymous function) jquery.min.js:4     WPSetAsThumbnail set-post-thumbnail.js:1     onclick      The rest of the script runs fine. I have increased the memory limit to 128M and my server provider (I am a reseller) has white listed the domain in mod_security. I have cleared my browser cache. I still have the problem!


How would I put the multi image upload plugin only on one particular page or template

The 'page' part sets the image upload to show on all pages. I want it to only show on one specific page or selected template.               public function __construct()         {             $this->post_types = array('page');     //limit meta box to certain post types             add_action('add_meta_boxes', array($this, 'add_meta_box'));             add_action('save_post', array($this, 'save'));             add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));         }


force login loophole

I want to restrict access to my wordpress site to allow registered users only. I have tried the following plugins:   * Require-login   * Authenticator   * WP-lock All of them have the same problem: After seeing the login page, you can easily retype the URL in the browser address bar to bypass the login screen and access the home page directly, without needing to login. Only the home page can be accessed in this way. Clicking on any menus, will take you back to the login screen. I suspect there is a problem with my site, not the plugins. I have the following active plugins:   * Advanced Custom Fields   * Akismet   * Analytics360   * Custom Post Templates   * Custom Post Type UI   * Disqus Comment System   * Duplicator   * Easy Tweet Embed   * Email This Page   * Google Analytics   * Gravity Forms   * HotSpots   * List category posts   * Mini twitter feed   * Peter's Login Redirect   * Select Q&A - WordPress Questions and Answers Plugin    * Raw HTML   * Relevanssi   * Revision Control   * Swiftype Search   * ThreeWP Activity Monitor   * Usernoise Pro   * W3 Total Cache   * WP-Lock   * WPML Multilingual CMS Any help would be much appreciated, thanks.


How can I replace content on site generated from plugin without changing plugin

I downloaded a login form but I'd like to change its content without actually changing the plugin files so that it won't cause problems when updating later on. How can this be done?


Get User Login Data (date, time... )

I did my best looking for information about this subject. Your guidance is appreciated. My goal is to perform some actions based on the number of user logins on my website per month and login days consecutivity. How can I get a specific user Login Data (date, time... ) using wordpress functions? If not what are the tables and fields to adress using SQL queries to get such infromation from database? Or I should maybe create and manage my own user meta data using hooks on `wp_login` action? Thank you very much.


Automatically email daily archive

Is it possible to automatically email the daily archive.php page as an html email newsletter? For example, at 4am every weekday WordPress would send an email of the 2011/04/25/ page. Any input is greatly appreciated!


How to remove set_post_thumbnail_size() in child themes?

I'm really stuck on this - this follows on from this post: How to override parent functions in child themes I can't figure out how to override Twenty Ten's set_post_thumbnail_size() function. I've put my code below for the other overrides I'm doing, but nothing happens when I add this to my function twentyten_child_theme_setup():               set_post_thumbnail_size( array(100,100) , array("class" => "alignleft post_thumbnail"), true );      I'm inserting the thumbnail in my loop like this:               <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) {     the_post_thumbnail(array(100,100), array("class" => "alignleft post_thumbnail"));     } else { ?>     <img src="<?php echo bloginfo('stylesheet_directory'); ?>/images/thumb-default.jpg" alt="thumb-default" width="100" height="100" />     <?php } ?>      Here's my function below - can anyone help me override this pesky function? Thanks, osu               function twentyten_child_theme_setup() {              // OVERRIDE SIDEBAR GENERATION!         function osu_twentyten_widgets_init() {             // Siedbar 1, located on LHS sidebar             register_sidebar( array(                 'name' => __( 'Primary Widget Area', 'twentyten-child' ),                 'id' => 'primary-widget-area',                 'description' => __( 'The primary widget area where the navigation goes', 'twentyten-child' ),                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ) );             // Area 2, located on RHS sidebar             register_sidebar( array(                 'name' => __( 'Secondary Widget Area', 'twentyten-child' ),                 'id' => 'secondary-widget-area',                 'description' => __( 'The secondary widget area', 'twentyten-child' ),                 'before_widget' => '
',                 'after_widget' => '
',                 'before_title' => '
',                 'after_title' => '
',             ) );         }         /* Deregister sidebar in parent */         remove_action( 'widgets_init', 'twentyten_widgets_init' );         /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */         add_action( 'widgets_init', 'osu_twentyten_widgets_init' );              // OVERRIDE EXCERPT READ MORE LINK         function osu_readon_link() {             return ' ' . __( 'Read More', 'twentyten-child' ) . '';         }         // Function to override         function osu_twentyten_custom_excerpt_more( $output ) {             if ( has_excerpt() && ! is_attachment() ) {                 $output .= osu_readon_link();             }             return $output;         }         remove_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );         add_filter( 'get_the_excerpt', 'osu_twentyten_custom_excerpt_more' );          }     /* IMPORTANT: Run the code for parent function overrides (involving hooks and filters) after theme setup! */     add_action( 'after_setup_theme', 'twentyten_child_theme_setup' );


Automatic image renaming based on title

Is there a plugin or a "hack" that can help me do this? I have spent hours try to figure this out so I would greatly appreciate nay help. I have WP 3.1 running php5 Thanks! eg.: **postitle_image-ID.jpg**


Category links including all posts

Really rusty on the wordpress front. I am using custom permalinks `/%category%/%postname%/` as well as the `WP No Category Base` plugin, so my urls look like this: http://www.url.com/parent_category/child_category/ I only have an index.php set up at the moment, with the most basic loop possible:               <?php if (have_posts()) : ?>          <?php query_posts(); ?>     <?php while (have_posts()) : the_post(); ?>
        <?php the_title(); ?>
        <?php the_content(); ?>
          <?php endwhile; ?>         <?php else: ?>        <?php endif;?>        The problem is, all posts are coming through, instead of just the posts in the category represented by the url. I didn't think I needed a custom query, because the link that took me to the particular url should have been carried across. What am I missing?


Get permalink for a post from inside Wordpress and route to a related site

I built a mobile version of a wordpress site and added some PHP code in the wordpress index.php file to detect mobile users and HTTP-redirects them to m.website.com ( _which is not a wordpress installation. This PHP standalone mobile site scrapes the wp site for posts and displays them_ ). All works well, and every request to the full site goes to m.website.com instead. The only problem is that my team leader wants me to redirect website.com/2011/04/13/post-title to m.website.com/2011/04/13/post-title for mobile users. And to do this, **my redirection script only needs to know the permalink of the page that index.php is trying to route to**. The mobile site's index.php will handle the permalink once it receives it. N.B. Currently, if you visit m.website.com/2011/04/13/post-title it displays properly. I only need to know how to trap the permalink from inside wordpress and feed it to my mobile redirection code. **EDIT:** Thanks to Tom J Nowell's comment below, I am ready to move the redirection script to whatever file it is at which Wordpress figures out the permalink, and not index.php any longer. So that once the permalink is known, a redirection to `m.website.com/router.php?path=2011/04/13/post-title` can be done, which becomes `m.website.com/2011/04/13/post-title` via htaccess. Thanks


Category specific themes?

My client wants to implement a special appearance to each of our category pages. Kind of like child themes... she wants to shift the background image, change a few graphics, and tweak the colors according to which category the user is visiting (horror, romance, etc). Is there a reasonable way to do this besides creating a different template for each page with imported CSS styles? Or is that really the only path to accomplish this? **UPDATE:** The answers below are all great. For our purposes, the easiest thing to do was to use the category specific classes provided by "body_class()" to override current styles. Thanks!


How to relate one custom post type to another custom post type

I am coding an exam plugin with following flow:   1. Subject Categories (custom taxonomy)   2. Exams (custom post type) related to subject categories (custom taxonomy)   3. MCQ's (custom post type) related to exam (custom post type) On Adding New MCQ I need to relate it with exams but exams is a post type not taxonomy. How can it be managed?


How to save attachment data?

So I have this plugin which associates images from the media upload modal to taxonomy terms via `/wp-admin/edit-tags.php`. The current version is in the branch named "button". Basically, I've swapped out the "Insert in Post" button (input type="submit") with a custom "Add Thumbnail to Taxonomy" (span element) which calls an ajax script which creates an association between attachment and term. All of this works well. The part that I cannot figure out is how to save information when a user makes changes to the attachment data (title, caption, etc.). While it's not really necessary for the plugin to do this ... more than a handful of users have requested this. And it makes sense to do because WordPress will do this when inserting into post content using the "Insert in Post" button. I've been through the javascript and I don't believe that the request is being sent asynchronously. The only thing that comes to mind is that because the "Insert in Post" button is an actual submit button, WordPress is submitting the modal form in the background while it is closed for the user. I've tried to implement similar functionality in my plugin by changing the span to a submit input, but this does no good at all. Firebug reports a 404 for my custom Ajax request and the modal does not close. This is really odd to me because the image still gets associated with the term. Any help or suggestions would be greatly appreciated here!


Publish all network posts to the primary site

Any posts published on another network site should be visible on the MainDomain.com. Sitetags works fine, but does not update itself. Any idea how how to make an auto update on the primary site? Thanks Jean


Save Changes function after table is sorted using jquery

I have a simple table, and the jquery works great for sorting. The fields drags an drops perfectly, and updates then and their. Also of course the data in the fields are saved in a array. The data in the fields saves after clicking "save changes" button but NOT the sort order. The sort order returns to its previous state. example: 1(bb) 2(tom) 3(fred) TO 1(tom) 2(bb) 3(fred) then clicks "save changes" after clicking "save changes" it returns to its previous state which is 1(bb) 2(tom) 3(fred) the sort order does NOT save only the values. what other function i am suppose to add, to make this work? The jquery works, it does its job of sorting, but for WordPress to understand that it was sorted another way, what do I do?


site admin for subscribers

I want a very basic page for my subscribers to change their passwords and profile. No Wordpress news etc. Is is possible to strip the admin section of subscribers and leave the absolutely bare minimals? Thank you.


Exclude subscriber users from user list

I want to exclude Subscribers from a user list. My code is:               $users = $wpdb->get_results( "SELECT display_name FROM $wpdb->users ORDER BY display_name ASC" );      How can I change that so subscribers are excluded from the list? I also looked at the get_users function in codex but it did not have an exclude by role parameter. Edit: Or another way would be to get the results filtered by capability (one that subscribers doesn't have).


Add update notification bubble to admin menu item?

I have re-worded this to make more sense. Ok, I have a plugin that uses a remote service that check for updates, much like default WordPress plugins, in this case it just checks an XML file. I want to show a menu bubble like this ![enter image description here](http://i.stack.imgur.com/rZZiu.png) when an update is available. It can show just a "1" or text like "alert", it doesn't matter. Since my plugin uses an options page (using `add_options_page`) the plugin settings show up under the default "Settings" submenu. I think I need to add the following CSS to get the bubble to show up,               1      and tie into the global `$submenu`. The problem is I cannot use a hard-coded array value for the menu since each site will have different values. So I cannot use `$submenu[80][10] .= <span class='update-plugins count-1' title='title'><span class='update-count'>1</span></span>` How can I find my plugins submenu value, do I have to loop through the array and match the string values? Also even when I hard-coded the values I could not get the bubble to show up.               //adding plugin to menu     add_action('admin_menu', 'sec_plugin_checker');          function sec_plugin_checker() {       add_options_page(' Plugin Checker', 'Plugin Check', 'activate_plugins',        'sec_plugin_check', 'sec_checker');               // the conditional where I want the bubble to appear          if (!empty($matches)){          echo "Match found !
";              global $submenu;         foreach( $submenu as $item ) {              $item[41][20] = sprintf( __( 'Updates %s', 'sec_plugin_checker' ),                       "                      1");                   }       }      and here is what a `var_dump($submenu);` looks like,               ["options-general.php"]=>     array(9){     ...          [41]=>         array(4) {           [0]=>           string(20) "Plugin Check"           [1]=>           string(16) "activate_plugins"           [2]=>           string(21) "sec_plugin_check"           [3]=>           string(23) " Plugin Checker"               ...                }


WordPress | WP_query with multiple category starting to show with a specific category

How I can show a WP_query result posts starting to show a query by a specific taxonomy and than all the others? I have thought to a UNION in the query, but I would something with the WP_query loop. ex. category id 24                           global $query_string;                  $query_args = explode("&", $query_string); // collect all querystring var                 $search_query = array();                      foreach($query_args as $key => $string) {                         $query_split = explode("=", $string);                         $search_query[$query_split[0]] = urldecode($query_split[1]);                 } // foreach                      $search_query['cat']=urldecode('24'); // APPEND the category                 $query = new WP_Query($search_query);                      <?php if ( $query->have_posts() ) : ?>
<?php printf( __( 'Search Results for: %s', 'mb' ), '' . get_search_query() . '' ); ?>
                           <?php                           /* Run the loop for the search to output the results.                            * If you want to overload this in a child theme then include a file                            * called loop-search.php and that will be used instead.                            */                            //get_template_part( 'loop', 'search' );                            get_template_part( 'loop', 'catfirst' );                           ?>                         ...      thanks in advance, Gianluca


count number of all comments by a user on different (non-repeated) posts

I thank you in advance for your help. I am using Wordpress for about 2 years, but always avoiding SQL inside my scripts and looking for built-in functions to perform my goals. To count the comments submitted by a specific user with `$user->ID` as id, I didn't find a built-in way, so I am using:                global $wpdb;                  $count = $wpdb->get_var(               'SELECT COUNT( comment_id ) FROM '. $wpdb->comments .'               WHERE user_id = '.$user->ID.'               AND comment_approved = "1"               AND comment_type NOT IN ("pingback", "trackback" )'             );      Actually my goal is to count number of all comments by a user on different posts. In other words, if a user commented 2 or more times on the same post, then only increment the `$count` variable by one . Your help is appreciated.


Posts miss schedule, no notification (3.7.1)

I have a site running 3.7.1 where posts are sporadically failing to post on schedule. Unlike the "missed schedule" error that sometimes occurs, these misses don't generate any notification and the posts are not flagged in any way. In the posts that have failed to publish, reviewing the settings shows that WordPress shows that the posts are still set as "scheduled" despite having a date that is in the past. One thing that is unique to this site, compared to other WP sites that I've managed in the past: there are over two months (60+) of posts scheduled for the future at any given time. Other possible causes seem to be plugin related. I am running W3 Total Cache on the site. I have tweaked the settings extensively and disabled the plugin but I have still seen the error, so I am skeptical there. Has anyone else encountered an issue like this? p.s. I am currently testing the WP Missed Schedule Fix Failed Future Posts to see if that resolves the problem.


SQL select of users by metadata

Hi I'm trying to select users with a particular role only, using the following sql statement...               SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email     FROM wp_users u, wp_usermeta m     WHERE m.meta_key = 'wp_capabilities'     AND m.meta_value LIKE '%supplier%'     ORDER BY u.user_registered      However, it reurns the whole table. What am I doing wrong? PS this needs to be a SQL select as I'm doing this in myphpadmin to export the data to csv. Thanks in advance!


copy attachment title to description and alt text

I have a blog with a lot (over 1000) images. Each image has a meaningful descriptive filename. Wordpress has title caption and description fields for images. What's the easiest way to batch process all images and copy the file name to the title alt description and caption fields. Also if I could update yoast seo fields too that would be great.


If has_term, load other theme

This is what I want to accomplish. I've created a taxonomy called `categorie` with the terms `app`, `web` and `branding`. When a project has the term app, I want to load another theme / blog. When a project has the term web or branding, I want to load `single.php`. The last one works just fine. This is my code so far               function load_single_template($template) {     $new_template = '';          if( is_single() ) {         global $post;              if( has_term('app', 'categorie', $post) ) {             $new_template = get_theme_roots('themeApp');         } else {             $new_template = locate_template(array('single.php' ));         }     }     return ('' != $new_template) ? $new_template : $template;      }      add_action('template_include', 'load_single_template');      So when a project has the term app, I want to load the theme `themeApp`. Any suggestions? Thanks in advance.


Submenu is missing when custom taxonomy page

I have problem that my sub-menu is missing when I use (tried built in categories also) custom categories as menu items. Basically what I want: Menu item (wordpress page) -submenu item what is custom taxonomy   \--sub categories   \--sub categories   \--sub categories   -submenu item what is custom taxonomy   \--sub categories Now I can get the menu to work with Menus. What I want is that my submenu is open when I am inside sub categories page. Submenu item actually should open first sub category. I am using custom walker for my menu design and now I am thinking that is there something missing that it will close submenu when on custom taxonomy sub category page.               class submenu_Walker extends Walker_Nav_Menu {            function walk( $elements, $max_depth) {              global $wp_query;         $current_menu = (int) $wp_query->queried_object_id;              $tops = array(); // top level menu items         $subs = array(); // sub menu items              _wp_menu_item_classes_by_context($elements);              foreach ($elements as $element) {           if (0 == $element->menu_item_parent) {             $tops[] = $element;             if ($element->object_id == $current_menu) {               $current_parent = $element;             }           }           else           {             $subs[] = $element;                  if ($element->object_id == $current_menu) {               $current_child = $element;                  }           }         }              if (!$current_parent)                $current_parent = $this->get_current_parent_from_sub($elements, $current_child);              if ($current_parent) {           $real_subs = array();                foreach ($subs as $item) {             if ($item->menu_item_parent == $current_parent->db_id)               $real_subs[] = $item;           }         }              // show top level elements              $s = '
';              foreach ($tops as $item) {           $s .= $this->display_item($item);         }              $s .= "
";              // show sub menu items              if (sizeof($real_subs) > 0) {           $s .= "

";           foreach ($real_subs as $item) {             $s .= $this->display_item($item);           }           $s .= '

';         }         return $s;       }            // get the parent page when a sub page is the current page            function get_current_parent_from_sub($elements, $current_child) {              foreach ($elements as $element) {           if ($element->db_id == $current_child->menu_item_parent) {             return $element;           }         }         return false;       }            function display_item($item) {              $i = '';         $this->start_el( $i, $item, 0, array() );         $this->end_el( $i, $item, 0, array() );              return $i;            }     }


Generate aggregated feed from member blogs

I currently manage a multisite installation with 7 member blogs. We need to produce a combined RSS feed of news from all 7. Currently we use Feedwordpress to syndicate 6 blogs into blog number 7. This isn't working out because we're duplicating content in the db. Ideally I need a cached feed to reduce server load (the feed is subscribed to via high-traffic portals). What's the best way of doing this? I've considered Yahoo Pipes, but how about using Wordpress transients to cache a query across all member blogs, and somehow publishing this as RSS? JSON could be an option, but RSS is probably preferred.


Page doesn't load

I have following code, but my page doesn't load anymore. What is wrong?               require( plugin_dir_path( __FILE__ ) . 'menu.php');     require_once( plugin_dir_path( __FILE__ ) . 'getuser.php');          add_action( 'wp_enqueue_scripts', 'ffd_load_scripts' );          function ffd_load_scripts()     {         $myoption =  get_option( 'fixformdata_options' );         $myoptionValue = maybe_unserialize( $myoption );                $arguments = array();         for($i=1; $i<= $myoptionValue[fieldcount]; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', merge_array(array(             'ajaxurl' => admin_url('admin-ajax.php'),             'idinfo' => $myoptionValue['idinfo']),$arguments)             );              wp_enqueue_script('jquery');         wp_enqueue_script('ffd_js_script', plugin_dir_url(__FILE__) . 'js/ffd_js_script.js');     }      Previously it worked fine, the problem is given by the $arguments I think. Tried some things but still have this issue. The problem is located in this part:               $arguments = array();         for($i=1; $i<= $myoptionValue[fieldcount]; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', merge_array(array(             'ajaxurl' => admin_url('admin-ajax.php'),             'idinfo' => $myoptionValue['idinfo']),$arguments)             );      When I use this code, everything works fine, but I really need the iterator:               function ffd_load_scripts()     {         $myoption =  get_option( 'fixformdata_options' );         $myoptionValue = maybe_unserialize( $myoption );                /*$arguments = array();         for($i=1; $i<= $myoptionValue['fieldcount']; $i++)         {             $arguments['index'.$i] = $myoptionValue['id'.$i];         }*/              wp_register_script('ffd_js_script', WP_PLUGIN_URL.'/FixFormData/js/ffd_js_script.js', array('jquery'));         wp_localize_script('ffd_js_script', 'myAjax', array(                 'ajaxurl' => admin_url('admin-ajax.php'),                 'idinfo' => $myoptionValue['idinfo'],                 'index1' => $myoptionValue['id1'],                 'index2' => $myoptionValue['id2']                 )             );              wp_enqueue_script('jquery');         wp_enqueue_script('ffd_js_script', plugin_dir_url(__FILE__) . 'js/ffd_js_script.js');     }


Template for specific post of custom post type

I have the CPT "event". I have created single-event.php. I want one particular event to use a different template than single-event. I read elsewhere that this could be done by creating a single-event-[slug].php but I tried it and it does not work. WP uses single-event.php. (I can't find this in the WordPress documentation, so I'm thinking maybe I misunderstood?) Is there a way of doing this?


Remove rel="attachment wp-att-XX"

When you add an image with "Add media" to the WYSIWYG editor the link around the image automatically gets a rel="attachment wp-att-XX". I would like to remove this with a script - Can anyone help me? :)


Paginate Child Pages Content on Parent Page

I am using the following code to display child page content on it's parent page. The code is working great, but it currently only shows the latest two child page posts, is there any way to display all of them and then add pagination to navigate through them?               <?php         $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');         $count = 0;         foreach($pages as $page) {             $content = $page->post_content;             if($count >= 2)                 break;             $count++;             $content = apply_filters('the_content', $content);             echo "
".$page->post_title."
";             echo "
".$content."
";         }     ?>      Thanks,   Josh


Upload images - Theme options

I'm using this great [tuts+ tutorial][1] for creating theme options page. It works great for me be beause I need to change background images of divs via css. It works great with one image but I dont know how to make it work with 2 images? It would be a huge help if you can tell me what I'm doing wrong here? Thanks!                 <?php     function wptuts_get_default_options() {         $options = array();             $options[] = array('logo' => '');             $options[] = array('fav' => '');         return $options;     }               function wptuts_options_init() {          $wptuts_options = get_option( 'theme_wptuts_options' );               // Are our options saved in the DB?          if ( false === $wptuts_options ) {               // If not, we'll save our default options               $wptuts_options = wptuts_get_default_options();               add_option( 'theme_wptuts_options', $wptuts_options );          }               // In other case we don't need to update the DB     }     // Initialize Theme options     add_action( 'after_setup_theme', 'wptuts_options_init' );          function wptuts_options_setup() {         global $pagenow;         if ('media-upload.php' == $pagenow || 'async-upload.php' == $pagenow) {             // Now we'll replace the 'Insert into Post Button inside Thickbox'              add_filter( 'gettext', 'replace_thickbox_text' , 1, 2 );         }     }     add_action( 'admin_init', 'wptuts_options_setup' );          function replace_thickbox_text($translated_text, $text ) {           if ( 'Insert into Post' == $text ) {             $referer = strpos( wp_get_referer(), 'wptuts-settings' );             if ( $referer != '' ) {                 return __('I want this to be my Image!', 'wptuts' );             }         }              return $translated_text;     }          // Add "WPTuts Options" link to the "Appearance" menu     function wptuts_menu_options() {         //add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);          add_theme_page('WPTuts Options', 'WPTuts Options', 'edit_theme_options', 'wptuts-settings', 'wptuts_admin_options_page');     }     // Load the Admin Options page     add_action('admin_menu', 'wptuts_menu_options');          function wptuts_admin_options_page() {         ?>

<?php _e( 'WPTuts Options', 'wptuts' ); ?>
                                       <?php settings_errors( 'wptuts-settings-errors' ); ?>                      <form id="form-wptuts-options" action="options.php" method="post" enctype="multipart/form-data">                          <?php                         settings_fields('theme_wptuts_options');                         do_settings_sections('wptuts');                     ?>
                         <input name="theme_wptuts_options[submit]" id="submit_options_form" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'wptuts'); ?>" />                         <input name="theme_wptuts_options[reset]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'wptuts'); ?>" />
                      </form>
         <?php     }          function wptuts_options_validate( $input ) {         $default_options = wptuts_get_default_options();         $valid_input = $default_options;              $wptuts_options = get_option('theme_wptuts_options');              $submit = ! empty($input['submit']) ? true : false;         $reset = ! empty($input['reset']) ? true : false;         $delete_logo = ! empty($input['delete_logo']) ? true : false;         $delete_fav = ! empty($input['delete_fav']) ? true : false;              foreach ( $wptuts_options   as $wptuts_options ) {               if ( $submit ) {                 if ( $wptuts_options['logo'] != $input['logo']  && $wptuts_options['logo'] != '' )                     delete_image( $wptuts_options['logo'] );                      $valid_input['logo'] = $input['logo'];             }             elseif ( $reset ) {                 delete_image( $wptuts_options['logo'] );                 $valid_input['logo'] = $default_options['logo'];             }             elseif ( $delete_logo ) {                 delete_image( $wptuts_options['logo'] );                 $valid_input['logo'] = '';             }             if ( $submit ) {                 if ( $wptuts_options['fav'] != $input['fav']  && $wptuts_options['fav'] != '' )                     delete_image( $wptuts_options['fav'] );                      $valid_input['fav'] = $input['fav'];             }             elseif ( $reset ) {                 delete_image( $wptuts_options['fav'] );                 $valid_input['fav'] = $default_options['fav'];             }             elseif ( $delete_fav ) {                 delete_image( $wptuts_options['fav'] );                 $valid_input['fav'] = '';             }              return $valid_input;     }          function delete_image( $image_url ) {         global $wpdb;              // We need to get the image's meta ID..         $query = "SELECT ID FROM wp_posts where guid = '" . esc_url($image_url) . "' AND post_type = 'attachment'";           $results = $wpdb -> get_results($query);              // And delete them (if more than one attachment is in the Library         foreach ( $results as $row ) {             wp_delete_attachment( $row -> ID );         }        }          /********************* JAVASCRIPT ******************************/     function wptuts_options_enqueue_scripts() {         wp_register_script( 'wptuts-upload', get_template_directory_uri() .'/wptuts-options/js/wptuts-upload.js', array('jquery','media-upload','thickbox') );                if ( 'appearance_page_wptuts-settings' == get_current_screen() -> id ) {             wp_enqueue_script('jquery');                  wp_enqueue_script('thickbox');             wp_enqueue_style('thickbox');                  wp_enqueue_script('media-upload');             wp_enqueue_script('wptuts-upload');              }          }     add_action('admin_enqueue_scripts', 'wptuts_options_enqueue_scripts');               function wptuts_options_settings_init() {         register_setting( 'theme_wptuts_options', 'theme_wptuts_options', 'wptuts_options_validate' );              // Add a form section for the Logo         add_settings_section('wptuts_settings_header', __( 'Logo Options', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');         // Add Logo uploader         add_settings_field('wptuts_setting_logo',  __( 'Logo', 'wptuts' ), 'wptuts_setting_logo', 'wptuts', 'wptuts_settings_header');         // Add Current Image Preview          add_settings_field('wptuts_setting_logo_preview',  __( 'Logo Preview', 'wptuts' ), 'wptuts_setting_logo_preview', 'wptuts', 'wptuts_settings_header');              // Add a form section for the fav         add_settings_section('wptuts_settings_header', __( 'fav Options', 'wptuts' ), 'wptuts_settings_header_text', 'wptuts');         // Add fav uploader         add_settings_field('wptuts_setting_fav',  __( 'fav', 'wptuts' ), 'wptuts_setting_fav', 'wptuts', 'wptuts_settings_header');         // Add Current Image Preview          add_settings_field('wptuts_setting_fav_preview',  __( 'fav Preview', 'wptuts' ), 'wptuts_setting_fav_preview', 'wptuts', 'wptuts_settings_header');           }     add_action( 'admin_init', 'wptuts_options_settings_init' );          function wptuts_setting_logo_preview() {         $wptuts_options = get_option( 'theme_wptuts_options' );  ?>
             <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />
         <?php     }          function wptuts_setting_fav_preview() {         $wptuts_options = get_option( 'theme_wptuts_options' );  ?>
             <img style="max-width:100%;" src="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />
         <?php     }          function wptuts_settings_header_text() {         ?>
<?php _e( 'Manage Options for WpTuts Theme.', 'wptuts' ); ?>
         <?php     }          function wptuts_setting_logo() {         $wptuts_options = get_option( 'theme_wptuts_options' );         ?>             <input type="hidden" id="logo_url" name="theme_wptuts_options[logo]" value="<?php echo esc_url( $wptuts_options['logo'] ); ?>" />             <input id="upload_logo_button" type="button" class="button" value="<?php _e( 'Upload Logo', 'wptuts' ); ?>" />             <?php if ( '' != $wptuts_options['logo'] ): ?>                 <input id="delete_logo_button" name="theme_wptuts_options[delete_logo]" type="submit" class="button" value="<?php _e( 'Delete Logo', 'wptuts' ); ?>" />             <?php endif; ?>             <?php _e('Upload an image for the banner.', 'wptuts' ); ?>         <?php     }          function wptuts_setting_fav() {         $wptuts_options = get_option( 'theme_wptuts_options' );         ?>             <input type="hidden" id="fav_url" name="theme_wptuts_options[fav]" value="<?php echo esc_url( $wptuts_options['fav'] ); ?>" />             <input id="upload_fav_button" type="button" class="button" value="<?php _e( 'Upload fav', 'wptuts' ); ?>" />             <?php if ( '' != $wptuts_options['fav'] ): ?>                 <input id="delete_fav_button" name="theme_wptuts_options[delete_fav]" type="submit" class="button" value="<?php _e( 'Delete fav', 'wptuts' ); ?>" />             <?php endif; ?>             <?php _e('Upload an image for the banner.', 'wptuts' ); ?>         <?php     }               ?>


Custom fields PHP foreach loop

In my theme, I am using some PHP to display custom field content. It checks if the fields are empty before displaying the content, because the_meta was showing titles for empty fields.
     <?php     $ck = get_post_custom_keys($post_id); //Array                  foreach ($ck as $k) {                  if (substr ($k, 0, 1) == '_')                  {   // skip keys starting with '_'                      continue;                  }                  $cv = get_post_custom_values($k, $post_id );  //Array                     foreach ($cv as $c) {                         if (empty ($c))                         {   // skip empty value                             continue;                         }                         $format_c = wpautop( $c, false );                         print_r ('');                         print_r ('
' . $k . '
');                         print_r ('
' . $format_c . '
');                         print_r ('');                     }                  }     ?>
      I would like to improve this so that the 'div.customfield-box' does not display unless there is content. I need to echo it inside the php, but where? The resulting html should look like:

Ingredients

Flour

Salt

Allergens

Wheat

      If there is no content, it should display nothing, not even the customfield- box.


How to insert Gallery shortcode to a meta box

When we create a Image Gallery from the Media Modal Box and click on "Insert Gallery" button, the gallery shortcode is added to the main text area. Is there a way to detect which Post Format is selected, and if its "Gallery" then is there a way to modify the action of the "Insert Gallery" button to add the shortcode to a meta box instead of the text area.


How to add a filter conditionally based on page related Conditional Tags

I am developing a WordPress plugin and can't conditionally add filters based on the conditional tags. This is my code:               add_Action('init', 'determine_location');          function determine_location() {     $d = get_option('display_locations'); //this is a checkbox field in the plugins settings with 7 options         if (isset($d)) {             if ($d[0] == 'home') {                 if (is_home()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d == 'post' || $d == 'post') {                 if (is_single()) {                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'page' || $d == 'page' || $d == 'page') {                 if (is_page()) {                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'category' || $d[1] == 'category' || $d[2] == 'category' || $d[3] == 'category') {                 if (is_category()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'tag' || $d[1] == 'tag' || $d[2] == 'tag' || $d[3] == 'tag' || $d[4] == 'tag') {                 if (is_tag()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             } else if ($d[0] == 'archive' || $d[1] == 'archive' || $d[2] == 'archive' || $d[3] == 'archive' || $d[4] == 'archive' || $d[5] == 'archive') {                 if (is_archive()) {                     add_filter('the_excerpt', 'insert_buttons_to_post_top');                     add_filter('the_content', 'insert_buttons_to_post_top');                 }             }         }      }               function insert_buttons_to_post_top(){        return "
Output
"     }      Currently this code shows no output. What is wrong here?


Pagination on archive.php page

I have an archive.php page with the following code:               <?php // Start your custom WP_query     $my_query = new WP_query();          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array('posts_per_page' ?> 1, 'paged' => $paged, 'category_name' => 'Casino Slots');     // Assign predefined $args to your query     $my_query->query($args);          // Run your normal loop     if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();     ?>      Test      <?php endwhile;     else :     // do stuff for no results     endif;          wp_pagenavi();          // RESET THE QUERY     wp_reset_query();     ?>      and it displays the posts fine, but the pagination never shows?


Setting up robots.txt with Yoast's Seo plugin

I was looking for a decent robots.txt solution for my wordpress sites and after some searching I found Yoast's SEO plugin that provides a complete SEO solution including indexation. I set it up it to **not** index the following pages: search results, login and register pages, all admin pages, date-based archives and tag archives. However, when I looked at the source of those pages, I couldn't find any meta robots tag except in the login/register page. Is there another way to tell search engines what to index except robots meta and robots.txt? If not, where is the indication to these pages not being indexed? Thanks in advance


sanitize vimeo embed code?

I have a custom meta box with a textarea where users can drop in vimeo embed code. Should I sanitize this code before I update_post_meta, and, if so, how should I go about it? I don't want to strip out important information (like the iframe)...I just want to make sure nothing malicious is getting entered.


Unified login page for a Multisite/BuddyPress site

I use WordPress Multisite... and BuddyPress installed on the main site on mysite.com Practically I want users to be automatically redirected to the main site login page every time they try to login from any of the blogs/sites/subdomains. > *.mysite.com/login.php => mysite.com/login.php **Let me give some exemples:** site1.mysite.com/wp-login.php redirected to mysite.com/wp-login.php site2.mysite.com/wp-login.php redirected to mysite.com/wp-login.php xyzkw.mysite.com/wp-login.php redirected to mysite.com/wp-login.php ....................... _any future subdomain LOGIN PAGE - with no exceptions - will have to be redirected to mysite.com/wp-login.php_


Need to create a Theme demo site that features multiple themes

I would like to create a site like: http://demo2.woothemes.com/?name=sentient for my clients, so that they can see the range of themes I offer. I own many templates from different providers, and sending them to the providers will not help as there are quite a few and not all offer this functionality (not to mention that the UI can be confusing to my clients) I want the site to be super simple to use, and provide the ability at first to just switch themes on using a demo site (Wordpress site with content) Found this previous question about same subject, this plugin was offered there, but the solution is far from simple in that the all templates need to support some specific functionality (the theme switching widget) - this is not good enough. I'd appreciate any suggestions you may have (creating a site with an upper frame that switches sites below?) - problem is I have very little time to experiment on this, and am looking for someone with the knowledge who is willing to share.


How to create a specific frontend URL (not a Page) from a theme or plugin?

My theme implements an AJAX action that returns some dynamic content and needs some functions from the Wordpress environment. How can I construct a URL for the AJAX call in the most elegant and robust way? In particular, I see lots of themes and plugins directly linking to PHP files that are inside their directory tree, which in turn are totally different entry points from Wordpress's `index.php`, and then include this:               // INCLUDE WORDPRESS STUFF     define('WP_USE_THEMES', false);     include_once('../../../wp-load.php');      From an architecture perspective, this does not seem elegant to me (we create another entry point to the app), and it also breaks if I want to symlink the theme directory to some place else. I think WordPress doesn't implement a full-fledged router as the ones from typical Web frameworks, but is there a way to create specific (not custom posts, for instance) frontend URLs?


Rename filename to post title. Post Title not being fetched

function new_filename($filename, $filename_raw) {         global $post;         $post = add_post_meta( $post_id, wp_get_attachment_url($attachment_id));         $info = pathinfo($filename);         $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];         $new = $post->post_title . '-mysitename' . $ext;         // the if is to make sure the script goes into an indefinate loop              if( $new != $filename_raw ) {             $new = sanitize_file_name( $new );         }         return $new;     }     add_filter('sanitize_file_name', 'new_filename', 10, 2);      Someone posted this function a while ago to rename filenames, I re-adjusted it a little bit but the problem is that the $post->post_title is not doing what it is supposed to do (meaning, not fetching the post title at all). Any ideas what could be going wrong here? (-mysitename is displayed in the filename though, thank god that works). So yeah, would really appreciate the help, been breaking my head over this for days. Thanks I'm using latest Wordpress version 3.9.2


How do you create a custom WPTouch theme?

I have WPTouch Pro installed and it does a great job at device detection as well as handling most blog posts. However, I want to make a mobile version of a homepage that doesn't have any blog posts. I know you can edit the css for a theme by making a child theme and editing it. Is this the preferred method to get WPTouch to show more content from the original page? That link is here: http://www.koolkatwebdesigns.com/wptouch-and-custom- templates/ Also, someone is using shortcodes; not sure if this works for content that WPTouch is already ignoring: http://www.renegadetechconsulting.com/tutorials/generate-mobile-specific- content-using-wptouch-pro-shortcodes Thanks in advance!


How to remove br and p tags from bbPress

bbPress is giving me a headache trying to figure out how to remove `<br>` and `<p>` tags from existing post in the database after an import. I have tried editing "formatting.php" but with no results except to hide all my forum posts for a day. Any suggestions?


Adjusting post width according to the image size

I am building a theme for a comic site. It seems some images are bigger than the post size. I need to resize the images according to the **Original Image size**. Can I achieve this through CSS? It doesn't matter if it extends the screen-size and scrolling window is shown.


/wp-login keeps loading. Weird code window.location

Some of my multi sites have got a weird code on the wp-login.php page. Its not all of them and yesterday was fine and now this is its there. window.location = 'http://www.mydomain.com/wp-login.php' I don't know where this script is coming from and where i can find it but it keeps loading my page and cant login to Wordpress.


How use %like% in sql statement wordpress

i use a **like** %text% statement in wordpress:               SELECT *  FROM location  WHERE name LIKE "%on" OR name LIKE "%on%"      i tried anything but it's not run:               $wpdb->get_results($wpdb -> prepare("SELECT *  FROM location  WHERE name LIKE %1s OR name LIKE %2s", '%'.like_escape('on'), '%'.like_escape('on').'%'), ARRAY_A);      please help me


WooCommerce Force Display of Base Country Order Addresses

It seems in recent versions of WooCommerce that the base country does not show on the order screens. Ex. we have 2 orders, one being from Australia and one from the United States. In the WooCommerce --> Orders screen the Australian order doesn't say Australia at the end of the order billing and shipping addresses (because our base location is Australia). The international orders do show the country though. How can that be fixed so that the base country is being shown in the formatted addresses still?