Creating a Dynamic Path to wp-blog-header.php

Created a class in an external script which is dependent on the Wordpress environment. Since it's a class I intend to use on various projects, I decided to dynamically create a path to wp-blog-header.php and here's what I came up with. It currently works for me, but I need to ensure that its foolproof.               $docRoot = $_SERVER['DOCUMENT_ROOT'];     $scriptName = $_SERVER['SCRIPT_NAME'];     $queryArray = explode("/", $scriptName);     $queryLength = count($queryArray);          require_once($docRoot . ($queryLength > 2 ? "/".$queryArray[$queryLength - 2] : "" ) . '/wp-blog-header.php');      Does anyone have a better solution or is this good enough to rely on, regardless of script location or WP installation setup?


Advice on setting up private site

I've developed a wordpress site which is only to be made available to around 30 people, whose email addresses I have in a spreadsheet. I want to allow these people to be able to register/login and then set their own password. What would be the best process for going about this? Thank you for any answers!


How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?

I have the following problem developing a WordPress theme and I am here to ask you if this solution could be a good solution or if exist some better way to do. I have a custom WP theme and into this theme there is a main menu. The website is multilanguage (italian and english) so I have to load the Italian main menu (contains the menu item in Italian language) if the visitor is italian and the main menu have to been loaded in the English version if the user is not italian. So I have found this solution: In the WP backend I create 2 different menus: **Menu 1** and **Menu 2** (the first one having voices in Italian language and the second one in English language) Then inside my theme (into the **header.php** file) I declare something like it:   1. First I detect the user language tacking it from **$_SERVER['HTTP_ACCEPT_LANGUAGE']**   2. Then, I use this value to show Menu 1 if the **$lang** value is **it* or * _Menu 2 if the *_ $lang** value is **en** Something like this:               <?php          $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);         //echo "Language is $lang";  IT SEEMS TO WORK: MY LANGUAGE IS CORRECTLY RECOGNIZED AS it              if($lang == it){      // If the user is Italian load Italian menu                  wp_nav_menu(array(             'menu' => 'Menu 1',              'theme_location' => 'primary',              'depth' => 2,             'container' => 'div',              /*'container_class' => 'navbar navbar-default',*/             'menu_class' => 'nav navbar-nav',              'fallback_cb' => 'wp_bootstrap_navwalker::fallback',              'walker' => new wp_bootstrap_navwalker())         );          }          else{            // If the user is not italian load English menu             wp_nav_menu(array(             'menu' => 'Menu 2',              'theme_location' => 'primary',              'depth' => 2,             'container' => 'div',              /*'container_class' => 'navbar navbar-default',*/             'menu_class' => 'nav navbar-nav',              'fallback_cb' => 'wp_bootstrap_navwalker::fallback',              'walker' => new wp_bootstrap_navwalker())         );          }     ?>      I think that in this way have to correctly work (I have to try) but, is it a good solution or could I do better in some other way?


Loss of sharpness in jpg imported as header in twentyeleven

When importing a jpg into the header position (jpg created in indesign at 1000 px wide) for the twentyeleven theme, the photos are not sharp. what is causing this and how do I fix it?


Importing 10 Years of Media into the WP Database

I've been running the same website for 10 years now, and whenever I would create a news story, I would manually upload and store all my news images in a "news" folder via FTP and then manually write the HTML to call up each of those images (yes, it was always a pain). Each month has a folder within that news folder named MMYY (0613, for example). Well, now I want to actually use Wordpress's upload and insert features instead of doing everything manually. And with help from this wonderful website, someone was able to help me set Wordpress to upload all future images into the folder structure I've had for the past 10 years (/news/0613 instead of Wordpress's default wp- content/uploads/2013/06). But now my problem is this: if I want to use all the other images and media stored in those 10 years of folders whenever I make a new news story, how do I pull them all into Wordpress? I could just insert the images manually by looking up their URLs, or insert them into Wordpress through the same way, but it would be nice to actually have them all stored in WP's database for easy look-up and inserting, all while using the existing files themselves in their stored locations (which, as I mentioned before, is now in the same folder structure that WP will be using to upload future images). I've looked everywhere and cannot find how to do this though or how to even approach something like this. I've looked through dozens of plugins as well. So I'm not sure if I'm using the correct terminology when I'm searching for my solution. Does anyone know what I can do or have tips for how I would even go about approaching this? Thank you! :)


Use wp_nav_menu to dynamically generate child menus

The goal: use wordpress's wp_nav_menu to generate a menu where child pages were dynamically added while keeping the correct submenu classes. **Before:**   1. Installations   2. Habits **After:**   1. Installations      * Roof     * Garden   2. Habits Basically, I have a wp_nav_menu set up to show some pages (i.e. "Installations" & "Habits"). Either of those pages could have several child pages associated with them and I wanted my navigation to dynamically add those child pages into the menu, without using wp_list_pages. In my case, the nav was pulling from a custom post type ("actions"), but this can be customized.


Infinite Scroll plug in on Ebuy theme

So Ebuy does not support infinite scroll, and my coding knowledge is minimal. I'm looking for some guidance as to how i can manually get in there and make infinite scroll work. Ive already got the plug in activated, but i am unsure as to what to put in the content selector, nav selector, next selector, item selector, and call back fields. http://soballer.com/product/accessories/ thats what it looks like now. it shows 10 items, then you have to click on "older entries". if anyone could help me set this up, id appreciate it! thanks


Use get_terms to get post_tags but limit to a taxonomy

So I'd like to get the top 5 post_tags by count. But I have an additional taxonomy that I use to further organize posts called Issue. So I want to be able to get the top 5 post tags used by posts in a certain taxonomy. I can currently get the top 5 posts tags by count system wide thats not a problem.               $taxonomies = array(          'post_tag'     );          $args = array(         'orderby'       => 'count',          'order'         => 'DESC',         'hide_empty'    => true,          'exclude'       => array(),          'exclude_tree'  => array(),          'include'       => array(),         'number'        => '5',          'fields'        => 'all',          'slug'          => '',          'parent'         => '',         'hierarchical'  => true,          'child_of'      => 0,          'get'           => '',          'name__like'    => '',         'pad_counts'    => false,          'offset'        => '',          'search'        => '',          'cache_domain'  => 'core'     );          $terms = get_terms ($taxonomies, $args);          $count = count($terms); $i=0;     if ($count > 0) {         $cape_list = '
';         foreach ($terms as $term) {             $i++;             $term_list .= 'slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '';             if ($count != $i) $term_list .= ' · '; else $term_list .= '
';         }         echo $term_list;     }      Thats the easy part. Any ideas on how to limit this to posts that are inside a specific taxonomy?


Unable To Login With Correct Credentials?

Me and my users can't login even using the correct credentials. We type in the correct username and password but then this error message comes up (it's been coming up for a while now, but I usually just ignore it press the backspace and I'm logged in): > Catchable fatal error: Object of class WP_User could not be converted to > string in /hermes/bosoraweb097/b2086/ipg.mysite.com1/wp-content/plugins/wp- > customer-reviews/wp-customer-reviews.php on line 241 Does anyone know why this is happening and how I can get back into my account?


Test if a Category contains certain Custom Post Types

I have several Custom Post Types and several Categories. Within my `pre_get_posts` hook (in `functions.php`), I'm changing the chronological order for very specific Custom Post Type archive pages.               function get_custom_posts( $query ) {         if ( ! is_admin() && $query->is_main_query() && empty($query->query_vars['suppress_filters']) ) {              if ( ($query->get('order') == '') && (in_array($query->get('post_type'), array( 'books', 'foo' ))) ) {                 $query->set('order','ASC');  // ascending order             }             if ( is_home() ) {                 return $query->set( 'post_type', array( 'post', 'books', 'foo', 'bar' ) );             } else if ( is_search() ) {                 return $query->set( 'post_type', array( 'post', 'page', 'books', 'foo', 'bar' ) );             } else if ( is_category() ) {                 return $query->set( 'post_type', array( 'post', 'books', 'foo', 'bar' ) );             }            }      }            add_action( 'pre_get_posts', 'get_custom_posts' );        * I am developing a child theme of Twenty Thirteen.   * For Category archives, it's properly using the parent template, `category.php`.   * For Custom Post Type archives, it's properly using custom templates in the child theme, `archive-books.php`, `archive-foo.php`, etc. **Questions/Issues:** 1) My code is working for the Custom Post Type archive pages... they load in ascending order like I want. However, I also need ascending chronological order on Category archive pages, but **_only if_** they contain one or more posts from my specified Custom Post Types. How can I do this? I'd only like to call out the Custom Post Types in my code... I prefer not to call out specific Categories as these may occasionally change, and these category archives may contain posts from multiple Post Types. 2) When I reverse the chronological order, as in my code above, the default pagination is labeled incorrectly. i.e., the oldest post is on the top of the first page and when I scroll to the bottom, the link is labeled `"Older posts"` but this link really takes you to the newer posts. When chronology is changed, I was expecting the pagination to automatically follow; did I miss something simple in my code?


Empty excerpt using wp_get_recent_posts

I have this simple shortcode to display the last posts with it's title and except:               add_shortcode('latest3', function(){         $recent_posts = wp_get_recent_posts(                 array(                     'numberposts'   => 3,                     'orderby'       => 'post_date',                     'order'         => 'DESC',                     'post_type'     => 'post',                     'post_status'   => 'publish'                 ), ARRAY_A);              $output = '
Latest posts
';         foreach ( $recent_posts as $recent ) {             $output .= '
'.$recent["post_title"].'
';             $output .= $recent["post_excerpt"];         }         return $output;     });      But for some reason the excerpt output is empty. `print_r($recents)` shows that there is indeed an array key called `post_excerpt` but is shown always empty.


List users except current user using wp_dropdown_user?

I am creating a plugin where I need to select other users except me(current user who is logged in).               $user_id = get_current_user_id();          wp_dropdown_users(array(         'name' => 'user',         'exclude' => '$user_id,1',         'show' => 'user_login'     ));      is not providing required result. How to overcome this issue?


Pagination on Custom Post Type: 404 Error

I've been getting a 404 error on a CPT archive page, and am not sure why. I can go to the page set for the custom post type archive, but the next page `/mycustomposttype/page/2` gets a 404 error. I don't think that there's anything wrong with my code and I've flushed my permalink rules and I think that the CPT is registered correctly. But my code is below. Any insights would be greatly appreciated since I can't see why the pages are not being found. I did some research here, and saw similar issues and tried to follow allow of the solutions presented. But no luck.

             <?php                   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             $args = array(               'post_type' => 'tn_cstm_sketchbook',               'orderby' => 'menu_order',               'order' =>  'ASC',               'posts_per_page' => 2,               'paged'=> $paged                );                    $loop = new WP_Query($args);               while($loop->have_posts()) : $loop->the_post(); ?>

                      <?php                     if(get_field('sketch')) {                     $sketch = get_field('sketch');                     $large_image = wp_get_attachment_image_src( $sketch, 'full' );                     $thumbnail = wp_get_attachment_image_src( $sketch, 'large' );                     $attachment = get_post( get_field('sketch') );                     $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);                   }                 ?>                          <a href="<?php echo $large_image[0]; ?>" data-id="<?php the_ID(); ?>"  class="reveal" >                        <img src="<?php echo $thumbnail[0]; ?>" alt="<?php echo $alt; ?>" />

                  <?php endwhile; ?>
                          <?php         // Bring $wp_query into the scope of the function         global $wp_query;              // Backup the original property value         $backup_page_total = $wp_query->max_num_pages;              // Copy the custom query property to the $wp_query object         $wp_query->max_num_pages = $loop->max_num_pages;         ?>
<?php next_posts_link('Next Entries'); ?>

<?php previous_posts_link('Previous Entries'); ?>
              <?php         // Finally restore the $wp_query property to it's original value         $wp_query->max_num_pages = $backup_page_total;         ?>

                 <?php              // Register Custom Post Taxonomy          public  function create_work_taxonomies() {                 register_taxonomy(                     'tn_cstm_sketchbook_plugin',                     'tn_cstm_sketchbook',                     array(                         'labels' => array(                             'name' => 'Sketchbook Categories',                             'add_new_item' => 'Add New Sketchbook Category',                             'new_item_name' => "New Sketchbook Category"                         ),                         'show_ui' => true,                         'show_in_nav_menus' => true,                         'show_admin_column' => true, //Show custom taxonomy in admin columns                         'show_tagcloud' => false,                         'hierarchical' => true,                         'args' => array( 'orderby' => 'term_order' ),                         'rewrite' => array('slug' => 'sketchbook-categories', 'with_front' => false )                     )                 );             }                   // Register Custom Post Type            public function create_sketchbook_work() {                 register_post_type( 'tn_cstm_sketchbook',                     array(                         'labels' => array(                             'name' => 'Sketchbook',                             'singular_name' => 'Sketchbook Page',                             'add_new' => 'Add New Sketchbook Page',                             'add_new_item' => 'Add New Sketchbook Page',                             'edit' => 'Edit Sketchbook Page',                             'edit_item' => 'Edit Sketchbook Page',                             'new_item' => 'New Sketchbook Page',                             'view' => 'View Sketchbook Page',                             'view_item' => 'View Sketchbook Pages',                             'search_items' => 'Search Sketchbook Pages',                             'not_found' => 'No Sketchbook Pages found',                             'not_found_in_trash' => 'No Sketchbook Pages Found in Trash',                             'parent' => 'Parent Sketchbook Page'                         ),                              'public' => true,                         'show_in_menu' => true,                         'menu_position' => 29,                         'taxonomies' => array( '' ),                         'menu_icon' => plugins_url( 'images/sketchbook-icon.png', __FILE__ ),                         'publicly_queryable' => true,                         'query_var' => true,                         'rewrite' => array( 'slug' => 'sketchbook', 'with_front' => false ),                           'has_archive' => true,                         'hierarchical' => false,                         'supports' => array( 'title', 'page-attributes' )                     )                 );             }          ?>


Change text of Description in Image Library

i would like to change or add text to the Media Library Overlay on the right side if you click on an image and can enter a description for the image. At the moment there stands "Description" or "Caption" (German Version installed). See Image here: ![enter image description here](http://i.stack.imgur.com/ugqMn.png)


Are nested subdomains possible with a subdomain multisite?

I currently have a multisite using sub domains setup, which works well so far:               example.com (main site)     site1.example.com      site2.example.com     site3.example.com      The question now is whether it's possible to add a new, separate site using the URL               en.site1.example.com      When I try to create the site in my network, I get the error               Missing or invalid site address      Is multisite designed to work with a setup like this?


Including the necessary functions for a custom ajax registration form

I know there are a few questions on registration forms but I think mine differs a bit as I haven't found an answer through searching. I'm making a simple subscribe widget that takes a user's email and adds it to the WordPress Users table as a subscriber. It begins with a simple form with just an email input and submit. The form's action is to a php file in my plugin folder, `ajax-signup.php`. I'm using ajax to post the form data to this file which then "registers" the email address and returns an ajax response. Older plugins just included the `registration.php` file which gave all the required functions to the ajax php file in order for it to perform the registration (check email validation, write to the database etc) as the file exists outside WP. What do I need to include, or what superior method is there that will allow me to do this? Maybe a function inside the WP environment rather than a standalone file? I'm not sure how to use ajax in this way though...


Prevent Brute Force Attack

I already used `Limit Login Attempts` wordpress plugin. Are there other ways to prevent brute force attacks? I'm worried because I saw a lot of locked out.


Display code if title of the custom post matches title of other post

I have two custom posts, one called "reviews" and another called "guides". I want to display a custom field from the post reviews if the title of the two matches. Something like this: (I am not good with codes, this was the way I found to explain how I think it should be)               <? php     if ('$post_title' 'guides' == '$post_title' 'reviews') {      echo ('custom_field' 'reviews');      else      return __(no details);     }     ?>


Assign a tag to custom post type using a query

I have a custom post type `courses` with a custom field `level`. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called `higher` to it. How would I go about this please? Many thanks Tim


How to adjust code to refresh a dropdown box with tags that are active on filtered category listing

I have multiple custom tags setup (ptags) and custom posttypes (products) and made it so i can filters posts by multiple tags in a category. Currently the code retrieves tags from posts relating to the active category (pcategory) I have dropdown boxes from general to specific e.g.: `<BRAND> <TYPE> <SIZE>` When a visitor selects an option, the info is posted to the current page (category page the user is on) and filters posts on that tag. Once that happens i want the tags removed from the dropdown box that are not active anymore on this category listing. If i select brand "A" and the page refreshes i don't want to show the sizes that do not apply to any of the posts. I hope you understand what i am trying to say. Maybe this can be solved by using AJAX or adjusting SQL query? My template code looks like this:               <form action="" method="get"><div>     <?php     $current_term1 = $wp_query->get_queried_object();        $args = array(     'categories'                => $current_term1->term_id,     'taxonomy'                  => "brand"     );     $outputbrand = get_category_tags_test($args);          $outputbrand = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $outputbrand);     echo $outputbrand;?>          <?php     $args = array(     'categories'                => $current_term1->term_id,     'taxonomy'                  => "type"     );     $outputtype = get_category_tags_test($args);          $outputtype = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $outputtype);     echo $outputtype;?>     <input type="submit" value="Filter" />     </div></form>      My functions.php code looks like this:               //begin test     function get_category_tags_test($args) {     global $wpdb;     $tags = $wpdb->get_results     ("         SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link, terms2.slug as tag_slug         FROM             wp_posts as p1             LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID             LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id             LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,                  wp_posts as p2             LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID             LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id             LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id         WHERE             t1.taxonomy = 'pcategory' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND             t2.taxonomy = (".$args['taxonomy'].") AND p2.post_status = 'publish'             AND p1.ID = p2.ID         ORDER by tag_name     ");     $output1 ="<select name=".$args['taxonomy'].">";     $output1 .='<option value="">'.$args['taxonomy'].'</option>';     foreach ($tags as $tag) {         $term_slug=$tag->tag_slug;         $term_name =$tag->tag_name;         $link = $term_slug;         $output1 .="<option value='".$link."'>".$term_name."(".$term->count.")</option>";     }     $output1 .="</select>";     return $output1;     } //test end      If there is any plugin that can do this you can also mention it because i could not find anything. :) Thanks


Static front page with excerpt

I'm currently developping a theme for WordPress, and I have run into a little issue. I have to display some text as well as a "latest articles" list on the front page. I have the front page set to **Static** in the settings, and the page which is used as a front page contains the text I want to display. All okay here, text displays correctly. The problem is, I only want to display an excerpt of this text on the front page, while still allowing visitors to click on the "Read more" button to read the full text. WordPress doesn't allow that, though : the page set to _front page_ doesn't behave like the others, and it is now only accessible by the front page itself. Is there a way to have 2 links pointing to the same page?   * The first one pointing to the front page (e.g. http://mydomain.com/), displaying only the excerpt inside the front page template   * The second one pointing to the classic page address (e.g. http://mydomain.com/?p=14), displaying the full page content like any other page Thanks for the answers!


How to Organize my Photo Albums?

I want to organize my photo galleries.   **Photos** > Personal > Professional For each sub page, I want to organize the photo albums with thumbnails. eg _Personal > [thumbnails image with dimensions 210x180]_ , also I want to describe it with the album title _[e.g. Paris]_ , and how many photos has this album _[e.g. 28 photos]_. When viewing this album, I want to display the photos for each album like this. I think that the solution is to use taxonomies, but I tried and didn't have the result that I want. Also, I installed the plugin Custom Post Type UI, but still did not understand how to do what I want. Any proposal or direction?


Append code into wp-config.php

We have multiple wordpress sites and need to update the wp-config for w3 total cache. We have to append `define('WP_CACHE', true);` into the wp-config.php file. Is it possible to do this via ssh. I don't want to have to go in and open each config file and add it myself. Your help will be much appreciated.


Wordpress Auto-Redirecting on 404

I believe that Wordpress will try to find a suitable URL if you enter a wrong one. So I have a page http://www.example.com/products/ and by mistake I enter http://www.example.com/prods/ Wordpress will probably automatically redirect. I think that it is similar to the Multiviews option in apache. Can the Wordpress features be turned off?


add_filter not adding the filter

i am adding a filter at the end of my themes functions.php               if( !function_exists( 'mars_widget_post_ids' ) ){         /**          * @param array $query          * @param string $widget_id          */         function mars_widget_post_ids( $query, $widget_id ) {             if( $widget_id == '2046' ){                 $query['post__in'] = array( 1,4,5,6 );             }             return $query;         }         add_filter( 'mars_main_widget_args' , 'mars_widget_post_ids', 100, 2);          /* checking the wp_filters */          }            global $wp_filter;       var_dump($wp_filter);      In this code above after add_filter, i dump the array $wp_filters to browser. there is no value with mars_main_widget_args . the add_filter function returns "1".


Display X images from a gallery in the sidebar

I've been hunting around for a day for this answer and thought I should turn to StackExchange in the hopes someone has an aswer. My goal is to display X images (for example, 4) in the sidebar of this one template, but I'd like it to be dynamic and either pull 4 random images, or the first or last 4 images in the gallery. I'm currently using this code below to manually pull 4 images, but can someone provide code to be a bit more clever about it?               <?php echo do_shortcode('[gallery include="317,309,325" columns="1" link="file"]'); ?>


Is the tagline area spam-bot proof?

Is the tagline area spam-bot proof? I've added my email address into the tagline area. Could spam bots pick it up? You can see it here: http://richardclunan.com (And if I add my email address into posts and pages, is it spam-bot proof there?) Thanks,


How to allow a user to make their post (ad) a draft, and then publish again without needing approval?

I'm using WordPress as a directory site, where a user can submit a post, which becomes their ad/listing. The users are assigned a custom wordpress role. Posts need to need to be approved and published by the admin once, and then they can freely update their post as they see fit. It work's fine like this at the moment because I haven't given the custom role any publishing capabilities. However, I also need the ability for the user to take their post offline (draft perhaps) temporary whenever they want, and make it published again whenever they want. Currently, when they make their post a "draft", they need to submit it for a review to make it published again - this isn't ideal. Is there a way around this so they can change their post from `published` to `draft`, and then back again from `draft` to `published`, without needing it to be approved? Or maybe I give them publish capabilities to start off with, but there's a plugin that requires their first post to be approved? (they are only permitted 1 post anyway). What about a custom metabox with a checkbox that controls whether or not the post is published? Unfortunately I would have no idea where to begin with this kind if functionality. I am using WPALchemy for other metaboxes though.


wp_dropdown_categories initial value

I am currently pulling in an option drop-down of a specific category using:               <?php wp_dropdown_categories('child_of=20'); ?>      I would like the initial value of the drop-down to say 'Bedrooms' and not be the first category. Is this possible?


Reusing pictures in gallery from other posts

I have two pages where I want to use galleries with the same pictures (those pages are in different languages). Is there any way to create a gallery with already uploaded images in the other post. By default it's not possible. maybe there is a plugin for this purpose? Thanks!


Check if specific username is logged in

How can you check if specific username is logged in?


Custom Wordpress category page showing all posts rather than the specified category

I am trying to build a custom view of categories, I want to have all 'post's show their thumbnail within a jQuery carosel (4 in each slide) , I have got it to a stage where it visually looks how I want it to look, but it's showing ALL posts rather then the category your on, I have a big feeling this is due to my custom loop oposed the the standard one (I am using twentyten as my base) any ideas what I am doing wrong? Also on a side note, cat.php (at the bottom) is made by manually adding a post call, with a post offset for each new item added, is there a better way of doing this so I don't need to manually add a case for each post I want to display? category.php...

              <?php                         $category_description = category_description();                         if ( ! empty( $category_description ) )                             echo '
' . $category_description . '
';                          /* Run the loop for the category page to output the posts.                      * If you want to overload this in a child theme then include a file                      * called loop-category.php and that will be used instead.                      */                     get_template_part( 'cat' );                     ?>

      cat.php (my custom loop)
     <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>          <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1, 'offset'=> 1 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1, 'offset'=> 2 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>

               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1, 'offset'=> 3 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1, 'offset'=> 4 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>     <?php     global $post;     $args = array( 'numberposts' => 1, 'offset'=> 5 );     $myposts = get_posts( $args );     foreach( $myposts as $post ) :  setup_postdata($post); ?>                     <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                           <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail('large');?>                                        <?php endforeach; ?>     <?php endwhile; // end of the loop. ?>


Reversing the order of items in a category rss feed?

Is there an easy way to reverse the default item order of a category rss feed?               Default: Last posted item first     Wanted: First posted item first      No plugins please, plain wp api function calls (such as add_action or add_filter) will do!


WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)

I'm trying to write a new "related posts" widget (for the single post view) for my custom post type, filtering by custom taxonomy terms that the related posts should have in common with the current post. I found this solution. But what I'd like to add is that the posts are ordered by relevance. I determine the relevancy by the number of taxonomy terms that they have in common: The more taxonomy terms in common, the more relevant. Example: Current post has tags (1), (2), (3) and (4). A related post with tags (1), (3) and (4) is more relevant than a related post with only the tags (1) and (2). Also, if possible, I'd like to add special severity/emphasis to one of the custom taxonomy terms (which I assume to be the "main" term of a post). Example: Current post has tags (1), (2), (3) and (4). (1) is the main term of the post. Posts should only be displayed as related posts, if they have at least this main term in common. A related post with tags (1) and (3) is more relevant than a related post with the tag (1) only. (Optional: A post with the tags (2), (3) and (4) is not considered a related post, or: this post has a lower relevance than any post that has the main term (1) in common.) Can you please help me with this? Thanks in advance! :) Regards, René


Not duplicating $post->ID leaves empty space.

My home page has a section at the top that displays a featured post from a time period if it has been set, otherwise it displays the most commented post of a time period, or it just displays the most recent post if none of the above are true. I then have two more loops on the page which display the 6 most recents posts (3 each). I am using the following code to avoid duplicate posts being displayed.               <?php               $do_not_duplicate = $post->ID;               if( $post->ID == $do_not_duplicate ) continue;          ?>      This does the job of avoiding duplicate posts by skipping over the post that matches the ID, however it leaves a blank space that makes the homepage look odd. Is there a way to display the next most recent post that isn't that ID, rather than skipping over it entirely?

                              <?php                               // Fetch from the 'featured' category                              $args = array(                                             'posts_per_page' => 1,                                                 'category_name'  => 'featured',                             'date_query'     => array( 'after' => '1 day ago' )                         );                              $the_query = new WP_Query( $args );                              // If no featured post is found fetch the most commented                              if ( 0 === $the_query->found_posts ) {                                $args = array(                                                 'posts_per_page' => 1,                                                     'orderby'        => 'comment_count',                                 'date_query'     => array( 'after' => '1 day ago' )                             );                              $the_query = new WP_Query( $args );                              }                              // If no most commented posts are available fetch the most recent                              if ( 0 === $the_query->found_posts ) {                              $args = array(                                                 'posts_per_page' => 1,                                                     'orderby'        => 'most_recent'                             );                              $the_query = new WP_Query( $args );                              }                                   ?>                              <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                              <?php $do_not_duplicate = $post->ID; ?>                                  <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?><a href="<?php the_permalink();?>"> <?php comments_number(); ?>
                                  <?php the_excerpt(); ?>
                              <?php                               endwhile;                               wp_reset_postdata();                              else:                               _e('No posts found');                              endif; ?>
                              <?php                               $args = array(                         'posts_per_page' => 3,                         'orderby' => 'most_recent'                         );                              $the_query = new WP_Query( $args );                              ?>
                              <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                              <?php if( $post->ID == $do_not_duplicate ) continue; ?>                                  <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?>
<a href="<?php the_permalink();?>"> <?php comments_number(); ?>
                             <?php the_excerpt(); ?>
                              <?php endwhile; else: ?>                              <?php endif; ?>                                        <?php wp_reset_postdata(); ?>
                              <?php                               $exclude = $most_recent;                                   $args = array(                         'posts_per_page' => 3,                         'orderby' => 'most_recent',                         'offset'  => 3                         );                              $the_query = new WP_Query( $args );                              ?>
                              <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                              <?php if( $post->ID == $do_not_duplicate ) continue; ?>                                  <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?>
<a href="<?php the_permalink();?>"> <?php comments_number(); ?>
                             <?php the_excerpt(); ?>
                              <?php endwhile; else: ?>                              <?php endif; ?>                              <?php wp_reset_postdata(); ?>


Two custom taxonomies in permalink structure

I'm struggling setting up custom permalink structure with custom taxonomies. I've read many questions/answers here but I can't get it to work (most frustrating is that I don't know of a way to debug and find the problem myself). Any help is greatly appreciated! **What you need to know**   * I have a custom post type called `items`   * `items` has two custom taxonomies:      * `types` and `locations`.    * Every item is associated with **one** `type` and **multiple (1+)** `locations` I'm trying to get this link structure for every `item`: `http://domain.com/type/location` whereas I only want the first location term to be used in this link structure. I haven't tried implementing the `/location` part of the link structure (I guess that's a little bit more complex), as I'm already struggling with the `/type/` part. So my code currently looks like this and this doesn't yield any changes in my permalinks: **in a plugin**               register_post_type( 'item',             array(                 'labels'        => $labels,                 'supports'      => array( 'title', 'editor', 'thumbnail', 'comments'),                 'public'        => true,                 'has_archive'   => true,                 'rewrite'       => true,                 'menu_icon'    => plugins_url( '/img/icon.png'),                 'menu_position' => 42,                 'categories'    => array( ),             )         );               register_taxonomy( 'types', 'item', array(             'labels'       => $item_types_labels,             'hierarchical' => true,             'query_var'    => 'type',             'rewrite'      => true,             'public'       => true,             'show_ui'      => true,         ) );      **in functions.php**               add_filter('post_link', 'types_permalink', 10, 3);     add_filter('post_type_link', 'types_permalink', 10, 3);          function types_permalink($permalink, $post_id, $leavename) {         if (strpos($permalink, '%types%') === FALSE) return $permalink;                  // Get post             $post = get_post($post_id);             if (!$post) return $permalink;                  // Get taxonomy terms             $terms = wp_get_object_terms($post->ID, 'types');                if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;             else $taxonomy_slug = 'no-type';              return str_replace('%types%', $taxonomy_slug, $permalink);     }         I set my permalink structure to the custom structure `/%types%/%postname%/`. My URL still looks like this `domain.com/item/postname`. Also: Whatever I put in place for `/item/` (e.g. `domain.com/this-doesn-make- sense-to-me/postname`), I get redirect to `domain.com/item/postname`.


Why are 404s not triggering my 404.php template?

404s are not triggering my 404.php template. The header status code, checked in firebug, is a 404, but the page that gets displayed is like a loop with 0 items (as if this were simply an archive page with 0 entries). If my permalinks start with /%year%/ and I go to bla.com/9999 (which should produce a 404), WP Debug shows the request as a year:               Request: 9999     Query String: year=9999     Matched Rewrite Rule: ([0-9]{4})/?$     Matched Rewrite Query: year=9999      If my permalinks start with /%category%/ and I go to bla.com/zzzzz (which should produce a 404), WP Debug shows the request as a category_name:               Request: zzzzz     Query String: category_name=zzzzz     Matched Rewrite Rule: (.+?)/?$     Matched Rewrite Query: category_name=zzzzz      What's going on? The Show Template plugin (which prints an html comment telling you what template was used to render the page) tells me that the page is rendering with the index.php template. How can I get my 404.php template to load?


jquery-issue: cannot load the basic jquery

I am pretty new to wp. I have installed wp 3.9 on a demo site. I wanted to configure and add some plugins; eg the   * facebook   * wp-rss-multi-importer I've noticed that I cannot do some configurations with the widgets Reference: Wordpress Widgets > They can be added, removed, and rearranged on the WordPress Administration > Appearance > Widgets panel.the order and placement is set by the WordPress > Theme in the functions.php file. Some WordPress Widgets offer customization > and options such as forms to fill out, includes or excludes of data and > information, optional images, and other customization features. on the page where I can configure the widgets I cannot get anything done. I cannot add widgets and I do not know why. btw: some friends mentioned that I have issues with jquery. Any suggestions to what might be wrong update: have deactivated all plugins and switched back the theme to twentyfourteen. but nothing happppened - all those steps did not help. see the firebug - output that i have... while viewing the admin-area:               <!DOCTYPE html>


How to modify default controls in Wordpress theme customizer

I'm trying modify the default control in the wordpress theme customizer specifically the action for the close button. By default clicking it will make you go back to the themes page, but I want it to go to another page. Here's what I tried so far:   1. add inline script to wp_head   2. add script to customize_register hook   3. enqueued script via admin_enqueue_scripts hook Here's the script that I'm trying to add:               jQuery(function(){       jQuery('#customize-header-actions a').attr('href', 'index.php');     });      So basically I'm trying to redirect the user to the admin dashboard upon clicking the close button in the theme customizer. But no luck so far, for the first and second method that I mentioned above it doesn't recognize jquery. So I tried plain javascript:               window.onload = function() {       var customizer_header = document.getElementById('customize-header-actions');       customizer_header.children[2].setAttribute('href', 'index.php');     }      But still it doesn't work. The customization bar seems to be existing somewhere else like inside an iframe but when I checked in chrome dev tools only the preview of the wordpress index page is in an iframe. As for the third method its basically the same problem. Its returning null for the selector as if the element didn't exist. Any ideas?


How do I force "users must be registered and logged in" on subsites?

So now I have finally found plugins for social network login that works on my web hotel. (The Nextend plugins.) :-) I have set "users must be registered and logged in to comment" on the main site (this is a multisite). Works nicely on the main site. Unfortunately this is not carried over to the subsites. How do I force this on the subsites too? (Without having to do it manually.) One more little problem (which I think is easier to solve): I want only the social plugin login on the login pages. Is there a really easy way to do that? UPDATE: Solved. Can be done by adding a filter for the "comment_registration" option. See https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_(option_name) Sorry for the noise.


Custom Permalinks for Custom Post Types

I have custom post types registered and they are working fine with their normal URLs. My Custom post types have 'members' as their slug. Now I am trying to have a custom permalink for my custom post types. Here is my $wp_write->add_rule               $wp_rewrite->add_rule('members/.+?/(.+)/$','index.php?post_type=pasha_members&name=$matches[1]', 'top');      Below is my $wp_rewrite->rules array.               array(         ['members/.+?/(.+)/$'] => 'index.php?post_type=pasha_members&name=$matches[1]'         ['category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$'] => 'index.php?category_name=$matches[1]&feed=$matches[2]'         ['category/(.+?)/(feed|rdf|rss|rss2|atom)/?$'] => 'index.php?category_name=$matches[1]&feed=$matches[2]'        ...     );      And here is the url that I am trying to access, I am not able to figure out what I am doing wrong.               http://wp.dev/members/city1-city2/best-compnay/      When I change Permalink settings to default in Settings->Permalink, I can access the custom post just fine using the following url.               http://wp.dev/?post_type=pasha_members&name=best-compnay      Let me know if you need more information. Any help pointers are much appreciated. NOTE: I have put the add_rule in init instead of activate just for the testing. I also have put the flush_rewrite_rules in the init, its also temporarily until its fixed.


Multisite Subdomain with same Wordpress Installation

I have Multisite enabled on my WP site (mandeltech.com). I made a few subdomains, and I want them to act (sort of) like pages. However, I don't want to redirect them to pages (otherwise I would accomplish that with cPanel). For example, I want them to share the same database as my main installation, so they have the same users and everything. I also want the same theme (I did that already) and menu (for some pages). I specifically want subdomains because they have connected, by largely different purposes. Essentially, I want a page like `mandeltech.com/shop/` to instead be `shop.mandeltech.com` (but I don't want to just redirect `shop.mandeltech.com` to `mandeltech.com/shop/`. Is this possible? Thanks!


Are there established patterns for developing custom post types?

I'm working on a custom post type. It has meta boxes, and it also adds meta boxes to other post types. It comes with some convenience functions to find posts of its type or the meta data it adds to existing post types. It also has some helper functions to render markup into a template. All this adds up to quite a few 'loose ends' in my code. I don't have too much experience developing for WordPress (my background is in .NET and C#) so I'm wondering where I can look for patterns to make my solution... more cohesive. For example guidelines for naming files and functions and organizing the code in my theme, or a framework for creating custom post types. Although it's not hard to find plugins to create custom post types in WordPress, I prefer a 'code-first' approach, where I can commit everything to source control. Some plugins may have a suitable API, but this is usually not communicated on the WordPress website.


WP_Query only ONE post, won't work

No matter what, I CANNOT figure out why WP_Query pulls in all posts, and completely ignores `posts_per_page` ... I only want to show one post.               <?php          $args = array(     'post_type'      => 'post',     'orderby'        => 'date',     'order'          => 'ASC',     'posts_per_page' => -1     );          // The Query     $the_query = new WP_Query( $args );          // The Loop     while ( $the_query->have_posts() ) : $the_query->the_post();     ?>

image

             <?php the_excerpt(); ?>

<?php the_title(); ?>

          <?php        endwhile;          // Reset Post Data     wp_reset_postdata();     ?>


Wordpress list posts from sub categories

has anyone an ideea how can you do something like this: So if the user is in a category, let's say `Main`and this categories has some subcategories and I want to list them and also list the posts, something like this: `Sub category name 1` -POST 1 -POST 2 `Sub category name 2` -POST 1 -POST 2 `Sub category name 3` -POST 1 -POST 2


Gallery with thumbnail carousel

first post so hopefully I don't break any rules! :P I'm in the process of building a Wordpress theme for the Architecture office I work in. I am creating a page template to use for individual jobs and am a bit swamped by all the galleries, jQuery etc out there. Basically I want to do what this firm has done with their photos. Requirements:   * Clean, minimalist style. Although I'm proficient with CSS so can probably tidy up any solution that way.   * Horizontal thumbnails along bottom.   * Fixed main image 'container' size.   * Easyish method of adding photos to a gallery and gallery to site (I won't always be the one adding pics). There are a few other considerations but basically I'm just after some pointers to get me going in the right direction, I'm feeling a bit overwhelmed just now. I'll be able to discuss this further once I have some ideas from you guys of what's realistically the best route. I was trying to look into using nextgen to create galleries etc, then jQuery on the front end, but I'm pretty far out of my depth. Once I know the best solution I'm pretty good at teaching myself how to implement it, so hopefully that'll work in this case too!! Hope that wasn't too long winded, thanks in advance! :)


Search engine for WP as CMS

I am running WP as a CMS at the moment and I've been looking for a decent search engine plugin to index the site. The requirements are:   * Facet posts based on custom taxonomies (aka, be able to drill down based on taxonomies assigned to posts)   * Fast   * Does not display the actual post but rather an excerpt Nice to haves: - Display most recent comment date, author I have come across the Apache SOLR plugin and it does a decent job except for faceting by custom taxonomy. It facets by Categories, Tags, and Author but the Categories is so convoluted that I might as well rethink how I apply categories to the posts. Does anyone have any experience with this? Thanks!


Contact Form 7 - add custom function on email send

Just playing around with `Wordpress / Contact Form 7`.      Is it possible / do you know how to **add custom javascript function on successful email send event**?


Any plugin or Script to integrate ajax selection module into WordPress page

I am creating a WebHosting site using WordPress. It needs a custom feature selection module to add remove amountof disk space etc. In this particular website that I like 1), there is a custom "instance selection"-module that adds ram space etc. the site is WordPress powered. Is there any plugin or script to get the same functionality like that ? 1) It's not the OPs site.


Continuous listing from a custom field

I have posts with custom fields called "cb_vote_nb_vote" which holds the vote count for every post, what I want to do is let's say posts under A category will be listed based on vote count, I do that and show numbers with:               query_posts('cat=47&meta_key=cb_vote_nb_vote&orderby=meta_value&order=DESC');                  if(have_posts()) :             while(have_posts()) : the_post() ; echo "
"; echo $wp_query->current_post +1; echo "
";  ?>      but the problem here is when you go to the new page it starts from number 1 obviously. How can I achieve that so the listing continues from the previous page?


iTunes byte range request conflict -- PHP download server solution?

After submitting a podcast to iTunes, I got this error message: "Your episodes are hosted on a server which doesn't support byte-range requests. Enable byte- range requests and try your submission again." This post from the Wordpress support forums and the other pages I've found refer to http://mobiforge.com/developing/story/content-delivery-mobile-devices as a solution, but I'm unclear on how to implement the provided code. Would it be added to a core file, saved as a separate file, or something else? Any other potential solutions to this issue would be greatly appreciated. Thanks.


Prevent private post 404

I want private posts (for those _not_ logged in) to use the `single.php` template just as public posts do, at the moment they get thrown over to the `404.php` template. I've had a good look through the core files but I cannot find where the template change (note: this is not a redirect) happens. Can anyone help? **Edit** To explain why I want this, I want all visitors to see a preview of the content, but logged in "members" to see the entire post content.


How can I add items to the menu via the PHP file?

I run a membership site and I want to add a tab to the navigation menu that says, "My Subscriptions" and then add certain pages to that tab, which will be specific for each member depending whether or not they have access to the content. Right now I just have 20 different menus and 20 different if statements in the PHP file and it is not very efficient, not to mention the amount of menus I have to create tenfold if I want to add more content. Basically, I need some piece of code in the menu PHP file that says :               if member_is_logged_in('1') {         add content 1 to "My Subscriptions     } elseif member_is_logged_in('2') {         add content 2 to "My Subscriptions      Can anyone help me out with this? Thanks!


Make Search Function include subdomain (blog.ourwebsite.com)

Wondering if there's a way to edit our search.php or .htaccess or function.php (or anything else...) so that our search function on our main site (www.oursite.com) includes the subdomain of blog.ourwebsite.com? Any thoughts or suggestions are appreciated it..


URL problem: www.sitename.com/blog and www.sitename.com/learn using same WP installation

I'm sure there has to be some way to make this with single wordpress instalation. Posts for "learn" page are tagged with "learn" and I built a custom template that has loop that prints only posts from that category. Also, posts on that "learn" page should have links like they are on separate WP installaton (www.sitename.com/learn/date-postname..) and same for blog (www.sitename.com/blog/date-postname..)


Force users to display default Gravatars

Is it possible for a WordPress site to display the users default Gravatar image (of chosen set, eg Retro, Identicon, etc), rather than the users uploaded avatar? As in, all user avatars next to comments would be a generated 'Retro' picture, regardless of whether they had a custom avatar at Gravatar or not. **Screenshot of the settings in question:** ![WordPress Screenshot](http://i.stack.imgur.com/jYeyi.jpg) Since these default avatars are generated based on the email of the user, I was wondering if it is still possible to generate them, or have Gravatar return these default generated avatars rather than the users custom avatar.


Using dynamic conditions in 'posts_where' filter

I have the following code which gives be posts that are published in the last 100 days               function smbd_cats_by_days ($where = '') {              $where .= " AND post_date < '" . date('y-m-d', strtotime("-100 days")) . "'";         return $where;     }          add_filter('posts_where', 'smbd_cats_by_days');      It is working fine. But now I want to make this function generic. (ie) I want the number of days to be stored in a variable instead of hard coding it as 100. How to do that?


How to remove "Image Information" and "post date/author" from a media page?

I'm trying to use Wordpress to setup a simple website for my business, and I'm having issues with the gallery page. Once an image is clicked and brought to it's specific page, it includes author and post information and as well as image info that I would not like included. Here is the page in reference: http://hhprintingco.com/our-work/lara-brandt- wedding-invitations-photo/ Previous answers to this question mentioned going to Settings > Media > Caraousel and unchecking the latter. My Settings > Media does not include anything about "Caroaousel". Much help would be greatly appreciated. Thanks!


Get avatar of the logged-in user in Wordpress

How can I get a user avatar to display in the header of my WordPress site? I've tried:               <a href="<?php echo get_author_posts_url($post->post_author); ?>" title="<?php the_author_meta( 'display_name', $post->post_author ); ?>">     <?php if( get_the_author_meta( 'user_custom_avatar', $post->post_author ) != '' ) { ?>         <img src="<?php the_author_meta( 'user_custom_avatar', $post->post_author ); ?>" alt="" />         <?php echo $curauth->display_name; ?>     <?php } else { ?>         <?php echo get_avatar( get_the_author_meta( 'user_email', $post->post_author ), '80' ); ?>     <?php } ?>           but every time the logged-in user goes to a different authors post, the avatar changes to that authors avatar. I want it to be that when a user logs in, his/her avatar stays on the top of the page all the time. Can this be done?


How to disable commenting from Twenty Ten theme?

This is a terrible user experience when I'm trying to do the most simple thing and it never works. There are many pages with "instructions" how to do this and none of the "instructions" work. Now we hate Wordpress for making the most simple thing just not possible.               ## Solution ##      This only worked when doing it via the quick-edit which is disastrous since there no instruction that says so. We should get our money back for this crap.


Default or Preset Content for Custom Post Types

I am trying to modify the code for default content to display based on post type, but so far I have been unsuccesful. The base code is:               add_filter( 'default_content', 'my_editor_content' );     function my_editor_content( $content ) {         $content = "default content goes here....";         return $content;     }      My modifications include:               add_filter( 'default_content', 'my_editor_content' );          function my_editor_content( $content ) {         if ( 'sources' == get_post_type() ) {             $content = "Please insert an image of the document into this area.  If there is no image, please descript the document in detail.";             return $content;         } elseif ( 'stories' == get_post_type() ) {             $content = "Please write your reminiscences, recollections, memories, anecdotes, and remembrances in this area.";             return $content;         } elseif ( 'pictures' == get_post_type() ) {         $content = "Please insert an image of a photograph into this area.";         return $content;         } else {         $content = "default!";         return $content;     };}      But this just isn't working. I feel like I have missed the obvious.


Query Custom Post Types & category_name?

I'm using jQuery Supersized to create a full screen image slideshow. The images are called from a custom post type called Slides. The code works fine but I want to be able to only pull in Slides in a specific category and for some reason I can't get this to work. I've tried adding '&category_name=' to the first line to this but it's not working:               query_posts('post_type=slides&category_name=project1&order=ASC&posts_per_page=-1');      Any ideas? Thanks               query_posts('post_type=slides&order=ASC&posts_per_page=-1');     $output = "";     $n= 0;          //Loop for Post Types Slides     if ( have_posts() ) while ( have_posts() ) : the_post();     $n++;          //Slide Image     $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');          //Get the Slide meta info     $slide_link = get_post_meta(get_the_ID(), 'mb_slide_link', true);          $output.="{";     $output.="image : '". $thumbnail[0] ."'";          if($slide_link != ''){     $output.=" , url : '". $slide_link." '";     } ;          $output.="},";


Calling Different Custom Post Timestamps in a table

I use WordPress to run an events site that people can sign down to if they have a subscription. At the bottom of each event, if you are admin you can see a guest list with Name, Email, Tel, Avatar (through BuddyPress) and for our information your subscription details. Subscription details are stored as Custom Posts & what I want to do is simply list, in date form when they first started their subscription. The subscription expiry seems to be pretty easy as it's stored as a meta key but I cannot get the thing to display individual post publish dates for each of the custom posts called. This is what I have so far: It's probably a bit rough and ready but I've only taught myself PHP over the last month or so since the website launched so please bear with me.

         User (Full Name)	         Email Address	         Phone	         Subscription
Expiry/Renewal	         Subscriber
 Since	         Photo

       <?php foreach($tickets as $ticket) { ?>
           <?php echo $ticket['name']; ?>
(               <?php $useremail = $ticket['email'];                   $user = get_user_by( 'email', $useremail );                   $IDuser = $user->ID;                   echo bp_get_profile_field_data( array( 'field'=>'Full (Legal) Name - Not Displayed*','user_id'=>$IDuser));                   ?>)           	           <?php echo $ticket['email']; ?>	           <?php $useremail = $ticket['email'];               $user = get_user_by( 'email', $useremail );               $IDuser = $user->ID;               $telno = bp_get_profile_field_data( array( 'field'=>'Mobile phone number - Not Displayed*','user_id'=>$IDuser));               {?><a href="tel:<?php echo $telno;?>"><?php echo $telno; }?>           	           <?php $useremail = $ticket['email'];               $user = get_user_by( 'email', $useremail );               $IDuser = $user->ID;               echo getSubscriberType($IDuser);               $subscriptions = getUserSubscriptions($IDuser);?>
                <?php echo date('d/m/Y',strtotime($subscriptions[0]['expiry'])); ?>           	                                 <?php               $useremail = $ticket['email'];               $user = get_user_by( 'email', $useremail );               $IDuser = $user->ID;               $subscriptions = getUserSubscriptions($IDuser);               echo get_the_date('M j, Y', $subscriptions);               ?>           	                      <?php $useremail = $ticket['email'];               $user = get_user_by( 'email', $useremail );               $IDuser = $user->ID;               echo get_avatar( $IDuser, 60); ?>
      So the bit between the comments seems to show the same date for everyone not the individual Subscription post it's called.... The call above; `<?php echo date('d/m/Y',strtotime($subscriptions[0]['expiry'])); ?>` works fine but I'm calling a specific meta key. As far as I understand, wordpress does not have a specific key for calling this data...? If anyone could help that would be fantastic as there's lots of help out there for calling timestamps on the page you're on or for specific post ID's but nothing with this style of call. ========================== EDIT: Tried to implement the code show in _duplicate_ answer but makes no sense - I'm not looking to show all posts as a list as there is plenty of blogs to help with that. I want to query my subscription CPT with the **user ID** found by taking it from the metadata off the Ticket CPT. The only thing that links the two CPTs is the UserID... What I'm struggling with is how to query and match the two Custom Posts to finally give the first Publish date of the subscription. Sorry it's a bit long winded - any help would be hugely appreciated.


Display last posts with comments link on static page

I want to create a static page which will be almost the same as the default one with latest posts. I know I can use `query_posts( 'posts_per_page=5' )` to display my last five posts, but the comment link to them is not included. How can I add such a link?


Custom image size mixes width and height in output

I want to use a couple of custom image sizes for a site that I'm developing. When I output the images I sometimes do not get the correct width size because it is mixed up with the height size. It guess it has something to do with how I declare the image sizes in the functions file. functions.php               add_image_size( 'small', 145, 999 );     add_image_size( 'medium', 300, 999 );     add_image_size( 'large', 455, 999 );     add_image_size( 'tablet', 1024, 9999 );                       $image = wp_get_attachment_image_src(get_field('custom-field'), 'medium');     print_r($image);      gives me               Array     (         [0] => http://example.com/wp-content/uploads/2012/09/example-300x399.jpg         [1] => 225         [2] => 300         [3] => 1     )      Notice the width size is no. 2 in the array, when it usually is 1. Is the output order different if the image is taller then wider? The "errors" that I get are all from vertical images.


Limit post view and management to custom user meta information

I added custom user meta information called "schools" and I want the editors to only be able to manage posts made by other users who are from the same school. How do I do that?


query pages by a childs publish date

I am currently working on a wordpress project and would like to know if its possible to query pages by a childs publish date? I currently only want to show the parent page so my arguments look like this:               $args = array(           'post_type' => 'support_tickets',           'numberposts' => -1,           'orderby' => 'date',           'order' => 'DESC'            );      Is there anything i can do to adapt the above to order by the latest child publish date? I have already been down the route of using comments, but this is not going to work for what i want. Has anyone achieved this before? Any help would be greatly appreciated


Title Page reverting to homepage

Whenever I add or edit a new page, the page title automatically switches to the same title that's used on my static homepage page. If I change the title to what I want it to say, it reverts back to that home page title as soon as I click to another form field. I am using The latest version of Wordpress 3.8.3 Does anyone know what could be wrong?


How to change default header image dimensions in twentyfourteen child theme?

I'm creating a child theme based on twentyfourteen and wish to change the custom header image dimensions. The custom header page states: > Images should be at least 1260 pixels wide. Suggested width is 1260 pixels. > Suggested height is 240 pixels. This appears to come from defaults set in `/inc/custom-header.php`:               function twentyfourteen_custom_header_setup() {         add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(             'default-text-color'     => 'fff',             'width'                  => 1260,             'height'                 => 240,             'flex-height'            => true,             'wp-head-callback'       => 'twentyfourteen_header_style',             'admin-head-callback'    => 'twentyfourteen_admin_header_style',             'admin-preview-callback' => 'twentyfourteen_admin_header_image',         ) ) );     }     add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );      This file is included by `twentyfourteen/functions.php`:               require get_template_directory() . '/inc/custom-header.php';      Because this line uses `get_template_directory()` and not `get_stylesheet_directory()`, I can't override it with my own version of `custom-header.php`. Is there a way I can change the requested dimensions in my child theme?


How can I set up WordPress/PHP to upload images as myself?

I just noticed that my VPS has been uploading images as `www-data` for the past 6 months, ever since I moved my WordPress install over to my new system. I've been told time and time again that my WordPress files need to be owned by me and only by me. The server is only used by myself and no one else except for public access to the front end. Should I be concerned that the server is uploading images as apache, and if so, is there anything I can do about it? I was told to stay away from programs like `suEXEC` if I'm the only person on the machine, but it would still be nice to be able to read/write to my `/uploads` folder.


How to setup a Giant Multisite with the Childs at their own Sub-domains?

In Wordpress, what i have known so far is to setup a Parent as a Multisite, and put the Childs at the `Sub Directories` (Not at their own separated Sub- Domains). So please suggest whether it is possible to have something like below. Multisite Parent:               www.example.com      Child Sites:               apple.example.com     banana.example.com      Please kindly let me know the best Guides to follow to do such thing.


Renaming admin user on multisite install by MySQL

As part of a general tightening of security, I want to change the name of the admin user on my multisite install to something less commonly used. This user is admin on all five sites in the network and has the grand, exalted title of Super Admin on the network. Using MySQL (technically MariaDB) to change the name...               update wp_users set user_login = "new_username" where ID = 1;     update wp_users set user_nicename = "new_username" where ID = 1;      ... didn't pose much of a problem. The problem I had was that when I now logged in with new_username I was no longer super admin. My user still had all his posts to his name, all his configurations and metadata etc. He was still admin on all five sites. But there was no way to access the network section of the control panel, i.e. the dropdown menu didn't list the network control panel, only that of the five sites. This leads me to believe that there is some additional setting that links the super admin title to the admin user. I have travled the database looking for some clues as to where there might be some setting that names the super admin (and specifically names him "admin"?) but I have come up short. Any suggestions? NB: I know I can setup a new user and transfer all posts and responsibilities but that would open up a whole new can of worms, so if at all possible I don't want to go down that road. Also I would rather like to learn how my setup works on the db level. EDIT: Based on the information supplied by user42826, I found that adding the following command to the two above did the trick:               update wp_sitemeta set meta_value = 'a:1:{i:0;s:5:"new_u";}' where meta_key = 'site_admins';      Note that 'new_u' is five characters, similarly to 'admin'. The new meta_value string was copy-pasted from the old string with the exception of 'new_u' replacing 'admin'.


Custom Taxonomy dont save in a frontend form for post a custom post

I have a Dropdown Categories ..               <?php wp_dropdown_categories('taxonomy=faenas_combenef_category&hide_empty=0&orderby=name&order=asc&name=location') ?>      And my post Process... for tax               if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {               $title      = trim($_POST['title']);     $content    = trim($_POST['description']);     $location   = trim($_POST['faenas_combenef_category']);               $my_post = array(                 'post_title'    => $title,                 'post_content'  => $content,                 'post_status'   => 'publish',                 'post_type' => 'faenas',                 'tax_input'    => array( $location )         );          $post_id = wp_insert_post($my_post);     wp_set_object_terms($post_id,$location,'faenas_combenef_category');         wp_redirect(home_url());     } // end IF          // Do the wp_insert_post action to insert it     do_action('wp_insert_post', 'wp_insert_post');       And my taxonomy register .....               $labels = array(             'name'              => _x( 'Comunas de Beneficiarios', 'taxonomy general name' ),             'singular_name'     => _x( 'Comuna de Beneficiario', 'taxonomy singular name' ),             'search_items'      => __( 'Buscar Comuna de Beneficiario' ),             'all_items'         => __( 'Comunas de Beneficiarios' ),             'parent_item'       => __( 'Parent Product Category' ),             'parent_item_colon' => __( 'Parent Product Category:' ),             'edit_item'         => __( 'Editar Comuna de Beneficiario' ),              'update_item'       => __( 'Actualizar Comuna de Beneficiario' ),             'add_new_item'      => __( 'Añadir Nueva Comuna de Beneficiario' ),             'new_item_name'     => __( 'Nueva Comuna de Beneficiario' ),             'menu_name'         => __( 'Comuna Beneficiario' ),         );         $args = array(             'labels' => $labels,             'hierarchical' => true,             'rewrite' => array( 'slug' => 'combenef' ),         );         register_taxonomy( 'faenas_combenef_category', 'faenas', $args );      The post result OK but a "faenas_combenef_category" dont save in the custom post TAX please help, i dont know happend.... I change type of My error was               $location   = trim($_POST['faenas_combenef_category']);      i rewrite this by               $location   = trim($_POST['location']);      But the post send value of Option and not the Name of Term of Taxonomy .... My Post was Title: Titledemo Description: Description Demo Location: 2 I need change this "2" by name of the Term of Taxonomy "faenas_combenef_category" My print of dropdown categories is:               <select name="location" id="location" class="postform">         <option class="level-0" value="2">Canela</option>         <option class="level-0" value="5">Tambillos</option>     </select>      I need locate a solution please SOLVED I add function :               function custom_taxonomy_dropdown( $taxonomy ) {         $terms = get_terms( $taxonomy );         if ( $terms ) {             printf( '<select name="%s" class="postform">', esc_attr( $taxonomy ) );             foreach ( $terms as $term ) {                 printf( '<option value="%s">%s</option>', esc_attr( $term->slug ), esc_html( $term->name ) );             }             print( '</select>' );         }     }      And change               $location   = trim($_POST['faenas_combenef_category']);      And print my new dropdown
<?php custom_taxonomy_dropdown( 'faenas_combenef_category' ); ?>
      Thanks Guys!


Run A Pre-Built Core PHP Application Under A WordPress Page or Post Route

I have a complete application built in Core PHP and a WordPress site which has stable traffic every month, I need to get this new business application up and running under mysite.com/support. The problem is that, this URL will be read as a WordPress post URL and will try to look for a post with the slug "support", instead I want it to run the index.php of a seperate folder, within the root of the wordpress site and run it as an independent site completely out of WordPress. Then I will make sure it will have similar looks and feel and make sure the menu has ways to link back. Is there a way to do this? That fastest one at that. Thanks for the help in advance :)


latitude/longitude meta_query

I've been trying to figure out a way to do radius search in WP and decided upon a simpler way than big queries, I'm having problems returning results though I've got a function called bar_get_nearby() that calculates the latitude/longitude max/min for a given postcode, so that I can then find all entries inside that max/min value.               // GET POSTCODES LAT/LNG     $geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.$_POST['location'].'&sensor=false');     $decode = json_decode($geo);     $latlon = $decode->results[0]->geometry->location->lat.','.$decode->results[0]->geometry->location->lng;     $dist = bar_get_nearby($decode->results[0]->geometry->location->lat, $decode->results[0]->geometry->location->lng);          // CHECK THEY WORK     echo $dist['max_latitude'].','.$dist['min_latitude'].'<--
';     echo $dist['max_longitude'].','.$dist['min_longitude'].'<---
';          // CREATE META QUERIES     $location_LAT = array('key' => 'latitude', 'value' => $dist['max_latitude'], 'compare' => '>=');     $location_LAT2 = array('key' => 'latitude', 'value' => $dist['min_latitude'], 'compare' => '<=');     $location_LNG = array('key' => 'longitude', 'value' => $dist['max_longitude'], 'compare' => '>=');     $location_LNG2 = array('key' => 'longitude', 'value' => $dist['min_longitude'], 'compare' => '<=');      I've also tried               $latitude = array('key' => 'latitude', 'value' => array($dist['max_latitude'],$dist['min_latitude']), 'compare' => 'BETWEEN');     $longitude = array('key' => 'longitude', 'value' => array($dist['max_longitude'],$dist['min_longitude']), 'compare' => 'BETWEEN');      There is no error and there is no results returned, when I run queries via PHPMyAdmin I do get results. We then run the query given the above arguments;               $args = array('post_type' => 'choirs', 'order' => 'asc', 'orderby' => 'title', 'posts_per_page' => 500,     'meta_query' => array(     $location_LAT,     $location_LAT2,     $location_LNG,     $location_LNG2     ));          query_posts($args);      Any help would be appreciated Thanks, P


Details of wp_localize_script

Hi can anyone explain me about this?               wp_localize_script( 'jquery', 'ZillaShortcodes', array('plugin_folder' => WP_PLUGIN_URL .'/zilla-shortcodes') );


jquery issue in functions.php

I am having an issue in a theme that I am working on and I don't see how to fix it. The theme has a few jquery scripts that it needs loaded into the head in order to work. Without all of them, the theme fails. Here are the ones I am calling jquery-1.8.2.min.js jquery-1.6.1.min.js jquery.easing.1.3.js jquery- ui-1.8.11.custom.min.js jquery-ui-1.8.21.custom.min.js now with WordPress, I thought that you could just enqueue jquery and all the versions would be loaded. My problem is that when I try that and remove those scripts above, it all fails. I am enqueueing all the scripts in the functions.php file. I have noticed that when I load some plugins, it also breaks the theme so I am trying to figure out how to get it working so that plugins won't make it crash. all of my scripts are called like so                $(function($){         $(document).ready(function() {      });      });      am I missing something?


User added CSS to alter shortcode

I am creating my first plugin and so far it has gone well. It is very simple thing that calls the css file up and allows users to add shortcodes which will then create different colored backgrounds and CSS driven tables. Now rather than input thousands of CSS Blocks of code I thought it may be easier if people could input some of their own info so they could change things like the background color of the tables etc. I came across this in the Codex...               <?php     function my_styles_method() {         wp_enqueue_style(             'custom-style',             get_template_directory_uri() . '/css/custom_script.css'         );             $color = get_theme_mod( 'my-custom-color' ); //E.g. #FF0000             $custom_css = "                     .mycolor{                             background: {$color};                     }";             wp_add_inline_style( 'custom-style', $custom_css );     }     add_action( 'wp_enqueue_scripts', 'my_styles_method' );     ?>      Now I have altered it to match my parameters but what I am not getting is where does the user actually change this color? I am using shortcodes so I really don't understand this part of it. Like where would they actually input #FF0000 if they wanted a red background. I have looked high and low for actual samples of this code in use but have had no luck. I hope this makes sense it is my first post here :-)


Ajax doesn't work on second call

I'm using Ajax to load posts into a sidebar that are filtered by a chosen category. It works perfectly fine the first time, but for some reason the second time it loads a mixture of results from the first category and the second category. Does anyone know why this is happening? Here is my Javascript:               function load_blog_posts_function(str)       {      jQuery.ajax({      type: "GET",      url: "wp-admin/admin-ajax.php",      dataType: 'html',      data: ({action : 'load_blog_posts_sidebar', symbol:str}),      success: function(data) {      $('.rpwe-ul').html(data);      $("#left-sidebar").width(347);      }      });      }      PHP               function load_blog_posts_sidebar()     {     $stockSymbol = $_GET['symbol'];     $args = array('posts_per_page' => 3, 'category' => get_cat_ID($stockSymbol));     $rpwewidget = get_posts($args);     global $post;     foreach ( $rpwewidget as $post ) : setup_postdata( $post ); ?>
                  <?php if ( has_post_thumbnail() ) {  ?>                      <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'rpwe' ), the_title_attribute('echo=0' ) ); ?>" rel="bookmark">                     <?php the_post_thumbnail(                          array( 45, 45, true ),                         array(                              'class' => 'rpwe-alignleft' . ' rpwe-thumb the-post-thumbnail',                             'alt'   => esc_attr( get_the_title() ),                             'title' => esc_attr( get_the_title() )                          )                      ); ?>                          <?php }
             <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'rpwe' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
             <time class="rpwe-time published" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo get_the_date(); ?></time>
     <?php endforeach; wp_reset_postdata();     die();     }      I was reading that this might be from the use of the global $post variable (the query doesn't reset?), however I tried using both wp_reset_postdata() and wp_reset_query() and it still doesn't work.


PHP calls to custom fields not being made. Query seems to be blocking them

Our Doctors

Our team includes an array of trained experts, who can make critical decisions regarding care that typically would require multiple office visits.

                         <?php                     $args = array('post_type' => 'Doctors', 'orderby' => 'rand');                     $query = new WP_Query( $args );                     ?>                     <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>                         <?php if ( has_post_thumbnail() ): ?>                             <a href="<?php the_permalink(); ?>">

<?php the_post_thumbnail( array(160,225) ); ?>

<?php the_title(); ?>

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

<?php the_field('hospital_name'); ?>

<?php the_field('hospital_address_line_1'); ?>

<?php the_field('hospital_address_line_2'); ?>

<?php the_field('hospital_phone_number'); ?>

<?php the_field('footer_content_1'); ?>

                 <?php the_field('footer_content_2'); ?>

      In my footer template, I'm trying to recreate preexisting widgets. I have a WP_Query setup to call a custom post type, and then I'm passing the post_thumbnails to a jQuery carousel. Below that I have another widget area that I'm trying to make more dynamic by using Advanced Custom Fields to fill the values. However, when I have my footer template structured this way (as it has to be), the php calls to get the custom field values do not get made. When I have the second footer_banner_box_container above the first one it works but as it sits it does not. Could be the theme but I'm really coming up empty. Any help would be appreciated


Error loading require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );

I manually installed wordpress and added elegant theme DIVI . The functions won't work because I get this error > Warning: require_once(/home/content/54/6495354/html/wp-admin/includes/ajax- > actions.php) [function.require-once]: failed to open stream: No such file or > directory in /home/content/54/6495354/html/wp-admin/admin-ajax.php on line > 33 > > Fatal error: require_once() [function.require]: Failed opening required > '/home/content/54/6495354/html/wp-admin/includes/ajax-actions.php' > (include_path='.:/usr/local/php5/lib/php') in > /home/content/54/6495354/html/wp-admin/admin-ajax.php on line 33 /** Load WordPress Bootstrap */               require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );      I think this is the problem area from that php file above. What is it asking for? Is it asking for my directory name and not finding it?


Is there an admin hook that will let me read GET variable before it's too late to set the header Location

I need to redirect the page based on the query vars in my plugin admin menu. I don't know where I can hook in to read the query vars or the GET vars order to decide if the page needs to be redirected.


Displaying Custom Taxonomies From Multiple Custom Post Types

I have multiple custom post types and each of them has multiples categories. I'm trying this code to display certain categories from all of the custom post types + regular post.               <?php query_posts( array(      'post_type' => array( 'post', 'miss_behave','emily_davies', 'gemma_patel', 'poppy_smythe' ),      'tax_query' => array(         'relation' => 'AND',         array(             'taxonomy' => 'category',             'field' => 'term_id',             'terms' => 4         ),         array(             'taxonomy' => 'miss_behave_category',             'field' => 'term_id',             'terms' => 141         ),         array(             'taxonomy' => 'emily_category',             'field' => 'term_id',             'terms' => 142         ),         array(             'taxonomy' => 'gemma_category',             'field' => 'term_id',             'terms' => 143         ),         array(             'taxonomy' => 'poppy_category',             'field' => 'term_id',             'terms' => 144         )               ),      'showposts' => 4)      ); if (have_posts()) : ?>      Which then the page doesn't show anything. The page shows something only if I query the default post only. Please help!


excerpt_length not working

I'm trying to build a theme, I want to control the length of the post excerpts by doing something like this in functions.php:               function theme_excerpt_length( $length ) {         return 45;     }     add_filter( 'excerpt_length', 'theme_excerpt_length', 999 );      But it doesn't seem to have the desired effect of reducing length of excerpt to 45 words. Even, without the function, some excerpts are longer than the default 55 words. What could be wrong?


Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles

I need to redirect **logged-in** and **non-admin** users, from page with id 172, to the home of the website. Note that users that are not logged in can actually see the page.               add_action('admin_init', 'xyz');     function xyz() {         if( is_page( 172 ) ) {                  if( is_user_logged_in() && ! current_user_can('update_core') ) {             wp_redirect( home_url() );             exit;                  }         }        }      Problem: This code is not working.


Trying to sort and display categories(not posts) by custom field: 'order'

I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in the order I choose. My problem is that I can't get them to sort; I can display the categories, and 'echo' each category's "custom_order" number, but I must be missing something when it comes to accessing and sorting the meta_value. Not sure if I'm going about this the right way either. Here is my code to add the field to the 'New Category' page:               <?php     function taxonomy_add_new_meta_field()      { ?>
         Order         <input type="number" name="term_meta[custom_order]" id="term_meta[custom_order]" value="">
Enter an order number for organizational purposes

     <?php     }          add_action( 'category_add_form_fields', 'taxonomy_add_new_meta_field', 10, 2 );     ?>      Here is my code to add the field to the 'Edit Category' page:               <?php     function taxonomy_edit_meta_field($term) {          $t_id = $term->term_id;          $term_meta = get_option( "taxonomy_$t_id" ); ?>
         Order	                      <input type="number" name="term_meta[custom_order]" id="term_meta[custom_order]" value="<?php                 echo esc_attr( $term_meta['custom_order'] ) ? esc_attr(     $term_meta['custom_order'] ) : ''; ?>">
Enter an order number for organizational purposes

     <?php     }     add_action( 'category_edit_form_fields', 'taxonomy_edit_meta_field', 10, 2);     ?>      Here is my code to save the contents of the field:               <?php          function save_taxonomy_custom_meta( $term_id ) {     if ( isset( $_POST['term_meta'] ) ) {         $t_id = $term_id;         $term_meta = get_option( "taxonomy_$t_id" );         $cat_keys = array_keys( $_POST['term_meta'] );         foreach ( $cat_keys as $key) {             if ( isset ( $_POST['term_meta'][$key] ) ) {                 $term_meta[$key] = $_POST['term_meta'][$key];                         }                     }                     update_option( "taxonomy_$t_id", $term_meta );             }     }          add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 2 );     add_action( 'create_category', 'save_taxonomy_custom_meta', 10, 2 );      The above snippets of code I got from this website: http://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/ Last but not least here is my attempt to sort my categories based on this field:               $args = array(     'parent' => $category->cat_ID,     'hide_empty'=>0,     'exclude'=>'1',     'meta_key'=>'custom_order',     'orderby'=>'meta_value_num',     'order'=>'ASC'     );     $subcategories = get_categories($args);      I then iterate through the $subcategories array with a foreach() loop. I thought I had it working until I added a third sub-category; I now see that it puts 'custom_order' 1 first, 'custom_order' 3 second, and 'custom_order' 2 third. Can anybody lend me a hand?


InfiiniteWP and WP Networks (multisite)

We have two servers. One that has individual, stand-alone WP installs. The second server has an instance of WP multisite (networks). We're looking to combine these two platforms on a new, beefier VM and are evaluating management tools. So far we've tested InfiniteWP (IWP) on the first box with the stand alone sites and have been pleased. However, my team has questions on how IWP will impact Networks. Has anyone experience on using IWP (or a similar management tool) on a server with both standalone and instances of networks? If IWP is not the tool, is there another option to be able to manage both Networks and an army of stand- alones co-habiting on the same LAMP stack?


add_submenu_page callback a file instead of a function?

I want to clean up my theme options because I can't keep track of everything. How can I get my page_callback to link to a file sintead of a callback? I know that I could include the file in the callback but why if I can simply call the file here?                 add_submenu_page(                    null            // -> Set to null - will hide menu link                 , 'Page Title'    // -> Page Title                 , 'Menu Title'    // -> Title that would otherwise appear in the menu                 , 'administrator' // -> Capability level                 , 'menu_handle'   // -> Still accessible via admin.php?page=menu_handle                 , 'page_callback' // -> To render the page             );


Is there anything like admin_notices for front end?

I'm new to Wordpress and trying to take advantage of the framework as much as possible. On the front end, I want a centralized message area to display error, success, and general notices similar to how they're handled via admin_notices on the back end. I'm not seeing a similar hook for the front end. I guess I'm asking which action should I be hooking into on the front end to mimic admin_notices?


problems with wordpress and php version 5.3.3-1

I recently installed a server with new php version - 5.3.3-1 and when I imported wordpress site and database, there were some problems with plugin settings - some of them were reset. In pagenavi plugin I even couldn't save settings at all. So the question is - **what changes in php 5.3.3-1 are the ones that reset plugin settings or interfere with common wordpress plugin coding practices**. And other question is - **what is the best newest php version recommended for wordpress and it's plugins to work without a hassle (for versions 2.3 - 3.0.1)**? Maybe someone can share most common deprecated php functions that are in frequent use in plugins? In old server php version is 5.2.6-3 and there everything works fine. Wordpress version in use is 2.9.2, but there are lots of other various version wordpress installations on the server which should be placed to the new one