title: Prevent searches less than 4 characters

text: When users search for 1,2 or 3 characters this puts a lot of strain on the database. A malicious user could search for 1,2 or 3 characters and bring my site down to its knees. I presume I could use some Jquery code to prevent users entering less than 4 characters when searching.                  <form method="get" id="searchform" action="<?php echo home_url(); ?>/">                                                              <input type="text" value="<?php _e( 'search', 'swagger' ); ?>" onfocus="if (this.value == '<?php _e( 'search', 'swagger' ); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'search', 'swagger' ); ?>';}" name="s" id="s" />                                       </form>       any suggestions?


title: need pages to display Title <plugin list category post>

text: My pages that are using the list category post do not have the title on them, and we would like that to happen. Is there some code that is telling the title not to display?


title: No line breaks in syntax highlighted code

text: I've installed Sunburst Code Prettify on my new blog. The prettifier uses Highlight.js to prettify code. I've placed the following Python code in a post:               [prettify class="python"]     >>> s=set(['a','b','c'])     >>> ''.join(s)     'acb'     [/prettify]      And got the following highlighting (with some paragraphs for context): ![enter image description here](http://i.stack.imgur.com/gA4RM.png) The line breaks are lost, some `>` were converted to `&#8221`, and there's an annoying gray background behind the rounded black code frame. I've tried another Highlight.js plugin, wp-highlight.js:               [code lang="python"]     >>> s=set(['a','b','c'])     >>> ''.join(s)     'acb'     [/code]      And got: ![enter image description here](http://i.stack.imgur.com/0oO5I.png) Same gray background, same loss of line breaks. I've tried switching themes (currently using Mosaic, switched to the standard Twenty-Ten), with no success. Any ideas what went wrong? **Update - what I've tried:** `<pre>`:               <pre>     [prettify class="python"]     >>> s=set(['a','b','c'])     >>> ''.join(s)     'acb'     [/prettify]     </pre>      Empty lines:               [prettify class="python"]     >>> s=set(['a','b','c'])          >>> ''.join(s)          'acb'     [/prettify]


title: meta_query works with single query but not multiple queries

text: This is very strange and I'm not sure why it is happening but this piece of code...                   $args = array(           'post_type' => 'property',               'sentance' => true,         'meta_query' => array(           array('key' => 'bhk','value' => $bhk,'compare' => 'LIKE'),         ));      or this, with a single meta_query work just fine, but                   $args = array(           'post_type' => 'property',               'sentance' => true,         'meta_query' => array(           array('key' => 'property_type','value' => $property_type,'compare' => 'IN'),         ));      when I add more queries in the array like below, it does not pull any results for my searches..                   $args = array(           'post_type' => 'property',               'sentance' => true,         'meta_query' => array(           array('key' => 'property_type','value' => $property_type,'compare' => 'IN'),         array('key' => 'city','value' => $city,'compare' => 'IN'),               array('key' => 'bhk','value' => $bhk,'compare' => 'LIKE'),         ));


title: post_categories array using variable

text: When using wp_insert_post can I do something like: `$categories = '1,2,3,4,5'` ...and then... `'post_category' => array($categories)`


title: How to get the image url in the input box from media library?

text: I have added a post meta to upload image using wordpress media uploader. Looks like it's a javascript work. I am no good in javascript. I took the js from here: Here is the js code:               jQuery(document).ready(function($){              // Instantiates the variable that holds the media library frame.         var meta_image_frame;              // Runs when the image button is clicked.         $('#meta-image-button').click(function(e){                  // Prevents the default action from occuring.             e.preventDefault();                  // If the frame already exists, re-open it.             if ( meta_image_frame ) {                 wp.media.editor.open();                 return;             }                  // Sets up the media library frame             meta_image_frame = wp.media.frames.meta_image_frame = wp.media({                 title: meta_image.title,                 button: { text:  meta_image.button },                 library: { type: 'image' }             });                  // Runs when an image is selected.             meta_image_frame.on('select', function(){                      //Grabs the attachment selection and creates a JSON representation of the model.                 var media_attachment = meta_image_frame.state().get('selection').first().toJSON();                      // Sends the attachment URL to our custom image input field.                 $('#meta-image').val(media_attachment.url);             });                  // Opens the media library frame.             wp.media.editor.open();         });     });      I have an input box with id `#meta-image`. But it does not return the img url there. Instead, it puts the image url inside the main post editor. Any idea how can I get this to work?


title: Inset image thumbnail from page into list

text: I currently have 10 child pages which each contain one main image and text. I then have the main parent page, which acts as a 'contents page'. I currently have this code on the main parent page...               <ul class="treatments-list h3">         <?php wp_list_pages('title_li=&child_of='.$post->ID=15); ?>     </ul>      This gets all the titles for these child pages and lists them, however, I would like to add an image thumbnail at the start of each of these lists, how can I do this? Thanks in advance.


title: How can i sort the categories by ID

text: Hi all I am newbie to wordpress I am using the wp_list_categories in the sidebar to display the categories . How can i display thus categories sort by id any one much appreciated...               <?php wp_list_categories('exclude=73');?>


title: function to show only featured image of the posts

text: The problem is whenever I display a post containing gallery, it shows them all on front page same as within post. I want a function for posts on front page to display only the clickable featured image with read more below for posts have predefined featured image. And if the post has some specific category eg. video, it should just display video and below some sharing buttons. This is what I achieved till now, being a newbie can't move further                function insertfeaturedimage($content) {     global $post;          if ( current_theme_supports( 'post-thumbnails' ) ) {              if (is_page() || is_single() || is_front_page()) {             $content = the_post_thumbnail('page-single');             $content .= $original_content;              }           }      return $content;     }          add_filter( 'the_content', 'InsertFeaturedImage' );       I want the above functionality to above function. Any help appreciated.


title: Use of antispambot with $curauth->email

text: This is probably pretty simple, but... I want to use the WP function **antispambot** not on **get_the_author_email** but on a value in a field I added to User Profile called **publicemail**. Everything I've tried throws a php error. This is the **antispambot** usage shown in the WP docs:               echo antispambot(get_the_author_email());      And this is the complete function I'd like to get to work with **antispambot** and have it encode **publicemail** :               <?php     if ( !empty( $curauth->publicemail )){     echo 'Email   publicemail.' ?subject=Webmail">     '; }     ?>


title: Alter BuddyPress member search to include search on added profile fields

text: I added a "company" field to member profiles via s2member plugin. However, this field is not included in the "member" search. For instance, when I search on the name of a company (when I know the company name I'm searching for is part of a member's profile info), the search displays "no results". How do I make added profile fields searchable?


title: Getting a peer review for my new plugin?

text: What is the best way to get an experienced WordPress developer take a look at my plugin and give constructive criticisms? I have written code to solve some of my questions on this site, and I think they could be useful to others too. However, since they would by my first public WordPress plugins, and I have seen many not-so-great examples in the public WordPress directory, I would like to know "where I stand", and how I can improve my plugins. I have read the list of best practices, and still need to apply some of them, but I would also like an answer to the more general question "Is this a good way to solve this problem?" I just re-read the related discussion on `wp-hackers` (I did not realize that the participants were also so involved in this site, and that the "best practices" question is a direct result of it). I'm not sure my needs would be covered by such a system, and I agree with Paul's concerns: > When I read the original comments on this thread last week I though the > purpose was to put together a peer review process where plugin developer can > offer advice to other plugin developers as review of their code. I > originally took this advice as something along the lines of "Well, your code > works but this set of routines you've written would be better served if you > just hooked into this WP filter and tried this technique (see xxx plugin as > an example)". The goal I thought was to share WP plugin development > knowledge and make any mediocre plugin developer a better developer. Like > myself. This would be a different scope than doing a point-by-point checklist review, it would be more of a "mentorship". It seems there are many people willing to do this, and (even better) many of them participate here on this site, so how can we transform all of that energy into something concrete? ~~My current example are three plugins I wrote tosolve my "image resize" problem. I wrote long introductory comments to each plugin, which (I hope) makes it easier to understand my intentions without reading the full code. Is there anything else I can do to make it easier for others to take a look at it?~~ _Please ignore my current concrete request. Not only is it too early for them, but I changed my mind and don't want to spoil the general discussion with my specific situation._


title: WP Query to get all posts (including in draft/pending review)

text: I currently have the following query:               $args = array(                   'post_type' => 'post',                   'orderby'   => 'title',                   'order'     => 'ASC',                   'posts_per_page' => 10,                 );          $my_query = new WP_Query($args);          while ($my_query->have_posts()) : $my_query->the_post(); ?>      This returns all the posts that are published. How can I alter it to show every post whether it's published, pending, or in draft?


title: How to save TinyMCE fields on Wordpress custom post type?

text:
I have a custom post type "career_opportunities" with a "responsibilities" textarea box:
Responsibilities
                         <?php wp_editor(                                         "",                                          "responsibilities",                                          array(                                             'textarea_name' => 'responsibilities',                                             'tinymce'=>true                             )); ?>      The problem is, it is not saving when I call "save_post":               add_action( 'save_post', 'save_career_opportunity' );                   /* When the post is saved, saves our custom data */         function save_career_opportunity( $post_id ) {                  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )                return;                  if( !isset( $_POST['career_nonce'] ) || !wp_verify_nonce( $_POST['career_nonce'], 'my_meta_box_career_nonce' ) )                     return;                  if ( 'page' == $_POST['post_type'] )              {                 if ( !current_user_can( 'edit_page', $post_id ) )                     return;             } else {                 if ( !current_user_can( 'edit_post', $post_id ) )                     return;               }                      $responsibilities  = $_POST['responsibilities']; // longer description                 $qualifications    = $_POST['qualifications']; // longer description                 $career_level      = $_POST['career_level']; //                  $minimum_education = $_POST['minimum_education'];                 $job_status        = $_POST['job_status'];                      update_post_meta($post_id, 'responsibilities', $_POST['responsibilities']);                 update_post_meta($post_id, 'qualifications', $_POST['qualifications']);                 update_post_meta($post_id, 'career_level', $_POST['career_level']);                 update_post_meta($post_id, 'minimum_education', $_POST['minimum_education']);                 update_post_meta($post_id, 'job_status', $_POST['job_status']);              }


title: Multiple WordPress outside wordPress installation?

text: I have a main page where i want to show up the latest post content of two or more blogs.. for now I have this code :                   <?php         // Include WordPress Blog 1         define('WP_USE_THEMES', false);         require('./blog1/wp-load.php');         ?>           <?php query_posts('showposts=3');?>         <?php while (have_posts()): the_post(); ?>             some of my blog 1 stuff.. .         <?php endwhile; ?>         <?php wp_reset_query();?>              <?php         // Include WordPress Blog 2         define('WP_USE_THEMES', false);         require('./blog2/wp-load.php');         ?>           <?php query_posts('showposts=3');?>         <?php while (have_posts()): the_post(); ?>             some of my blog 2 stuff.. .         <?php endwhile; ?>         <?php wp_reset_query();?>      blog no. 1 is showing it's content but blog no. 2 doesn't show up the content.. .how can I reconstruct them both to work in one page which is my main page... are this possible to reconstruct?


title: Get the latest taxonomy/category?

text: I'm designing a custom magazine theme, where categories are used for different sections, and I created a custom "edition" taxonomy. The editor will create a new term in that taxonomy for each new edition published, i.e. the number of the issue. How can I query the latest "edition", so I can combine it with each category and then publish only the posts that belong to the newest edition? Something along the lines on: ?edition=34&cat=studies


title: Using shortcode in template file

text: this is shortcode in template:               function shortcode_frame_left( $atts, $content = null)     {             return ''. do_shortcode($content) . '';     }     add_shortcode('frame_left', 'shortcode_frame_left');      this is how using in post content:               [frame_left]  [/frame_left]      I am trying to use this shortcode in template file for displaying post thumbnails. What i try:               if (has_post_thumbnail()) {          apply_filters( 'the_content', "[frame_left]".the_post_thumbnail()."[/frame_left]");      }      and               if (has_post_thumbnail()) {          $thumbnail = '[frame_left]'. the_post_thumbnail() . '[/frame_left]';     echo do_shortcode("$thumbnail");          }      What am i doing wrong?


title: What is the best way to create a menu item that links to all posts with a certain tag?

text: I guess the title says it all. Short of creating a page with a custom template that links all the posts with a given tag (this is NOT a scalable solution, particularly if you want to let a customer do this), how would you add a menu item that takes you to a tag archive?


title: Is it possible to add classes to list items in wp_nav_menu()?

text: I am using               <?php     wp_nav_menu(         array(             'theme_location' => 'header-menu',             'menu_class' => 'nav-bar',             'container' => 'nav'         )     );     ?>      to output my navigation menu list. Currently they automatically get classes added to them like `page-item-8`, `page-item-6`. I work on a local machine and upload to my server. My problem is the `page-item` numbers are different and I can't select them properly. What I want to do is add a class `home`, `shop`, `services`, etc to the respective list item. Is there a better way to do this. Thanks in advance.


title: Create gallery doesn't show uploaded images

text: When you do Add Object in a page, for example, a screen is shown where you can see your uploaded images. But it doesn't work for me. No images are shown. What can it be due to? If I open the Multimedia Library the images are there. If I try to upload an image from this interface (add object) I get an error: There has been an error while uploading. Try again later (not literal, translated from spanish).


title: Hierarchy with users (manage other users)

text: Is there a way to assign users to a specific other user. For example, a user registers as a custom user role called manager. Then as a manager, I can assign other users to this manager and therefore be able to at some place (probably on the frontend and not in the dashboard) allow the manager to list users assigned to the manager. I was thinking to some point I can add something like a 'manager' field where users can choose who their manager is, and then create some functionality to read that field in the database and list users based on what user is logged in. I just didn't know if this is something that there is already a pre-built solution (don't want to reinvent the wheel) or if this is already built in WP to some extent.


title: Pass UserName and Password to WordPress wp-login.php from custom login template

text: i have a my custom login template where user enter his/her login details now i want like when user will click on button for Login user's details username and password i want to send to wp-login.php page to validate user and after that it will redirect to my home page. is this possible and if yes then how ??


title: How can I get some of a posts meta data whilst it is still inserting?

text: I'm trying to make a function where a child post of a certain post type inherits the same title and slug as its parent. I'm using WP Types to define my post types and their relationships. But I'm having trouble with the below code:               function copy_parent_post_title( $post_id ) {              $new_post = get_post($post_id);              if($new_post->post_type == 'carnews-adverts') {                  $parent_id = get_post_meta( $post_id, '_wpcf_belongs_carnews_id', true );             $parent_title = get_the_title($parent_id);             $post_slug = sanitize_title_with_dashes($parent_title);                  $post_update = array(                 'ID'           => $post_id,                 'post_title' => $parent_title,                 'post_name' => $post_slug             );                  remove_action( 'wp_insert_post', 'copy_parent_post_title' );             wp_update_post( $post_update );             add_action( 'wp_insert_post', 'copy_parent_post_title' );              }          }     add_action( 'wp_insert_post', 'copy_parent_post_title' );      The problem is this line:               $parent_id = get_post_meta( $post_id, '_wpcf_belongs_carnews_id', true );      I presume it is because at this point the post's meta data hasn't been inserted into the database yet? If so how can I achieve what I want by accessing the get_post_meta upon inserting a post? Thanks


title: Multisite features

text: I was thinking about creating a network of user-created blogs. I've read somewhere about wordpress multisite feature, and i was wondering if this is what i'l looking for... What i need to do is create a website where users register and create their onw blog. Does wordpress multisite offer this feature out of the box ? If not, would manually implementing this feature into wp be doable, or should i start from 0 or another platform ? Thank you!


title: Delete users from multisite after they have not logged in for a set amount of time?

text: I have added this to the users as they log into any of the sites on my multisite.               update_user_meta( $user_id, '_last_login', time() );      Now I want to delete all of the users that have not logged in for the past 6 months. I am looking for the sql version of this as I will then include it into a scheduled task to run once a week to clean the database.                       $time = strtotime('-1 hour');             $user_query = new WP_User_Query(array('meta_key' => '_last_login', 'meta_value' => $time, 'meta_compare' => '<=', 'fields' => 'ID'));                  if (!function_exists('wpmu_delete_user')) {                 include(ABSPATH . "wp-admin/includes/ms.php");             }                  if ($user_query->results) {                 foreach ($user_query->results as $old_user) {                     wpmu_delete_user($old_user);                 }             };


title: Hide comments column in WP backend

text: Is there a way to hide the comments column in the backend? When you look at the pages, there's a comments column even though I'v disabled them. I made WP into a cms and it may cause some confusion.


title: CMS - User confusion when creating new page and having to select template and save first to see correct fields

text: I've made WP into a cms and there's a few niggling things that cause confusion. The main one is that when you create a page, you have to first select a template then enter a title then save as draft for it to show the correct fields on the page (I'm using the advanced custom field plugin). Is there any way to get around this? A couple of users have now said "why aren't I seeing the correct fields to fill in?", this is down to not selecting the template and saving first.


title: How to disable style filtering in post?

text: I need to put HTML code directly in post. It works, except for some css attributes :   * background-image   * position Every time a "editor" or "admin" user try to type those attributes in a style properties :               <div style="position:absolute">      The whole style properties is removed. It works fine for the superadmin. I tried to put this in my function.php :               remove_filter('content_save_pre', 'wp_filter_post_kses');     remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');      But it doesn't work. I tried to edit roles, but the "unfiltered_html" capabilities seems to be deprecated, and anyway, checked for both admin and editor by default. I know this filter is for security. But my site will be accessible to only one user, so I can't assume he won't try to hack his own site. Thank you very much EDIT : I found a page explaining the problem, but without the solution : http://shinephp.com/is-unfiltered_html-capability-deprecated/


title: Post thumbnail outside of loop

text:
I'm trying to show a post thumbnail outside of the loop. The reason for this is that i want the featured image to show inside a custom page template, which will set the header image for the particular page for which the custom page template is set. I've tried the obvious `the_post_thumbnail();` and as expected, it didn't work. What's the best solution for using the featured image outside of the loop? The custom page template code i'm working with...

              <?php IMAGE WILL GO HERE ?>

             <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Top Content')) :          endif; ?>

                         <?php the_content(); ?>                         <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentythirteen' ) . '', 'after' => '
', 'link_before' => '', 'link_after' => '' ) ); ?>
                                                   <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '', '' ); ?>
                      <?php comments_template(); ?>


title: What is the "proper" way to generate a javascript variable depending on a custom field value?

text: On my site I have some posts with a custom field "Name". Now, in case the post has "Name" set, I want to generate this code:               <script type='text/javascript'>         var FG_DONATE_BUTTON_PARAMS = { attribution: 'honor',   attribution_name: Name}          </script>      where Name after attribution_name refers to the custom field value. For test purpose, I've used this code in the header               $nameAttribute= get_post_meta($post->ID, 'Name', true);      printf('<script type=\'text/javascript\'>     var FG_DONATE_BUTTON_PARAMS = {          attribution: \'honor\',          attribution_name: \'' . $nameAttribute .'\'     } </script>');      But I have two problems. One, the value of the $nameAttribute doesn't get passed through, and secondly, it's ugly :) I think I can manage the value problem, but I'm unsure what would be the "proper" way to output this.


title: Programatically add a page in Wordpress

text: I am trying to add a page to WordPress programatically. I am using this code:                function add_media_page(){     if(!(is_page('My New Post'))){          // Create post object       $my_post = array(          'post_title' => 'My new Post',          'post_content' => 'This is my post.',          'post_status' => 'publish',          'post_author' => 1,          'post_type' => ['page']       );          // Insert the post into the database       wp_insert_post( $my_post );     }     }     add_action( 'init', 'add_media_page' );       However when i use the last line in the array 'post_type' => ['page'] it causes the admin to crash and show a blank page. Does anyone know what's happening here


title: Auto create Nextgen Gallery on post creation

text: I was wondering if there is a way to create a nextgen gallery with a function, so that I can hook that into my front end post creation setup. The gallery could be completely empty or be created with the featured image of the created post.


title: Inserting custom fields into single.php

text: I am trying to get a custom field to show straight after the main body of text in single.php BUT before the Outbrain and Facebook Connect boxes. If I put the line to show the address above `<?php the_content('Read the rest of this entry »'); ?>` then it shows above the body text, if I place it below, it doesn't show at all. Is there any way to insert it into `'the_content'`? Thanks!


title: Configure Wordpress to connect to Mysql DB using SSH tunneling

text: Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling. Stage: I have a wordpress instance over an apache server on machine (called WP_server). WP_server, does not have Mysql server and has blocked port except 80 (http) and 22 (ssh). In other place is another machine (Mysql_server) which has a MySQL instance. This server can provide a database to WP_server. These two server have ssh access. How should I configure wordpress to use ssh tunneling?


title: Change custom post type GUID in RSS

text: So i got the RSS feed which output some custom post types, but the GUID looks bad to me, it's like:               ?post_type=mycustompost&p=124      The reason i want to change this is that I don't need people to know it's Wordpress or to see my custom post type name (this is very important in this project) Is there a filter or hook to rewrite this? Thanks


title: How to internationalize header image?

text: I have in the following code in the template:               <img src="<?php header_image(); ?>" />      However, I want to change this image according to the language selected (through GET parameter lang). The question is, how to change this function to look for different images according to the received GET parameter? I thought of:   1. Change this code on header.php to a fixed image path, so I could put an if and choose between the images I want.    2. Replace the result of the function get_header_image() and use it instead on header.php according to the received parameter, sort of replacing the string suffix .png to _en.png or .png to _es.png.   3. Change the header_image() function to behave the way I want. All these ways look ugly to me. Are there better ways?


title: How to modify the HTML formatting of an oEmbed link?

text: I am trying to add oEmbed DeviantArt integration to a custom theme. I found that first step is quite easy, I added               wp_oembed_add_provider( 'http://*.deviantart.com/#/d*', 'http://backend.deviantart.com/oembed' );         to theme's _functions.php_. Now, I would like to change the default HTML output to add more information, available in DeviantArt JSON response (DeviantART reference), like author_name, author_url, etc. If I have studied well the WP code that manage the output is inside function _data2html_ in _class-oembed.php_ , but I don't like change the code here. How can I add a function to my theme, to achieve the desired result?


title: Add custom template page programmatically

text: I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code:                global $user_ID;         $new_post = array(             'post_title' => 'Test Template Page',             'post_content' => 'Some text',             'post_status' => 'publish',             'post_date' => date('Y-m-d H:i:s'),             'post_author' => $user_ID,             'post_type' => 'page',             'post_category' => array(0)         );         $post_id = wp_insert_post($new_post);         if (!$post_id) {             wp_die('Error creating template page');         } else {             update_post_meta($post_id, '_wp_page_template', 'tp-file.php');         }      tp-file.php is my custom template page.When I put that file into the my-theme folder,it works fine,but I want to do this with file from plugin folder so I don't have to force users to copy that file from plugin folder to template folder. Is this possible?Any idea?


title: Change Page Order by Custom Field (Magic Fields)

text:
My code lists the child pages ordered by post title, pulling through the first image attachment of the child post as the thumbnail. The child pages contain custom fields created using the Magic Fields plugin. Can anyone help me adjust my code so that I can have my pages listed in descending order of a custom field called 'price'? This is my code:                   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>             <div class="page" id="post-<?php the_ID(); ?>">
                           <?php $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY post_title", 'OBJECT');   ?>               <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
<a href="<?php echo  get_permalink($pageChild->ID); ?>" alt="<?php echo $pageChild->post_title; ?>" title="<?php echo $pageChild->post_title; ?>">     <?php $attachments = get_children( array(                     'post_parent'    => $pageChild->ID,                     'post_type'      => 'attachment',                     'numberposts'    => 1, // show all -1                     'post_status'    => 'inherit',                     'post_mime_type' => 'image',                     'order'          => 'ASC',                     'orderby'        => 'menu_order ASC'                     ) );     foreach ( $attachments as $attachment_id => $attachment ) {         echo wp_get_attachment_image( $attachment_id, 'medium' );     } ?>
<a href="<?php echo  get_permalink($pageChild->ID); ?>" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?>

          <?php endforeach; endif; ?>

                  <?php endwhile; endif; ?>      I would appreciate any help! Thank you.


title: I have two problems ( SEO )

text: how are you ? In my website I want to make the author's page and category(slug of it is country) to be in google reslut .. like this : http://rehlat-world.com/profile/saqaf , but when I search in google : site:rehlat-world.com , I didn't find authors page. how can include authors page in google result , this is my robort and this is my sitemap note: I change the slug of author ( http://rehlat-world.com/author/** from author to profile ( http://rehlat-world.com/profile/** ) .. how can include author page in google result ? ALSO , when I search in google (site:rehlat-world.com) some of posts repeated like this : http://rehlat- world.com/%D8%A7%D9%84%D9%8A%D9%85%D9%86-%D8%A7%D9%84%D8%B3%D8%B9%D9%8A%D8%AF-%D8%AC%D9%88%D9%84%D8%A9-%D8%B3%D9%8A%D8%A7%D8%AD%D9%8A%D8%A9-%D9%85%D8%B5%D9%88%D8%B1%D8%A9-%D8%AC2.html http://rehlat- world.com/%D8%A7%D9%84%D9%8A%D9%85%D9%86-%D8%A7%D9%84%D8%B3%D8%B9%D9%8A%D8%AF-%D8%AC%D9%88%D9%84%D8%A9-%D8%B3%D9%8A%D8%A7%D8%AD%D9%8A%D8%A9-%D9%85%D8%B5%D9%88%D8%B1%D8%A9-%D8%AC2.html?replytocom=37 same reslut but change in the last of like "?replaytocom=37" WHY?


title: Front end login and page restriction

text: I've read a few posts about this topic, but I haven't found any plugins that fit my need. What I want to achieve: User A and B both have a login. When user A logs in, he's redirected to www.somesite.com/ **a** / and when user B logs in, he's redirected to www.somesite.com/ **b** / Now, www.somesite.com/ **a** / should be private for user A, and user B or anyone else should not be able to access this page. I found this plugin that would allow a redirect after login: https://wordpress.org/plugins/redirect-after-login/screenshots/ But as you can see, this is only for the standard user roles. I will of course need some custom members/groups, since I could have many users that should only be able to see their own personal page (Right now my need is only around 7 users). It is very important that I, as an admin, can control the content on these pages. It shouldn't just be a simple "update profile page". So yeah, to sum up: I need each user to have a private page, that they are redirected to when they login. I hope that someone has tried this before, and has some ideas. I don't think there's one plugin that can do all I'm looking for, so I guess I need a couple of plugins that can talk well together. Please do tell if I need to provide more information.


title: Where are available Roles Defined in the wp_ database?

text: I got on the list to test a private beta of a plugin I'm using on a multisite network. The plugin authors have code in there to add a custom role. They have a bug that removes the ability to give a user any role except their one custom role. When I visit `../wp-admin/network/site-users.php`, the "Add User" role pulldowns only show the one role this plugin added. The change role pulldown menu shows all the WP default roles, plus a few extra roles this and other plugins have added. If I attempt to change a user to one of these roles, I get a "You can't give users that role" error page. I've been discussing this with the developer, and they seem baffled. I've been looking through my database and the codex, and I can't find where the valid roles are defined.


title: How to upload and add images to the existing post from the front-end with admin approval which is posted by other user

text: I want, by admin approval, that a logged in user can upload a image and add to the post which is posted by other user. He should add the image to the post from the Front-End.


title: Template file renders on local install, not on web

text:
I've been building a website that involves a child theme of Twenty Twelve and a custom post type with associated custom taxonomy, "area". I've built a template file (cribbed from code found elsewhere) to render an taxonomy archive of this post type, `taxonomy-area.php`. I've been experimenting on my desktop MAMP install, and when I get things the way I like them, upload them to my web hosting service (Dreamhost, fwiw), or reproducing the configuration there. Not the most efficient way to do business, I admit, but I haven't had any success with any of the staging/production plugins. Anyhow, this taxonomy-area.php file works as expected on my desktop. But the "meat" of the template fails to render—that is, the PHP between `<? get_header(); ?>` and `<?php get_sidebar(); ?>` That code is as follows:

      <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>       <?php         $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1');       if (have_posts()) : ?>
Area Listing: <?php echo $term->name; ?>

         <?php while (have_posts()) : the_post(); ?>           <?php $url = get_post_meta($post->ID, 'honyaku_url', true); ?>           <?php $desc = get_post_meta($post->ID, 'honyaku_description', true); ?>             <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

               <a href="<?php echo $url; ?>" title="<?php the_title(); ?>" rel="bookmark">                 <?php the_title(); ?>

<?php echo $desc; ?>

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

            The output HTML is as follows:


title: Set authentication cookies to be shorter but then extend with every page load

text: I'm trying to get around the otherwise very insecure way of Wordpress handling authentication cookies. I mean, having the cookie expire in 2 weeks only if I build a membership site is obviously not ok, but at the same time, making it expire in 15 minutes while the user is logged in would be more than annoying. I have searched and tested extensively, and narrowed down the somewhat complicated code forest around this in Wordpress to the `pluggable.php` file under the `wp-includes` folder and found `wp_set_auth_cookie` function on line 652 (v 3.5.1). Now this does give me the possibility to change the times, however those are, as mentioned above, fixed to the login time, instead of to the user's last activity. I tried to add this function or the `wp_signon` function using this one to my header, but it didn't do the trick. Any plugin or hook or something that you can think of that would help me with this? Thanks a lot for your help in advance! **EDIT (June 6, 2013):** I tried with following code in the `functions.php` file of my template, but all it does it that it logs me out when I reload the page, it doesn't actually renew the auth cookies. The issue may be with the arguments (`$userinnow, $remember, $secure`) which, by the way, I don't need/use, except for `$userinnow`.               /* Renew cookie at every page load */     function renew_wp_cookie() {              global $current_user;         get_currentuserinfo();         $userinnow = $current_user->user_login;         if (is_user_logged_in()) {             wp_set_auth_cookie($userinnow, $remember, $secure);         }         else wp_clear_auth_cookie();          }          add_action('init', 'renew_wp_cookie');


title: Get only the path from a function like previous_post_link

text: I want to use something like `previous_post_link('%link','',TRUE )` and put the path into a javascript variable. So using something like `var previous = "<?php previous_post_link( '%link','',TRUE ); ?>";` outputs : `<a href="http://www.website.com/photo/1085" rel="prev"></a>` but instead I only want the path output in that variable. `http://www.website.com/photo/1085` I like this function because it allows you to remain in category so I am hoping for a solution where I still can easily have that as an option.


title: Handling front-end file uploads, considering safety and ease of use

text: I'm looking to adapt an existing forum-like plugin which has no facility for attaching media. The plugin works as a Custom Post Type, so it would be as "simple" as attaching an image to a post. I am only concerned about attaching images rather than any file type, but the plugin does use `wp_editor` and as such the solution should in some way integrate with that. I'm not overly fussed about creating a tinyMCE button, as long as the solution is capable of inserting a thumbnail of the image into the tinyMCE textarea. Please note, I am referring to the front-end of my website rather than the admin area. In an absolutely ideal situation, I would like this scenario to occur:   * User clicks "Ask a question"   * Use enters their post details   * User clicks a button on the tinyMCE interface which, similar to StackExchange, asks the user to upload a file.   * System then inserts the correctly-sized thumbnail into the tinyMCE textarea, having crunched the file into this thumbnail size   * Clicking this image should offer the same functionality as an image attachment in a Post   * User can then click again to insert a new image   * User can also delete the image from the tinyMCE textarea as needed However, I am happy for the tinyMCE button to be peripheral - if a "file upload" box is significantly easier, that's fine. I came across this link but I'm always apprehensive about reading WordPress articles on t'interwebs as I'm never too sure of how secure they are, nor am I a php security expert by any stretch of the imagination. Thanks in advance,


title: How to understand a specific bit of Wordpress syntax

text: I am changing a theme in Wordpress, and in an earlier theme, there was something like this that added a an email signup widget to the page:               [green_tick_1_list width="100%"]      But in the new theme that I installed, this just shows up as text. Is there any way to make it show up as the email signup form like it used to? And what is that syntax? Is that something I can create in WordPress per each theme I use?


title: Wrapping images in tags based on size

text:
I am making a site for a client where all the thumbnails on a page need to be styled differently than regular sized images. Right now I have a snippet of code I found that allows me to wrap every image inserted into a post in a div, but I would like to only wrap the thumbnails. Code:               function filter_images($content){         return preg_replace('/\s*/iU', '

', $content);     }     add_filter('the_content', 'filter_images');      Is there a way I can do this?


title: Resizing image into thumbnail, small, medium and large options greyed out

text: I am working with WordPress 3.3.1 and cannot resize the image I am trying to add to the page as the thumbnail, small, medium and large options are greyed out. the size of the image in question is 276x354. I have created my own theme and have added `<?php the_post_thumbnail(); ?>` template tag but to no avail. Does deactivating the visual editor have anything to do with this. I have not come across this problem before and would appreciate any pointers on what could be causing this problem. Thanks in advance. nav


title: post_content not parsed using save_post action hook

text: A site I'm building for a client has to be able to download Vine's to a server when they've been posted using a shortcode (`[vine id="..."]`). This works fine for my local install (it's a Multisite install if that helps). I post the shortcode, save the post, the Vine .mp4 file (format `vine-<post ID>.mp4`) is saved to my uploads directory (with correct post ID) and when I view the post, the correct file is shown. However, on the online site, something seems to go wrong: when the post is saved, and then I view the post, the file seems to exist but with no content (i.e the correct data was not passed to the functions to download the video file). I have narrowed this down to what I think it's very likely that it is: for some reason, the online site has a problem getting the content of the post after it's been saved to the database. Hopefully this will be a bit clearer after I show my code:               function vineDL() {         global $post;         $vinePostContent = $post->post_content; // retrieve post content         if (in_category("Vines")) { // check it's in correct category             preg_match_all('/\[vine.+id=[\'"](.+?)[\'"]\]/i', $vinePostContent, $matches); // match the [vine id=""] shortcode             $vineID = $matches[1][0]; // get the actual ID from the matched array             downloadVine(vine($vineID)); // some other functions which are involved in downloading the Video file (from prior investigation, I believe these are not at fault)         }     }          add_action('save_post', 'vineDL'); // add post actions     add_action('draft_to_publish', 'vineDL');     add_action('new_to_publish', 'vineDL');     add_action('pending_to_publish', 'vineDL');     add_action('future_to_publish', 'vineDL');      As you can see, the shortcode needs to be matched so the ID can be taken and passed into the other functions (which are quite big and I'd rather not show them). I think the problem is, that the online install of WP seems to think that the post content is empty when the post is saved and therefore nothing is matched, so the ID cannot be passed to the other functions which do the actual downloading. To back this up, when I enable `WP_DEBUG`, and go to 'Add New Post', there are two messages at the top of the page, telling me that `$post->post_content` is not a proper object. also, this occurs on my local install as well as the online install. If someone has a better way of retrieving the ID, which is a shortcode attribute defined in another function (and works perfectly), then I'd be very interested to hear as I know this is a flaky method of getting data from a post. Hope someone can help me out, thanks very much :)


title: Help with overloading the limits of CPU/RAM issue in a resseler account with wp sites

text: The server that I am on has these characteristics:   * Intel(R) Xeon(R) CPU E5506 @ 2.13GHz/24GB ddr3   * CloudLinux Server release 5.7 64 bit/litespeed webserver   * And overall are 800 clients (in whois.domaintools.com that I am looking right now the Shared IP Address of the server that I am is the "Reverse IP: 1,195 websites use this address.") And the limits are 1gb of memory and 25 concurrent connections In the reseller account that I have I created two accounts:   1. WordPress Multisite with 3 sites in under contraction/coming soon message with 2 gb ram and 30 concurrent connections (I don't know why, I am waiting for an answer from my host provider). The last 7 days from Resource Usage Details   2. A WordPress eZine blog with 4000-6000 monthly unique visitors/150-200 a day visits with 2 gb ram and 20 concurrent connections (I don't know why, I am waiting for an anwser from my host provider). The last 7 days from Resource Usage Details The eZine blog has 25 Active Plugins:   * Admin Locale   * AdRotate   * All in One SEO Pack - Pro Version   * Calendar Posts   * CloudFlare   * Contact Form 7   * Easy Mashable Social Bar   * FeedBurner FeedSmith   * Google Analytics for WordPress   * Google XML Sitemaps   * JW Player Plugin for WordPress   * NextGEN Gallery   * Really Simple CAPTCHA   * registration-login   * TentBlogger SEO Categories   * Top 10   * Twitter Embed   * W3 Total Cache   * WP-DownloadManager   * WP-Optimize   * WP-PageNavi   * WP-reCAPTCHA   * WP-UserOnline   * WP Smush.it   * WP Smush.it NextGEN Gallery Integration My problem is when am going to apply or save the setting of a plug in or when am going to publish or save as a draft a post I get same message: > 503 Service Unavailable > > The server is temporarily busy, try again later! Powered By LiteSpeed Web > Server LiteSpeed Technologies is not responsible for administration and > contents of this web site! Also it takes a lot of time for my site load. It doesn't load the virtual editor of the post. And the only thing that my hosting provider suggests to optimize my site(But, I already use plug ins (CloudFlare,W3 Total Cache, WP Smush.it & WP Smush.it NextGEN Gallery Integrationor) in order to optimize my site) to move to a Cloud server. What do you think about that? Should I move to a Cloud server or use CDN to my current reseller account or in a new host provider? Also, does the problem really starts from me or my hosting has done a lot of overselling? Please suggest me anything that will be useful for my problem and if it's necessary to give you some information(That I might have forgot to mention) to help you understand.


title: Custom taxonomy list in Worpdress

text: I just registered following code in my function               add_action( 'init', 'create_resources_taxonomies', 0 );          function create_resources_taxonomies() {         $labels = array(             'name'              => _x( 'cat2', 'taxonomy general name' ),             'singular_name'     => _x( 'cat2', 'taxonomy singular name' ),             'search_items'      => __( 'Search category' ),             'all_items'         => __( 'All category' ),             'parent_item'       => __( 'Parent category' ),             'parent_item_colon' => __( 'Parent category:' ),             'edit_item'         => __( 'Edit category' ),             'update_item'       => __( 'Update Category' ),             'add_new_item'      => __( 'Add New Category' ),             'new_item_name'     => __( 'New category Name' ),             'menu_name'         => __( 'genre' ),         );              $args = array(             'hierarchical'      => true,             'labels'            => $labels,             'show_ui'           => true,             'show_admin_column' => true,             'query_var'         => true,             'rewrite'           => array( 'slug' => 'genre' ),         );              register_taxonomy( 'genre', array( 'resources' ), $args );     }      and i want to get category list in my sidebar, so i added following code in my sidebar               <?php         $taxonomy     = 'genre';     $orderby      = 'name';      $show_count   = 0;      // 1 for yes, 0 for no     $pad_counts   = 0;      // 1 for yes, 0 for no     $hierarchical = 1;      // 1 for yes, 0 for no     $title        = '';          $args = array(       'taxonomy'     => $taxonomy,       'orderby'      => $orderby,       'show_count'   => $show_count,       'pad_counts'   => $pad_counts,       'hierarchical' => $hierarchical,       'title_li'     => $title     );     ?>          <ul>     <?php wp_list_categories( $args ); ?>     </ul>      But i just get "No categories" text. What is wrong with my code?


title: Sorting custom post types by taxonomy (So close)

text: I have a custom post type called 'requests' that has a custom taxonomy 'request-categories'. I've created a template with a modified loop that allows me to view my custom post type in a certain 'request-category' for instance 'electronics-requests'. The loop works if I manually change the args for post type and taxonomy but, in order for it to be usable, I need to figure out how to deal with the urls so that `mysite.com/requests/request-category/electronics-request` will modify the loop in such a way that will provide the expected results. The way I see it, `mysite.com/requests` will be an actual page, while the `request-category` and `electronics-request` portions of the url would be assigned to the appropriate variables in the loop. WHich seems easy enough but I don't know how to keep wordpress from 404ing. I'm trying to do exactly what wordpress already does with posts and categories. I'm very close to having this working but I'm running in to a wall here. It seems to me that this should be a standard feature and this is critical to full functionality of custom post types.


title: Help building array hierarchically with taxonomies (to get posts)

text: What I need to do is to : -+ Retrieve all terms assigned to a page -+ Get all posts assigned to each term -+ Organize the output in the hierarchic way as in the admin I'm OK with the first two items, but I cannot seems to find a way to organize my output in the correct hierarchical manner (probably because i'm not good with arrays and probably PHP in general). This is what I got for now :               public function return_all_tax_objects() {              $obj_term_posts = array();              foreach ( $this->return_object_terms() as $obj_term ) {                  if ( $obj_term->parent ) {                 unset( $key );                 $ancestors = array_reverse( get_ancestors( $obj_term->term_id, $obj_term->taxonomy ) );                 foreach ( $ancestors as $ancestor ) {                     $ancestor_term = get_term( $ancestor, $obj_term->taxonomy );                     $key .= "[$ancestor_term->slug]";                 }                 $key .= "[$obj_term->slug]";             }                  if ( array_key_exists( $key, $obj_term_posts ) ) {                       $get_term_posts = $this->get_posts_for_term( $obj_term );                  array_push ( $obj_term_posts[ $key ], $this->get_posts_for_term( $obj_term ) );                  } else {                      $obj_term_posts[ $key ] = $this->get_posts_for_term( $obj_term );                  }              }         return $obj_term_posts;     }      And `$this->return_object_terms()` corresponds to a function to returns all terms for a `ID` for all Custom Post Types I have set up, in a flat array :               public function return_object_terms() {              return wp_get_object_terms( $this->object_id, $this->return_object_taxonomies(), array ( 'orderby' => 'term_id', 'order' => 'ASC', 'fields' => 'all' ) );     }      As you will see in my snapshot for the returned values, I'm close, but : **Edit :** Changed code for a better option. Still, not working. Somehow, I got it all but mixed up. I have the correct posts, but I'm not updating the correct index somwhere. Essentially, what I need is a way to nest child terms into parent term, so I could structure my output :               -+ Direction générale des services     --+ (posts)     ---+ Services Techniques     ---+ (posts)     ----+ Directeur des Services Techniques     ----+ (posts)     ---+ Services Administratifs     ---+ (posts)     ...      ![Firebug capture of returned array $obj_term_posts](http://i.stack.imgur.com/RRSul.jpg)


title: Adding custom code to a WordPress site

text: I have coded a small calculator in 3 files, HTML/JS/CSS + 1 image, and I need to integrate it in the main column of a WordPress site. It's a standard calculator tool, a div with 2 dropdown, and a result appearing when options are selected. The tool needs to appear just as an article would, taking all the main column of a 3 columns layout. Maybe it could be a shortcode but not a sidebar widget. I just need this piece of custom code to display in a page. No other requirements. I'm a software coder and have no WP experience. What's the best way to do that, do I need to make a plugin?


title: Allow access to stand-alone php file Wordpress

text: I am developing a wordpress theme and I want to use `jQuery.load()` to load data from a PHP file in my theme directory called `process.php` to a div in a wordpress page template. I haven't had any issues with `load()` in the past but Wordpress is preventing me from loading the data or even accessing the process.php file in the browser. When I navigate to the full path of the file (eg: http://[site]/[theme]/functions/process.php) I get the following error in Chrome > Internal Server Error. The server encountered an internal error or > misconfiguration and was unable to complete your request. Please contact the > server administrator, **@gmial.com and inform them of the time the error > occurred, and anything you might have done that may have caused the error. > More information about this error may be available in the server error log.` I've read similar questions but they involve modifying the `.htaccess` file. Does anyone know how to do this from a theme perspective ie: using `$wp_rewrite`. ## EDIT > Linux Server error log states                   [Mon Mar 12 14:00:52 2012] [error] [client 121.98.81.237] SoftException in Application.cpp:245: File "/var/www/vhosts/****.co.nz/httpdocs/npr/wp-content/themes/_s_2/functions/process.php" is writeable by group [Mon Mar 12 14:00:52 2012] [error] [client 121.98.81.237] Premature end of script headers: process.php      and this is process.php               <?php      echo "hello from php";     ?>


title: How to include own css on wordpress tinymce editor?

text: I have added some text on tinymce editor on load.   (Every time you click on Add new the tinymce editor load with this text.) but problem is how to enable css class which are using in default text. Thanks


title: Multi site problem. Redirecting to signup and sub-sites not working

text: I'm having a nightmare of a time with a multisite setup I'm working on. I've worked on plenty of MS installations before and never come across anything like this. Basically http://www.energyhair.com.php54-1.dfw1-2.websitetestlink.com/ is the primary domain (It's a test domain, obviously) but everytime I, or anyone else, tries to access it they get redirected to the signup page regardless of what page they try and access. I've tried editing .htaccess and also adding the noblogredirect bit to wp- config to no avail. The other issue is the sub-site, http://shop.energyhair.com.php54-1.dfw1-2.websitetestlink.com/ that just doesn't seem to be working at all. The site exists, it's in the database and you can also see it's information in the network super-admin area. Could it possibly be down to the test domain my client is using? Any help would be most appreciated.


title: Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!

text: I have a custom-taxonomy for a custom-post-type just like categories. I've used the standard loop in my `taxonomy-event_type.php` template so far …               if ( have_posts() ) : while ( have_posts() ) : the_post();       This meant that the template only showed the posts associated with the current term (category) the post was in. So on `url/event_type/workshops` only all posts that were set to "workshops" in the backend would appear. Now i've changed that standard loop to a custom loop where I'm passing some args so I can sort the posts by a meta-value (the event date)               $args = array(         "post_type" => "wr_event",         "meta_key" => "_wr_event_date",         "orderby" => "meta_value_num",         "order" => "ASC"         //"terms" =>          );              $wr_events = new WP_Query( $args );              if ( $wr_events->have_posts() ) : while ( $wr_events->have_posts() ) : $wr_events->the_post();      This works perfect. Only thing. It breaks the standard behaviour for the term (category) I'm currently viewing. So with this custom loop when viewing `url/event_type/workshops` or `url/event_type/lectures` always the same posts appear! How can I again view only the posts associated with the current term "workshops" or "lectures"? Thank you for your help! edit: if I do …               $current_cat = get_query_var( 'event_type' );     echo $current_cat;          $args = array( …      The `$current_cat` holds the right term (category) I'm currently in. Only problem is that the posts in the loop are always the same. How can I filter by this term?


title: How do I fix my 'Path' field when editing pages via the Dashboard?

text: I am encountering the same problem described here: Unable to set path. In every module where I can edit a page, a `p` appears after the word 'Path'. I can click on it; clicking on it highlights some of the text. How do I fix this issue? ![enter image description here](http://i.stack.imgur.com/FuB1n.jpg)


title: meta tag placement for google verification

text: Please tell me in simple terms starting from the dashboard of a 3.3.1 webpage how to get to the place where I put this meta tag google is requiring in order to verify my site. If you start with on the main page--Please explain how to get there. My main page is just a post. then I have other pages. I've placed this meta tag all over my pages and google has not been able verify from any of them.


title: Image Upload Form is Disabling Comment Addition

text:
I have an image upload form that is being added to `the_content` using a filter. However, the existence of this image upload form makes it so that comments cannot be added. Because there are two submit buttons, the comment submit button seems like it's actually submitting the image upload form. Here is the form:               <form method="post" action="" enctype="multipart/form-data" >
<input type="file" accept="image/*" name="uploaded_attachment" id="uploaded-attachment">

<input type="submit" value="Upload">
     <form>      Is there an easy way to make it so the comment submit only submits comments and this form only submits the image upload? Thanks in advance.


title: WordPress cache feeds

text: I would like to implement a custom cache for all the feeds in my site. The rss requests are very intensive and I have a big db load. Do anyone know of a good action before running the rss query so I can cache it? I'm using memcahed and all the feeds should be cached for 1 hour.


title: Show Subpage in Author Slug Address

text: I changed author slug to "profile" then i created a page named "profile" and a subpage named "edit" for showing profile editing page. Now profile edit page link is "mysite.com/profile/edit" but author slug think the edit page is a user and show 404 page instant my page. My question is how to show edit page under author slug? Sorry for my bad english. Thanks


title: Exclude images from "inserted into post" when trying to get attachments

text: I have here the coin-slider which takes all pictures from the gallery. I get the attachments through the following code:               $attachments = get_posts(array('post_type' => 'attachment', 'post_parent' => $post->ID));      But this function also gives me pictures, which were posted inline on a page. If I look to article image I can see the picture in the tab gallery. The picture is also shown in the editor. How can I exclude pictures which where inserted into the editor? I've seen that there is an `exclude` option for `get_posts`, but neither `get_the_post_thumbnail();` nor `get_post_thumbnail_id();` does work for me. The image is still included in the slider and the post. **Edit:** It seems that it impossible to place a picture in a post without putting it in the gallery. If it is in the gallery it is also in the result of `get_posts`. Now I have uploaded a file per FTP on the webserver and placed the image by using an URL. Now it seems to work, but it isn't an acceptable solution ...


title: Numberposts 1 not cooperating in 3.5

text: Trying to fix my custom gallery after the 3.5 upgrade, and using the code below I'm trying to get the first image of the gallery in "large" size above the content output followed by the remaining images in the corresponding gallery in "thumbnail" size...but 'numberposts' => 1 isn't liking what I'm doing for some reason. And, what's the trick to completely stripping the gallery shortcode [and it's contents] out?               single.php          <?php //GETS THE FIRST IMAGE     $args = array(     'order'          => 'ASC',     'orderby'        => 'menu_order',     'post_type'      => 'attachment',     'post_parent'    => $post->ID,     'post_mime_type' => 'image',     'post_status'    => null,     'numberposts'    => 1,     );     $attachments = get_posts($args);         if ($attachments) {                  foreach ($attachments as $attachment) {                  echo wp_get_attachment_link($attachment->ID, 'thumbnail', false, false);     }     } else {        $post_content = $post->post_content;     preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);     $attachment_ids = explode(",", $ids[1]);     foreach ($attachment_ids as $attachment_id) {             echo wp_get_attachment_link($attachment_id, 'medium', false, false);     }} ?>          <?php the_content(); ?>           <?php //GETS REMAINING IMAGES     $args = array(     'order'          => 'ASC',     'orderby'        => 'menu_order',     'post_type'      => 'attachment',     'post_parent'    => $post->ID,     'post_mime_type' => 'image',     'post_status'    => null,     'numberposts'    => -1,     );     $attachments = get_posts($args);         if ($attachments) {     $no_show=true;             foreach ($attachments as $attachment) {     if($no_show) {$no_show=false; continue; }             echo wp_get_attachment_link($attachment->ID, 'thumbnail', false, false);     }     }  else {        $post_content = $post->post_content;     preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);     $attachment_ids = explode(",", $ids[1]);     foreach ($attachment_ids as $attachment_id) {             echo wp_get_attachment_link($attachment_id, 'thumbnail', false, false);     }}?>


title: How do I display a full post, not just an excerpt?

text: I am a newbie, so apologies in advance if my terminology is off. I have purchased a theme (WP SmartStart) and I would like the posts in the blog to display fully, not just as excerpts. I read previous questions and answers, and found comments that said to exchange `the_excerpt` with `the_content`. I searched through all the php files, but the only thing that seemed relevant was in the Functions.php file. I will paste it below, but I don't know how to change it so that the full post will display as I have not yet learned php. Any help you can offer would be greatly appreciated. Here is the code that I think needs to be changed:               if ( !function_exists('ss_framework_excerpt_length') ) {          // Sets the post excerpt length to 40 words (or 20 words if post carousel)     function ss_framework_excerpt_length( $length ) {              if( isset( $GLOBALS['post-carousel'] ) )             return 20;              return 40;          }     add_filter('excerpt_length', 'ss_framework_excerpt_length');          }          if ( !function_exists('ss_framework_auto_excerpt_more') ) {          // Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis     function ss_framework_auto_excerpt_more( $more ) {              return '…';          }     add_filter('excerpt_more', 'ss_framework_auto_excerpt_more');


title: All pages showing up as homepage on Wordpress website

text: Why would this be happening? Every link I click on on my site results in the homepage again. You can check it out here: http://www.whatamidoingonline.com What is going on here? This just started all of a sudden this morning. I have tried deactivating all plugins (changing plugin directory name), tried publishing new posts and pages, etc.. The problem was caused by a plugin that was supposed to fix a permalink problem, so I deactivated the plugin and the old problem still persisted. Go to my site and click on any of the blog posts, you'll see they result in a 404 error. When I first saw this, I tried yout method. I changed the permalink structure and they worked! but changing them back broke them again. I can't change the permalink structure permanently because of link building and social media stuff I have already done.


title: Is there a plugin that provides a stackoverflow style editor for wordpress?

text: I am tired of the tinymce editor in wordpress and I really love the stackoverflow editor which allows me to write with markdown grammar. So I want to write blog with markdown in wordpress. Now I am using this plugin in my wordpress: > Plugin Name: Markdown QuickTags   >  Plugin URI: http://brettterpstra.com/code/markdown-quicktags   >  Description: Replaces the WordPress QuickTags with Markdown-compatible ones   >  Version: 0.8.2   >  Author: Brett Terpstra   >  Author URI: http://brettterpstra.com   >  License: GPLv2 It replaces the original editor of wordpress and provides a light-weight interface for me to write with markdown. However, compared with Stackoverflow's editor, it lacks:   1. The SO editor have auto syntax highlighting. I don't need to specify which kind of language I am typing in. The Markdown QuickTags plugin do not provide the ability for syntax highlighting, and plugins like Wp-markdown-syntax-highlight requires me to manually add a tag to indicate the type of language. Also, I have no idea if the two plugins could work together.   2. The SO editor provides live preview, which is the most cool part of SO. Is there any wordpress plugin(s), or combination of plugins that can meet my requirement? I personally could do some development but I know little about php and js, so it's really hard for me to write one from scratch (or from the two plugins I mentioned above). **Point 1 above is the most important.** And I **don't care** if the plugin auto-converts markdown to html, or requires me to click a button like "render" before publishing.


title: Gettext Loads slightly different text

text: @ all single post pages the text to indicate one needs to be logged on to leave a comment is not displayed as expected I have this gettext:               msgid "You must be %1$slogged in%2$s to post a comment."     msgstr "U moet %1$singelogd%2$s zijn  om een reactie achter te laten op dit artikel."      Which is loaded on single.post via comments.php there using:               <?php printf(__('You must be %1$slogged in%2$s to post a comment.', 'framework'), '', '') ?>      The language file is loaded via the parent theme's functions.php using `load_theme_textdomain( 'framework', TEMPLATEPATH.'/lang' ); ` which should load the language file from the parent or child theme I think. But the text I see is `U moet iingelogd zijn op om een reactie achter te laten op dit artikel.` How does this exta i get there? Does TEMPLATEPATH only look for the lang file in the child theme? I do not think so otherwise I would have had no text getting translated as the child has no language file And second, if one is not true, why do I get this odd text?


title: Regenerate auto excerpts after updating many posts

text: I had around 100 posts that I imported into my blog. Many of the special characters (e.g. apostrophes, etc) were mangled upon import. I finally went through and fixed them all manually by editing each post and updating it. My theme displays the automatic excerpt of each post on the front page and these have NOT updated. My question is: How can I get WordPress to regenerate the automatic excerpts for all the posts? I'm using 3.5.2 and my theme is using "the_excerpt();" template tag to display these. I haven't used the manual excerpt field to make any of these excerpts.


title: Displaying the errors from my BuddyPress script

text: I have a .csv file with hundreds of rows and 2 columns. First column is the group name, and the second is the group description. I need forum to be active on all of the groups. I was told to use this code:               <?php          include "../../../wp-load.php";          $groups = array();          if (($handle = fopen("groupData.csv", "r")) !== FALSE) {         while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {             $group = array('group_id'    => 'SOME ID',                      'name'        => $data[0],                      'description' => $data[1],                      'slug' => groups_check_slug(sanitize_title(esc_attr($data[2]))),                      'date_created' => gmdate( "Y-m-d H:i:s" ),                      'status' => 'public'       );             $groups[] = $group;         }            fclose($handle);     }          foreach ($groups as $group) {         groups_create_group($group);     }           ?>      So I created a php file with this code and opened the file in the browser, and I got a blank screen. And it didn't create the groups. I have no idea what to do from here. What should I do?


title: How can I assign widgets from WP to appear in bbpress?

text: The usual set-up: www.domain.com - wordpress installation with sidebars and widgets; www.domain.com/forum - bbpress. BBpress is integrated via bbpress- integration plugin. The question is - how can I assign one sidebar with it's widgets to appear on bbpress' sidebar and be fully functional? Widgets contain contents of wordpress. It would be very tedious to write these specific widgets as custom functions to be inserted in bbpress.


title: How to add href="" custom post type?

text:
I am trying to modify the CPT Bootstrap Carousel plugin, so that I can add a link button to the carousel items. The plugin creates a custom post type called cptbc_post_type, this post type is basically a gallery which you can display by adding a shortcode. What I want to do is to add a button with a href value that can be set from the backend. The post already supports the title and an excerpt to be set from the backend. I kind of understand where I need to add the code but I can´t figure it out. Any help would be appreciated. The code:               <?php          // Custom Post Type Setup     add_action( 'init', 'cptbc_post_type' );     function cptbc_post_type() {     $labels = array(         'name' => 'Carousel Images',         'singular_name' => 'Carousel Image',         'add_new' => 'Add New',         'add_new_item' => 'Add New Carousel Image',         'edit_item' => 'Edit Carousel Image',         'new_item' => 'New Carousel Image',         'view_item' => 'View Carousel Image',         'search_items' => 'Search Carousel Images',         'not_found' =>  'No Carousel Image',         'not_found_in_trash' => 'No Carousel Images found in Trash',          'parent_item_colon' => '',         'menu_name' => 'Carousel'     );     $args = array(         'labels' => $labels,         'public' => true,         'exclude_from_search' => true,         'publicly_queryable' => false,         'show_ui' => true,          'show_in_menu' => true,         'query_var' => true,         'rewrite' => true,         'capability_type' => 'page',         'has_archive' => true,          'hierarchical' => false,         'menu_position' => 21,         'supports' => array('title','excerpt','thumbnail', 'page-attributes')     );      register_post_type('cptbc', $args);     }               // Add theme support for featured images if not already present     // http://wordpress.stackexchange.com/questions/23839/using-add-theme-support-inside-a-plugin     function cptbc_addFeaturedImageSupport() {     $supportedTypes = get_theme_support( 'post-thumbnails' );     if( $supportedTypes === false )         add_theme_support( 'post-thumbnails', array( 'cptbc' ) );                    elseif( is_array( $supportedTypes ) ) {         $supportedTypes[0][] = 'cptbc';             add_theme_support( 'post-thumbnails', $supportedTypes[0] );     }     }     add_action( 'after_setup_theme', 'cptbc_addFeaturedImageSupport');          // FRONT END          // Shortcode     function cptbc_shortcode($atts, $content = null) {         // Set default shortcode attributes         $defaults = array(         'interval' => '5000',         'showcaption' => 'true',         'showcontrols' => 'true'     );          // Parse incomming $atts into an array and merge it with $defaults     $atts = shortcode_atts($defaults, $atts);          return cptbc_frontend($atts);     }     add_shortcode('image-carousel', 'cptbc_shortcode');          // Display latest WftC     function cptbc_frontend($atts){     $id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page     $args = array( 'post_type' => 'cptbc', 'orderby' => 'menu_order', 'order' => 'ASC');     $loop = new WP_Query( $args );     $images = array();     while ( $loop->have_posts() ) {         $loop->the_post();         if ( '' != get_the_post_thumbnail() ) {             $title = get_the_title();             $content = get_the_excerpt();             $image = get_the_post_thumbnail( get_the_ID(), 'full' );             $images[] = array('title' => $title, 'content' => $content, 'image' => $image);         }     }     if(count($images) > 0){         ob_start();         ?>         <div id="cptbc_<?php echo $id; ?>" class="carousel slide">
             <?php foreach ($images as $key => $image) { ?>                 <li data-target="#cptbc_<?php echo $id; ?>" data-slide-to="<?php echo $key; ?>" data-interval="<?php echo $atts['interval']; ?>" <?php echo $key == 0 ? 'class="active"' : ''; ?>>
             <?php } ?>

             <?php foreach ($images as $key => $image) { ?>                 <div class="item <?php echo $key == 0 ? 'active' : ''; ?>">                     <?php echo $image['image']; ?>                     <?php if($atts['showcaption'] === 'true') { ?>

<?php echo $image['title']; ?>

<?php echo $image['content']; ?>

                     <?php } ?>
             <?php } ?>
             <?php if($atts['showcontrols'] === 'true') { ?>                 <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹                 <a class="right carousel-control" href="#cptbc_<?phpecho $id; ?>" data-slide="next">›             <?php } ?>
     <?php }     $output = ob_get_contents();     ob_end_clean();          // Restore original Post Data     wp_reset_postdata();              return $output;     }          // Call the carousel in javascript, else it won't start scrolling on its own     function cptbc_footer_js() {     ?>          <?php     }     add_action('wp_footer', 'cptbc_footer_js');          ?>


title: Query Number of Loaded Posts in Loop

text: I'm loading posts via a query of a custom taxonomy called 'band':               $args = array(     'tax_query' => array(         array(             'taxonomy' => 'band',             'field' => 'slug',             'terms' => array('learn', 'trade', 'invest', 'spend')             )         ),     'post_type' => 'post',     'showposts' => 50 );      Because some bands feature less content than others, by the end of the loop I'm left with lots of one kind and only a couple of another so in order to balance the content I want to get to the end of my loop and ask something like:               if( number of posts in band 'learn' <= 6 ) {         #load more learn posts     }      With this method I hope to get my most recent 50 posts but then ensure that I have a minimum of six in each band. I'm using Isotope to filter the Masonry layup so if the user hits the 'Learn' filter button I want to guarantee that the filtered results will find a minimum number of posts in any 'band'.


title: Testing Multisites with vagrant or Can I use multisite with only an IP address (without domain name)

text: I'm testing multisite on a vm spun up by using Vagrant. I seem to be having trouble accessing multisite URLs. I've added them as such... ![enter image description here](http://i.stack.imgur.com/hUmIi.png) But when I attempt to visit them in the browser, I unfortunately see a 404 as such... ![enter image description here](http://i.stack.imgur.com/MxIhL.png) As directed, the contents of the .htaccess file are:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]      And I've added the following block of code to `wp-config.php`:               /**      * For developers: WordPress debugging mode.      *      * Change this to true to enable the display of notices during development.      * It is strongly recommended that plugin and theme developers use WP_DEBUG      * in their development environments.      */     define('WP_DEBUG', true);     define('WP_ALLOW_MULTISITE', true);          define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', '192.168.33.10');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);          /* That's all, stop editing! Happy blogging. */      If curious, the only options in my Vagrant file being used are:               [vagrant@vagrant-centos64 vagrant]$ cat Vagrantfile  | grep -v \#          Vagrant.configure("2") do |config|          config.vm.box = "centos64-x86_64-20131030"     vm.network :private_network, ip: "192.168.33.10"      Did I over look something? Is multisite possible with using a IP address and subdomains?


title: Using wp-cli to Update WP Networks / Multisite from 3.5.1 to 3.8

text: I've been handed a WP Networks site that is running WP (Networks) 3.5.1 on RHEL 5.8 with about 40 sites attached to it. I see the need to update to 3.8. By background, I'm more familiar with maintaining Drupal sites with `Drush`. My first hunch here is to use `wp-cli` to run the update. Is this the preferred update method in the WP community or am I better swapping out php files from the tar ball? That is, can I depend on `wp-cli` to run a clean update from 3.5.1 to 3.8? Many thanks!


title: Why are simple updates to wp_postmeta's "_edit_lock" so slow?

text: In our MySQL slow query log, the cumulatively slowest query is a simple update to wp_postmeta. Here's an example:               UPDATE `wp_postmeta`       SET `meta_value` = '1392835505:386'       WHERE `post_id` = 94705 AND `meta_key` = '_edit_lock';      Relevant details on our setup:   * MySQL slow query time set to 1s   * wp_postmeta's storage engine is InnoDB   * Running within a large Multisite installation with tens of thousands of posts on the main WP blog (where these slow queries are occurring)   * High activity in the WP admin area (lots of writers/editors working concurrently, but generally on their own (not others') content)   * Low activity on the public side of WP (not actually serving up content from the main blog)   * The slow queries seem to all be using the "_edit_lock" key; queries of the same format (that use a key other than "_edit_lock") do not seem to be slow. Why is it that this is the slowest query on our system? Does it have something to do with WP's specific use of "edit locks"? Thanks! :) * * * Update: Output from mysqlsla below:               ______________________________________________________________________ 001 ___     Count         : 606  (16.83%)     Time          : 2257.760468 s total, 3.725677 s avg, 1.00512 s to 84.645869 s max  (20.60%)       95% of Time : 1355.289277 s total, 2.357025 s avg, 1.00512 s to 12.343604 s max     Lock Time (s) : 182.502 ms total, 301 μs avg, 29 μs to 157.542 ms max  (0.21%)       95% of Lock : 22.882 ms total, 40 μs avg, 29 μs to 57 μs max     Rows sent     : 0 avg, 0 to 0 max  (0.00%)     Rows examined : 1 avg, 1 to 2 max  (0.00%)     Database      : xxx_wp     Users         :             xxx_wp@localhost  : 98.84% (599) of query, 51.03% (1837) of all users             yyy_wp@localhost  : 1.16% (7) of query, 0.94% (34) of all users          Query abstract:     SET timestamp=N; UPDATE wp_postmeta SET meta_value = 'S' WHERE post_id = N AND meta_key = 'S';          Query sample:     SET timestamp=1392835506;     UPDATE `wp_postmeta` SET `meta_value` = '1392835505:386' WHERE `post_id` = 94705 AND `meta_key` = '_edit_lock';


title: How can I load certain JavaScripts only on blog pages?

text: Here's the situation I'm having. I am developing a site and on the single post pages of the site I am using various social sharing buttons (i.e. Google+, Facebook, LinkedIn, Twitter, etc). I am following the official developer documentation for each of these buttons and most of them require inserting JavaScript before the closing tag. This is all fine and dandy and I've got it working perfectly. However, my only issue is that since these social icons are ONLY on the single post blog pages I don't want that JavaScript being loaded on other pages as it will only add unnecessary resources to be loaded and I'd like to keep my page speed as fast as possible. For the life of me I can't figure out how to go about doing this. I thought at first about writing some conditional PHP code that detected if you were on a single post page and if so it loaded the scripts in the footer. However, I realized that I don't think there's a realistic way to do that since each single post URL doesn't have a consistent part of the URL in it (i.e. /blog/). I could add the JavaScripts to the single.php template for single post pages but that wouldn't work either since it's calling the footer in those pages via and I would like these scripts to be loaded in the footer, not the template itself. Anyways, any input would be appreciated. I'm sure there is a way to do it, I'm just racking my brain and can't figure it out.


title: Removing Title Tag from Thumbnails

text: I'm currently adding thumbnails to my page with: `<?php the_post_thumbnail( 'category-thumb' ); ?>` and this in the fuctions.php:               if ( function_exists( 'add_image_size' ) ) {         add_image_size( 'category-thumb', 200, 142 );     }      How do i stop the title tag from being added?


title: Admin comments and user restrictions

text: I have set a bunch of roles within wordpress with the help of the "members" plugin. But the capabilities regarding the comments moderation are very limited ("manage_others_comments" or not) What I need to do is: "If my user is level1, only show the comments of category A,B,C, but if my user is level2, only show comments from category B,D,E" I would need that for the "Admin dashboard", for the "Admin post edit", and, if possible, for the "admin search form". I'm struggling with the code to find where I can find the scripts making the related db queries in order to filter them by categories but I just can't find them. PS: I only need this feature for the Admin panel, no the front-end. Any idea?


title: Display the popular tags by default in the backend post edit page (without having to click on the link that displays them)

text: I know there should be a way to call the AJAX function by page load but I've been looking at how to do this for hours and can't figure it out. Any help is appreciated.


title: Wordpress capability_type arguments

text: I don't know how to figured out what's wrong with my code, Why Custom Post Types "Book" doesn't show on my dashboard, I logged as Admin and I use latest WordPress installed 3.4.1 Here with my code               function codex_custom_init() {            $labels = array(         'name' => _x('Books', 'post type general name'),         'singular_name' => _x('Book', 'post type singular name'),         'add_new' => _x('Add New', 'book'),         'add_new_item' => __('Add New Book'),         'edit_item' => __('Edit Book'),         'new_item' => __('New Book'),         'all_items' => __('All Books'),         'view_item' => __('View Book'),         'search_items' => __('Search Books'),         'not_found' =>  __('No books found'),         'not_found_in_trash' => __('No books found in Trash'),          'parent_item_colon' => '',         'menu_name' => __('Books')            );              $capabilities = array(         'publish_posts' => 'publish_books',         'edit_posts' => 'edit_books',         'edit_others_posts' => 'edit_others_books',         'delete_posts' => 'delete_books',         'delete_others_posts' => 'delete_others_books',         'read_private_posts' => 'read_private_books',         'edit_post' => 'edit_book',         'delete_post' => 'delete_book',         'read_post' => 'read_book'         );                 $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,          'show_in_menu' => true,          'query_var' => true,         'rewrite' => true,         'capability_type' => 'book',         'capabilities' => $capabilities,         'has_archive' => true,          'hierarchical' => false,         'menu_position' => null,         'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )       );             register_post_type('book',$args);          }          add_action( 'init', 'codex_custom_init' );      My code is to add new custom post with custom capabilities for usage of members plugin.


title: Child theme functions.php do I use php open and close tags?

text: I setup a child theme which works fine. It's importing the main style.css and has custom css styles along with custom header.php and footer.php files When using functions.php in a child theme it's going to append the child themes functions.php to the main theme. Do I need to wrap my functions in opening and closing php tags or can I just add the following without php tags `add_image_size( 'related-thumbnail', 130, 130, true );`


title: Incrementally add or substract from usermeta field

text: I'm trying to create a system to add credits to a user account and then later subtract from the credits when the user submits a post. I have the functions I need to trigger the adding credits and the removing of credits, I just need help with the actual code to get that part done. This is what I want to do: ## Adding credit   1. Set a variable called "`add_credit_amount`" with amount of credit to be added.   2. Get the current user's `ID`   3. Get current `users meta field value` stored in the "`my_user_credit`" field   4. Add the "`add_credit_amount`" variable to the "`my_user_credit`" amount   5. Update the users "my_user_credit" field with the new amount. ## Removing credit   1. Create a variable called "`remove_credit_amount`" and set the amount of credit to be removed.   2. Get the current user's `ID`   3. Get current `users meta field value` stored in the "`my_user_credit`" field   4. Check to see if the value in the "`my_user_credit`" field is greater than or equal to the "`remove_credit_amount`".   5. If it is then subtract the "`remove_credit_amount`" variable from the "`my_user_credit`" field amount and update the users "`my_user_credit`" field with the new amount.   6. If it is not then `echo` this message: "You do not have enough credits to post." * * * Thanks in advance to anyone who can help. UPDATE @JoshuaAbenazer I'm trying to get this to work. I don't want to show the form if they don't have enough credits. Can you see why it does not work right? It does not seem to return the value for the meta field. Thanks               <?php      global $user_ID;     $user_ID = wp_get_current_user();     $creditcount = get_user_meta( $user_ID, 'my_user_credit', true );     if($creditcount <= 4){     echo 'please get more credits';     } else {     echo do_shortcode('[gravityform id=2 title=false description=false]');     }          ?>      Thanks


title: Hiding an added admin page menu using css

text: I have added an admin page in wordpress but i needed it to be hidden.I added the page successfully like this               function add_admin_page()     {     $themename = 'Cesaro';     $page_function = 'admin_page';     add_menu_page($themename." Options", $themename, 'edit_themes', $page_function, 'admin_page');     }     add_action('admin_menu', 'add_admin_page');      To hide it,i looked at its css using firebug and discovered a pattern or so it seems.Pages added in the format i demonstrated have a css id that starts with #toplevel_page_{page_added} so the css id to the page i added is #toplevel_page_admin_page. I went ahead and did               #toplevel_page_admin_page{     display:none !important;     }      Is this format #toplevel_page_{page added} consistent with all wordpress installations?.


title: Posts published last 10 minutes

text:
i have a "featured" section on home page. i want to hide this section after 10 minutes of post publish time. here is the code, i am using. problem is that it hide the "featured" section after 12 hours of post publish time ------- index.php -------                <?php $args = array(         'posts_per_page' => 1, // We are showing only one post         'category_name' => 'featured_post' // showing form category prime                             );          add_filter( 'posts_where', 'filter_where' );     $the_query = new WP_Query( $args );     remove_filter( 'posts_where', 'filter_where' ); ?>          <?php     if ($the_query->have_posts()) :?>      <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>     <?php endwhile; ?>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php endif; ?>      ------- Function.php -------                function filter_where( $where = '' ) {      // posts published last 30 minutes      $where .= " AND post_date > '" . date('Y-m-d H:i:s', strtotime('-10 minutes')) . "'";      return $where;      }      * * * please guide me.


title: Add Class to Specific Link in Custom Menu

text:
I know you can add a class in the custom menu options, but it adds it to the LI before the A. I want to apply the class directly to this specific A rather then the whole LI. So instead of the output being
Link
      I want it too be like this.
Link
      Any ideas?


title: Conditional statement not working in function

text: Why doesnt this work ? I am trying to selectively load scripts but the second if statement is not loading them where it should.               function my_init() {         if (!is_admin()) {                  wp_deregister_script('jquery');             wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js', false, '1.5');             wp_enqueue_script('jquery');                      if (in_category('41') )  {                 wp_register_script('validator', '/wp-content/themes/myTheme/library/jquery.validationEngine.js', array('jquery'), '2.0', false);                 wp_enqueue_script('validator');                      wp_register_script('vEngine', '/wp-content/themes/myTheme/library/jquery.validationEngine-en.js', array('validator'), '2.0', false);                 wp_enqueue_script('vEngine');                 }              }                  }     add_action('init', 'my_init');      If I remove the second if statement for that category it works but I want to restrict it to a single category or even an is_single('123') What am I doing wrong?


title: Multiple plugins using the same OAuth class issues

text: I just updated a plugin that needed to be updated. The issue is they added support for OAuth, the problem this plugin and another are using the same OAuth classes. Is there a easy way to fix this? I've never messed with OAuth or classes in PHP, I'm not a programmer. Error:               PHP Fatal error:  Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1


title: WP Insert Post function - Insert Post Thumbnail

text: Whilst performing wp_insert_post, how would one insert the post thumbnail. I tried the code below to no avail.               $postit = array(         'post_title' => $itemtitle,         'post_content' => '',         'post_status' => 'publish',         'post_type' => 'items',         'post_author' => $user_ID,         'tags_input' => $the_post_id,         'post_thumbnail' => $itemimage,          );      $the_post_idit = wp_insert_post( $postit);      Any ideas, Marvellous


title: Apply different Class for each element in a foreach()

text:
sorry for the silly question, but I am really lost. I want to apply the following CSS to the even elements of my foreach. **CSS**               .blogArticles a {         float: left;         max-width: 250px;         width: 25%;         color: #333;     }          .blogArticles a:nth-child(even) {         margin: 30px 0 -30px 0;     }      **PHP** **UPDATED (I used snap.svg to render the SVG)**
              <?php                  $page = (isset($_GET['paged'])) ? $_GET['paged'] : 1;                  $args = array(                         'paged'          => $paged,                         'orderby' => 'id',                         'order' => 'DESC',                         'cat' => 50,                         'posts_per_page'    => 20,                         'post_status'      => 'publish',                         'suppress_filters' => true                         );                                        $blogPosts = query_posts( $args );                  if ( have_posts() ) : while ( have_posts() ) : the_post();                  $categories = get_the_category();                  $count = 0;             if ($categories) {                 foreach($categories as $category) {                     $class = ($count%2 == 0) ? "even" : "";         ?>                          <a href="#" class="mix <?php echo $category->name; ?> <?php echo $class; ?>" target="_self" onclick="return false;" data-path-hover="m 0,0 0,100 c 24.580441,3.12569 55.897012,-8.199417 90,-8.199417 34.10299,0 65.41956,11.325107 90,8.199417 L 180,0 z">
                             <?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>                                           <?php the_post_thumbnail(); // Fullsize image for the single post ?>                             <?php endif; ?>                             <svg viewBox="0 0 180 320" preserveAspectRatio="none"><path d="m 0,0 0,171.14385 c 24.580441,15.47138 55.897012,24.75772 90,24.75772 34.10299,0 65.41956,-9.28634 90,-24.75772 L 180,0 0,0 z"/></svg>

<?php the_title(); ?>
                                 <p class="label <?php echo $category->name; ?>"><?php echo $category->name; ?>
                                 <button>View</button>

                                       <?php                      $count++;                 }              }              ?>              <?php endwhile; ?>

         <?php html5wp_pagination(); ?>
      **function.php**               function html5wp_pagination()     {         global $wp_query;         $big = 999999999;         echo paginate_links(array(             'base' => str_replace($big, '%#%', get_pagenum_link($big)),             'format' => '?paged=%#%',             'current' => max(1, get_query_var('paged')),             'total' => $wp_query->max_num_pages         ));     }      The problem is that in the foreach every printed `$class` is even! Any hint on where it is my mistake? Thank you in advance! * * * **_If you have problem, as me, displaying the suggested great pagination function, here is the code fixed for the pagination of @Pieter Goosen_**               <?php $count = 1; ?>         <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             $args = array('paged' => $paged,........);             $blogPosts = new WP_Query( $args );                  if ( $blogPosts->have_posts() ) : ....... while ( $blogPosts->have_posts() ) : $blogPosts->the_post();                 ........                 ........                 ........             }      ?>         <?php $count = $count+1; ?>         <?php endwhile; ?>              <?php wp_reset_postdata(); ?>

          <?php custom_pagination($blogPosts->max_num_pages); ?>