Using flickr api in custom wordpress plugin

I'm currently trying to add flickr api to my custom wordpress plugin... and am failing. :( I was trying to use this tutorial, Getting Started With Flickr API, to learn the basic code structure and then I was going to refer to flickr's app garden for documentation to do what I'm wanting; but, it's not working. What I have... I built a new PHP file and named it "class.flickr.php" and added the code listed in the tutorial...               <?php              class Flickr{              private $flickr_key;         private $flickr_secret;         private $format = 'json';              // Setting up flickr_key and flickr_secret         public function __construct( $flickr_key ) {                  $this->api_key_shown_here = $flickr_key;         }              public function searchPhotos( $query = '', $tags = '' ){ // Begin searchPhotos                   $urlencoded_tags = array();                  if ( !empty( $args )) {                      $tags_r = explode( ',', $tags );                 foreach ( $tags_r as $tag ) {                          $urlencoded_tags[] = urlencode( $tag );                 }             }                  // Construct the url             $url  = 'http://api.flickr.com/services/rest/?';             $url .= 'method=flickr.photos.search';             $url .= '&text=' . urlencode( $query );             $url .= '&tags=' . implode( ',', $urlencoded_tags );             $url .= '&sort=relevance';             $url .= '&safe_search=1';             $url .= '&content_type=4';             $url .= '&api_key=' . $this->flickr_key;             $url .= '&format' . $this->format;             $url .= '&per_page=10';                  // Get search results             $result = file_get_contents( $url );                  // Remove the unneccessary strings that wraps the result returned from the API             $json = substr( $result, strlen( "jsonFlickrApi("), strlen( $result ) - strlen( "jsonFlickrApi(") - 1 );                  $photos = array();             $data = json_decode( $json, true );                  // Check if the status didn't fail             if ( $data['stat'] != 'fail' ) {                      // Return only the data for the photos as that's the only thing that we need                 $photos = $data['photos']['photo'];                 return $photos;             } else {                      return false;                    }         } // end searchPhotos          }       and then tried calling the above method in my page template (which is in the same folder as "class.flickr.php"), using the following code...               <?php // Flickr search photos test          require_once( 'class.flickr.php' );          $flickr = new Flickr( $flickr_key );          $results = $flickr->searchPhotos( $query, $tags );     if ( !empty( $results )) {              foreach( $results as $photo ) {                  $src = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_m.jpg';             ?>                  <img  src="<?php echo $src; ?>" alt="<?php echo $photo['title']; ?>" />              <?php }                      }      But, alas, all I'm getting is a blank screen. Any help would be appreciated. ;)


adding a shortcode into a custom post type

I want to add the upload file plugin shortcode to a custom post type for a client build (if there's a better way to do this, please tell me). Basically I've got this -               echo '
Description:
';     echo '<input type="text" name="_Description" value="' . $Description . '" class="widefat" />';     echo '
Requirement:
';     echo '<input type="text" name="_Requirement" value="' . $Requirement . '" class="widefat" />';     echo '
Solution:
';     echo '<input type="text" name="_Solution" value="' . $Solution . '" class="widefat" />';     echo '<?php do_shortcode("[inline_upload]"); ?>';      this doesn't throw any errors on the page but the outputted is                     Is it possible to add a shortcode to a custom post type? Is there an easier, cleaner way to do this? Thanks in advance edit: The code is in a custom post type file that I'm calling via the functions.php to be part of the menu system. Clicking add new to it creates all the forms but outputs the I guess I'm doing it wrong?


Get post id by attachment id?

I have attachment id, but can't find way to get post id by this attachment id. I can loop all posts and find it, but maybe exists easy way get it. Does anyone know a similar function?


tax_query operator woes

I am trying to filter posts by multiple taxonomies. My code below works great, but their is one thing I can't quite figure out. When I filter the posts it seems that they only show the posts that apply to all my taxonomy 'terms'. So to illustrate my problem: Let's say I have a post and that post is "Montana". And Montana has a 'regions' taxonomy of 'region1'. It also has a 'population' of 'pop1'. And we have another post called "Idaho" and is in 'region2' and is in 'pop1'and, additionally, it is also in 'pop2'. So I run my query:               $myquery['tax_query'] = array(     'relation' => 'OR',     array(                 'taxonomy' => 'regions',                 'terms' => array(region1),                 'field' => 'slug',                 'operator' => 'IN',          ),     array(                 'taxonomy' => 'population',                 'terms' => array(pop1),                 'field' => 'slug',                 'operator' => 'IN',          )     );          query_posts($myquery);      Everything works great...Idaho and Montana Both show up. So I run another query, this time filter by another population term 'pop2' along with 'pop1'.               $myquery['tax_query'] = array(     'relation' => 'OR',     array(                 'taxonomy' => 'regions',                 'terms' => array(region1),                 'field' => 'slug',                 'operator' => 'IN',          ),     array(                 'taxonomy' => 'population',                 'terms' => array(pop1,pop2),                 'field' => 'slug',                 'operator' => 'IN',          )     );          query_posts($myquery);      Now Idaho and Montana should both show up right?...but they don't. Only Montana shows up because it has 'region1', but Idaho doesn't show up because it isn't in region1 nor does it have BOTH 'pop1' and 'pop2'. So my question: Is it possible to have the taxonomy operator work when at least one of the terms match instead of all of them having to be true?


Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly:               add_filter('the_content', 'say_hello');     function say_hello($content){         if(is_single() || is_page()){             print $content." Thank you for reading!";         } else {             print $content;         }     }      But the following codes don't seem to work:               add_action('init', 'prepare_head');     function prepare_head(){         if(is_single() || is_page()){             // include javascripts             wp_enqueue_script("jquery");             //some more js goes here (registered and enqueued)...                   //include css             $styleSrc = plugins_url("css/style.css", __FILE__);             wp_register_style("say_hello_style", $styleSrc);             wp_enqueue_style("say_hello_style");         }     }      Am I doing it wrong? Help is much appreciated! Thanks!


Get attachment if matches a variable

how do I match an image title from the media library to a variable then echo that image? this is my current code...                   <?php     $args = array(         'post_type' => 'attachment',         'numberposts' => -1,         'post_status' => null,         'post_parent' => null,         );      $attachments = get_posts( $args );          if ($attachment->post_title == $programme) {              echo the_attachment_link($post->ID, false);     }     ?>


Simple Social Icons plugin not work on my blog

I am using http://wordpress.org/plugins/simple-social-buttons/ Plugin, but its not working properly. This plugin worked on GoPress theme, but is not working on Ribbon theme, which I downloaded from http://www.spiceupyourblog.com/ ### Problem with plugin: **Social icon button does not display on archives. But in Gopress theme it displayed** this is a code that display archives,

             <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                 <div class="post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">

<?php the_time('d M Y'); ?>

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

 <?php _e('By ','mythemeshop'); ?><?php the_author_posts_link(); ?>

 <?php the_category(', '); ?>

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

                                          <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">                         <?php if ( has_post_thumbnail() ) { ?>                              <?php echo '
'; the_post_thumbnail('featured',array('title' => '')); echo '
'; ?>                         <?php } ?>
                         <?php echo excerpt(56);?>

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php _e('Read More','mythemeshop'); ?>

             <?php endwhile; else: ?>

<?php _e('There has been an error.', 'mythemeshop'); ?>

<?php _e('We apologize for any inconvenience, please hit back on your browser or use the search form below.', 'mythemeshop'); ?>
                         <?php get_search_form(); ?>

             <?php endif; ?>             <?php if ($options['mts_pagenavigation'] == '1') { ?>                 <?php pagination($additional_loop->max_num_pages);?>             <?php } else { ?>

<?php next_posts_link( __( '← '.'Older posts', 'mythemeshop' ) ); ?>

<?php previous_posts_link( __( 'Newer posts'.' →', 'mythemeshop' ) ); ?>

             <?php } ?>


How many caching plugins should be used?

Online researching shows that there are many plugins out there to perform caching on WP. Just to name a few:   * WP Super Cache   * W3 Total Cache   * WP Widget Cache   * DB Cache Reloaded   * 1 Blog Cacher   * Hyper Cache Is using just one plugin good, or is there a point in using more then one at the same time?


How do you cope with the task of adding hierarchy to the navigation menu?

Say we got a theme with a horizontal menu that shows only the top-level pages. How do you manage with the task to make the menu hierarchical, adding subpages? Any appropriate plugins for that? If you use custom css for that and you're not good enough for writing it yourself, where do you look for sample scripts? Dynamicdrive.com is one place I found some stuff, but not too much.


How can I find the hook I need to rewrite a function?

I want to change the behavior of a bbpress/Buddypress "create group" page. I found the function I need to rewrite, it's the function `create_screen` in plugins/bbpress/includes/extend/buddypress/group.php. I think I need to do something like               remove_action( 'some_hook_here', 'create_screen'  );       add_action( 'some_hook_here', 'create_screen' );      But I don't know what hook I have to use, or where to find it. This is my first time trying to write a wordpress plugin, so I'm a little lost.


add_action('pre_get_posts', array(&$this, 'pre_post_search')) problem

I have used `add_action('pre_get_posts', array(&$this, 'pre_post_search'));`. But I can not receive value of $this in `pre_post_search`


How to test if blog page is active

bear with me here as I explain my problem. Generated menu via wp_nav_menu, so I have use of the .current_page_item class. The thing is, I've used jQuery to replace the generated link text with some custom images that I have made and I have to use jQuery now to swap out the image so that the button looks "underlined". Now, I've gotten it to work for all of my pages EXCEPT for the Blog page. The Blog page is specified under the Settings > Reading tab, and the Front page = Home, Blog page = Blog. Here's my jQuery code to try to check if the current page is the blog:                   $('#menu-item-75 a').empty()             .append('<img id="blog-btn" src="<?php bloginfo('template_url'); ?>/images/blog-btn.png" />');         // tests if blog page is active, swaps images depending on test result         <?php if (is_page('Blog')) { ?>             $('#menu-item-75 img').attr('src', '<?php bloginfo('template_url'); ?>/images/blog-btn-hover.png');         <?php } else { ?>             $('#menu-item-75 img').mouseenter(function () {                 $(this).attr('src', '<?php bloginfo('template_url'); ?>/images/blog-btn-hover.png');             }).mouseleave(function() {                 $(this).attr('src', '<?php bloginfo('template_url'); ?>/images/blog-btn.png');             })         <?php } ?>      Any help/tips/advice would be greatly appreciated! Thank you! *** EDIT *** Problem hasn't been solved yet, HOWEVER, I think I'm getting close. I tried a few other things:                   <?php if (is_page(get_option('page_for_posts'))) { ?> // doesn't work         <?php if (get_option('page_for_posts')) { ?> // WORKS, but leaves menu item underlined all the time instead of only if the blog page is active      How can I test this otherwise, so the blog menu item is only underlined when the page is active?


How Can You Exclude Categories From Your RSS Feeds?

I've searched and found posts that have asked and answered how to merge different categories into an RSS feed. **What I need to know is how to exclude specific categories from the RSS feed?** Specifically, I use WP to post blog articles and to post portfolio items onto my site. I want to exclude the portfolio category from appearing in the RSS feed, making only blog posts available.


MYSQL Join on meta key value?

I have very basic mysql knowledge (able to update and join tables) and am using phpMYAdmin but I am trying something just beyond my level now. I have looked at many other questions and answers but cannot find a solution for me. I am sure there is a very simple answer. This is what I am trying to do...               usermeta t1 looks like this:     user_id |  meta_key  | meta_value|     ---------------------------------------      1      |   mk1      |  value1  |      2      |   mk2      |  value2  |      3      |   desc     |  name    |      4      |   mk4      |  value4  |      5      |   desc     |  name    |      6      |   mk6      |  value6  |      7      |   mk7      |  value7  |      8      |   desc     |  name    |      9      |   mk9      |  value9  |      10     |   desc     |  name    |           userdata t2 looks like this:      user_id  |   desc   |        ---------------------      1        |   bob    |      2        |   joe    |      3        |   nancy  |      4        |   jane   |      5        |   lee    |      6        |   jeff   |      7        |   jill   |      8        |   scott  |      9        |   len    |      10       |   carey  |      I want to update the t1 meta_value column in all the cells wtih the value "name", where the meta_key is "desc", with the data from t2.desc column, and joined where t1.user_id = t2.user_id, but I don't know how to do this! Does anyone have some mysql suggestions?


Need help with rewrite_rules_array

I have a page that I access at /category/tasks and the file is located at wp- content/themes/my-theme/tasks.php. I would like to make it so I can add a flag after tasks and pick up the query strong in tasks.php. This works fine when I access the page with /category/tasks/?when=upcoming. Can someone tell me how to use rewrite_rules_array so it will send the variable through the query string using the URL structure /category/tasks/upcoming?


Custom post type index (maybe using get_template_part)

I just created a custom post type "publication" with the slug "publications". Now im stuck trying to view all the publications index in a URL like: http://www.myExampleSite.com/publications Do I have to create some custom layouts for it, and how it will be using an index clone of twentyten theme, maybe using get_template_part? Thanks in advanced.


How to check if a theme is active?

I'd like to be able to check if the twentytwelve theme is active. I know if I was checking for an active plugin I'd do something like:               $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );     if ( in_array( 'plugin-folder/plugin-folder.php', $active_plugins ) ) {         //do stuff     } else {     add_action( 'admin_notices', 'create-a-notice' );     }      What's the proper way to check if a theme is active so I can run a function for that theme?


Check spam in custom form - akismet

I have a plugin that has input form, I have decided to check submitted data with akismet. I do have API key, WP comments are filtered correctly... here is, what I found: http://www.binarymoon.co.uk/2010/03/akismet-plugin- theme-stop-spam-dead/ problem is, that `$response` is always empty - I have tried to `var_dump()` it, right after calling `akismet_http_post()`, output was `string(0) ""`... Can you give me a hint what I did wrong? Thanks


Convert my php code into shortcode

I have this type of 8 block of `<div>` so I want to convert it into shortcode :

Category name

 Category Description

             Link to particular Categories post.

Category name

 Category Description

             Link to particular Categories post.

Category name

 Category Description

             Link to particular Categories post.
      Help me that how to convert my this php code into shortcode to add in the page?


What's the URL for a category archive?

If my category URL is: /blogs/category/foo and my archive URL is: /blogs/2011/02/ what's the URL for 'foo' blogs from February 2011?


Show the latest post from child category?

How do i show the latest post from a child category? I have the category Photos, but I want to only show the latest post from the Child category "Paparazzi" what do i add to the code below to do this               <?php      query_posts('category_name=photos&showposts=1'); while(have_posts()) : the_post();      ?>


User Custom Dashboard

I wondering is there any way/plugin to configure the User Dashboard or Panel. I know there already has a plugin called WP User Frontend able to do this, but the plugin so far is not support for custom post type. What a shame. My goal is make the user dashboard look like the frontend as much as possible. The original backend is too 'Wordpress' feel. I don't want my client to feel that way. Can I use the frontend theme integrated into the backend dashboard? Any idea?


$wpdb->update Issue

Can anyone see what I have wrong here?               $wpdb->update(         $table,           array(             'lat'=>$paper_lat,             'lon'=>$paper_lon         ),          array(             'id'=> $result=>id         ),          array(             '%d',             '%d'         ),          array('%d')     );      This gives me a white screen. As far as I can tell I have the format correct according the the codex but it is giving me fits. I am sure that it is something simple but if someone would point it out to me I would greatly appreciate it.


Add code to template dynamically

I'm working on something these days I do not know if it's good practise. My plugin has to take some templates and put them into theme instead of existing `header.php` and `footer.php`. **EDIT2 :** Not a good idea in fact, pretty uncool :/ **EDIT3 :** Last EDIT was sick, I guess I'm fed up with this work. Nevertheless I'm pretty stunned WordPress does not allow to include some code in template. Is it for security reasons?


How to use create_term, edit_term, delete_term actions?

I've created a Custom Taxonomy and I want to hook a function when User adds new Term to my Custom Taxonomy. Can someone please show me how to use following actions in Wordpress?   1. create_term   2. edit_term   3. delete term All these actions are defined in wp-includes/taxonomy.php as follows:               do_action("create_term", $term_id, $tt_id, $taxonomy);     do_action("edit_term", $term_id, $tt_id, $taxonomy);     do_action('delete_term', $term, $tt_id, $taxonomy);      Whenever I try to hook my function with add_action, the Custom Taxonomy page works indifferently. Page does not refresh when I add/edit new Taxonomy Term and attempting to delete any existing term gives me error: "An undefined error occurred." Actually all changes are getting registered to Database... page doesn't refresh on add/edit, but the Term is added/changed successfully. Even delete action actually deletes the term; I can see the changes when I refresh the page. I think there is something which the function may need to return... something is holding the Wordpress back and I just don't know what's going wrong. Waiting for your valuable reply... Regards, Ruturaaj.


How can i hide and display elements automatically?

I have at the end of my blog page an element that shows / lists the next articles from page 2. If there is no second page , this element shows nothing. I would like to hide the element automatically, as long when there is no second page. Once there is a second page, the item should be displayed automatically. Does anyone know how I can implement something like that? here is a screenshot of this element when the blog have two sites: ![enter image description here](http://i.stack.imgur.com/u5yUK.jpg) and here, when an second page does not exist: ![enter image description here](http://i.stack.imgur.com/Eqv4y.jpg) You'll see, this looks not nice when an second page does not exist. I have implemented this function with the following code:                               <?php if ( is_home() && !is_paged() ) {                   $post_num = get_option('posts_per_page'); ?>

Further articles<a href="<?php echo esc_url( home_url( '/' ) ); ?>page/2/" title="Zur Seite 2">on page 2:

                     <?php query_posts('showposts='.$post_num.'&offset='.$post_num);                     if (have_posts()) : ?><?php while (have_posts()) : the_post();  ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
                     <?php endwhile; ?><?php endif; ?><?php wp_reset_query(); ?>

                 <?php } ?>      I hope you can help me! :>


paginate function in archive for custom-post-type

I have a custom-post-type for events and use the normal `archive.php` template to list all previous events. The thing is that I use a custom query for my event-post-type inside `archive.php` like this …               <?php                 if ( is_post_type_archive('wr_event') ) :                      get_event_list( false, 'DSC' );                 else:                     rewind_posts();                     get_template_part( 'inc/posts' );                 endif;             ?>      The function `get_event_list()` looks like this …               function get_event_list( $latest = true, $order = 'ASC' ) {         echo '
';              $yesterday = time() - 24*60*60;         $compare = $latest ? '>' : '<';              $args = array(             'post_type' => 'wr_event',             'posts_per_page' => 'posts_per_page' => is_archive() ? 16 : -1,             'meta_key' => 'event_date',             'orderby' => 'meta_value_num',             'order' => $order,             'meta_value' => $yesterday,             'meta_compare' => $compare         );              $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post();             get_template_part( 'inc/event', 'item' );         endwhile;         wp_reset_postdata();         echo '
';     }      I'm using the same function `get_event_list()` in my `index.php` to list all events - and on my index I want to list ALL of them. That's why I have `posts_per_page => -1`. In my `archives.php` where I want to use the same template I want however only 16 "events" to be listed and a pagination underneath. I have the following function in my `functions.php` that does work fine in my search-template. But it doesn't for this custom-archive.               function get_pagination_links( $type = 'plain', $endsize = 1, $midsize = 1 ) {         global $wp_query, $wp_rewrite;           $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;              // Sanitize input argument values         if ( ! in_array( $type, array( 'plain', 'list', 'array' ) ) ) $type = 'plain';         $endsize = (int) $endsize;         $midsize = (int) $midsize;              // Setup argument array for paginate_links()         $pagination = array(             'base'          => @add_query_arg('paged','%#%'),             'total'         => $wp_query->max_num_pages,             'current'       => $current,             'show_all'      => false,             'end_size'      => $endsize,             'mid_size'      => $midsize,             'type'          => $type,             'prev_next'     => false         );              return paginate_links( $pagination );     }      The pagination shows up underneath my events and only 16 events are listed. However, if I click on page two, the same list of the first 16 events is listed. Any ideas how to make that pagination work with my custom-post-type archive?


How to keep track of when a vote is cast?

I have setup a great voting system on my website, but since I want to sort the top rated posts by week, month and alltime...I now need to able able to keep track of when a vote has been cast. Could anybody help/nudge me in the right direction? I followed this tutorial: http://wp.tutsplus.com/tutorials/how-to-create-a-simple-post-rating-system- with-wordpress-and-jquery/ JQuery:                   jQuery(document).ready(function() {           jQuery(".post-like a").click(function(){               heart = jQuery(this);               // Retrieve post ID from data attribute               post_id = heart.data("post_id");               // Ajax call               jQuery.ajax({                   type: "post",                   url: ajax_var.url,                   data: "action=post-like&nonce="+ajax_var.nonce+"&post_like=&post_id="+post_id,                   success: function(count){                       // If vote successful                       if(count != "already")                       {                           heart.addClass("voted");                           heart.siblings(".count").text(count);                       }                   }               });               return false;           })       })        Hooks for functions.php               add_action('wp_ajax_nopriv_post-like', 'post_like');       add_action('wp_ajax_post-like', 'post_like');        Post like function:                   function post_like()       {           // Check for nonce security           $nonce = $_POST['nonce'];           if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )               die ( 'Busted!');           if(isset($_POST['post_like']))           {               // Retrieve user IP address               $ip = $_SERVER['REMOTE_ADDR'];               $post_id = $_POST['post_id'];               // Get voters'IPs for the current post               $meta_IP = get_post_meta($post_id, "voted_IP");               $voted_IP = $meta_IP[0];               if(!is_array($voted_IP))                   $voted_IP = array();               // Get votes count for the current post               $meta_count = get_post_meta($post_id, "votes_count", true);               // Use has already voted ?               if(!hasAlreadyVoted($post_id))               {                   $voted_IP[$ip] = time();                   // Save IP and increase votes count                   update_post_meta($post_id, "voted_IP", $voted_IP);                   update_post_meta($post_id, "votes_count", ++$meta_count);                   // Display count (ie jQuery return value)                   echo $meta_count;               }               else                   echo "already";           }           exit;       }       Already voted:                   function hasAlreadyVoted($post_id)       {           global $timebeforerevote;           // Retrieve post votes IPs           $meta_IP = get_post_meta($post_id, "voted_IP");           $voted_IP = $meta_IP[0];           if(!is_array($voted_IP))               $voted_IP = array();           // Retrieve current user IP           $ip = $_SERVER['REMOTE_ADDR'];           // If user has already voted           if(in_array($ip, array_keys($voted_IP)))           {               $time = $voted_IP[$ip];               $now = time();               // Compare between current time and vote time               if(round(($now - $time) / 60) > $timebeforerevote)                   return false;               return true;           }           return false;       }       Is this doable with the code I already have? Any help or advice would be awesome, thanks a lot.


Add Embed.ly API objects to post_meta on update

I created a new post type `fr_news` for adding news to a site. The user inputs a URL, and what I want it to do is use the Embed.ly API to display the news. I've got the API side figured out. Here's the working API code:               global $embedly_options;          $embedly_options = get_option('embedly_settings');          $api = new Embedly\Embedly(array( 'key' => $embedly_options['key'], 'user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)' ));     $fr_news_url = $post->fr_news_url;          $embedly_resp = $api->oembed( $fr_news_url );      Which outputs this when when `print_r( $embedly_resp )` it:               stdClass Object (          [provider_url] => http://www.ibtimes.com          [description] => House Minority Leader Nancy Pelosi, D-Calif., said there will be strong opposition if House Republicans don't make their recent concurrent resolution favorable to achieving a compromise.          [title] => Pelosi: 'Strong Negative' Reaction If GOP Won't Compromise          [author_name] => Laura Matthews          [thumbnail_width] => 770          [url] => http://www.ibtimes.com/government-shutdown-2013-pelosi-warns-strong-negative-reaction-if-republicans-dont-go-compromise          [thumbnail_url] => http://s1.ibtimes.com/sites/www.ibtimes.com/files/styles/v2_article_large/public/2013/09/10/pelosi-2013.jpg          [author_url] => http://www.ibtimes.com/reporters/laura-matthews          [version] => 1.0          [provider_name] => Ibtimes          [type] => link          [thumbnail_height] => 506      )      However, instead of pulling on page load, want to add to pull from API and add to post_meta every time the URL changes changes:               add_action( 'transition_post_status', 'get_fr_news_embedly', 9 );          function get_fr_news_embedly( $new_status, $old_status, $post ) {         if ( $new_status != 'trash' && $post->type == 'fr_news' ) {         // Post is not in trash and is fr_news              global $embedly_options;              $embedly_options = get_option('embedly_settings');              $api = new Embedly\Embedly(array( 'key' => $embedly_options['key'], 'user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)' ));         $fr_news_url = $post->fr_news_url;              $embedly_resp = $api->oembed( $fr_news_url );              if ( ! update_post_meta ( $post->id, 'fr_news_objs', $embedly_resp ) ) add_post_meta( $post->id, 'fr_news_objs', $embedly_resp );     }     }      I'm pulling and displaying it this way:                       <?php $embedly_resp = get_post_meta( the_ID(), 'fr_news_objs', true ); ?>             <?php print_r( $embedly_resp ); ?>      to no avail.


Create a Link to Larger Image from within list of smaller images

I have this in my functions.php:                function display_images_in_list($size = thumbnail) {           if($images = get_posts(array(         'post_parent'    => get_the_ID(),         'post_type'      => 'attachment',         'numberposts'    => -1, // show all         'post_status'    => null,         'post_mime_type' => 'image',                 'orderby'        => 'menu_order',                 'order'           => 'ASC',      ))) {         foreach($images as $image) {             $attimg   = wp_get_attachment_image($image->ID,$size);           echo $attimg;                  }         }     }      Then I have this in my template page:               <?php display_images_in_list('ca_thumb-large'); ?>      This code displays a list of images on the front-end post. I need to add a link to wrap each image. The link should point to a larger version of the same image. I have a larger image size with the name of recipe-full that I want to show when clicked. I think I just need to modify the function, but I'm having trouble here.


wordpress mega menu without plugin

I created a mega menu on my site using wordpress native wp_menu. I wanted to display 4 columns in each mega menu. each column contains 5 links you can see it live here (it's in hebrew but check the top menu from right to left) click here Up until this point everything works lovely. what I want to do now is displaying more than 5 links in each column (say 10 for example) but only in the first drop down menu (from the right) here is the original code:               <?php $menu_name = 'top_menu';     $menu = wp_get_nav_menu_object($menu_name);     $menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );     ?>
     <?php     $count = 0;     $submenu = false;     $i=0;     $output = '';     foreach( $menuitems as $item ){         $link = $item->url;         $title = $item->title;              //if no parent         if ( !$item->menu_item_parent ) {         $parent_id = $item->ID;         $output .= '
             '.$title.'';         }              if ( $parent_id == $item->menu_item_parent ) {                  if ( !$submenu ) {             $submenu = true;             $output .= '

';             }                      $i++;                         $output .= '
                             '.$title.'
';                  if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ) {                     $output .= '

';             $submenu = false;     $i=0;             } else if($i==5) {                     $output .= '

';                     $i=0;             }         }              if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id ) {         $output .= '
';         $submenu = false;         }         $count++;     }     echo $output; ?>
      Note this part in the code:               else if($i==5)      this determines how many links I want to display in each column. if I change this to 10 it will work but it will work across all the drop down menus and I want it to work only for the first link on the right and all the others shoould remain 5. so I figured I will create a Boolean variable which will display different number in the first row if it sets to **TRUE** and then change it to **FALSE** to go back to 5. this is what I came up with:               <?php $menu_name = 'top_menu';     $menu = wp_get_nav_menu_object($menu_name);     $menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );     ?>
     <?php     $count = 0;     $submenu = false;     $i=0;     $output = '';     $first_menu = true;     foreach( $menuitems as $item ){         $link = $item->url;         $title = $item->title;              //if no parent         if ( !$item->menu_item_parent ) {         $parent_id = $item->ID;         $output .= '
             '.$title.'';         }              if ( $parent_id == $item->menu_item_parent ) {                  if ( !$submenu ) {             $submenu = true;             $output .= '

';             }                      $i++;                         $output .= '
                             '.$title.'
';                  if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ) {                     $output .= '

';             $submenu = false;             $i=0;             } else if (($i==10) && ($first_menu == true)) {                     $output .= '

';                     $i=0;                     $first_menu = false;             } else if ($i==5) {                     $output .= '

';                     $i=0;             }         }              if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id ) {         $output .= '
';         $submenu = false;         }         $count++;     }     echo $output; ?>
      See the variable **"first_menu"** which I set to true to show 10 in the first menu. unfortunately it is not working I will appreciate any help! Thanks


Custom Post Type Pagination For Genesis Child Theme

Is there any possible to implement the pagination for custom post type in **_Genesis_** child theme, I'm using **_Genesis_** : 2.0.2 and **_Wordpress_** version is : 4.0. I've tried the following code in my template, but it's not working for me.               <?php echo genesis_posts_nav(); ?>      And my normal category pagination also not working for me in my genesis child theme.               <?php echo genesis_posts_nav(); ?>      **My Custom Template Code Here :**               <?php           remove_action( 'genesis_loop', 'genesis_do_loop' );          add_action( 'genesis_loop', 'sk_do_loop' );          function sk_do_loop(){          $args_spotlight_latest = array('posts_per_page' => 5,'post_type' => 'spotlight', 'post_status'=>'publish','meta_key' => 'featured_slider','meta_value' => 'true');     $spotlight_posts_latest = new WP_Query($args_spotlight_latest);          /** Content Area **/          if($spotlight_posts_latest->have_posts()){              while($spotlight_posts_latest->have_posts()){         $spotlight_posts_latest->the_post();                                 $feat_image = wp_get_attachment_url(get_post_thumbnail_id());                 ..............         ..............         ..............        }          }          genesis_posts_nav();          }          ?>      Can anyone help me in this. Thanks in advance.


Have custom post type Visibility be private by default, and have radio button also set to "Private"

I have been following the advice of this answer, but ran into a glitch... The post Visibility says "Private" on my custom post, but if you click the "Edit" link to reveal the radio buttons, the "Public" button is still selected (see screen shot). So in fact my post is not private at all, even though it says that word in the visibility field (so appears to be working at first glance). Here is what my code looks like **Edits: this was changed to show the correct code:               // Set Updates post to private by default          add_action( 'post_submitbox_misc_actions' , 'wpse118970_change_visibility_metabox' );     function wpse118970_change_visibility_metabox(){         global $post;         if ($post->post_type != 'updates')             return;             $post->post_password = '';             $visibility = 'private';             $visibility_trans = __('Private');         ?>         <script type="text/javascript">             (function($){                 try {                     $('#post-visibility-display').text('<?php echo $visibility_trans; ?>');                     $('#hidden-post-visibility').val('<?php echo $visibility; ?>');                 } catch(err){}             }) (jQuery);         </script>         <?php     }      Any suggestions? *Note: I commented out the print_r($post); because it was giving me extra text on my page that I didn't want my client looking at (see screen shot). I also removed the call to show the message, as I didn't want to draw attention to it. Guess I could have also removed that code to clean it up, but hadn't thus far.


How to add a new plugin page under desired Options page?

Using WordPress Settings API tutorial I created a new custom menu and corresponding sub menus. Each of my menus have a page of its own. I used `add_menu_page()` and `add_submenu_page()` for that. (Here is the Complete Code) **Admin--------**   **»** Special Admin   **»** Price Quotation Now I'm trying to make a Plugin for some additional purposes. I want to integrate my plugin with the custom menu, I created earlier. I placed a checkbox saying "Activate Price Quotation" in the "Special Admin" page. When the user Activates the Price Quotation the plugin will come into action. Then plugin will be available in the "Price Quotation" submenu_page. There I'll make some tabbed pages under the Price Quotation page with some certain functionalities. I tried with a basic plugin with `add_plugins_page()`:               <?php     /*      * Plugin Name: Price Quotation      * Plugin URI: http://www.example.com      * Author: Mayeenul Islam      * Author URI: http://www.example.com      * Version: 1.0.0      */     ?>          <?php          function add_a_menu(){         add_plugins_page(             'Price Factor',             'Price Factor',             'edit_posts',             'edit_private_posts',             'price_factor_callback'         );     }     add_action('admin_menu', 'add_a_menu');          function price_factor_callback(){         echo "This is Price Quotation Page";     }          ?>      But this `admin_menu` filter added the menu under the default "Plugins" menu by default. How can I manage to call the menu or menus where I decided them to?


Custom post type items open in archives?

I have my own custom post type under: wordpress/custom But when I open any item of this post type they open in: wordpress/archives/custom/title Why there's 'archives' and how to get rid of this from my urls? The taxonomy is registered like below:               register_taxonomy("our_frontpage_types", array("frontpage"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => true));      And the post is registered like:               add_action('init', 'fp_register');        * UPDATE * Ok, now I know it was a problem with permalinks, BUT /%category%/%postname% is far from perfection. Is there something like %section%/%postname%?


Is there a html tag filter for the excerpt?

Maybe now, with the wordpress 3.6, there is a filter on allowing html tags on the_excerpt() I am trying to get the_excerpt() to allow certain html tags and I searched and searched and all I find is outdated info. What is a valid method to do it?


Clean way to initialize plugin in newly-added site when plugin has been network activated?

I've been working on migrating one of my plugins to support multisite installs and am attempting to figure out the cleanest way to handle the following series of events:   1. Plugin is Network Activated   2. New site is added I'm currently listening to the activation hook which works for every other case, both individual activations and site-wide ones, but I'm not getting an activation hit when the new site is added. Incidentally, this strikes me as a bug in WP core... In any event, I need to catch this series of events and run activation things. I was looking at combining the wpmu_create_blog hook and is_plugin_active_for_network, but I'm not sure if there might _fingers crossed_ be a better way to do this.


Trying to list terms of a custom taxonomy using get_categories

I'm using this little snippet of code to try and list the terms of a custom taxonomy for use in a meta box select box but it doesn't show anything when I implement it (Despite working with the default 'category' taxonomy)               $partners = array();     $partners_obj = get_categories(array('taxonomy' => 'partner-cat'));     $partners[''] = '-';     foreach ($partners_obj as $partner) {         $partners[$partner->cat_ID] = $partner->cat_name;;     }      As you can see, my custom taxonomy is 'partner-cat' and there are posts in a custom post type in 2 separate terms of this taxonomy. Any help would be most appreciated.


How can I save custom meta to one global value?

I have added a custom meta box to one of my custom post types. It contains a checkbox that will indicate that this is the "featured monthly product" (there can only ever be one). When I check this box, I would like to update a global custom value which is then accessible anywhere. In other words: I would like to update a custom meta field without being post- specific. Is this possible? I know there is an option of creating a global options page, but I need this to be within edit.php.


Disappearing Widget Text area

I recently encountered a strange thing for the first time with Wordpress...all of my text boxes in every widget sidebar disappeared! Other widgets are still there. Has this happened to anyone else? I am using 10 different sidebars on 10 different templates and all text widgets have failed. Is there a limit to how many sidebars you should have? What else could be the problem?


Display latest post from Wordpress Featured Category that is also in X,Y,or Z categories

I want to display the latest post from a "featured" category `(id=1)` that may also be in either `X` category, `Y` category, or `Z` category `(id=2,3,4 respectively)`. Note, there are other posts in categories `(A,B)` that may also be listed under "featured" but I want to limit my results to the `XYZ set`. Is there any `special loop` I can use to achieve this, or do I need to run a `SQL query`? Also important to know that these are all top-level categories, so no child or parent cats to look through.


Get post by ASC from custome field DATE picker

i want to custome post by ASC. i have some add some post in bachend one of the field date picker. i want to post by date which i set in date picker field               <?php             $args = array(                  'post_type'=>'upcoming_events',                  'order' => 'ASC',                 );             global $more;              query_posts( $args );              while (have_posts()) : the_post();              ?>      **Ex.** some post which i set date(datepicker cusomefiled) and title output is below **DATE(datepicker)** **title** 19-12-2013 London 29-12-2013 Spain 15-01-2014 Paris **i want to** **DATE(datepicker)** **title** 15-01-2014 Paris 19-12-2013 London 29-12-2013 Spain


'Was this post useful' plugin

I'm searching for an FAQ plugin, which should have 'was this post useful' option (it can be implemented as a set of plugins as well, not necessary to be all-in-one plugin). Generally FAQ can be implemented as category with posts, but I'll need expand/collapse JS only in that category, and I need the 'was this post useful' option only in that category as well, so I prefer a plugin for it. Any suggestions? _Wordpress version: 3.2.1_


Add jQuery in dashboard when is already added in main plugin page

Hi guys I have added jQuery and my jQuery fail to my main plugin page and it works great by this was.                   function load_scipt() {             wp_register_script( 'reserveit', plugins_url( '/js/reserveit.js', __FILE__ ), array( 'jquery' ), '2.5.1' );             wp_enqueue_script( 'reserveit' );                  wp_register_script( 'datetimepicker', plugins_url( '/lib/datetimepicker/js/jquery-ui-timepicker-addon.js', __FILE__ ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jquery-ui-datepicker' ) );             wp_enqueue_script( 'datetimepicker' );                  wp_enqueue_script( 'jquery-ui-core' );             wp_enqueue_script( 'jquery-ui-datepicker' );             wp_enqueue_script( 'jquery-ui-slider' );             wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );         }              add_action( 'wp_enqueue_scripts', 'load_scipt' );               Now I need to add jQuery datepicker to input in my admin menu, but it isn't working here is the code.          function load_scipts() {         wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'jquery-ui-datepicker' );         wp_enqueue_script( 'jquery-ui-core' );         wp_enqueue_script( 'jquery-ui-widget' );                   wp_register_script( 'admin-menu', plugins_url( 'admin-menu.js', __FILE__ ), array( 'jquery', 'jquery-ui-datepicker' ), '2.5.1' );         wp_enqueue_script( 'admin-menu' );         wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );     }            add_action( 'wp_enqueue_scripts', 'load_scipts' );      I tried everything but it isn't working. my path to files working but I have no idea where can the problem is. this is my reserveit.js jQuery(document).ready(function($) {                   jQuery('#datepicker').datepicker({             dateFormat: 'dd-mm-yy'         });          });      and this is my admin-menu.js               jQuery(document).ready(function(jQuery) {              jQuery('#datepicker').datepicker({             dateFormat: 'dd-mm-yy'         });     });      Please if you have idea write comment.


I want to add a custom field in the rss title of each post, but don't want it to be shown on the site

I've seen that other sites have done this but didn't manage to do it myself. I have certain custom fields for each post and I want one of these custom fields to be shown in the RSS feed in the title for each item after the item's actual title. For example, if the post is named "Abracadabra and hocus pocus" and is written by James A. Author I would like the feed item title to be "Abracadabra and hocus pocus by James A. Author". How can this be done?


Appearance > Menus > Left Sidebar > Add Toggle

How can i add my own toggle here ? There are toggles for each post type but I would like to add this without creating a new post type. Where should I start looking ? ![enter image description here](http://i.stack.imgur.com/Lyoix.jpg) Let say I wish to add something like this:![enter image description here](http://i.stack.imgur.com/mrbvr.jpg) It will work the same as link with URL = # and it will look more clear for some people


Change the values of numberposts gallery

I have installed this plugin (http://wordpress.org/plugins/media- categories-2/) to categorize my images. In my functions.php I have put the following code to limit the number of images shown in the gallery:               function get_random_gallery_images(){         global $wpdb,$post;             $ids = "";             $counter = 0;             $number_of_posts = 1;             $args = array(             'post_type' => 'attachment',             'numberposts' => 1,             'post_status' => null,             'orderby' => 'rand',             'post_parent' => $post->ID             );             $attachments = get_posts($args);             if ($attachments) {                 foreach ($attachments as $attachment) {                          if ($counter != 0) {                         $ids .= ','.$attachment->ID;                     }                     else {                         $ids .= $attachment->ID;                     }                     $counter++;                 }             }             return $ids;     }       in my single.php I have put the following code:               $attachment_ids = get_random_gallery_images();     $category_current = get_the_category($post->ID) ; //for getting the images of that specific category     echo do_shortcode('[gallery columns="1" category="'.$category_current[0]->name.'" include="'.$attachment_ids.'" link="file"]'); The problem is that is does not matter if I change the values of numberposts. It always displays all of the images. What I am doing wrong? I only want to display 1 image.


Remove path from the create/edit a post view

Been fiddling around, trying to remove the "path" info that's shown when you create/edit a post in wordpress. Been able to remove word count and the saving draft info, but not the path thingie This is what I'm talking about: http://dl.dropbox.com/u/3618143/Sk%C3%A4rmavbild%202011-03-13%20kl.%2001.08.11.png Also, the autosave-info that shows up on posts that's being edited. "Last edited by admin" etc. Can't seem to find that either. Any ideas?


How to output CSS to the beginning of the stylesheet in a Wordpress Plugin

I'm trying to insert some CSS at the very top of the Current Theme Stylesheet via plugin. (So that the CSS is easily over-ridden by the plugin user). How would you prepend CSS to the Theme Stylesheet? Also i'm trying to put some Javascript just before the /body tag in the theme, how would that be accomplished?


Admin new order email customization

I'm using Woocommerce with Gravity forms and the Woocommerce gravity forms plug-in. I want to change the new order email (admin-new-order.php) so that instead of getting an email that lumps all products chosen via a gravity form into the left hand column making it very difficult to read, the products chosen are clearly itemised in the middle column. How do I do that?


redirecting improperly after updating custom taxonomy term when referring from CPT edit page

I have a custom taxonomy "stat groups" (non-hierarchical) for my custom post type "stats". I created a link on the edit page for the chosen stat group term on the edit page for a stat. After clicking the link and submitting the changes to that term, wp redirects to the edit-tags.php but without the post type in the query string... So the edit page comes up correctly, but in the navigation, it is showing the expanded "Posts" section instead of my custom post type's. This is particularly annoying because I have custom css for the custom taxonomy's edit page, because there are added fields, and it is just messing it all up when it doesn't include the post type in the query string I am guessing this is happening because of the http_referrer? I cannot figure out how to get it to redirect back to the custom post edit page on saving the custom taxonomy term. I have tried passing the redirect url in the query string to the edit page for the term, capturing it from the $_GET var, putting it in a hidden input value, then capturing it from the $_POST on save and trying to redirect using it after the save but it's not working. I've tried using wp_redirect as well as redirect canonical there. So what I really want to do is for it to redirect back to the referring stats edit page for the post it was on after saving the edits to the custom tax term. If I can't do that, I'd at least like it to redirect to the right edit- tags page. Anyone? Thanks for any help in advance! :)


Is it better to create a function or a variable for current_theme_supports?

Well I just asking myself this, there are two ways I could implement this. What would be a better fit to coding standards? Or is this just a a matter of personal like? **And what about php and memory, assuming this would be way more complicated and executed very often. Would it cost more memory to create a function or a variable?** Solution 1:               function stuff(){              [...]              $fluid = ( current_theme_supports('greatness') ) ? '-greatness' : '';              $output = '
';              [...]          }      Solution 2:               function stuff_alternative(){              [...]                      $output = '
';              [...]          }          function bootgen_is_great(){              if ( current_theme_supports( 'greatness' ) )             return '-greatness';          }


Can't get CSS Into the Head via add_action

I'm trying to add some CSS to the head part of the CSS but I can't get it to work (I want to add it to the head before the Theme CSS so the plugin user can easily over-ride plugins default CSS without !important over-rides). Here is what I tried:               <?php      add_action('wp_head', 'addCSS');     function addCSS() {         wp_register_style( 'prefix-style', plugins_url('AddToCartStyles.css', __FILE__) );         wp_enqueue_style( 'prefix-style' );     }     ?>      EDIT: Maybe the way I worded this was confusing. I Don't want to include the CSS in the plugin Admin Page, I want to include the CSS in the regular theme pages (e.g. the pages the end user will actually see).


How to remove specific categories from posts?

I need to select all posts from database without fetching some categories.   For example I fetch posts with this code:               $featuredPosts = new WP_Query();     $featuredPosts->query('showposts=40');      So, now, how can i remove categories with id of: 22, 23 and 24?


Add News Feed to bespoke website, only to one page on whole site

I have built a bespoke website that is **not** currently managed by WordPress. For SEO purposes and to announce special offers etc, my client would like to add a News Feed to the site. To save me having to write a bespoke CMS for a single page, I would like to implement WordPress on just this particular page. I am currently very confused as to how WordPress works as, believe it or not, there is too much information on the net and resultantly I am just left baffled... I was therefore hoping that someone may be able to answer a few of my queries, thus pointing me in the right direction for creating this WordPress powered News Feed. Here are my questions:   1. In Plesk, it offers me to install WordPress on a site, how does this differ to just copying the WordPress directory to my site and going through the steps on the pages?   2. Is there a particular part of WordPress that I should be looking at in order to implement a custom News Feed?   3. I have noticed that there are PHP `wp_*` functions, is there documentation for these?   4. Does it matter which directory WordPress is installed in? i.e. if my website is at `httpdocs/`, should I be placing WordPress into `httpdocs/wp/`?   5. Where does my client go to to login to WordPress? I assume it will be `http://domain.com/wp/`, is this correct?   6. Does WordPress manage all of the data as in images, text etc? Obviously it stores the text in the DB, but what directory does it store all the images in?   7. I will inevitably be implementing an infinite scroll on the News feed page, therefore, how would I go about retrieving the data from the database, with limits for paging etc? I have never used WordPress before, so please forgive my naivety...   **_Please note, I am not asking you to write the code for me, I simply need pointing in the right direction._**


Custom static page get_header error

I have a pretty simple question. I want to make a static about page for my wordpress site. I don't like the format of the wordpress static pages that are managed through the control panel so I thought I would make my one custom page where I would have full control of the layout, formatting & content. I have experience doing web development, so I thought I would edit the `header.php` file of my tweaked theme to induce a statically typed menu link to `about.php` in the wordpress root directory. When I tried to import the contents of `header.php` in the `about.php` file I got a 500 level internal server error. I am confused as to why I got this error. Was the error caused by my page being poorly constructed or because my hosting service has some configuration issue. I am not new to PHP or web-development but I am new to wordpress. What caused this error? **Error page:**               0     Internal Server Error          The server encountered an internal error or misconfiguration and was unable to complete your request.          Please contact the server administrator, cgiadmin@yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.          More information about this error may be available in the server error log.      **about.php**               <?php get_header(); ?>

Hello World!

          <?php /* get_footer(); */ ?>


Tracing the life of a query

I can't find documentation regarding this - but is there a way to see how a query might bounce around from one filter to another? I've got a list of possible wp_filters and their relevance but I can't determine what's happening to a query I'm making. Here's the basics - I'm attempting to use the Relevanssi plugin with WooCommerce and the Vintage theme, searching through custom fields. I can see that the query is returning correctly before it's being displayed; just before it's displayed all the posts are removed.


How do I approach removing menu items on the fly based on settings in my plugin?

I've started writing a plugin that allows the administrator to select specific pages and set them to be visible **only to logged-in users** ; the plugin optionally applies the restriction to **all child pages** too. When a site visitor attempts to view any of these pages, they get redirected to the login page. So far, so good. It all works to that point, and duplicates functionality I've seen in existing plugins. However, what I also want to do is to **automatically remove all of those pages (including child pages, where specified) from the front-end site's menus**. I don't want them visible at all unless you're logged in. I've seen solutions where people create two menus and switch between them depending on logged-in status, but that's an extra step I'd rather not have. I thought I could perhaps approach this by adding a filter or action hook for 'wp_nav_menu_items' in the plugin code, but I've had no success with that yet. Any thoughts? Thanks Phil * * * Additional details (smaller chunk of the problem): Here's some code from my plugin that I'm trying to use to hook into the menu items:               add_filter('wp_nav_menu_items','ppa_filter_visible_menus');          function ppa_filter_visible_menus($nav) {         die("filter menus");     }      The problem I have is that ppa_filter_visible_menus is not called.


Find the first occurrence of a custom field

I was wondering if anyone can help. I'm using the advanced custom fields plugin and I'm trying to find the first occurrence of a custom field by date, so really the newest post which has a custom field set to true. The field I'm looking for is field type: true/false field name: featured_post I want to exclude this post from the homepage so I'm trying to edit the globe query in functions.php               function filter_posts_blog_page() {         if(is_home())         {         // $firstfeatured         // excluded the $firstfeatured          }      }     add_filter('pre_get_posts', 'filter_posts_blog_page');      Sorry, I do not know much php but any help would be great.


Apply custom names for generic custom taxonomy name?

Hello, this is more of a 'is it possible' type question. Keep in mind, I am no php master by any means, but can generally figure things out : ) Say i have a wordpress site that is for displaying menu items, focusing on pizza. I have a custom post type of 'menu items' and i would need several custom taxonomies attached to that post type. Things like toppings, sauces, cheeses, crusts, etc… BUT, what if the end user doesn't want to name their taxonomies that way, say they wanted specialty toppings, veggies, meats, gluten free, instead? Is there a way for me to name my custom taxonomies something general like, ingredient set 1, ingredient set 2, ingredient set 3, ingredient set 4, ect...and in the theme options panel, set up some sort of override for that taxonomy name? Something like: Taxonomy Name: Ingredient set 1 -> Friendly Name: Toppings   Taxonomy Name: Ingredient set 2 -> Friendly Name: Sauces etc… I have tried searching online but haven't found anything about it, but my wording could be off. Any ideas would be greatly appreciated!


Walker Class - Check if menu item has description and if so add class to li

I am using a pretty common walker class to pull in the description when I call the `wp_nav_menu` function. I am using this to add an optional second line for the menu, using the description. This of course makes the menu items uneven, if some have descriptions and some don't. I've come down to two possibilities:   1. Within the custom walker class, check to see if a menu item has a description and if so, add a unique class to the parent `li` on that menu item only.   2. Use css to vertically center the anchor text within the li if it has the span (description) or not Anyone know of either solution, or another one? Walker Class being used:               class description_walker extends Walker_Nav_Menu {     function start_el(&$output, $item, $depth, $args) {         global $wp_query;         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';              $class_names = $value = '';              $classes = empty( $item->classes ) ? array() : (array) $item->classes;              $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );         $class_names = ' class="' . esc_attr( $class_names ) . '"';              $output .= $indent . '
ID . '"' . $value . $class_names .'>';              $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              $item_output = $args->before;         $item_output .= '';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;         $item_output .= '' . $item->description . '';         $item_output .= '';         $item_output .= $args->after;              $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }     }


Add item ONLY to the primairy navigation

this code add the proper "home" to navigation... what i try to get is add home to ANLY the primairy navigation, how do i target the "main" only               function new_nav_menu_items($items) {         $lang = qtrans_getLanguage();              wp_nav_menu( array( 'theme_location' => 'primary', 'items_wrap' => '

Home
%3$s
' ) );         $homelink = '
' . __('Home') . '
';         $items = $homelink . $items;              return $items;     }     add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );


Display all of a post's categories except the current category

I use categories to order my posts into timelines. So for example, Jennifer Lopez There are no subcategories. All categories are on one level. The top post, "Wants Gomez" actually has two categories: Jennifer Lopez and Selina Gomez. I'd like to display only the categories that are not in the current category, so in this case I'd like to see "Selina Gomez" displayed after the date. Some posts may have three or more categories. For example, if a post had "George Bush, Dick Cheney, Barack Obama" as categories, when I look at the Barack Obama category I would see only George Bush, Dick Cheney displayed on the post, but if I looked at the George Bush category I would see Obama and Cheney. I need the category name to link to the category page i.e. "Barack Obama" text will link to the Barack Obama category page.


How to show monthly archive posts?

my custom archives page is :               <?php get_header();           print ('
');         $archi = wp_get_archives('echo=0');         $archi = explode( '
' , $archi );         $archi_count = count($archi);         $count = 1;         $itemCount = 0;         foreach( $archi as $link ) {             $link = str_replace( array( '
' , "\n" , "\t" , "\s" ), '' , $link );             if($count == 1) {                 print('

');                     $itemCount++;             }             if(!empty($link)){                   $arr = array($link);                 print('
' . $arr['0'] . '
 ');                 $itemCount++;             }             else continue;                       if($count == (ceil($archi_count/3))) {                 print('

');                 $count=1;             }             else $count++;           }         if ($count != (ceil($archi_count/3)) && $count > 1) // If last column does not have it's 7 items, then close the column             print('

');     print('
');          get_footer(); ?>      It's showing a list of months archive links such as Apr 2014. When I click it redirects to htttp://www.mysite.com/blog/2014/04. In this page how can I show all the posts those are posted in Apr 2014.? Means in **date.php**.. my date.php               <?php     $args = array( ****WHAT ARE THE ARGUMENTS I HAVE TO PASS HERE?****);             $lastposts = get_posts( $args );     foreach($lastposts as $post) : setup_postdata($post);     archive_row();     endforeach; ?>      In function.php               function archive_row() { // archive rows archive.php, date.php         echo '
' . get_the_title() .'
';                 }


Custom category search box for WordPress

I've seen plugins that add an additional drop down list of categories to the standard WordPress search bar, however this doesn't really help me at all. My site has a lot of posts in a lot of categories and what I want to do is add a large search box at the top of each category page titled 'search [cat name]: ' this search box will only search the posts within the category they are currently looking at. To save me having to place code (and create a category page template for each category I have) it would be brilliant if this can somehow be dynamically created. So what I am aiming to achieve is this:   1. Dynamically created search bar title   2. A search box that only searches within the category the user is currently viewing I have this:               <form method="get" id="search form" action="/">     <div>     <input type="text" value="" name="s" id="s" />     <input type="hidden" value="22" name="cat" id="africa" />     <input type="submit" id="search_submit" name="Search" value="Search"/>     </div>     </form>      But it doesn't seem to work, nor does it dynamically fill in the category ID which means i would have to create a new category template for each category I have. It'll be very much appreciated if anybody could help me with this, thanks.


Filtering post-formats from the loop using new WP-Query();

Hi i am currently building upon a theme that i have build previously for my blog. The following code is to point to the latest post (the featured post). As this will have a different styling than all the other posts. However. I would like to filter out the post-format: links using the WP-Query i have defined within the loop since it brings me a lot more flexibility. How would i go around doin that?                <?php $featured = new WP_Query();  $featured->query('showposts=1'); ?>                         <?php while ($featured->have_posts()) : $featured->the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" class="maintitle"><?php the_title(); ?>
                                 <?php the_excerpt(); ?>                                 <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="btn">Read more »       Best Regards Lucas


Advanced Tax Query

Below is my tax query, at the moment this returns all posts which have at least one of the specified terms. Is there a way I can have it return only posts which have **ALL** of the specified terms?               [tax_query] => Array         (             [relation] => AND             [0] => Array                 (                     [taxonomy] => services                     [field] => term_id                     [terms] => Array                         (                             [0] => 3                             [1] => 10                             [2] => 6                             [3] => 9                         )                          [operator] => IN                 )                  [1] => Array                 (                     [taxonomy] => awards                     [field] => term_id                     [terms] => Array                         (                             [0] => 13                             [1] => 12                         )                          [operator] => IN                 )              )


Custom Menus, Widgets & Conditional Statements

I'm employing custom widgets for my client because it's easy and they have several menus they need to create specific to site sections. I then want to allow them to add to the custom menu dynamically using widgets (I create the spaces needed for the widget and they drag and drop the menus into that widget bucket). I tried using the following code but when the left nav sidebar is supposed to load, the page stops loading.               if (is_page( 'sport-fitness' ) || '269' == $post->post_parent){     //menu for Sport & Fitness pages
             <?php dynamic_sidebar( 'sidebar-7' ); ?>
          }elseif(is_page( 'eat-smart' ) || '118' == $post->post_parent){     //menu for Eat Smart pages
         <?php dynamic_sidebar( 'sidebar-8' ); ?>
          }else{     //default menu          }      The custom menus need to show up on all child pages (but not the parent page because that uses a different layout). What am I doing wrong with the above? I got this to work:               if (is_page( 'sport-fitness' ) || '269' == $post->post_parent){     //menu for Sport & Fitness pages          wp_nav_menu( array('menu' => 'sport-fitness' ));          }elseif(is_page( 'eat-smart' ) || '118' == $post->post_parent){     //menu for Eat Smart pages          wp_nav_menu( array('menu' => 'eat-smart' ));          }else{     //default menu          }       But then I'm stuck without the headers that the widgets provide (which they want). For example: **SPORT & FITNESS**   * Home   * Link 1    * Link 2   * Link 3 Help would be greatly appreciated. I've been trying to figure this out for a couple days now and it's a blocker to finishing their site. TIA!


I followed this tutorial to create custom metaboxes. It seems like qtranslate enables you to use shortcodes almost everywhere. For example: Post titles:               Cheng Feng Enterprises鄭峰企業Cheng Feng Compania      Widgets:               [:en]My name is Alex Chen.          I provide Spanish-English-Chinese          translation services in Taiwan.          I'm available for hire.          [:zh]我的名字是亞歷陳。          我提供西班牙語 - 英語 - 中國          在台灣的翻譯服務。          我可供租用.      None of these methods work for custom metaboxes. Has anyone successfully integrated qtranslate with custom metaboxes?


Menu item counter in custom walker

How can I get an item counter working in a custom walker ? I need the corresponding number (not the id) of each menu item for some class names, because my elements have position:absolute and each one has its class (class_name_1, class_name_2, ...) with individual top margins. I'm not using CSS3, so I can't use the nth-child pseudo class. Thanks in advance ! EDIT: I managed to achieve this using (modified from example on codex):               if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name]))      {         $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );         $menu_items = wp_get_nav_menu_items($menu->term_id);              $menu_list = '
';         $current_item = 1;         foreach ( (array) $menu_items as $key => $menu_item )          {             $title = $menu_item->title;             $url = $menu_item->url;             $menu_list .= ''.$title.'';             $current_item += 1;         }         $menu_list .= '
';     }      else      {         $menu_list = '';     }      Anyway, a solution to do this with the walker may be useful in the future. Thanks !


Display alt text as tool tip on page

I'm using the Background Manager Wordpress plugin (http://wordpress.org/plugins/background-manager/) and I'm trying to display a custom element on the page that I have not been able to find any help on as of yet, including with their forums. The plugin outputs a full-screen background, which includes alt text, and I'm wondering if there's a way I can display the alt text on the page in a DIV? The code that displays on the page currently is:

           I can adjust the plugin to output the caption as the image title instead, if that makes it easier, but obviously I'd prefer not to change the plugin so I can allow for updates to the plugin later on. I tried adding in CSS (using `.myatu_bgm_fs:after { content: attr(alt) ; }`) to make this work, but it wasn't correct. If I can't find a solution this way, I've got an option to create a custom taxonomy along with some javascript, but I'd prefer not to go that route as it still requires a fair bit of testing compared to this pre-built plugin. Thanks for any help. **Update:** I'm thinking I must be able to use javascript to make this work, but everything I have tried has failed. One test was to use this scripting, but perhaps I'm using it incorrectly:               $('img[alt]').each(function() {         $('.inner-quote').append('
' + $(this).attr('alt') + '
');     });      **Update 2:** It turns out that javascript won't work because the image is being contained within the NOSCRIPT element. Not sure how to approach this now except to get rid of the plugin and do this another way.


Flat category URLs but retaining hierarchy?

I have the categories as follows:               - Beauty     -- Hair     -- Makeup      WP expects the URLs to be:               /beauty     /beauty/hair     /beauty/makeup      Is it possible to have the following links while still keeping the hierarchy on the backend?               /beauty     /hair     /makeup


Make display name unique

Right now you can make your Display Name whatever you want, you can even impersonate an admin. Is it possible to make the Display Name unique?


Bulk add tag (or any sort of label) to posts who have custom excerpt

The situation is the following: The blog as of now has 2200+ posts. In the beginning (2007/2008) I was using manual excerpts where I would put an image and a little bit of text. The manual excerpt (excerpt field populated with an image and text) is shown on archives and wherever wanted. However recently I decided not to use the manual excerpt (excerpt field populated with an image and text). I switched to the automatic wordpress excerpt, limit the number of words, and fetch the first image in the post (if there is any) wherever I want it. Way more flexibility that way. In order to retain the uniformity of the site I use conditional tag has_excerpt () to adjust or apply new css rules to those posts who have manual excerpt. The conditional tag checks if the post uses the excerpt field (has manual excerpt). Now I want to remove all manual excerpts (excerpt field populated with an image and text) and in the same time to label those posts (adding tag for example) in order to be able to continue to apply conditional CSS rules for those posts. For example using has_tag (). I want to do this because those posts have slightly different images than the other posts and I have to apply slightly different CSS rules for them. Now since there are thousands of posts, it would be insane to go all through them manually. I'm sure there is an easy way to do this via few SQl commands.   1. Add tag (or any other label you might think is better) to all posts who have manual excerpts (excerpt field populated with an image and text).   2. Delete the content in the excerpt field on all posts.


wordpress custom post types and permalinks

I have a custom post type called Content, that has a capability type of 'page' and is set to 'hierarchical' => true. I have two pages with the same name "Children", but they have different parents. What should i be doing differently so that WP doesnt display both of them at the same time no matter which of the two urls i go to? Here is a snippet of my code that displays the rewrite rules:               add_filter('rewrite_rules_array', 'mmp_rewrite_rules');         function mmp_rewrite_rules($rules) {             $newRules  = array();             $newRules['content/(.+)/(.+)/?$'] = 'index.php?content=$matches[2]';              $newRules['content/(.+)/?$']      = 'index.php?campus=$matches[1]';                   return array_merge($newRules, $rules);         }              function filter_post_type_link($link, $post)         {             if ($post->post_type != 'content')                 return $link;                  if ($cats = get_the_terms($post->ID, 'campus'))             {                 $link = str_replace('%campus%', get_taxonomy_parents(array_pop($cats)->term_id, 'campus', false, '', true), $link); // see custom function defined below             }             return $link;         }         add_filter('post_type_link', 'filter_post_type_link', 10, 2);              // my own function to do what get_category_parents does for other taxonomies         function get_taxonomy_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {                 $chain = '';                $parent = &get_term($id, $taxonomy);                  if (is_wp_error($parent)) {                 return $parent;             }                  if ($nicename)                     $name = $parent -> slug;                 else                     $name = $parent -> name;                  if ($parent -> parent && ($parent -> parent != $parent -> term_id) && !in_array($parent -> parent, $visited)) {                     $visited[] = $parent -> parent;                     $chain .= get_taxonomy_parents($parent -> parent, $taxonomy, $link, $separator, $nicename, $visited);                  }                  if ($link) {                 // nothing, can't get this working :(             } else                     $chain .= $name . $separator;                 return $chain;             }      The two urls are like so: /content/peoria/new-visitor/children/ /content/peoria/connect/next-generation/children/ When going to either one of those urls, it should only be the content of that particular 'page' and not the contents of both on the same page. Any suggestions? Im assuming the $newRules area needs to be redone, but id love some help with find out what thats supposed to be. Thanks!


Creating a Slider Shortcode Based on Nivo Slider

I´m new with wordpress and I need to create a slider based on Nivo library. There I would like to create the shortcode using this syntax:               [slider]     [image]http: //www .domain.com/images/1.jpg[/image]     [image]http: //www .domain.com/images/2.jpg[/image]     [image]http: //www .domain.com/images/n.jpg[/image]     [/slider]      The output code would be like this:

         This is an example of a HTML caption with a link.

       I have not so much experience with php either and I tried to do something like this:               function nivo_slider_func($atts)     {       extract(shortcode_atts(array('gallery_name' => ''), $atts));       $output = "
";       $output .= "
";       $atts = shortcode_atts(         array(           'url' => '',           'title' => ''         ), $atts);            foreach ($atts as $atts) {         $src = $atts['url'];         $title = $atts['title'];         $output .= "";       }       $output .= "

";       return $output;     }          add_shortcode( 'slider', 'nivo_slider_func' );      But it does not work correctly. Could you help me with this, please? Thanks in advance!


Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links

**Problem (Example)** : I have one custom taxonomy called "portfolios". It is tied to a custom post type called "portfolio". I create a portfolios term called Animals and another called Pets. Then I create a portfolio post called Beagle that belongs to both portfolios terms. In their respective term archives, Beagle is displayed as expected. **Question:** The permalink for the Beagle post is always `http://example.com/portfolios/animals/beagle`, irrespective of the taconomy term archive (animals or pets) in which it is being displayed. How can I make the permalink reflect the term of the current archive page? In other words, I need `http://example.com/portfolios/animals/beagle` to be the permalink on the "animals" archive and `http://example.com/portfolios/pets/beagle` to be the permalink on the pets archive - and they both send you to the same post "Beagles". **Note:** This also affects how the Prev/Next links within the post will function (more on that later). Here is the code I have so far:               add_action( 'init', 'portfolio_post' );     function portfolio_post()     {         $labels = array(             'name'          => _x('Portfolio Items', 'post type general name'),             /* The rest of the labels, right out of the codex */         );         $args = array(             'labels'              => $labels,             'public'              => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'show_ui'             => true,              'show_in_nav_menus'   => true,             'show_in_menu'        => true,              'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => get_stylesheet_directory_uri() . '/images/portfolio-icon16.png',             'capability_type'     => 'post',             'hierarchical'        => false,             'supports'            => array('title','editor','page-attributes','thumbnail','revisions'),             'taxonomies'          => array('portfolios'),             'has_archive'         => 'portfolios',              'rewrite'             => array('slug' => 'portfolios/%portfolios%'),             'query_var'           => true         );          register_post_type('portfolio',$args);     }          /* Register the "Portfolios" Taxonomy */     add_action( 'init', 'portfolios_taxonomy', 0 );     function portfolios_taxonomy() {         $labels = array(             'name'                => _x('Portfolios', 'taxonomy general name'),             /* The rest of the labels, right out of the codex */     );         $args = array(             'labels'              => $labels,             'public'              => true,             'show_ui'             => true,             'show_in_nav_menus'   => true,             'show_admin_column'   => true,             'hierarchical'        => true,             'query_var'           => true,             'rewrite'             => array('slug' => 'portfolios'),         );         register_taxonomy('portfolios', array('portfolio'), $args);     }          add_filter('post_type_link', 'portfolio_permalink_filter_function', 1, 3);     function portfolio_permalink_filter_function( $post_link, $id = 0, $leavename = FALSE ) {         if ( strpos('%portfolios%', $post_link) === 'FALSE' ) {             return $post_link;         }              $post = get_post($id);         if ( !is_object($post) || $post->post_type != 'portfolio' ) {             return $post_link;         }              $terms = wp_get_object_terms($post->ID, 'portfolios');         if ( !$terms ) {             return str_replace('portfolios/%portfolios%/', '', $post_link);         }         return str_replace('%portfolios%', $terms[0]->slug, $post_link);     }      The following URLs do what they are supposed to do:   `http://example.com/portfolios` <-- portfolio archive (archive-portfolio.php)   `http://example.com/portfolios/animals/` <-- term archive (taxonomy- portfolios.php)   `http://example.com/portfolios/pets/` <-- term archive (taxonomy- portfolios.php)   `http://example.com/portfolios/animals/beagle` <-- post (single-portfolio.php) However, making `http://example.com/portfolios/animals/beagle` = `http://example.com/portfolios/pets/beagle` continues to elude me. **Post Prev/Next Links**   If you are navigating through posts in the "Pets" archive using the prev/next links at the bottom of the posts, when you get to the "Beagle" post, the prev/next links now display the previous and next links to posts in the "Animals" archive (because of the way I generate the prev/next links and because the Beagle permailnk term is "animals"). Here is the code for the prev/next links:                   /* Previous/Next Links within primary parent portfolios taxonomy term */     $post_ids = get_posts(array(         'numberposts'   => -1, // get all posts.         'post_type'     => 'portfolio',         'fields'        => 'ids', // Only get post IDs         'tax_query'     => array(array('taxonomy' => 'portfolios', 'field' => 'name', 'terms' => $portfolio_terms[0])),         'orderby'       => 'title',         'order'         => 'ASC'     ));     $thisindex = array_search($post->ID, $post_ids);     $previd = $post_ids[$thisindex-1];     $nextid = $post_ids[$thisindex+1];     echo '
';     if ( !empty($previd) ) {        echo '
« '. get_the_title($previd) .'
';     }     if ( !empty($nextid) ) {        echo '
'. get_the_title($nextid) .' »
';     }         echo '
';      The logic above will likely have to change once the first problem is solved, but I'm not sure what it should change to. It looks like @TheDeadMedic hinted at a solution on this answer, but since the questioner was not going in that direction, it was never elaborated upon. > If you're assigning multiple categories to a single product, I can easily > change how it determines which one to use in the permalink. Thanks to reading tons of stackexchange Q/A's and some tutorial blogs over the past few days, I was able piece together what I have so far, but I've hit a wall with this problem. I appreciate any help the community can provide.


How to share post?

I found this code that will share my post in social medias but right now it share the whole page and not the individual post. How do I make it share only the individual post? I know its something with the url i the code but dont know what to change it to. This is the loop for the post.                                <?php $wp_query = new WP_Query( array(                                                      "cat" => "1",                                                      "posts_per_page" => "15",                                                      "post_type" => "post",                                                     "paged" => get_query_var('paged') ? get_query_var('paged') : 1                                                     )                                                                                );                 while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>                      <div <?php post_class(); ?>>
                             <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">                                 <h1 class="tmpost-<?php the_ID(); ?>">                                 <?php $tit = the_title('','',FALSE); echo substr($tit, 0, 150); if (strlen($tit) > 150) echo " ..."; ?>

                         <div class="tmpost-<?php the_ID(); ?>-item">

                             <?php _e('Av', 'tm_myid_text'); ?> <?php the_author(); ?>

                             I <?php $category = get_the_category(); echo $category[0]->cat_name; ?>

                             <?php the_time('M jS, Y') ?>

                     <?php if (has_post_thumbnail()) { ?>                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">                         <?php the_post_thumbnail( 'Full' ); ?>                                              <?php } else { ?>                     <?php } ?>

                         <?php the_content(); ?>

                                 <a href="<?php the_permalink() ?>" target="_blank">                                      <?php comments_number(__('(0) Kommentarer ', 'tm_myid_text'), __('(1) Kommentar', 'tm_myid_text'), __( '(%) Kommentarer', 'tm_myid_text') );?>

               <a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&text=<?php the_title(); ?>">               <a href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank">               <a href="https://plus.google.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank">                                             <a href="mailto:?Subject=Simple Share Buttons&Body=I%20saw%20this%20and%20thought%20of%20you!%20 <?php the_permalink(); ?>&text=<?php the_title(); ?>">

     <?php if ($count == 1) : ?>

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


Custom Columns WordPress Admin

I am just about finished creating custom columns through the WordPress admin panel. The custom post type I am using is called "slides". I figured out how to add the column titles and all of the column content (because they're WordPress defaults)...what I am missing is how do I add content to the "thumbnail" column? Some kind of if statement like: if admin-thumbnail exists display the admin-thumbnail image...which sounds simple enough, I just don't know how to add it to that specific column. The code I have so far is: http://pastebin.com/YfuYUW5c. Thanks, Josh


How to append text to title of Custom Post Type post (without affecting all titles on page)?

This question 'How to correctly get post type in a the_title filter' is exactly what I'm trying to achieve. I have set a filter as below but it affects all titles on the page (in the menu, sidebar and footer) rather than just the post title. Apparently I need to use the `add_filter` just before the loop and add `remove_filter` after the loop, but I'm not sure how to do this. I'm developing a plugin and am looking for a solution that does not involve making any changes in theme/template files. Love to hear any and all suggestions. Thanks               function custom_title( $title ) {         global $post;         $text = 'Extra text: ';              if ( get_post_type( $post->ID ) == 'custom_post_type' ){             return $text . $title;         }         else {             return $title;         }     }          add_filter( 'the_title', array($this, 'custom_title' ) );


How can I show these pictures in two columns in my page?

This page is long and cumbersome. I am trying to find a plugin/hack that would put the images on this page in two columns to make it a bit easier to digest. Removing the `<p>` tags doesn't seem to accomplish that. I have all of the pictures hosted on S3 to keep the bandwidth usage down (hosted on home DSL). The gallery plugins I looked are kind of confusing and I really just want something really simple. Here is a portion of my post I want to make two columns:
[caption id="" align="alignnone" width="350" caption="I 300 w/ Hitachi Alt"]               [/caption]     [caption id="" align="alignnone" width="350" caption="Hitachi mounting bracket"]               [/caption]
      Any thoughts or ideas?


Making certain categories of CPT not publicly queryable

I am developing a custom CMS for a client and one of the `Custom Post Types` is 'contact', these contacts are organized into categories by a `custom taxonomy`; my question is whether there is a way to **set only certain categories to be publicly queryable**. I only seem to be able to get solutions working where either make all posts of a certain post type non-public and not- publicly queryable or the other way around but not just those in a certain category. Some additional information as suggested by @kaiser: The custom taxonomy set up the same way normal categories are set up for posts and pages. It is just the one custom taxonomy which handles this aspect. I want to work with one custom post type only for this as i would otherwise be forced to duplicate a lot of custom fields, for example: all 'contacts' have a lot in common (contact details, etc..) but out of these 'contacts' i only want certain 'categories' to be visible and accessible from outside of admin; as an example, a contact with category 'artist' should show publicly and show up in category and sitemap pages but not those under 'providers'. I do not wish to use multiple CPTs or multiple taxonomies if i can avoid it. Thank you all for your input.


wp_count_posts, wp_count_terms and wp_count_comments for specific user?

Is there a way for the functions `wp_count_posts`, `wp_count_terms` and `wp_count_comments` to return their results only for a specific user, possibly by using a user's `ID`? I'm making a custom "Right Now" dashboard widget for a custom post type and I need it to show data for the current user only, not for the whole site. Thanks in advance. * * * **EDIT** : In response to @kaiser 's comment below, I did the following, but nothing's happening - the results are the same as when the filter is out (which should not be the case - checked that this user has a different number of published `employee` post types). It seems that the code inside my function is not even being called at all coz it's not outputting the test `echo` statement inside it:               <?php          // employer right now widget     wp_add_dashboard_widget('dashboard_right_now', __('Right Now'), 'employer_dashboard_right_now');     function limit_to_current_user( $where ) {         global $wpdb, $current_user;         $current_user_ID = (int) $current_user->ID;              $new_where = $wpdb->prepare(              $where . " AND post_author = %s "             ,$current_user_ID );              var_dump($new_where); // not dumping anything, not even string(0) "" and no errors reported whatsoever, even in php_error_log              return $new_where;     }     function employer_dashboard_right_now() {              // modify query to limit to current user         add_filter('posts_where', 'limit_to_current_user');         // execute queries         $num_employees = wp_count_posts('employee');         $num_comm = wp_count_comments();         // remove filter         remove_filter('posts_where', 'limit_to_current_user');              // more code here...          }          ?>


Media library only show 2 items per page?

For some reason WordPress media manager is only showing 2 images per page? This is happening on 2 separate sites now and I can't get rid of it. Is there a way to manipulate items per page for the wp-admin media library?