Inserting ads into wordpress default rss feeds

i'm hoping i'd find some help in regards to inserting ads into wordpress default rss feeds (i do not use feedburner)               <?php     function insertAds($content) {         $content = $content.'
Have you visited WpRecipes today?
';         return $content;     }     add_filter('the_excerpt_rss', 'insertAds');     add_filter('the_content_rss', 'insertAds');     ?>      Source here But i read that the_excerpt_rss and the_content_rss is kind of deprecated. Can anyone advise me on the present hooks to use? Thanks


Override default jquery ui library with newer version

The latest version of jquery ui core fixes a bug that's on my site. The problem is that Wordpress comes with an earlier version. How do I override the default jquery ui core? One solution I've found is to edit the script-loader.php file in wordpress includes folder but I don't want to touch the WordPress core unless I have to. Below is the core change that worked that I want to avoid.               $scripts->add( 'jquery-ui-core', '/wp-content/themes/themefolder/jquery.ui.core.min.js', array('jquery'), '1.9.2', 1 );


Make Profile link, link to the BuddyPress profile instead of the WordPress dashboard?

I am using the plugin Sidebar Login for BuddyPress which enables users to insert a login box in the sidebar which in turn produces three links: Dashboard, Profile, and Logout. My issue is that the Profile link, links to the WordPress dashboard. I would like it to link to the actual BuddyPress profile page. Is there any way I can change something in `sidebar-login.php` or `admin.php` to remedy this problem? I have pasted `sidebar-login.php` here: http://pastebin.com/V2v1t4gm I have pasted `admin.php` here: http://pastebin.com/6KjxeZ3h


Filer taxonomy posts by current category

I have a custom taxonomy 'where' and I am using this code to get taxonomy terms on single.php               <?php echo get_the_term_list( $post->ID, 'where', 'Where: ', ', ', '' ); ?>      How can I customize this code in a way if user click on 'where' terms, they should get posts of this taxonomy only from the current category.


How do I create a template page with a specific widget as the content?

I have installed a widget so that I may add testimonials. This widget cycles through the testimonials in the sidebar and everything is fine. What I now want to do is create a testimonials page that retrieves all the entries from this widget. The functionality already exists in the widget to retrieve all the testimonials, however I cannot find a way to get the widget explicitly. I have tried the_widget() but cannot work out what the widget's PHP class name is. Is there another way of grabbing this widget? [edit] @user8982, thank-you for your suggestions, however this is not what I require.   * I am using Wordpress V3.2.   * 1, The plugin I am tring to access is 'Testimonials Widget' by   'j0hnsmith'.   * I am using a custom theme. I have already created a template file. I have a testimonials widget registered in the main sidebar. I would like to, in my template, retrieve this widget (as an object preferably) and have it echo every testimonial instead of showing/hiding them one at a time.


Code needs wrapper/container to put footer back in, but where?

A previous developer made some huge messes, most of which I have fixed over time. The last problem, though, has to do with properly getting a footer in there, which he deleted. I believe if I can get some assistance here understanding where to reposition elements from the body back into header (which I'm almost sure is necessary) and then what to put a container or wrapper around in the body/main page templates (he set them all up exactly the same, so fixing one will allow me to then go fix all), I can then take care of the other problems of preset height for pages and absolute positioning for footer, when it should be relative, and so on. So, my focused question is, where could I put a wrapper/container around code in the body, so I can then go do the other relevant changes that will make dynamic height of the pages, and allow me to put "get footer" back in my template.php files, to be relatively positioned? My apologies if I'm not posting correctly. Another developer directed me here. First time here , and I'm not sure of the protocols, including how much info to post to get a Q answered, and how to post code. Many thanks for your help and patience. This is the site: www.voltrek.com. Here is the last few lines of the header.php and then the code for one of the templates, in this case the Home page, that are all done the same. Also, Simple Sidebar Navigation is used for page hierarchy. Header (last few lines) > >     <?php wp_head(); ?> >      >     <body <?php body_class(); ?>> >   >
 >     <?php if ( !function_exists('dynamic_sidebar') || > !dynamic_sidebar('Simple Top Nav') ) : ?> <?php > endif; ?> >   Homepage template                `get_header(); ?>
          <img class="voltrek_site_top_section" src="<?php echo (get_template_directory_uri() . '/images/voltrek_site_top_section.png');  ?>" alt="" />                    <a id="voltrek_site_contact" href="<?php echo get_permalink(463); ?>">Contact us                         <img class="voltrek_homepage_photo" src="<?php echo (get_template_directory_uri() . '/images/voltrek_homepage_photo.jpg');  ?>" alt="" />

                           <?php include("voltrek_page_hierarchy.php"); ?>                    <?php the_secondary_content(1)?>

                           <?php the_secondary_content(2)?>

                           <?php the_secondary_content(3)?>

                 </html`


Is there a way to order posts and custom post types as one group?

I have tried several plugins which seem to purport to do this (like this one), but they either don't or are very poor in their implementation and cause problems (the one linked seems to randomly select. I have a WP_Query in my index.php as follows:               <?php     if ( get_query_var('paged') ) $paged = get_query_var('paged');       if ( get_query_var('page') ) $paged = get_query_var('page');          $query = new WP_Query( array( 'post_type' => array('post','secondposttype'), 'paged' => $page ) );          if ( $query->have_posts() ) : ?>      As such, my homepage displays ordinary posts and posts from the custom post type "secondposttype". I am also using conditional count scripts, so I can customise what appears, etc:               <?php if ($count == 1) : ?>      The solution we currently use is the Q2W3 Post Order plugin, which works great if there is just _one_ post type. I have tried automatically adding a custom taxonomy value to new posts/custom post type posts, querying that custom taxonomy in my index.php and then using Q2W3 Post Order to order posts within that taxonomy, but it simply doesn't work (plus, this feels much more hacky than it should be). My question is: is there a way to order posts and custom post types as one big list? Such that, when I query them like above, I can order how they are displayed? I would find it hard to believe that wanting to do this is a rare occurrence. **EDIT:** I'm going to give an example of what I want to do. I want to display posts and posts from the second post type on the homepage through one WP_Query. And I want to be able to control it that so the order could go like this:   1. Post 1 from "post" post type   2. Post 1 from "secondposttype" post type   3. Post 2 from "secondposttyle" post type   4. Post 2 from "post" post type   5. Post 3 from "secondposttype" post type And then, on another day, I might want the order to be:   1. Post 3 from "secondposttype" post type   2. Post 1 from "post" post type   3. Post 2 from "post" post type"   4. Post 1 from "secondposttype" post type   5. Post 2 from "secondposttype" post type There are plugins which order one post type, so that you can decide which post appears first, second, third, fourth, etc. I just want to be able to group posts and some other post types so that not only do they appear in one stream (which is possible through WP_Query) but that they can be ordered in whatever order and that posts and posts from the second post type are treated as one and the same for ordering purposes.


include a post unrendered into a post, then render the whole thing

With a few extra lines in my functions.php I've created a shortcode that lets me include the content of a post:               function include_content( $atts ) {       $id = (int) $atts['id'];       if ( ! $post = get_post( $id ) )         return '';       return apply_filters( 'the_content', $post->post_content );     }     add_shortcode( "include", "include_content" );      Now, if I make a posting like               A few weeks ago I published an epic statement: [include id="345"]      WP generates
A few weeks ago I published an epic statement:
FTW!
     just my 2 ¢

      So, obviously the content of the old post is wpautop'ed before it's included. If simply returning $post->post_content, that content would end up unrendered (i.e. no `<br />`) within the outer posting. Now, how can I get rid of the paragraph tags around the imported post, i.e. how can I do the include first and wpautop the whole thing after? Any code improvements are welcome, too! Thanks!


Turning off trackbacks & comments

We have a few different websites running various versions of Wordpress that have comments and trackbacks turned off, yet I still receive emails saying there's some waiting for me! I've turned them both off in the admin area and also removed the comments box completely yet I still get them, how can I fully turn them off?


Can I bind a post_type='post' category to a custom post_type category?

I am using an automation solution to pull my videos into a category. It seems the automation solution cannot account for custom post types and custom post type categories, so I'm having to send all of my video content to a normal category. How can I still take advantage of my theme's custom post types? Is there a way I could do some hard wiring? Or is there a plugin that will help me connect the two? _Edit_ This is as far as I was able to get with automating the solution programatically (but you can see, this depends on the taxonomy name of the custom-post-type-category being standardized as 'taxonomy_uniquename'):               //insert rss item into database store        $post = array(               'post_author' => $campaign_author[$key],         'post_category' => $cat,          'post_content' => $description,          'post_date' => $date_placeholder,         'post_date_gmt' => $gmt_date,         'post_name' => $permalink_name,         'post_status' => $post_status,          'post_title' => $title,         'post_type' => $campaign_post_type[$key],         'tags_input' => "$tags",         'original_source'=> $link     );       $post_id = wp_insert_post( $post, $wp_error );          //echo $wp_error; exit;     if ($campaign_post_type[$key]!='post'||$campaign_post_type[$key]!='page') {         wp_set_object_terms($post_id,intval($cat[0]),"taxonomy_$campaign_post_type[$key]");     }


Changing Tag, Changes Category in Custom Post Type

I have a custom post type called recipes. Then, I have a taxonomy called r_cat which is to show the categories, such as Diabetic Diet Recipes, etc. I also have tags. What is happening, if I try to change the recipe category name and slug, it also changes the tag name and slug. So, they are linked? Do I have something in the setup of the CPT or taxonomy that causes the taxonomy category and tag to be one and the same? Here is my code:               add_action('init', 'cptui_register_my_cpt_recipes');     function cptui_register_my_cpt_recipes() {     register_post_type('recipes', array(     'label' => 'Healthy Recipes',     'description' => '',     'public' => true,     'show_ui' => true,     'show_in_menu' => true,     'capability_type' => 'post',     'map_meta_cap' => true,     'hierarchical' => false,     'rewrite' => array('slug' => 'healthy-recipes', 'with_front' => false ),     'query_var' => true,     'has_archive' => true,     'supports' => array('title','editor','custom-fields','thumbnail','page-attributes','post-formats'),     'taxonomies' => array('post_tag','r_cat'),     'labels' => array (       'name' => 'Healthy Recipes',       'singular_name' => 'Recipe',       'menu_name' => 'Recipes',       'add_new' => 'Add Recipe',       'add_new_item' => 'Add New Recipe',       'edit' => 'Edit',       'edit_item' => 'Edit Recipe',       'new_item' => 'New Recipe',       'view' => 'View Recipe',       'view_item' => 'View Recipe',       'search_items' => 'Search Recipes',       'not_found' => 'No Recipes Found',       'not_found_in_trash' => 'No Recipes Found in Trash',       'parent' => 'Parent Recipe',     )     ) ); }          add_action('init', 'cptui_register_my_taxes_r_cat');     function cptui_register_my_taxes_r_cat() {     register_taxonomy( 'r_cat',array (       0 => 'recipes',         ),         array( 'hierarchical' => true,         'label' => 'Recipe Categories',         'show_ui' => true,         'query_var' => true,     'rewrite' => true,     'show_admin_column' => false,     'labels' => array (       'search_items' => 'Recipe Category',       'popular_items' => '',       'all_items' => '',       'parent_item' => '',       'parent_item_colon' => '',       'edit_item' => '',       'update_item' => '',       'add_new_item' => '',       'new_item_name' => '',       'separate_items_with_commas' => '',       'add_or_remove_items' => '',       'choose_from_most_used' => '',     )     ) );      }      Thanks for any help. I'm so hope its an easy fix??


Why in my theme I can't see all the statics content under the posts?

I am pretty new in PHP and I have the following problem, I am developing this WordPress problem: http://onofri.org/WP_BootStrap/ As you can see it is shown the unique post present on my blog (the one named Hello Wordl) but under it the rest of my theme is not shown. This is the code of the page and how you can see under the shown post there are many other static information that have to be shown:               <?php get_header(); ?>

Lorem ipsum dolor sit amet

                         consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et...

Lorem ipsum sit dolor

                             Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.
                          Acquista il pacchetto

Lorem ipsum sit dolor

                             Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.
                          Acquista il pacchetto

Lorem ipsum sit dolor

                             Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.
                          Acquista il pacchetto

                  <?php                 if ( have_posts() ) :                     // Start the Loop.                     while ( have_posts() ) : the_post();                              /*                          * Include the post format-specific template for the content. If you want to                          * use this in a child theme, then include a file called called content-___.php                          * (where ___ is the post format) and that will be used instead.                          */                         get_template_part( 'content', get_post_format() );                          endwhile;                     // Previous/next post navigation.                     twentyfourteen_paging_nav();                      else :                     // If no content, include the "No posts found" template.                     get_template_part( 'content', 'none' );                      endif;             ?>
Ultimi Articoli

                                      <time datetime="2010-11-10" pubdate>                         10/11/2010                     </time>
FIRST POST TITLE

                     POSTS CONTENT
                                           <address>                         MY NAME                     </address>

Ultimi lavori

Il nuovo sito di HTML.it

                             Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

                             Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus etiam sem...

                             Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

                                 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
                             Marco Rossi Direttore Marketing

Lorem.com

                             Click per ingrandire

Lorem.com

                             Click per ingrandire

Lorem.com

                             Click per ingrandire

Lorem.com

                             Click per ingrandire

News e aggiornamenti

Lorem ipsum

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                             Leggi tutta la news

Lorem ipsum

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                             Leggi tutta la news

Lorem ipsum

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                             Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                             Leggi tutta la news

                                 Lorem ipsum

                                 Sit dolor

                                 Adipiscing nunc

                                 Condimentum diam

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                     Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

                                     Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus etiam sem...

                                     Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper. Donec eget orci metus, ac adipiscing nunc. Pellentesque fermentum, ante ac interdum ullamcorper.

                                     Vivamus imperdiet condimentum diam, eget placerat felis consectetur id. Donec eget orci metus, ac adipiscing nunc.

                                     Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

                                     Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus etiam sem...

                                     Donec id elit non mi porta gravida at eget metus id elit mi egetine. Fusce dapibus, tellus ac cursus comodo egetine metuss gorp.

Servizi e offerte

Opzione Free

                                 Gratuito

                                 Dapibus ac facilisis in

                                 Morbi leo risus

                                 Porta ac consectetur ac

                                 Vestibulum at eros

                                 <button class="btn btn-success btn-block btn-round-bottom" type="button">                                     Abbonati                                 </button>

Opzione Pro

                                 € 5.99 al mese

                                 Dapibus ac facilisis in

                                 Morbi leo risus

                                 Porta ac consectetur ac

                                 Vestibulum at eros

                                 <button class="btn btn-success btn-block btn-round-bottom" type="button">                                     Abbonati                                 </button>

Opzione Super

                                 € 9.99 al mese

                                 Dapibus ac facilisis in

                                 Morbi leo risus

                                 Porta ac consectetur ac

                                 Vestibulum at eros

                                 <button class="btn btn-success btn-block btn-round-bottom" type="button">                                     Abbonati                                 </button>

          <?php get_footer(); ?>      In the previous code this is the section that show my posts into the homepage:               <?php         if ( have_posts() ) :             // Start the Loop.             while ( have_posts() ) : the_post();                      /*                  * Include the post format-specific template for the content. If you want to                  * use this in a child theme, then include a file called called content-___.php                  * (where ___ is the post format) and that will be used instead.                  */                 get_template_part( 'content', get_post_format() );                  endwhile;             // Previous/next post navigation.             twentyfourteen_paging_nav();              else :             // If no content, include the "No posts found" template.             get_template_part( 'content', 'none' );              endif;     ?>      But, as you can see, all the static contents that are situated under this PHP code is not shown (if I delete this part of code it work well and I can see the last part of my theme) Do you have some idea about how can I solve this problem? What am I missing? Tnx Andrea


Initial wordpress deploy via git

Currently, I've got my local machine setup and pushing to staging via git. There are cases where I upload images locally to test admin page interaction. In my `.gitignore` file I'm ignoring everything but the theme and plugin folders. I'm curious as to how you handle the initial push to a staging server. Namely the uploads folder. Do you push everything, then modify the `.gitignore` file to not show uploads? Just trying to perfect my process. Any insight would be helpful.


Function to erase every post from a taxonomy

I'd like to have a piece of code that erase every single post from a taxonomy of a post type when triggered. How can I do it? Thank you.


How to get thumbnail from post attachment in this loop

I use this code to display Most popular posts based on view count, but I dont have images in post content I have all images attached to post via attachment (gallery) How to replace this "thimthumb" thumbnail with first attachment of this listed posts?
                 <?php _e('
Popular
','iphoto');?>
                 <?php                 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                 $args = array(                     'meta_key' => 'views',                     'orderby'   => 'meta_value_num',                     'paged' => $paged,                     'order' => DESC,                     'showposts' => 9                 );                 query_posts($args);                     while (have_posts()) : the_post();                     $output = preg_match('//i', $post->post_content, $imgs);                      $cnt = count($imgs);                 ?>
                 <?php if ( $cnt > 0 ) {  ?>                 <a class="same_cat_posts_img" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php echo '';?>                 <?php } else {  ?>                 <a class="same_cat_posts_img" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img alt="<?php the_title(); ?>" src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php bloginfo('template_url'); ?>/images/default.jpg&w=60&h=60&zc=1" />                 <?php } ?>
                 <?php endwhile; wp_reset_query(); ?>


Create a Seperate widget for both Tags and TagsCloud?

Is it possible to create a seperate widget for "Tags" and "TagsCloud"? This question is similar, however how would you make 2 seperate widgets for "Tags" and "TagsCloud"? The difference is class would be called "tags" instead of "tagscloud" and the default settings for wp_tag_cloud() would have the same size no matter how many posts? How do I display a tag cloud with both post tags AND a custom taxonomy?


Jigoshop search taxonomy

I was wondering does anyone know how I can modify the search so it searches a taxonomy? at the moment it just looks for a product title, but not the taxonomy assigned to the post. Please help


Custom WP Query from meta_value stored as serialised array

I'm using a Magic Fields 2 multicheck box to store Services which can be assigned to Case Studies. The data is stored as a serialised array in WordPress, and I need some help to extract the "related posts". I know that you can't simply use the array as the meta_value (WordPress simply doesn't support it) so I have to use multiple loops or add custom code within the loop. This is the code I have so far:               <?php     $related_case_study_args = array(         'post_type' => 'case-studies',         'posts_per_page' => '-1',       // get all posts     );          $related_case_study_loop = new WP_Query($related_case_study_args);          if ( $related_case_study_loop->have_posts() ) :           ?>
See Related Case Studies:
          <?php          while ( $related_case_study_loop->have_posts() ) : $related_case_study_loop->the_post();          ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
          <?php          endwhile; endif;     wp_reset_query();          ?>      which works fine and pulls in each of the Case Studies. On each Case Study, there are individual services this needs to filter by. How can I get the meta_value, extract it and only display entries which are related? I've tried using this code inside the "while" statement just to see if the data is returned correctly, but without any success:               // returns an array as this is a multicheck field in Magic Fields 2     $services = get_post_meta($post->ID, 'services', true);          // foreach item in the array     foreach ($services as $service) {         if ( sanitize_title($service_title) == sanitize_title($service) ) {             echo '
' . esc_attr($service) . '
';              }     }      Any help here would be appreciated! Many thanks, James


How to create a page template that display posts with a certain category in the Genesis Framework?

I know how to to create this kind of templates. Usually, I just start a custom WordPress loop. But when I checked a template file in the Genesis Framework I saw this: **page_blog.php:**               <?php          /*           WARNING: This file is part of the core Genesis framework. DO NOT edit           this file under any circumstances. Please do all modifications           in the form of a child theme.           */                    /**           * Template Name: Blog           * This file handles blog post listings within a page.           *           * This file is a core Genesis file and should not be edited.           *           * @category Genesis           * @package  Templates           * @author   StudioPress           * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)           * @link     http://www.studiopress.com/themes/genesis           */          genesis();      This is the Blog Page and I'm puzzled. How do I create a template that lists posts with a certain category?


Is it necessary to use Timthumb in Wordpress 2.9+?

as Wordpress 2.9 comes with built in post thumbnail features, is it necessary to use Timthumb ? if yes specify


How to add a WYSIWYG text editor to the Category Edit Screen

I've been working lots with categories lately, what with the increased awareness and demand for themed or silo'd site structures. To that end, I'm looking to enhance my category landing pages by relabeling the "Description" field as "Summary Description" and adding a new field called "Detailed Description". I will be using the "Summary Description" field on my category index page (a listing of all my site's categories) and I want to use this new "Detailed Description" field to show on the landing page for each category. So I need a rich text edit field added to the Category Edit Screen. Does WordPress make it easy to create an instance of a rich text edit field, perhaps pulling a light version of the post/page editor? I probably don't need a toolbar, but it might be nice to have some basic formatting buttons like B, I, U, hyperlink, etc...


Function to check if custom page is used by page?

I have template-clientlist.php now I search on wordpress doc but can find a function on how to check if page used template-clientlist.php               template-clientlist.php          <?php     /*     Template Name: Page Of Posts     */     ?>      Is there function that exist or custom function to check if page used the custom template?


Wordpress MU users - how are they organized?

WP and WP MU are a bit different, for example in users. I'm not sure that I understand user functionality correctly. Tell me please what are the differences between WP and WP MU users? For example I know that MU-users register only once on the main site of a network (ie they shouldn't register on each subsite). Also I know that a user can eighter have or not have a subsite. And know that there is a possibility to add a user to a certain subsite. It seems that's all I know :) Is it possible for user to register oneself on a certain subsite (but not only in the network in general) to be already automatically assigned to a certain subsite right after registration? How? What is a possibility to add a user to a certain subsite for? Can I delete a user from a certain site? And so on...


Temporary redirect Original wordpress to subfolder to create new site on root location?

I'm going to update the Wordpress site of my brother-in-law, within 2 weeks and I want to move his current site to a subfolder, while all users can still visit his website through `http://domain.com/`. While that redirect is active, I want to have a new Wordpress website be located at the rootfolder on the server, but accessible through a different link, such as `http://beta.domain.com`, but all files, such as images, should be either relative (`/wp-uploads/...`) (preferred, I guess?) or point to `http://domain.com/wp-uploads`, where the site actually is located and will move to when all is done. Though.. I got a slight clue how to do it.. But rather get informed by you guys. Please advice me how I can handle this current and new site-situation, that should have an easy 'migrate-when-ready' property, the best way. Thanks! **_My thoughts_**   _Current website: Set at`WP-settings` the site-url to `http://domain.com/`, but Wordpress URL to `http://domain.com/temporary`;   New website: Set at `WP-settings` the site-url to `http://domain.com/beta`, but Wordpress URL to `http://domain.com/`._ _I'm unsure if that's all I got to do, don't I?_


Implementing action correctly

Hi I am implementing a core plugin plus add ons. There is a settings page and I would like to hook some validation routines for the addon plugin into the core plugin's validation function. However it's not working. Can you point me in the right direction? Here's an excerpt of what I have:                   register_setting( 'myp_settings', 'myp_settings', 'myp_settings_validate' );              function myp_settings_validate( $input ) {           $options = get_option( 'myp_settings' );           do_action( 'myp_settings_validate', $input, $options );           return $options;         }      The above is in the core plugin's code, while the below is in the addon plugin:               add_action( 'myp_settings_validate', 'myp_settings_et_validate', '', 2 );          function myp_settings_et_validate( $input, $options ) {              if ( ! isset( $input['excerpt_enable'] ) || $input['excerpt_enable'] != '1' )         $options['excerpt_enable'] = 0;         else         $options['excerpt_enable'] = 1;              if ( ! isset( $input['thumbnail_enable'] ) || $input['thumbnail_enable'] != '1' )         $options['thumbnail_enable'] = 0;         else         $options['thumbnail_enable'] = 1;              return $options;     }


Display deepest post category, when post have multiple categories

I want to display the direct category ancestor of a given post. An illustrative example: These are the categories I have:                Cat1      Cat2       Cat2.1        Cat2.1.1        Cat2.1.2       Cat2.2        Cat2.2.1        Cat2.2.2       Cat2.3      Cat3       Cat3.1        Cat3.1.1      Cat4      I check the whole trailing, like in:                 Cat1       [X]Cat2         [X]Cat2.1             Cat2.1.1          [X]Cat2.1.2 <-my post            Cat2.2             Cat2.2.1             Cat2.2.2            Cat2.3       [x]Cat3<         [x]Cat3.1          [x]Cat3.1.1 <-my post          Cat4      So I have `'my post'` assigned to a multiple categories. Lets say I am navigating to `'my post'` like this : `Cat3->Cat3.1->Cat3.1.1->my post`. Now, in the single post page, I want to display the name of the direct category ancestor of `'my post'` (`Cat3.1.1` in this case). But the question is how to do this?


Any examples of adding custom fields to the category editor?

I think I'm pretty close to cracking this nut :) I'm trying to add a set of custom fields to the Category editor. Since I'm not dealing with post meta, I believe I'll be writing my custom category field values to the wp_term_taxonomy table rather than the wp_options table. Is this correct? If there are any examples of how to do this, please share a link or bit of code. I'm not sure how to capture and save my custom category fields. Here's my code...               //add the hook to place the form on the category editor screen     add_action('edit_category_form','ce4_category_admin');          //Adds the custom title box to the category editor     function ce4_category_admin($category){         echo "category: ".$category->term_id; //great, I got a reference to the term_id, now I need to get/set my custom fields with this key         ?>

                 Full Category Title	                 <input name="_ce4-categoryTitle" id="_ce4-categoryTitle" type="text" size="40" aria-required="false" value="<?php echo get_taxonomy($category->term_id, '_ce4-categoryTitle'); ?>" />
The title is optional but will be used in place of the name on the home page category index.

                 Full Category Text for Landing Page	                 <textarea style="height:70px; width:100%;margin-left:-5px;" name="_ce4_fullDescription" id="_ce4_fullDescription"><?php echo get_taxonomy($category->term_id, '_ce4_fullDescription'); ?></textarea>
This text will appear on the category landing page when viewing all articles in a category. The image, you supply above, if any, will be used here and this content will wrap around it.

     <?php     }          //How to save the custom field data? Normally I'd use..     //add_action('save_post', 'custom_save_function');     //but this is not a post, so perhaps there's another method?


Give access of horizontal scroling plugin to user role editor

How do i give access to user role editor without using any plugin using bellow function               function HSA_add_to_menu()               {                  add_options_page('Horizontal scrolling announcement',  __('Horizontal Scrolling', WP_hsa_UNIQUE_NAME), 'manage_options', 'horizontal-scrolling-announcement', 'HSA_admin_options' );              }


How long is "as long as possible" in wp_cache_set()?

The documentation for `wp_cache_set()` says that if you pass in 0 for `$expire` (which is also the default), then it is cached for "as long as possible". How long is this? What determines it? Are we talking hours, days? In my case: I have a _very_ expensive SQL query on a multisite network of literally 100s of blogs, the result of which could be cached for weeks (really forever - could just manually flush it when needed). Should I use WordPress's cache or sort something out myself?


Next/Previous links doesn't work in the same category

I created a category and call it "Blog". Then I created some posts and assign "Blog" as category for the posts. So I'm trying to go to previous/next into the same category and doesn't work. Here is my code:                        <?php previous_post_link('%link', __('← Previous'), TRUE); ?>         <?php next_post_link('%link', __('Next →'), TRUE); ?>           None of the links is being displayed even if I have more than one post created. If I remove the TRUE value then it goes to other categories. What am I doing wrong?


Custom terms inserting as single string with commas, not separated

I have a front end form, one of the inputs asks for a comma separated list of keywords which should each end up being a custom term, I just saw in the backend the terms are entered as single string with the commas and not individually. My code is below, how can I turn the string ie; term1,term2,term3 which may be entered in the input to 'term1','term2','term3' which is what the format looks like it needs to be to insert each keyword as a unique term? I've tried both with `wp_insert_post` and `wp_set_object_terms`               $keywords = $_POST['keywords'];          $new_post = array(         'post_title'    => $title,         'tax_input'    => array( 'keyword' => array( $keywords ) ),         'post_status'   => 'publish',         'post_type' => 'test'     );          $nonce = $_POST['nonce'];      if ( ! wp_verify_nonce( $nonce, 'form-nonce' ) ) {          die( 'Security check' );       } else {         $pid = wp_insert_post($new_post);         //var_dump($new_post);              //wp_set_object_terms($pid,$keywords,'keyword');      }         wp_redirect( get_permalink($pid) );          //echo $pid;         exit();


Data Validation

I'm using Wordpress as CMS and have a checkout page where info is inserted into the db using $wpdb->insert. I have 2 questions:   1. Is 'sql injection' already a part of that function or do I need to add my own code?    2. Are there wordpress form input validation functions that I can use on my custom form?


Does WordPress have fine-grained view permissions?

I am considering using WordPress for a number of users in overlapping groups, e.g. a user may be in group A and group B, or only group A. Is it possible to use WordPress to limit access to particular Pages. e.g. Only members of group B can view this page, only members of groups A and C can view that page. Would this permission extend to the menu item linking to the page? (e.g. if user can't view page, they can't see the menu tab/menu item)


How do I search inside specific taxonomies in Wordpress

I am trying to search for posts in specific taxonomies but any time I search, I get results from all the other pages instead of Wordpress searching within the selected category in the taxonomy. I named my taxonomy: "publication_categories". It contains all categories for a custom post type which I named "publication". This is the code I have for my custom-search.php:               <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">     <div class="alignleft">     <select name="taxonomy">     <option value="0">Select...</option>     <?php     $theterms = get_terms('publication_categories', 'orderby=name');     foreach ($theterms AS $term) :         echo "<option value='".$term->slug."'".($_POST['publication_categories'] == $term->slug ? ' selected="selected"' : '').">".$term->name."</option>\n";     endforeach;     ?>     </select>     </div>     <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" class="searchinput" />     <input type="submit" id="searchbutton" value="Search" class="btn" />     </form>


exclude ids through post__not_in

I am trying to make a function and exclude in the post query that way im able to define the id's in my function but it is only excluding 1 post instead of the 4 it is returning. any suggestions on how I can go about successfully executing this? ### function in the functions.php file               function slider_exclude(){         $exclude_query = query_posts(array('showposts' => 4, 'cat' => 'news',));         foreach($exclude_query as $post_ids){             return $post_ids->ID.',';         }     }      ### my loop               $args = array(         'post__not_in' => array(slider_exclude()),         'post_type' => 'post',         'posts_per_page' => 15,         'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)     );     query_posts($args);


I have a WordPress site and all the time the /wp-login.php was brute-forced to get the admin's password. I changed the address of the login page and now wp- login.php is and empty file which is not processing brute-force post requests. Question: **What useful can be done with brute-force post requests?** For example can I send these post requests back to their IP and load their servers instead of mine? Or something else? Maybe somebody have some interesting ideas about it? Or maybe somebody can share resources about it?


Customizing the dashboard page or post overview

What would be the best way to add some basic HTML to the page overview (edit.php)? Basically I want to add some text, like a meta box, to explain some things about the page system to my multisite users. Found the answer thanks to the solution provided by OleVik. Here's a few more resources on the topic: How to show an urgent message in the WordPress admin area Plugin API/Action Reference/admin notices


How do display simple page for printing product info?

I'm using WP 3.1.2 and latest e-commerce plugin. Now I'm stuck at creating simple page for printing product info. It has to be only product information with not WordPress header and footer. The pop up window appears nicely but now I need to check against something in header and footer files to when not to display them. I can't check by post id cause then I need to edit it every time new product is added. And I can't add GET parameter to URL cause then WP e-commerce plugin doesn't show product, instead it displays products page. How can I possibly do this?


mod-rewrite exception? keep #hash in matching urls?

Hey guys, My WordPress permalink structure is set to `/%postname%/. When I create a page with a name "FAQs" the permalink generated is "mydomain.com/faqs". When I link to this page in my code (hardcoded) like this... `<a href="<?php bloginfo('home'); ?>/faqs#b" title="FAQ's">FAQs` (pay attention to the #b hash at the end) ...wordpress somehow automatically notices that there is a page `/faqs` and replaces `/faqs#b` just with `/faqs` (without the hash). Is there a chance I can write a kind of exception to my .htaccess file so WordPress doesn't do that? Any idea how I could make that work?


Huge amount of queries on my site

My site is reaching CPU limits all the time, I just ran Debug Queries and got more than 4000 queries, no wonder site is slow.


Defining the same price to all WooCommerce Products

All of my products on my site are $1 and during an import I did using WooCommerce import it didn't save all the _regular_price & _sale_price values, so there is no way for the user to buy that product. Is there a mysql query that can go through and apply a value to all of the nulls to the $1 value?


Sticky post for all pages and categories

I want to have a sticky post for all my pages and categories. The choice of "sticky post" in the edit post, didn't work. I found many pieces of code but I haven't the result that I want. I prefer to implement coded and not with a plugin. Any help? Thanks in advanced.


Sort comments by karma

I'm using the plugin comments rating (thumbs up - thumbs down) on my comments template. It stores "karma" in the db column "comment_karma" in comments table. I am looking for a way to sort wp_list_comments by higher karma to lowest. Have tried something like               <?php wp_list_comments('callback=mu_custom_callback&orderby=comment_karma&order=DESC') ?>      but it's not working. thanks **UPDATE** I got it working placing in functions.php `               function comment_comparator($a, $b)         {             $compared = 0;             if($a->comment_karma != $b->comment_karma)             {                 $compared = $a->comment_karma < $b->comment_karma ? 1:-1;             }             return $compared;             }      and in comments.php               global $wp_query;         $comment_arr = $wp_query->comments;         usort($comment_arr, 'comment_comparator');         wp_list_comments('callback=gtcn_basic_callback', $comment_arr);      Found on this website


How to make search engine index PDF files?

I'm looking for a plugin or a idea so that my WP 3.1 search engine can index PDF files. Has anyone be through that need too ? Thanks !


Plugin or theme that sort posts as 'top this year' and 'top last month"?

Is there any free WordPress plugin or theme that sort posts as 'top this year' and 'top last month" or 'top 24 hours' based on voting? I'm using the Vote It Up plugin right now. But it doesn't have the capability of sorting post as a loop. Any suggestions?


Q&A functionality with a plugin?

I want to know whether someone knows of some plugin which can insert question answer functionaily just like MakeUseof? I want this functiolity in an existing site, not some standalone theme floating around in the market. Or any detailed explaination how with multiple plugins this can be acheieved. I want much simmillar facility as on the makeuse of site. With tabs like most popular, unanswered etc.


do_shortcode doesn't work on some pages

Im using Artiss Currency Converter to convert some numbers on my website. Im trying to out put `do_shortcode('[convert number=1 from="aud" to="jpy"]')` in 2 pages. One is a template page in `mythemefolder/newtemplate.php` and the other is in `mythemefolder/functions/single_product.php` `do_shortcode('[convert number=1 from="aud" to="jpy"]')` works Perfect in `newtempalte.php` but it doesn't seem to work in `single_product.php`. Why is that? How can I fix it and does it matter where the php file is for `do_shortcode` to work? This is the funciton in single_product.php                   function cps_ajax_search($meta_boxes){         $posts = cps_search_posts();?>          <?php get_template_part("sidebar-left-common");?>          <?php require_once(TEMPLATEPATH."/functions/var/default-box-one.php"); ?>

             <?php  'Home »';?>              <?php cps_breadcrumbs(); ?>

      <?php _e('Sort By:','language');?>     <?php cps_sort_by('miles') ?> -      <?php cps_sort_by('year') ?> -     <?php cps_sort_by('price') ?>

     <?php wp_reset_postdata();?>             <?php                 $displayed = array();                  if(!empty($posts)): foreach($posts as $post):                           if(in_array($post->ID,$displayed)):                         continue;                     else:                         $displayed[] = $post->ID;                     endif;                 ?>     <?php global $options;$fields;$options2;$options3;$symbols;                   $fields = get_post_meta($post->ID, 'mod1', true);                   $options2 = get_post_meta($post->ID, 'mod2', true);                   $options3 = get_post_meta($post->ID, 'mod3', true);                   $symbols = get_option('gorilla_symbols');                   $options = get_option('gorilla_fields'); ?>                <?php $blogurl = get_bloginfo('template_url'); ?>     <?php $surl = get_bloginfo('url'); ?>
     <?php                $args = array(         'order'          => 'ASC',         'orderby'        => 'menu_order',         'post_type'      => 'attachment',         'post_parent'    => $post->ID,         'post_mime_type' => 'image',         'post_status'    => null,         'numberposts'    => 1,         );              $attachments = get_posts($args);         if ($attachments) {                       foreach ($attachments as $attachment) {                  echo 'post_name.'>'.wp_get_attachment_image($attachment->ID, 'thumbnail_results').'';         }     } ?>

<a href="<?php echo $post->post_name ?>" rel="bookmark" title="<?php echo $post->post_title ?>"><?php if ( $fields['year']){ echo $fields['year'];}else {  echo ''; }?> <?php echo $post->post_title ?>

<?php if (isset( $fields['miles'])){                                 ##### New ##########                                 //number_format($fields['miles'],0,'.','.')                                 echo number_format($fields['miles'],0,'.',',').' '.$options['milestext'];                                 ##### End ##########                                 }else {  echo ''; };?>

<?php if (isset( $fields['vehicletype'])){ echo $fields['vehicletype'].' | ';}else {  echo ''; };?> <?php if (isset( $fields['transmission'])){ echo $fields['transmission'];}else {  echo ''; };?>
<?php if (isset( $options2['cylinders'])){ echo $options2['cylinders'].' '.$options['cylinderstext'].' | ';}else {  echo ''; };?><?php if (isset( $fields['interior'])){ echo $fields['interior'].' | ';}else {  echo ''; };?><?php if (isset( $fields['epamileage'])){ echo $fields['epamileage'];}else {  echo ''; };?>

<?php include(TEMPLATEPATH."/functions/var/default-box-one.php");                                 //echo $symbols['currency'];                                      ##### New ##########                                 // echo number_format($fields['price']);                                   ##### End ##########                                    ?>                                    <span id="calPriceInAud<?php echo $callPriceInAudCounter; ?>">Calculating...

                   <?php endforeach; else: ?>
<?php _e('Sorry, no listings matched your criteria.','language');?>
                 <?php endif; ?>

<?php _e('BACK TO TOP','language');?>

                                 <?php cps_show_pagination() ?>

         <?php              exit;     }      As you can see CarCostCalculator(`<?php echo $fields['price']; ?>`,14, 2500, 1100,`<?php echo do_shortcode('[convert number=1 from="usd" to="aud"]');?>`) has `do_shortcode('[convert number=1 from="usd" to="aud"]')` but it doesnt work. But works fine on the template file.


How to change the menu color

I need to change the menu color of the wordpress 2011 theme to transparent. this is the header
<?php _e( 'Main menu', 'twentyeleven' ); ?>
                 <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?>

<a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?>
                 <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assigned to the primary location is the one used. If one isn't assigned, the menu with the lowest ID is used. */ ?>                 <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>                        As you can see, the menu uses php. I have no clue how to style php. Thanks


How can I force oEmbed to display fixed height & width dimensions?

I'm trying to explore new ways of embedding videos on to my site as a few of my contributors are having trouble viewing flash embeds when they use the preview function. Ideally it would be easiest to use oEmbed via the [embed] shortcode but i'm running into a problem that I don't seem to be able to find a solution for. I know that you can specify the maximum dimensions of the embed via the Media tab, but that is not what I want to do. Every single photo or video displayed on our site is 560px x 340px for continuity purposes and those are the dimensions I want to force onto the oEmbeds, but I cannot find a way to do it! Looking for help here as Google has been useless!


Protecting HTML5 video

I shall explain my situation as best I can so you can see where i'm coming from. I'm working on a wordpress site for a sports team, there are loads of teams. We want to put coaching sessions on our site. This is so that all the coaches can see how the sessions should be done as many are parent coaches. The problem is that there are a lot of coaches, in a very tight knit community, often families have kids in rival teams for other districts, so what we want to do is protect our material from either; just being downloaded by our coaches and shared with opposition coaches, or people who shouldn't have access to it in the first place, or people acquiring links to the videos and just accessing the videos themselves and possibly distributing them. There is a lot of movement with players and coaches between local teams. We need to maintain that all the work we are doing stays solely within our club and not allow somebody to leave and takes hours worth of footage and training sessions to a rival club. All the coaching sessions are in private pages, I did start using youtube unlisted videos to stream the videos in, but this is insecure as you can just get the link from the source code and distribute it. I'm now using HTML5 secure video player plugin, my videos are in a folder outside my document root, but it appears I can just right click the video and download it when it's playing in Chrome. This is obviously a problem too. I saw using a CDN may avoid this too, I have got a cloudflare account - I'm a little lost really with how to protect these videos. This is my first real venture with video. Does anybody have any advice in how to protect local HTML5 videos.


Efficiently sort only certain categories by custom field

I have a site with about 1,000 posts spread out over 70 or 80 categories. Some of these categories require the posts be sorted by a custom field, others not. I've got a working solution by having 60+ category template files defined (e.g. category-123.php, category-124.php) and each of those calls a separate loop file:               get_template_part( 'loop-123', 'category' );      The loop-123 file then runs a new query and sorts it correctly before passing it to the loop:               <?php     $the_query = new WP_Query("cat=123&meta_key=programnumber&orderby=meta_value&order=ASC");     ?>     <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>      However, there has to be a more efficient way to do this than to create 60+ file pairs. I'm just not seeing it, though.


header_image not working after site copy

I did a copy of a production site to a development site, but the header_image doesn't work after the copy. The copy was done by doing a copy&replace of the host in the db dump file. Everything seems to work except that I now only get the default custom header image and not the one that was earlier configured for each site. I have looked into debugging this issue, but it gets complicated. Has anyone experienced this issue and know how to solve it?


How to make the link to the category for a post go to corresponding page number in archive?

For instance, I am at http://url.com/single-post and in the post there is a link to the category that navigates to http://url.com/category/page/3/ which is the corresponding archive page that contains the current post. I'm trying to pass a global variable from archive.php to single.php but it is not working:               //archive.php      <?php     echo '$page: '.$page.'
';     global $postCatPagenum;     $postCatPagenum = $page;     echo '$postCatPagenum: '.$postCatPagenum;     ?>          //single.php     <?php     global $postCatPagenum;     echo '$postCatPagenum: '.$postCatPagenum;     ?>      Eventually I would like to make a function like this to run in single.php:               // Persistent category page     function persistant_cat_page() {       global $postCatPagenum;       $category = get_the_category();        if (!$postCatPagenum){           $pageUrl = '';       } else {           $pageUrl = '/page/'.$postCatPagenum;       }       if($category[0]){           echo 'term_id).$pageUrl.'">'.$category[0]->cat_name.'';       }     }      Thanks!


Get Posts updated or published within the last x hours

Okay, I'm trying to get posts that have been published within the last x amount of time, options being 8, 24 or 72 hours. I have the variables being passed to my featureHandler.php via ajax, then returning the posts, here is how I'm doing it:               $vars = $_GET['vars'];     $time = $vars[0];     $order = $vars[1];          if ($time == 8 ) {         function filter_where($where = '') {                  //posts in the last 8 Hours             $where .= " AND post_date > '".date('Y-m-d H:i:s', strtotime('-8 hours'))."'";             return $where;         }         add_filter('posts_where', 'filter_where', 10, $time);     } elseif ($time == 24) {         function filter_where($where = '') {                  //posts in the last 24 Hours             $where .= " AND post_date > '".date('Y-m-d H:i:s', strtotime('-24 hours'))."'";             return $where;         }         add_filter('posts_where', 'filter_where', 10, $time);     } elseif ($time == 72) {         function filter_where($where = '') {                  //posts in the last 72 Hours             $where .= " AND post_date > '".date('Y-m-d H:i:s', strtotime('-72 hours'))."'";             return $where;         }         add_filter('posts_where', 'filter_where', 10, $time);     }          ?>          <div class="article-wrapper">     <?php          query_posts(array(            'post__not_in' => get_option('sticky_posts'),      ));          $itemCount = 0;          while ( have_posts() ) : the_post();      This is semi working, I think, except that a post I just created, only shows up in 24 or 72, but not in the case that $time==8, why is that? And how can I make this code more efficient? Thank you SINCERELY.


filter the_content, custom post type, and wp_query

I thought this was going to be quick and easy, but naturally it's turning out to be more complicated. I'm writing a simple plugin that creates a custom post type "Ad", and then puts a random ad at the bottom of posts. So I've created my custom post type - that's easy. Then I created a few ads, and I want to put the featured image from a random ad at the bottom of a post. So I wrote a function to get a random ad's featured image, and then I wrote a function to filter the content and put the ad at the bottom of the post. Here's what I have:               function wpa_choose_ad() {         $args = array(              'post_type' => 'ad',             'posts_per_page' => 1,               'orderby' => 'rand',                          );         $the_query = new WP_Query( $args );              if ( $the_query->have_posts() ) {         while ( $the_query->have_posts() ) : $the_query->the_post();             $the_ad = the_post_thumbnail();         endwhile;         }         wp_reset_postdata();              return $the_ad;     }          function wpa_bottom_ad($content) {         $ad = wpa_choose_ad();              if( is_single() && is_main_query() ) {             $content .= $ad;         }            return $content;     }     add_filter('the_content', 'wpa_bottom_ad');      This puts the ad at the top of the post, and does nothing at the bottom of the post. I think somehow it's running my wp_query at the beginning of the post. What am I doing wrong?


Custom message if tag returns empty results

Is it possible to return a custom message if the tag search returns empty? On my menu i have a link as: www.domain.com/tag/example I don't want to remove the link but also it's a bit annoying if the user presses on this and he sees a blank page. At least a message "sorry there no results for this tag" would do! many thanks Andy


Using multiple line variable inside a function?

I am using the commenting system to all users to add a private note that only they can see to posts and I am using the wordpress comments system to do it. I wrote a function to call the logged in user comments in a shortcode to display on their profile page. I can get this to work without passing it through a variable but it always shows up at the top of the page. I can't seem to call these variables inside the function. All I get is a blank page. Please take a look and tell me what I am doing wrong.               function notes_by_comments() {          global $wpdb;          $current_user = wp_get_current_user();          $note_content = '
Notes
';          $commentQuery = "SELECT * from $wpdb->comments WHERE user_id=$current_user->ID ORDER BY   comment_date DESC LIMIT 0 ,5";          $comments = $wpdb->get_results($commentQuery);     foreach ($comments as $comment) {          $note_content. = '
Note for comment_post_ID). '#comment-'.$comment->comment_ID .'">';     $note_content. = get_the_title($comment->comment_post_ID) . ' -';            if(get_post_type( $comment->comment_post_ID ) === 'for_sale_listings'){      $note_content. =  "Sale Listing";     } elseif (get_post_type( $comment->comment_post_ID ) === 'rental_listings'){     $note_content. = "Rental Listing";     } elseif (get_post_type( $comment->comment_post_ID ) === 'roomate_share'){     $note_content. = "Roommate Share";     }          $note_content. = '
' . $comment->comment_content . '

';          return $note_content;          }      }          add_shortcode('notes', 'notes_by_comments');


creating front end image uploader that uploads images as posts

there is this website lolhappens similar to 9gag. This is a website built over wordpress. How i am sure of this? check this link . Now to my best of knowledge this is a wordpress website where the images are shown as posts and their thumbnails(a fixed width and variable height) are shown of front page in a recent ones first order. Now here is my question: How did they implement a front end image uploader that ultimately shows that images as a posts.And how can i achieve similar functionality . If there are more than one ways what would probably be the recommended. Is there a plugin that has such functionality out of the box? Secondly is it also possible that the person who uploads the images sees a preview before finally clicking a button to it to the website Thirdly they have to add a minimum number of tags (predefined tags and users cant add their own) and a tick that says it is adult pic or not before they can submit it .


issues including a file from a plugin directory

I have a processForm.php _in theme directory_ that does what it says. I am trying to **include a file** (which i need in order to run a specific function in processform.php) from a plugin directory and have been unable to do so. As suggested in first solution in this thread I tried :               include( plugin_dir_path( __FILE__ ) . 'test-plugin/needed_file.php');       I was pretty sure this would work but unfortunately it throw a warning like so :               Warning: include(/home2/xxx/public_html/wp-content/themes/xxx/test-plugin/needed_file.php) [function.include]: failed to open stream: No such file or directory       * * * As said earlier the processForm.php lies in the theme directory and I have no issues anywhere else, calling files within the template directory. If this may help, there is alos a constant defined for this particular plugin's path which goes like this :               define('WPFP_PATH', plugins_url() . '/test-plugin');       So in accordance to a solution suggested here, I tried using code below :               include(WPFP_PATH . '/needed_file.php');      Unfortunately it throws three types of warning : First warning :               http:// wrapper is disabled in the server configuration by allow_url_include=0       Second warning :               failed to open stream: no suitable wrapper could be found in....      Third warning :               Failed opening 'http://awesomeness.com/wp-content/plugins/test-plugin/needed_file.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in.....      > So the bottomline is How do I include this file into my processForm.php ( > which is in root of theme directory).


one get_posts to return a number of custom posts for each meta value

I have setup a custom post 'product' with a custom field `cf_type`. I wish to have one `get_posts` that will return 20 total products, 10 products with `cf_type: fog` and 10 with `cf_type: gof`. Is that possible?               $args = array(         'post_type' => 'product',         'meta_query' => array(             array(                 'key' => 'cf_type',                 'value' => 'fog',   // need to have 10 with value 'fog' and 10 with value 'gof'             )         ),         'numberposts' => 10,         'orderby' => 'modified',         'order' => 'desc'      );     $prodslist = get_posts( $args );`


Xili language plugin not showing language flag

I just updated my wordpress version to 3.4.2 and I installed xili-language plugin v. 2.8.1   Everything works quite nice except one detail - I have 2 languages pl & english. I uploaded icon for polish flag to _../twentyten-xili/images/flags_ where I have other flags, but wordpress won't show it in navigation menu. Meantime it is showing flag for english. I named file pl_pl.png and it has the same width and height as other flags. What is more curious - I did it on localhost (but with twentyeleven-xili theme) and it worked smoothly.   Any idea? edit: link to plugin http://wordpress.org/extend/plugins/xili-language/


Recent Comments from Specific Category Widget

I've been trying to create a sidebar widget to display recent comments from specific category. I'm having difficulties in determining how Wordpress knows from which categories the comments are. I have checked the codex on `get_comments` function but it doesn't seem to allow fetching from specific categories. I've found some hints from Kovshenin's blog, but can't seem to make it work properly, because my try either shows all comments (disregarding the categories) or doesn't show it at all. I'm basing the widget from `Widget_Recent_Comments` (found from `wp- includes/default-widgets.php`). Here is what I have so far. I believe the output is controlled around this area:                   $output = '';         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );              if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )             $number = 5;              $category_name = empty( $instance['category_name'] ) ? '' : $instance['category_name'];              $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );         $output .= $before_widget;         if ( $title )             $output .= $before_title . $title . $after_title;              $output .= '
';         if ( $comments ) {             foreach ( (array) $comments as $comment) {                 $output .=  '
' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), 'comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '') . '
';             }         }         $output .= '
';         $output .= $after_widget;              echo $output;      And here is the full codes: http://pastebin.com/VH666jty Basically my widgets is similar to the default Recent Comments widget. Only that it has an optional `Display comments only from category/categories: ...`, where user could input by themselves. Leaving it blank will display comments from all category, while putting some category slug, separated by comma (e.g.: `mycategory,othercategory`) will display comments only from those selected categories.


Exclude ALL posts from sub categories

Need help with a wordpress-task I want ALL the posts from sub categories to be excluded. Example:   * Cake      * Pie        * Apple       * Pear       * Banana If i post a post in Banana, i don't want it to show up in Pie or Cake. I just want posts that are posted in banana to show in banana, not in the top categories. How can i do this? I found a code for it to put in functions.php but and it does the trick with the first category, but not the second.               function fb_filter_child_cats($query) {     $cat = get_term_by('name', $query->query_vars['category_name'], 'category');     $child_cats = (array) get_term_children( &$cat->term_id, 'category' );     // also possible     // $child_cats = (array) get_term_children( get_cat_id($query->query_vars['category_name']), 'category' );     if ( !$query->is_admin )     $query->set( 'category__not_in', array_merge($child_cats) );     return $query;     }     add_filter( 'pre_get_posts', 'fb_filter_child_cats' );


Load comments per post on click with AJAX

I'm working on a theme that uses a slider to display blog posts. Beneath the slider is a pagination that displays like a timeline, with a date instead of a page number, calling the corresponding blog post. I want to display the comments for each post, but outside the slider. So, I have this code in my header, to get the comments with ajax: :: EDITED (now using **wp-admin/admin-ajax.php** to handle request, as advised below) ::               $(".timeline-entry a").live('click', function(event) {       event.preventDefault();       $.ajax({          url: '<?php echo admin_url('admin-ajax.php'); ?>',          type: 'POST',          action: 'do_ajax',          data: {             'post_id' : '72' //using a post id that I *know* has comments, for testing!          },          dataType: "json",          success: function(myResult) {             alert(myResult);          },          error: function(error) {             alert(error);          }       });     });      In my functions.php:               add_action('wp_ajax_nopriv_do_ajax', 'retrieve_comments');     add_action('wp_ajax_do_ajax', 'retrieve_comments');          function retrieve_comments(){               $myPost = $_REQUEST['post_id'];         $output = get_comments('post_id=' + $myPost);         $output = json_encode($output);                   if(is_array($output)){                      print_r($output);                      }                   else{                      echo $output;                   }                   die;     };       I get `0` in the alert box... so that means the ajax is happening, but something is wrong with my php function, right? Thanks for your help.


WBR tag breaking hyperlinks

I was investigating the cause of hyperlinks breaking on a friend's website. She copies over her content from email and pastes it in the Wordpress editor. In a few articles, the content between the a tags has wbr in it and that seems to break the hyperlinks. You can find it on http://chandni.org/information- about-awards-scholarships-and-more/ In case it's fixed by the time you see the thread, the copied content               http://www.msrlm.org/mrlif/<wbr />faqenglish.html      what is shown by wordpress               http://www.msrlm.org/mrlif/<wbr>faqenglish.html      I am guessing it's due to the fact that it uses and not . Should I replace the former with the latter? Looking for inputs from people who're familiar with wbr tag.


Automatically Assign Parent Terms When A Child Term is Selected

I have deep hierarchical taxonomy and I want to have all parent term assigned when I select a child term. I need it for category structure on a online listing/classified site. **CPT name:** `product` **Taxonomy Name:** `product_cat`


add_action in functions.php, do_action in plugin?

I am trying to set an `add_action` function in my currently active WordPress theme `functions.php` file, for a defined `do_action` function within an activated WordPress plugin. The `add_action` function in my currently active WordPress theme `functions.php` file doesn't work. However, it works if I copy the `add_action` function from my currently active WordPress theme `functions.php` file into the activated WordPress plugin file right before the `do_action` function. Is there a way to do this?


Defining a global array in functions.php?

I try to create an array of years, which is avaible in my template-files and in at least one other function in the functions.php.               function get_the_years()      {         global $year_arr = range(2001, date('Y'));         return $year_arr;     }      Then I want to use it in a function, which creates a term for every year in the custom taxonomy 'year'.               function create_year_terms() {     foreach($year_arr as $value){            $term = term_exists($value, 'year');             if ($term !== 0 && $term !== null) {                 echo $value . ' category exists!';             }             else { wp_insert_term(                 $value, // the term                  'year', // the taxonomy                 array(                     'description'=> 'The name of a year',                     'slug' => $value )                 );                 echo'term '. $value . ' created';             }         }      } And trying to attach this function to the wp_login hook               add_action('wp_login', 'create_year_terms');      I tried to make my hoeworks and I guess I understand "something" but I'm a bit scared to kill something by putting wrong stuff in my functions.php, so please excuse my question.


why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?

I am using a new blog on WPMS (3.0.1, updating is not an option) to aggregate posts (and their featured image) from a few blogs on the same install, and I have to do it programmatically rather than through a pre-made plugin due to firewall restrictions. I've tried several ways of doing it, and feel like this method is most promising. Here's what I've cooked up:               switch_to_blog(oldblognumber);     $zargs  = array( 'numberposts' => 1, 'category_name' => 'featured');     $zlastpost = get_posts( $zargs );     foreach($zlastpost as $post) : setup_postdata($post);         $extrapost = array();         $extrapost['post_title'] = get_the_title();         $extrapost['post_content'] = get_the_content();         $extrapost['comment_status'] = 'closed';         $extrapost['post_status'] = 'publish';         $extrapost['post_date'] = get_the_date( $d = 'Y-m-d H:i:s');         $extrapost['post_category'] = array(80);         $upload_dir = wp_upload_dir();         $oldid = get_the_ID();         $image_url = wp_get_attachment_url(get_post_thumbnail_id($oldid));         $image_data = file_get_contents($image_url);         $filename = basename($image_url);         switch_to_blog(newblognumber);                       $file = $upload_dir['path'] . '/' . $filename; //removed the conditional cuz it was giving me trouble             file_put_contents($file, $image_data);             $post_id = wp_insert_post($extrapost);             $wp_filetype = wp_check_filetype($filename, null );             $attachment = array(                 'post_mime_type' => $wp_filetype['type'],                 'post_title' => sanitize_file_name($filename),                 'post_content' => '',                 'post_status' => 'inherit',             );                               $attach_id = wp_insert_attachment( $attachment, $file, $post_id );             require_once(ABSPATH . 'wp-admin/includes/image.php');             $attach_data = wp_generate_attachment_metadata( $attach_id, $file );             wp_update_attachment_metadata( $attach_id, $attach_data );             set_post_thumbnail( $post_id, $attach_id );                                restore_current_blog();         wp_reset_postdata();     endforeach;     restore_current_blog();      The post insertion works just fine, and it pulls the image alright, but somewhere in there things are getting muddled and it spits out an absurd attachment url: http://myblogs.com/newblog/wp- content/blogs.dir/newblognumber/files//internet/http/wp- content/blogs.dir/oldblognumber/files/year/month/filename.jpg. Likewise, in the loop where I ask for the_post_thumbnail, I get a broken image whose src is http://myblogs.com/newblog/files//internet/http/wp- content/blogs.dir/oldblognumber/files/year/month/filename-200x100.jpg For what it's worth, since I'm using a pre set_post_thumbnail version of WP, I just manually define the function in my newblog's functions.php:               function set_post_thumbnail( $post, $thumbnail_id ) {     $post = get_post( $post );     $thumbnail_id = absint( $thumbnail_id );     if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );        if ( ! empty( $thumbnail_html ) ) {            update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );            return true;        }     }     return false;     }      I've tried fudging GUIDs and using regular expressions to force urls into submission among other things, but all to no avail. Please let me know if you have any guidance for me! * * * I have also tried an alternate method of setting the post thumbnail of an inserted post, but this simply calls the original file in the oldblog's upload directory, which will not suffice, as I'd like to generate new image sizes for the newblog's Media Library, and I'd prefer to not go through and add them to each of the original oldblogs. Here's that attempt:               switch_to_blog(oldblognumber);     $zargs  = array( 'numberposts' => 1, 'category_name' => 'featured');     $zlastpost = get_posts( $zargs );     foreach($zlastpost as $post) : setup_postdata($post);         $extrapost = array();         $extrapost['post_title'] = get_the_title();         $extrapost['post_content'] = get_the_content();         $extrapost['comment_status'] = 'closed';         $extrapost['post_status'] = 'publish';         $extrapost['post_date'] = get_the_date( $d = 'Y-m-d H:i:s');         $extrapost['post_category'] = array(80);         $oldid = get_the_ID();         $thumbo = get_the_post_thumbnail($oldid);         $filename = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );         switch_to_blog(68);             $post_id = wp_insert_post($extrapost);             $wp_filetype = wp_check_filetype(basename($filename), null );                 $wp_upload_dir = wp_upload_dir();                 $attachment = array(                     'guid' => _wp_relative_upload_path( $filename ),                      'post_mime_type' => $wp_filetype['type'],                     'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),                     'post_content' => '',                     'post_status' => 'inherit'                 );                 $attach_id = wp_insert_attachment( $attachment, false, $post_id );                 require_once(ABSPATH . 'wp-admin/includes/image.php');                 $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );                 update_post_meta( $post->ID, '_thumbnail_id', $attachment_id );                 wp_update_attachment_metadata( $attach_id, $attach_data );                 set_post_thumbnail( $post_id, $attach_id);                     restore_current_blog();             wp_reset_postdata();         endforeach;     restore_current_blog();           I've tried feeding a number of things to wp_insert_attachment's $filename parameter, but that doesn't seem to be my answer.


WordPress Script Loading/Unloading -- wp_deregister_script('jquery')

I have a few questions relating to WordPress loading / unloading up javascript tools. After reading a nicely written response to a question by Pieter Goosen, that got me to do a bit of studying and a clean up of the code I'm using to load up my libraries. This code is from my child-theme's function.php file. I've got a few functions on my site that use the datepicker calendar tools. Additionally there are a few plugins that I'm sure use jQuery.               function jquery_loadup() {             //wp_deregister_script('jquery');    <--- ?H             wp_enqueue_script('jquery');             //wp_enqueue_script('jquery-migrate');             wp_enqueue_script('jquery-ui-core');             wp_enqueue_script('jquery-ui-datepicker');             wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css');     }     add_action('wp_enqueue_scripts','jquery_loadup');      I was under the impression that the line `wp_deregister_script('jquery')` essentially resets/clears all previous 'requests' for the jquery scripts so they don't interfere with one another. That line followed by `wp_enqueue_script('jquery');` should result in a minimal clean load of jQuery via the WordPress commonly used scripts registered handle / script paths system, no? I would think that the deregister call tests for the presence of a previous 'install' for jquery, and if it finds one or more, stops their loading, if none are registered, do nothing. What I'm seeing is that when I use the `wp_deregister_script('jquery')` I'm get an error on the websie `"ReferenceError: jQuery is not defined"`. When this happens, all of my JavaScript functions fail. What the heck? When remarked out, the site functions fine. Questions: Am I missing something? What am I not understanding about the deregister call? Why would I be getting an error message? Note, the line in there for `jquery-migrate` is supposed to be for software using older versions of jQuery. I tested it, but I can't see that it does anything on my site, so I've taken it out to improve download and response times. Question: Is that a bad idea? references:   * Excellent Reply on Script Loading by Pieter Goosen   * WordPress Codex on Enqueue Script


Need webcam chat plugin for my client

I am developing a website where I need a webcam chat plugin. I have tried many plugins from wordpress.org but none of them worked. Can anyone please suggest me a working plugin. Plugins that did not work:   1. TokBox OpenTok Plugin **Problem** : > In the dashboard,it only pops up once i.e the first time the plugin is used > and still the button to start webcam did not work(Also note that it did not > show up my webcam.) **Resolved:** The problem was with the dashboard. I uploaded the files and it started to work . Thanks 2\. Tinychat** **Problem** : > Was unable to find API for it.   1. VideoWhisper Video Presentation **Problem** : > Keeps on loading and does not work Thanks.


How to stop wordpress mangling R syntax '<-'?

I have a self-hosted WP install, and have been using codecolorer (and have tried a few others along the way) to highlight R syntax. Looks nice, too. The problem is that R uses a `<-` symbol instead of `=` when assigning objects (on pretty much every single line), and when you switch from 'Visual' to 'HTML' while editing a post it will mangle the code - `<-` becomes `<-`; worse, sections of the code will disappear. It would be possible to use `=` for the 'assign' command but it's not, strictly-speaking, correct. At the moment I have to do all the pretty writing and inserting of images in WYSIWYG 'visual' mode, then switch to HTML just before I post to fix up the R code, and then be careful _never_ to switch back again. Ever. Any fixes for this behaviour? EDIT: examples! Putting this into the Visual editor:               [cc]     lorum <- ipsum     [/cc]      Produces the following in the _final post_ :               lorum <- ipsum      Going back to HTML mode and putting a `<-` code worked _for the final post_ but then I could never switch back to Visual without the `<` being interpreted as part of a tag.


Delete post with all files attached to it

On my site I have multiple authors, who can add/edit/delete custom posts and upload (attach) images to those posts. The problem is - when they delete their posts, attachments stay on the server. So, I would like to get rid of all files attached to the post when it gets deleted. Can anyone share and example how it's done?


Enqueue script only for IE

I want to use dd belatedpng so the PNG's on my website appear properly on IE. The script I've always used on non-wordpress websites was               <!--[if lt IE 7 ]>         <script src="js/dd_belatedpng.js"></script>         <script> DD_belatedPNG.fix('img, .ir'); </script>     <![endif]-->      Now that I need to use it on a Wordpress website, I'm trying to find a way of adding script using enqueue script, although I don't like it at all. At the end of the day, the theme is only going to be used on a single website, I'd prefer to hardcode the scripts path. Anyway, is there a way of adding IE conditionals to enqueue script and or register script?


Add Column to Term Database

Currently the Term Database has four columns. `term_id` `name` `slug` `term_group`. I would like to add another column called `menu_order`. How can i do this? The outcome i want is to be able to order my custom terms. If anyone knows of a beter way to do this please let me know. So far i already have code that sets up the input box. I just need help trying to order it using the `get_terms()` function.               add_action ( 'section_edit_form_fields', 'create_section_menu_order');     function create_section_menu_order( $tag )      {         //check for existing featured ID         $section_order = get_option( 'section_menu_order' );         $order_id = '';         if ( is_array( $section_order ) && array_key_exists( $tag->term_id, $section_order ) ) {             $order_id = $section_order[$tag->term_id];         }         ?>
                 <?php _e('Order') ?>	                                      <input type="text" name="section_menu_order" id="section_menu_order" size="10" style="width:60px;" maxlength="6" value="<?php echo $order_id; ?>">
                     The order your Sections will show. (Numeric digits only)
         <?php     }          add_action ( 'edited_section', 'save_section_menu_order');     function save_section_menu_order( $term_id )      {         if ( isset( $_POST['section_menu_order'] ) && is_numeric($term_id))          {             $section_menu_order = get_option( 'section_menu_order' ); //load existing category featured option             $section_menu_order[$term_id] = intval( $_POST['section_menu_order'] ); //set featured post ID to proper category ID in options array                update_option( 'section_menu_order', $section_menu_order ); //save the option array         }     }


Can I make simple global tooltips in Wordpress?

We wish to have ALL external links within a Wordpress site have a simple mouseover tooltip without having to place a title tag or rel or class tag within it. I've tried several methods using the $('a[href=http]') selector but can not for the life of me get anything to work. Here is the code I came up with that does work in a standard HTML page but can't get it to work within Wordpress. In theory this sounds so simple: find all external links and when moused over display this tooltip text...                     ANY help with this would be unbelievably appreciated!


Make a menu visible for a single category and it's content

I'm working on a site with 3 major sections. Therefore I want to create archives for each section and those archives should be visible only in the category page and it's posts.   At this point, I made the menu visible only for the category page, but when I open a post, the widget is not displayed. How do I create archives for specific categories, and how do I display them in a specific category and its posts?


How to add an anonymous function in wordpress hooks by removing create_function

Currently I have the code below which I would like to replace `create_function` with some anonymous function. How can this be done?               add_action('widgets_init', create_function('',           'return  register_widget("time_more_on_time_widget");'     ));


Dynamically excluding current page id

I'm attempting to create a "related posts" section on pages using query_posts. I'm wanting to use this simply because we want to show random posts from one category on one page, so a plugin would be overkill. The problem I'm having is dynamically excluding the current page the user is on from the list. Here's the code I'm using and I've tried several methods to exclude the current page but none have worked.               <?php          // The Query     $post_id = get_the_ID();     query_posts("showposts=4&post_type=page&post_parent=168&orderby=rand&exclude='. $post_id .'");          // The Loop     while ( have_posts() ) : the_post();     echo '
';     the_title();     echo '
';     endwhile;          // Reset Query     wp_reset_query();          ?>      Am I going about this wrong or am I using the incorrect code or both? TIA! **On Edit:** After Milo's suggestion, I got to looking again and combined with his reply and a post on the WP forum, I got it to work with the following (seems 'exclude' didn't want to work for this):               <?php         $this_post = $post->ID;         global $post;         $args= array(             'post_type' => 'page',             'posts_per_page' => 4,             'post_parent' => 168,             'orderby' => 'rand',             'post__not_in' => array($this_post)          );     $rel_posts = get_posts($args);     foreach($rel_posts as $post) :     setup_postdata($post);     ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php endforeach; ?>


SSO system between 2 WordPress installs on different servers

This is essentially a repeat of this question, but it has not been answered. I am trying to create an SSO system between two separate WordPress installs that are on different servers using different databases. The main site has a full database including a users table containing over 300,000 users. Because of the size of the users table, we do not want to replicate each of them on the second site or do a traditional SSO system where each user is created in the database as they login. Ideally, we would like to reference the users table on the main site and use those same users on the second site. So far I have tried using wp_remote_post() to send a user object to the second site while overriding the pluggable.php functions and setting the $current_user global with the posted user object. This, however, isn't working as well as I'd hoped because the methods that are normally available in the WP_User object are not available in the posted object, which results in fatal errors when methods like $user->exists() are used. I am aware of the CUSTOM_USER_TABLE solution, but that obviously won't work in this example as the sites are on separate servers with separate databases. **TL;DR:** Need SSO. Separate servers. Help.


Create custom archive page for individual authors which is separate from the author.php page

If this is a duplicate, I apologize. I have searched and searched with no luck. I have a custom author.php set which shows the most recent 10 posts (As it's set in the admin panel under General > Reading). I want to have a link to "View all posts by this author". This will link to a page showing all posts by that specific author. All the information I've found has been about the author.php page which I don't want to change. Thanks


404 on author page using custom permalinks and pagination

I have some author pages in my theme (using a modified version of the UDesign theme and the Pagenavi plugin. Pagination works on the blog, but not on the author pages. I'm getting 404's on the author page urls. This works: xxxx/author/dr-fiona-nd/ This does not: xxxx/author/dr-fiona-nd/page/2/ Both of these work: xxxx/blog/ xxxx/blog//page/2/ Where do I start on this? I've seen lots of posts about custom content types, but this is a standard post. I've seen other information on adding custom rewrite rules and endpoints, but I'm thinking there's probably some other standard CMS based solution for this, am I wrong? Looking for some direction, thanks for any help!


using theme check plugin to remove waring and errors from my theme

i have solve the most of issue now only the followings issue reaming. 1.the most important WARNING: curl_init was found in the file twitteroauth.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls. Line 195: $ci = curl_init(); WARNING: curl_exec was found in the file twitteroauth.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls. Line 221: $response = curl_exec($ci);


Display Featured Image

I am having some issues trying to get featured image to appear on my front page. I am using Genesis, then genesis child theme. I only want the featured image to appear on my `front-page.php`. I know I need to write a custom loop in order for the featured image to appear only. However I am having trouble completing it.I am not sure what code to write into my custom loop. I did this:               /** Code for custom loop */     function my_custom_loop() {          }          /** Replace the standard loop with our custom loop */     remove_action( 'genesis_loop', 'genesis_do_loop' );     add_action( 'genesis_loop', 'my_custom_loop' );


Hook pages by id on static front-page

I would like to build a one page website upon the Wordpress CMS. I'm looking for a way too hook my pages on a static frontpage by id, since I have several page types. I've tried:               $id=6;      $post = get_post($id);      $content = apply_filters('the_content', $post->post_content);      echo $content;        But this returns only the content and not the content with the HTML. Any tips on how to achieve this?


How do you edit the html of teaser excerpts

All my teaser excerpts have no formatting applied to them. With firebug I can get the text to look how I want by editing the html but I don't know where to edit the html in wordpress. How can I do this? Thanks


Are post, page and category IDs unique to each other?

I was looking for a function to get all ancestors of a post **or** category and found get_ancestors( $object_id, $object_type ). To my surprise, the Codex shows that the second parameter is required:               $object_type             (string) (required) The name of the object type (page, hierarchical post type, category, or hierarchical taxonomy) in question              Default: None       Aren't post, page and category IDs all unique to each other, i.e. the intersection of their sets would be empty? If not, why not? It only seems to complicate an API if you have to specify the object type given that posts, pages, and categories are all data objects of a single CMS.


Show Custom Field

i am using WCK - Custom Fields and Custom Post Types Creator. I am have code for show image.                       <?php      $my_meta = get_post_meta( $post->ID, 'my_meta_name', true );      if( !empty( $my_meta[0]['avatar'] ) ){         $src = wp_get_attachment_image_src( $my_meta[0]['avatar'], 'full' );         echo '';      }     ?>      Ok! Need show url, after my iditing code i am view postid on site:                  <?php      $my_meta_archive = get_post_meta( $post->ID, 'Books1', true );     if( !empty( $my_meta_archive ) ){         foreach( $my_meta_archive as $entry ){             $attch = wp_get_attachment_url( $id );             echo '123'.$attch[0].'123';         }     }     ?>      and                   $my_book_url = get_post_meta( get_the_ID(), 'Books1', true);              if( ! empty( $my_book_url[0]['archive'] ) ) {                  echo '
Link: ' . $my_book_url[0]['archive'] . '
';         }          ?>      Its code show me Post ID                    <?php      $my_meta_archive = get_post_meta( $post->ID, 'my_meta_name', true );      if( !empty( $my_meta_archiv[0]['archive'] ) ){            echo '22'.wp_get_attachment_url( $my_meta_archiv[0]['archive'].'22';      }     ?>      Its code not display View documentation ty


Dashboard Contact Form

Is there a way to make a dashboard contact form widget? I just simply want to have it there so users can give feedback directly from their dashboard.