title: Conditional category query breaking?

text:
In my loop.php (see below) I basically have a condition where if the page is not paginated (i.e. if the URL does not look something like this: example.com/page/2) then display 2 posts with a category of "featured- content"...otherwise if the page is paginated then display 5 posts. This works fine except it is not properly querying the "featured-content" category as posts marked with this category are not always showing up in the loop feed. I hope I articulated the issue properly, if not please let me know and I'll clarify.                                        <?php include('includes/featured-content-slider.inc.php'); ?>                                            <div class="container_16" <?php if (!is_paged()) { echo "id=home";} ?>>                                        <section class="grid_10 featured-news" <?php if (is_paged()) {echo "id=margin-top-120-o";}?>>
Featured Content
                                                                            <?php                         if (!is_paged()) {                             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                                 $args=array(                                     'post_type'=>'post',                                     'category_name' => 'featured-content',                                     'posts_per_page' => 2,                                     'paged'=>$paged                                 );                                 $temp = $wp_query;                                 $wp_query= null;                                 $wp_query = new WP_Query($args);                         } else {                             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                                 $args=array(                                     'post_type'=>'post',                                     'category_name' => 'featured-content',                                     'posts_per_page' => 5,                                     'paged'=>$paged                                 );                                 $temp = $wp_query;                                 $wp_query= null;                                 $wp_query = new WP_Query($args);                         }                             if (function_exists('wp_pagenavi')) { wp_pagenavi(); }                             if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();                         ?>                                                                                <article class="post" id="post-<?php the_ID(); ?>" <?php post_class(); ?> >                                                                       <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>
By <?php echo get_the_author(); ?> / <?php echo get_the_date('m.d.Y'); ?>
                                                                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(640,320)); ?>
<?php the_excerpt(); ?>
                                                                                <?php include('includes/social.inc.php'); ?>
                                                                                <?php                             endwhile; endif;                             /* PageNavi at Bottom */                             if (function_exists('wp_pagenavi')){wp_pagenavi();}                             $wp_query = null;                             $wp_query = $temp;                             wp_reset_query();                         ?>                                                                        <?php if ($wp_query->max_num_pages > 1) : ?>
                             <?php next_posts_link( __( '← Older', 'twentyten' ) ); ?>
                             <?php previous_posts_link( __( 'Newer →', 'twentyten' ) ); ?>

                     <?php endif; ?>
                                                        <div <?php if (is_paged()) {echo "id=margin-top-120-o";}?>>                     <?php include('includes/whats-happening.inc.php'); ?>


title: Is it possible to install a theme via a plugin?

text: I'd like to simplify the installation and default settings of my theme, by creating a plugin that installs it (versus the traditional "Appearance > Install Themes" routine. Once installed, I want to be able to delete the plugin from the site, so there will be no dependencies on it after activation. Is this possible? I would include the theme.zip file inside the plugin.zip file so that it could easily be transferred up and over to the themes directory. If possible, any examples of this would be helpful. Thanks in advance for your help.


title: Wordpress Permalink Redirect 301

text: <?php     $permalink = get_permalink( $id );       header("Location: ".$permalink, true, 301);     ?>      Iam redirecting the URL without the id to id with 301 this php code is giving me problems, is the correct way to do it.


title: Software for WordPress Theme and Plugin Development?

text: What software do you use for your WordPress related needs? Please state your OS. On windows XP I use:   * filezilla (FTP)   * notepad++ (for reading of PHP / CSS files)   * firebug (a firefox extension to allow me to play with a website elements) Other things which I don't use regularly, but would like to use more \- xaamp (local version of WP) \- github/SVN (a version control system for my files) What about you?


title: Long option names fail silently?

text: This was really driving me crazy. I was debugging some code with code- generated transient names and they were failing like crazy for no apparent reason. After much much pain and experimentation I figured out that it fails when over certain key length:               $key = '1234567890';     var_dump( get_transient($key) ); // works just fine     var_dump( set_transient( $key, $key, 10) ); // false when not expired               $key = '1234567890123456789012345678901234567890123456';     var_dump( get_transient($key) ); // always returns false     var_dump( set_transient( $key, $key, 10) ); // always true      Apparently `option_name` field in database is `varchar(64)`. However I absolutely can't figure out why this doesn't produce any database errors and all returns and hooks on setting transient work just fine... Except that in reality timeout option doesn't get written and it all fails miserably. I suspect this query in `add_option()`:               $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $value, $autoload ) );      Can anyone help figure out what it should do when option's name passed is too long and why it doesn't produce errors or anything?


title: Wordpress shop: enable custormers to select product color using image thumbnails on Custom Fields

text: I use Wordpress Custom Fields to provide customers with various product color codes in a drop-down list, but now I would like to add the various color thumbnails for ease of selection...similar to how color is selected in this site: http://www.blackhairspray.com/outre-quick-weave-belinda-outreqsbel.html Can anyone give me an idea of how to do this in wordpress please or point me to a relevant tut? since googling has failed to provide the goods so i am eagerly holding my breathe for a SuperUser delivery :-)


title: WP function/filter for modifying http headers?

text: Is there a dedicated WP function, action or filter to use when adding/modifying the HTTP headers? For now I just hook a PHP header() call into the WP 'init' hook like this:               add_action('init', 'add_header_xua');     function add_header_xua(){         if(!is_admin()){             header('X-UA-Compatible: IE=edge,chrome=1');             }     }      But is this the correct way to do that?


title: unable to change default URL at "General Settings" page

text: Okay I have the Default URL for the blog at "General settings" grayed out and unable to change the url of the blog anymore. The current value is "http://blog.financialcoachshow.com/blueocean/institutional" screenshot link I know this happens when you have custom defined for the site/blog url at the wp-config.php file , however I have the following defined in wp-config.php               define ('WPLANG', '');     define('WP_HOME','http://www.blueoceanportfolios.com/company');     define('WP_SITEURL','http://www.blueoceanportfolios.com/company');      while I was hoping to have SiteUrl/blog url at "General Settings" blueoceanportolios.com/company as defined above it is locked to http://blog.financialcoachshow.com/blueocean/institutional What else could be causing be the possible reason for such conflicting value ?


title: Contact Form 7: Email custom HTML inputs or make a field readonly

text: I am trying to email a custom input               <input type="text" name="total" id="total" class="wpcf7-text" readonly="readonly" />      I tried `[total]` but it does not work. Or isit possible to make a field readonly with WPCF7?


title: Display all authors and their only one latest post

text:
I have a website with many authors and posts. I need to create a list of all authors and for each one display his latest post (not posts, **only one post** ). This better explains what I need:

name of the author
              Title of his latest post

      This is the code I am using so far which works OK but it's only one loop. I need to create many of these if I want to display all authors automatically:
         <?php         query_posts('showposts=1&author=7');          if (have_posts()) : while (have_posts()) : the_post();         ?>

name of the author
                  Title of his latest post
         <?php         endwhile; endif;          ?>
      Is there any simple way of doing it with only one loop?


title: Display thumbnail only on the very first post in the loop?

text:
What's the best way to use `<?php the_post_thumbnail();?>` in my loop **BUT** only show a thumbnail on the FIRST post? Meaning, only the first post in the loop will have it's image shown? **Here is an example of a loop that shows the image for ALL posts:**                     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
          <?php the_post_thumbnail();?>            <?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?>
        <?php the_content(); ?>
      Thank you!


title: How would I increase the Author Role to be able to add a new category?

text: How do I increase Author Role permissions to be able to add Categories? Other solutions welcome. We just need guest authors to be able to add categories while ensuring there is not already a existing appropriate category.


title: Wordpress pagination not working in search result page

text:
I have a problem with pagination on search results page. The page links appear, but when i click onto page 2, it gives me a 404 error. Page 1 : http://templategraphy.com/wp-demo/businessguru/?s=Blog+Image (page 1) Page 2 : http://templategraphy.com/wp-demo/businessguru/page/2/?s=Blog+Image (Page not found) search.php               <?php                       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                         $args = array( 'paged' => $paged );                         $the_query= new WP_Query($args);                          ?>
                   <?php  if (have_posts()) : ?>                  <?php while (have_posts()) : the_post(); ?>                  <div id="post-<?php the_ID(); ?>" <?php post_class('item'); ?>>                  <?php                 $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );                      if ( has_post_thumbnail() ) {                       echo '';                 echo '';                  echo '';                 }                 ?>
                   <?php  endwhile; ?>                   <?php           next_posts_link( 'Older Entries', $the_query->max_num_pages );           previous_posts_link( 'Newer Entries' );         ?>             <?php          // clean up after our query         wp_reset_postdata();          ?>
              <?php  else : ?>
Not Found

Sorry, but you are looking for something that isn't here.
             <?php  endif; ?>
      Please suggest some solutions.


title: How can I show a different theme for admin users? WP 3.8+

text: I've been searching around for a long while now. There seem to be plugins available for this, but hardly anything that is current. Many of the plugins I have already tried do not work correctly with WordPress 3.8+ My needs are basic. All I want to do is load another theme if I am logged in as an admin, so that I see a different front-end. Thanks, Michael.


title: Getting only a specific post type with get_post?

text:
I'm using the following function to get some posts based on their vote (Vote it Up plugin):               function top_voted($number){         $a = SortVotes();         echo '
';         $rows = 0;         //Now do not include deleted posts         $i = 0;         while ($rows < $number) {             if ($a[0][$i][0] != '') {                     $postdat = get_post($a[0][$i][0]);                 if (!empty($postdat)) {                     $rows++;                     echo '
';                     echo '
'.$a[1][$i][0].'

guid.'" title="'.$postdat->post_title.'">'.$postdat->post_title.'
';                     echo '
'.$a[1][$i][0].'

'.$postdat->post_content.'
';                     echo '
';                 }             }             if ($i < count($a[0])) {                 $i++;             } else {                 break; //exit the loop             }         }         echo '
';     }      I would like to only get the posts of a certain post type. I think I have to do something with `get_post` but I'm not familiar with it. Any suggestions?


title: Theme Customization API options on install

text: I'm working on a theme that use the WordPress Theme Customization API. Everything is working as it should, except on initial theme install. Some of my options need to be set straight away on theme install. After looking around it seems that setting the default arg in the add_setting option should set the option right away, but it's not. Here's a short excerpt of my code:               add_action( 'customize_register', 'generate_customize_register' );     function generate_customize_register( $wp_customize ) {              // Add Layout section         $wp_customize->add_section(         'layout_section',             array(                 'title' => __( 'Layout', 'generate' ),                 'capability' => 'edit_theme_options',                 'description' => __( 'Allows you to edit your theme\'s layout.', 'generate' ),                 'priority' => 30             )         );              // Add Header Layout setting         $wp_customize->add_setting(             // ID             'generate_settings[header_layout_setting]',             // Arguments array             array(                 'default' => 'fluid-header',                 'type' => 'option'             )         );              // Add Header Layout control         $wp_customize->add_control(         // ID         'header_layout_control',         // Arguments array         array(             'type' => 'select',             'label' => __( 'Header Layout', 'generate' ),             'section' => 'layout_section',             'choices' => array(                 'fluid-header' => __( 'Fluid / Full Width', 'generate' ),                 'contained-header' => __( 'Contained', 'generate' )             ),             // This last one must match setting ID from above             'settings' => 'generate_settings[header_layout_setting]',             'priority' => 1         )     );     }      As you can see, I created a section, a setting with a default and a control for that setting. When I go to the Theme Customizer and save the options, a generate_settings table is created in the database with the options inside, as it should be. However, on a fresh install of the theme, if I go into the database, no generate_settings table exists - the settings are only added to the database when I go into the Theme Customizer and save the options. Am I doing something wrong? Is there anything I can do to populate the database with these settings on fresh theme install? Thanks!


title: Screenshorts are not showing in plugin download page

text: My first plugin is approved and i already uploaded it on SVN. Everything works fine except the screenshorts. In WP plugin download area my plugin is not showing the screen shorts. I have the screen shorts in asset directory in SVN. here is the link of my readme.txt file http://plugins.svn.wordpress.org/odvut-author- bio/trunk/readme.txt I searched on google but didn't find any solution for me :( Any help please?


title: wp_get_attachment_image_src returns image on main domain, false on subdomain

text: I've got a multisite install in development where both the subdomains and the main site use the exact same page templates for showing data. However, when I try to get a profile image (added ID in wp_usermeta), I get `false` on the subdomains, but the actual image data returned on the main domain. I came across that it might be a permalink issue, but both have the same structure. Just to make sure I changed, saved, changed back, saved them. Also figured that it 'could' be due to entering a `string`, so casted the ID to `int` as well, just to be safe. Anyone know what might be causing this?               /* Code */     if( isset( $user[ 'meta' ][ 'prof-pic' ] )){         $logo = wp_get_attachment_image_src( $user[ 'meta' ][ 'prof-pic' ][ 0 ], 'pic' );         echo '<pre>';         var_dump($user[ 'meta' ][ 'prof-pic' ][ 0 ]);         var_dump($logo);         var_dump(wp_get_attachment_image_src( (int)$user[ 'meta' ][ 'prof-pic' ][ 0 ], 'pic' ));         echo '</pre>';     }          /* Results Subdomain */     string '94' (length=2)     boolean false     boolean false          /* Results Main site */     string '94' (length=2)     array (size=4)       0 => string 'http://site/wp-content/uploads/2014/06/Viper-160x100.jpg' (length=90)       1 => int 160       2 => int 100       3 => boolean true     array (size=4)       0 => string 'http://site/wp-content/uploads/2014/06/Viper-160x100.jpg' (length=90)       1 => int 160       2 => int 100       3 => boolean true


title: How to edit/remove a term that's in multiple taxonomies?

text: Some of the terms on my site appear with the same exact slug, in multiple taxonomies. For example: 'education' appears in both the 'department' taxonomy and the 'topic' taxonomy. Now, I can't seem to modify or delete a term from one taxonomy without affecting the term in the other taxonomy.   * If I change 'education' to 'department-of-education' in the 'department' taxonomy, it changes to 'department-of-education' in the 'topic' taxonomy as well.    * If I delete 'education' from departments, it disappears from topics as well. How can I separate the terms? Wordpress does seem to prevent same-named terms in different taxonomies in the admin, but my taxonomies and terms were imported in the course of a site migration using a WXR file, and Wordpress let them in—so now I'm stuck with them.


title: Check which user saw which page

text: How can I have analytics which show which registered user saw which page? Is there a plugin that can provide this functionality?


title: Include custom post types in categories widget

text: So I got a fairly simple setup, one CPT with the default `category` and `post_tag` as taxonomies. Say I have 1 post and 1 CPT entry assigned to the same category. I need this to be reflected inside the category widget as well. I've managed to display both of them on the category page via the `request` filter so the links generated by the widget work. The problem is that if the post didn't exist, the widget would not generate a link for the category (considering it empty). Also, the item count is incorrect, 1 instead of 2. ### Digging through the widget code, this is what's causing the problems:               wp_list_categories(apply_filters('widget_categories_args', $cat_args));      So I can alter the arguments via the filter but `wp_list_categories()` doesn't have an argument for what post type it should use. ### I've seen someone else encounter the problem before: http://wordpress.org/support/topic/custom-post-types-and-category-widget \- no luck http://themehybrid.com/support/topic/custom-post-types-and-category-widget \- same guy, can't read Justin's responses but I assume no luck again. he filed a ticket at the end which got closed ### Thoughts on the solution I'd really like to not copy/paste the default widget code and create a new one but solve this using a filter somehow. That being said, would a custom walker help with this? Any ideas? As a sidenote, I solved a similar issue with the Archives widget using this:               /*     * Add CPTs to wp_get_archives()     * http://bajada.net/2010/07/15/adding-custom-post-types-to-wp_get_archives     */     function ucc_getarchives_where_filter( $where , $r ) {         $args = array( 'public' => true , '_builtin' => false );         $output = 'names'; $operator = 'and';              $post_types = get_post_types( $args , $output , $operator );         $post_types = array_merge( $post_types , array( 'post' ) ); $post_types = "'" . implode( "' , '" , $post_types ) . "'";              return str_replace( "post_type = 'post'" , "post_type IN ( $post_types )" , $where );     }     add_filter( 'getarchives_where' , 'ucc_getarchives_where_filter' , 10 , 2 );       Cheers!


title: Check post_date in pre_get_posts

text: I want to change the order of a feed using pre_get_posts filter. But I want to exclude dates older than today. I see how one could do that if the date were in a meta key, but the date is in post_date. How can I check post_date to only show posts later than today? The site shows future post dates. is_feed) { $query->set('order','ASC'); } return $query; } add_filter('pre_get_posts','feedFilter'); ?>


title: Exclude Current Post from Recent Posts Loop

text: what would be the best way to exclude the current post I am viewing from this recent posts query. Thank You!               <?php                 global $post;                 if (in_category('top-lists')) {                     $myposts2 = get_posts('numberposts=5&offset=0&category=7');                 }                 else if (in_category('playlists') || in_category('playlistall')) {                     $myposts2 = get_posts('numberposts=5&offset=0&category=6,37');                 }                 else if (in_category('news') || in_category('news')) {                         $myposts2 = get_posts('numberposts=5&offset=0&category=95');                 }                 else {                     $myposts2 = get_posts('numberposts=5&offset=0&category=-6,-7,-37,-95,-177');                 }                      foreach($myposts2 as $post) :                 ?>


title: Add mass action to wp-admin/users.php

text: I'm heavelly modified my Wordpress, it's amazing what you can do with wordpress hooks, actions.. But i'm not able to find how can i add mass action for users. Let's say i select 5 users and i want to asign them some user_meta value.


title: Add dollar sign and commas to a number?

text: I have a field on the admin side where a user enters a number for a price. If a user enters 1000000 I'd like to be able to display on the front-end $1,000,000. Any ideas on how to accomplish this? **Edit** More details, the post is a custom post type 'property'. To add the meta fields on the back-end I'm using Meta Box Script, http://www.deluxeblogtips.com/2011/03/meta-box-script-update-v30.html The code to display the numbers on the front-end I use               $meta = get_post_meta(get_the_ID(), 'rw_propPrice', true); echo $meta;


title: Wordpress development PHP errors diagnosis process

text: I'm spending a lot of time improving my skills with PHP and Wordpress. Occasionally, as I'm working on developing a custom framework I'll upload a new version and it completely breaks, displaying a white screen, sometimes totally blank, but usually with a brief error message. The error messages are often quite cryptic and impossible to diagnose simply because I'm not at the point where I'm familiar enough with the code to understand the dialect. Is there any way to obtain more detailed information related to an error when an error occurs? If so, how? What steps do you take to diagnose a problem in PHP if the error message is vague and you don't understand it?


title: JQuery Slider - Similar to www.internetmarketinginc.com

text: I am looking to add some functionality to a JQuery Slider for Wordpress. I would like to have both navigation styles present like they have done on http://www.internetmarketinginc.com/. I'm not sure how to tie the meta data (Slide title) and the dot navigation together. If I need to present more info, please let me know. Thanks in advance. Jeremy


title: Get posts by menu ID

text: I'm a little stuck here. I have a menu in Wordpress with some posts in it. What I would like is to retrieve all the posts as objects. I think I'm pretty close, but the SQL query doesn't seem to work as I want. This is wat I have so far:               $querystr = "     SELECT wposts.* FROM wp_posts wposts     LEFT JOIN wp_postmeta wmeta ON wposts.ID = wmeta.post_id     LEFT JOIN wp_term_relationships wrel ON wrel.object_id = wmeta.meta_value     LEFT JOIN wp_terms wterms ON wrel.term_taxonomy_id = wterms.term_id     WHERE wterms.term_id= $menu_id     ";          $posts = $wpdb->get_results($querystr, OBJECT);      I'm pretty sure it's a stupid little SQL logic error, but I realy can't find it..


title: Highlight current category, when using get_categories

text: I'm successfully using helgatheviking's answer from this post: Show children of top level category only See code below:               // get the category object for the current category     $thisCat = get_category( get_query_var( 'cat' ) );           // if not top-level, track it up the chain to find its ancestor     while ( intval($thisCat->parent) > 0 ) {         $thisCat = get_category ( $thisCat->parent );     }          //by now $thisCat will be the top-level category, proceed as before     $args=array(         'child_of' => $thisCat->term_id,         'hide_empty' => 0,         'orderby' => 'name',         'order' => 'ASC'     );     $categories=get_categories( $args );     foreach( $categories as $category ) {          echo 'term_id ) . '" title="'     . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' .     $category->name.'';  }      ?>      However, in this list of sub categories, I need to highlight the current category. I'm sure there is an easy answer, but I can't figure it out myself.


title: How to get the post of category

text: I have created the 2 categories. And these two categories have child category, how can i get the post of the category when I clicked on the category title. Please guide me


title: shortcode change variable base on user

text: How would I put this together. For plugin Contact Form 7 Data Base how would I add in the "Submitted Login" (user display name) to the search="name" Original Shortcode               [cfdb-table form="Contact form 1" show="Submitted Login,your-email,your-message" search="AndrewA"]      Tried to put this together a few ways, none worked.               <?php echo do_shortcode('[cfdb-table form="Contact form 1" show="Submitted Login,your-email,your-message" search="' . $current_user->display_name .'"]');?>      This is so users can see their contact form data they have submitted. Thanks for any help.


title: Custom Post Type nest under a normal WordPress Page

text: **EDIT Again, nope it's not impossible, just nasty. Solution below.** * * * Trying very hard to get this working. Have tried numerous suggestions here on stackexchange/overflow My goals are to simply select a 'page parent' on my custom post type and:   * Get permalinks displaying nicely, eg: /page/sub-page/sub-customposttype/   * One custom post type could have a different parent page to another custom post type.   * Get WordPress menu highlighting working, eg: it will apply an 'active' class to any parent menu items when viewing a child custom post type.   * (without hardcoding any page ids or custom slugs) Here is the "Page" that I wish to make as parent: http://ultimateclientmanager.com/support/documentation-wiki/ Here is a "Wiki" custom post type that I wish to nest under that ^ page: http://ultimateclientmanager.com/support/documentation-wiki/change-request/ I have the "Wiki" custom post type slug set to 'support/documentation-wiki' in the code, this allows the permalink URL to look nice like above. However the 'wiki' does not have a parent selected, so menu highlighting does not work (and having different parent page urls for the wiki items would be impossible). Here's some of my recent attempts on getting it to work.   1. Set the "wiki" item post_parents to the ID of my "page".   2. Leave the custom post type rewrite slug set to 'support/documentation-wiki'   3. This generates a URL like: /support/documentation-wiki/support/documentation-wiki/change-request/   4. This produces a 404 error.    5. Debug shows query string of `wiki_page=support%2Fdocumentation-wiki%2Fchange-request&post_type=wiki_page&name=support%2Fdocumentation-wiki%2Fchange-request`   6. And a matched rewrite query of `wiki_page=support%2Fdocumentation-wiki%2Fchange-request&page=` and:   1. Set the "wiki" item post_parents to the ID of my "page".   2. Change the "wiki" post type slug back to just 'wiki' (instead of 'support/documentation-wiki')   3. This generates a URL like: /wiki/support/documentation-wiki/change-request/   4. This produces a 404 error.    5. Debug shows query string of `wiki_page=support%2Fdocumentation-wiki%2Fchange-request&post_type=wiki_page&name=support%2Fdocumentation-wiki%2Fchange-request`   6. And a matched rewrite query of `wiki_page=support%2Fdocumentation-wiki%2Fchange-request&page=` and a desperate attempt to get the correct URL displaying:   1. Set the "wiki" item post_parents to the ID of my "page".   2. Change the "wiki" post type slug back to just 'wiki' (instead of 'support/documentation-wiki')   3. Hack wp_rewrite during the 'wp' hook, change the struct from '/wiki/%wiki_page%' to just '%wiki_page%' like: like: `$wp_rewrite->extra_permastructs['wiki_page']['struct'] = '%wiki_page%';`   4. This generates a correct URL like: /support/documentation-wiki/change-request/   5. But this also produces a 404 error because there it doesn't match anything in the query: `pagename=support%2Fdocumentation-wiki%2Fchange-request&page=` The parent page correctly shows up in the admin "wiki" listing and editing area, just do not seem to be getting anywhere in the frontend. Current permalink settings are just `Day and name http://ultimateclientmanager.com/2013/04/04/sample-post/` This is 3.5.1 setup as multisite.


title: Restore a Plugin's Default Settings

text: Is there a way to code "Restore Defaults" button into a plugin options page? I'm writing a plugin right now that has sets up some default values on activation (via `register_activation_hook`), and I'd like to give users the option to restore those defaults again with a click. Possible? Thanks!


title: Call the content of a page in AJAX in Wordpress

text:
Out of Wordpress, I've made a simple index page wich call the content of 10 other pages thanks to AJAX. Now I need to put this into Wordpress and the AJAX calls don't work at all. I have created the homepage and 10 other pages. When the user arrives on my website, the homepage has a menu. Each item of this menu has a link with the HREF relative to 1 of the 10 pages (thanks to get_permalink( page_id );). My script get the value of the HREF and try to load the content of the page. I worked out of Wordpress but it doesn't inside of Wordpress. Here is the menu :

<a href="<?php echo get_permalink( 41 ); ?>" data-parallax>Règle #0 -La coparentalité

<a href="<?php echo get_permalink( 43 ); ?>" data-parallax>Règle #1 -N’obligez pas votre enfant à faire un choix

<a href="<?php echo get_permalink( 45 ); ?>" data-parallax>Règle #2 -Optez pour un discours positif

<a href="<?php echo get_permalink( 49 ); ?>" data-parallax>Règle #3 -Épargnez les détails à votre enfant

<a href="<?php echo get_permalink( 51 ); ?>" data-parallax>Règle #4 -Ne faites pas de votre enfant votre messager

<a href="<?php echo get_permalink( 53 ); ?>" data-parallax>Règle #5 -Détachez-vous de votre ex-conjoint

<a href="<?php echo get_permalink( 55 ); ?>" data-parallax>Règle #6 -Fixez des limites et des attentes pour vos enfants

<a href="<?php echo get_permalink( 57 ); ?>" data-parallax>Règle #7 -Restez ouvert à la communication

<a href="<?php echo get_permalink( 59 ); ?>" data-parallax>Règle #8 -Devenez adulte et responsable

<a href="<?php echo get_permalink( 61 ); ?>" data-parallax>Règle #9 -Mettez votre enfant en confiance et en sécurité

<a href="<?php echo get_permalink( 63 ); ?>" data-parallax>Règle #10 -Apprenez à rebondir !

      In function.php, I have that :               /************************************************************************/     /*  JS     /************************************************************************/          function load_my_scripts() {              //Include one of my custom javascript files         wp_register_script('scrollTo', get_stylesheet_directory_uri().'/js/jquery.scrollTo-min.js', array('jquery'), filemtime( get_stylesheet_directory().'/js/jquery.scrollTo-min.js'), true );         wp_register_script('seo-parallax', get_stylesheet_directory_uri().'/js/jquery.seo-parallax.js', array('jquery'), filemtime( get_stylesheet_directory().'/js/jquery.seo-parallax.js'), true );         wp_register_script('myscript', get_stylesheet_directory_uri().'/js/scripts.js', array('jquery'), filemtime( get_stylesheet_directory().'/js/scripts.js'), true );              wp_enqueue_script('scrollTo');         wp_enqueue_script('seo-parallax');         wp_enqueue_script('myscript');     }     add_action('wp_enqueue_scripts', 'load_my_scripts');      In jquery.seo-parallax, I have that :               (function( $ ) {       $.fn.SEOParallax = function() {             var container_id = "content"; // the id of the container (must be the same on each page)             var container = $("#"+container_id); // the container where the content will be put in             var pages = $("a[data-parallax]"); // every content that should be injected             var number = 0;             // console.log(number);             $(container).html("");             pages.each(function(page){                 var page = $(this);                      var url = $(this).attr("href");                 console.log(url);                 // Remove the current content                 $.get(url, function(data) {                     // console.log(url);                     var code = $(data);                     code.each(function() {                         if($(this).attr("id") == container_id){                             subcontainer = $("")                             $(subcontainer).appendTo($(container));                             $($(this).html()).insertAfter($(subcontainer));                             $(page).attr("href", "#rule-photo-"+number+"-anchor");                             number += 1;                              }                      })                 });             });                 // wrap the content and include it in the page                  // end       };     })( jQuery );      In scripts.js, I have that :               ;( function($) {         $( "body" ).SEOParallax();              $( "body" ).delegate( "a", "click", function() {             $( 'html, body' ).animate( {                 scrollTop: $( $( this ).attr( "href" ) ).offset().top             }, 1200 );             return false;         } );     } )( jQuery || {} );      So normally, when the page is loaded, the seo-parallax script take the 11 links that are in the navigation, empty #content of the current page and add the content in #content of each page. On chrome, the content is not in the good order. Normally y has to place the content is this order : 0-1-2-3-4-5-6-7-8-9-10. But instead, it's randomly placed (example : 1-4-0-9-6-10-2-5-8-3-7). **UPDATE :** I've called `<?php var_dump($GLOBALS['wp_query']) ?>` juste before `<?php get_footer(); ?>`, here what I have :               object(WP_Query)#23 (47) { ["query_vars"]=> array(55) { ["error"]=> string(0) "" ["m"]=> int(0) ["p"]=> string(2) "41" ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> string(2) "41" ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["comments_popup"]=> string(0) "" ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["fields"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(false) ["update_post_term_cache"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["post_type"]=> string(0) "" ["posts_per_page"]=> int(10) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" } ["tax_query"]=> object(WP_Tax_Query)#43 (2) { ["queries"]=> array(0) { } ["relation"]=> string(3) "AND" } ["meta_query"]=> object(WP_Meta_Query)#42 (2) { ["queries"]=> array(0) { } ["relation"]=> NULL } ["post_count"]=> int(1) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(true) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(false) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(false) ["is_404"]=> bool(false) ["is_comments_popup"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(true) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash"]=> string(32) "8f15f3752a526b936a323e2a33ace1e5" ["query_vars_changed"]=> bool(false) ["thumbnails_cached"]=> bool(false) ["query"]=> array(0) { } ["request"]=> string(143) "SELECT wp_4_posts.* FROM wp_4_posts WHERE 1=1 AND wp_4_posts.ID = 41 AND wp_4_posts.post_type = 'page' ORDER BY wp_4_posts.post_date DESC " ["posts"]=> &array(1) { [0]=> object(stdClass)#62 (25) { ["ID"]=> int(41) ["post_author"]=> string(1) "7" ["post_date"]=> string(19) "2013-03-20 11:06:49" ["post_date_gmt"]=> string(19) "2013-03-20 11:06:49" ["post_content"]=> string(0) "" ["post_title"]=> string(38) "La coparentalité, comment ça marche?" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(34) "la-coparentalite-comment-ca-marche" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-03-20 14:29:31" ["post_modified_gmt"]=> string(19) "2013-03-20 14:29:31" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(43) "http://miniguide.wp.2houses.com/?page_id=41" ["menu_order"]=> int(0) ["post_type"]=> string(4) "page" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["ancestors"]=> array(0) { } ["filter"]=> string(3) "raw" } } ["post"]=> object(stdClass)#62 (25) { ["ID"]=> int(41) ["post_author"]=> string(1) "7" ["post_date"]=> string(19) "2013-03-20 11:06:49" ["post_date_gmt"]=> string(19) "2013-03-20 11:06:49" ["post_content"]=> string(0) "" ["post_title"]=> string(38) "La coparentalité, comment ça marche?" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(34) "la-coparentalite-comment-ca-marche" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-03-20 14:29:31" ["post_modified_gmt"]=> string(19) "2013-03-20 14:29:31" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(43) "http://miniguide.wp.2houses.com/?page_id=41" ["menu_order"]=> int(0) ["post_type"]=> string(4) "page" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["ancestors"]=> array(0) { } ["filter"]=> string(3) "raw" } ["queried_object"]=> object(stdClass)#62 (25) { ["ID"]=> int(41) ["post_author"]=> string(1) "7" ["post_date"]=> string(19) "2013-03-20 11:06:49" ["post_date_gmt"]=> string(19) "2013-03-20 11:06:49" ["post_content"]=> string(0) "" ["post_title"]=> string(38) "La coparentalité, comment ça marche?" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(34) "la-coparentalite-comment-ca-marche" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2013-03-20 14:29:31" ["post_modified_gmt"]=> string(19) "2013-03-20 14:29:31" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(43) "http://miniguide.wp.2houses.com/?page_id=41" ["menu_order"]=> int(0) ["post_type"]=> string(4) "page" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["ancestors"]=> array(0) { } ["filter"]=> string(3) "raw" } ["queried_object_id"]=> int(41) }      Where is the problem ? Thanks you


title: woocommerce create subscription for user using functions / hooks provided

text: I have to create order with predefined "Free" product/subscription for existing user in word press. Need help with sample code.


title: How to sync roles across Multisite?

text: How to synchronize roles on all sites of the Multisite Network if roles were changed on main site?


title: Get parent menu item id on submenu ul using start_lvl

text:
I'm struggling with the `Walker_Nav_Menu`. In the `start_lvl` function, where I create the `<ul>` tag holding my submenu, I want to insert the item ID from the parent menu item.   I know that I can not use `$item`, since that is not available at this point of the walker. The menu structure I want to achieve is something like this:

         ...

...

...

...

      As you can see, I want to give the submenu an ID containing the item ID of the menu element holding that submenu. So: Is there any way to get the item ID of the parent menu item in the `start_lvl` function? Regards,   Niels


title: Pagination with get_posts seems to work but links not showing

text: I've a custom page template where I want to query 2 posts from a post type and 1 post from another post type. I have it set up like this:               $paged = get_query_var('paged') ? get_query_var('paged') : 1;          $articles = get_posts(array(       'post_type' => 'articles',       'numberposts' => 1,       'posts_per_page' => 1,       'paged' => $paged     ));          $news = get_posts(array(       'post_type' => 'news',       'numberposts' => 2,       'posts_per_page' => 2,       'paged' => $paged     ));          $all_posts = array_merge($articles, $news);      Then I do the loop:               <? foreach ($all_posts as $post): setup_postdata($post) ?>       <? get_template_part('content') ?>     <? endforeach ?>      And finally I add pagination. I tried WP-PageNavi as well as regular WordPress functions.               wp_pagenavi();     next_posts_link();     previous_posts_link();      When I go to the page I can see 3 posts as expected (1 article, 2 news) but there is no pagination. If I manually navigate to `/page/2`, `/page/3`, etc. it seems to work and show the next 3 posts but _only_ the `previous_posts_link` shows up, not the `next_posts_link` or PageNavi. The real world example is slightly more complicated and `query_posts` or `WP_Query` are not an option. How to get pagination working properly?


title: How to modify URL structures in custom post types and taxonomies or terms

text: I am well aware that there are several posts covering the topic of customizing the **permalink URL structure** of **custom post types** , **custom taxonomies** , and **taxonomy terms**. However, none of them are real clear, don't work correctly, or cause problems elsewhere. * * * Here are a few links, which already "kind of" cover **URL rewriting**.   1. How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name   2. Custom post types, taxonomies, and permalinks   3. Mixing custom post type and taxonomy rewrite structures? * * * I am looking to create a _permalink URL structure_ along the lines of:   * Post Type Name: cars   * Taxonomy Name: dealers   * Term Name: honda   * Post Title: 123 Hot Rod Lane * * * Example setup of the ideal permalink URL structure: **Generic permalink structure:** `domain.com/post-type-name/taxonomy-name/term-name/post-title/` **More specific permalink structure:** `domain.com/cars/dealers/honda/123-hot-rod-lane/`   * `/cars/` needs to be accessible as an archive listing of every post made in the post type.   * `/cars/dealers/` needs to be accessible as an archive listing of every post made in the taxonomy.   * `/cars/dealers/honda/` needs to be accessible as an archive listing of every post made in that taxonomy term.   * `/cars/dealers/honda/123-hot-rod-lane/` needs to be accessible as a singular view of the post made in the cars custom post type. * * * Just to be clear, so no one does any unnecessary work while replying to this question. I do NOT need anything other than just adding the correct rewrite rules for my post type, taxonomy, and terms. This questions is directly in regards to **permalink URL rewriting** , and NOT in relation to listing of posts or archives. I just need to be sure WordPress recognizes them properly, while using conditional calls like `is_post_type_archive()` or `is_tax()` or `is_singular()`, etc. I've attempted numerous times, from numerous questions/answers on this site. Nothing seems to work. Here is my registered custom post type, and registered custom taxonomy:                   public function register_custom_data(){             /* Register a post type for Cars. */             $labels = array(                 'name' => _x('Cars', 'post type general name'),                 'singular_name' => _x('Car', 'post type singular name'),                 'add_new' => _x('Add New Car', 'Car'),                 'add_new_item' => __('Add New Car'),                 'edit_item' => __('Edit Car'),                 'new_item' => __('New Car'),                 'all_items' => __('All Cars'),                 'view_item' => __('View Car'),                 'search_items' => __('Search Cars'),                 'not_found' =>  __('No Cars found'),                 'not_found_in_trash' => __('No Cars found in Trash'),                  'parent_item_colon' => '',                 'menu_name' => __('Cars')             );             $args = array(                 'labels' => $labels,                 'public' => true,                 'publicly_queryable' => true,                 'show_ui' => true,                  'show_in_menu' => false,                  'show_in_nav_menus' => false,                 'can_export' => true,                 'query_var' => true,                 'rewrite' => true,                 'menu_icon' => NULL,                 'capability_type' => 'post',                 'has_archive' => true,                  'hierarchical' => false,                 'menu_position' => NULL,                 'supports' => array(                     'title',                      'editor',                      'thumbnail'                  ),                 'rewrite' => array(                     'slug' => 'cars',                      'with_front' => true                 )             );              register_post_type('mbe_cars', $args);                  /* Car Dealers */             $labels = array(                 'name' => _x('Dealers', 'taxonomy general name'),                 'singular_name' => _x('Dealer', 'taxonomy singular name'),                 'search_items' =>  __('Search Dealers'),                 'all_items' => __('All Dealers'),                 'parent_item' => __('Parent Dealer'),                 'parent_item_colon' => __('Parent Dealer:'),                 'edit_item' => __('Edit Dealer'),                  'update_item' => __('Update Dealer'),                 'add_new_item' => __('Add New Dealer'),                 'new_item_name' => __('New Dealer Name'),                 'menu_name' => __('Dealers')             );                   $args = array(                 'hierarchical' => true,                 'labels' => $labels,                 'show_ui' => true,                 'query_var' => true,                 'rewrite' => array(                     'slug' => 'dealers',                     'hierarchical' => true                 )             );                  register_taxonomy('mbe_car_dealers', 'mbe_cars', $args);                  /* Update urls. */             flush_rewrite_rules();         }


title: Isolating WordPress to a subfolder

text: I'm trying to isolate a wordpress installation on our site to a specific subfolder. I created a folder on our root site named `_wp` and placed all the wordpress files in there. I added the following rewrite rules to the htaccess in our root folder to allow permalinks within the wordpress installation to work properly.               # Wordpress     RewriteBase /_wp/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /_wp/index.php [L]      This allowed permalinks within the subfolder to work, but it is also allowing requests for files outside the `_wp` folder to forward to the wordpress site. For example, the following page on my wordpress site: http://www.mysite.com/_wp/mypage can also be accessed by the following URL: http://www.mysite.com/mypage I don't want this to happen. I want to isolate all access to the wordpress site by requiring the `_wp` prefix. Does anybody know how I would modify the htaccess above to allow this?


title: Add first url to custom field on publish_post

text: I post a lot using Press This and I allow other users to post. Lately I noticed some duplicates and I m trying to find a way to stop this. I am trying to get the first link from the post, add it to a custom field which will be checked on each publish_post and if it exists add the user's name in another custom field. I did one test and the url was added to the "link" custom field and that s it. It stopped working. I m not sure what I m doing wrong.               add_action( 'publish_post', 'check_post' );     function check_post( $post_id ) {     $user_info = get_userdata(1);                  function get_first_link() {                      global $post, $posts;                 preg_match_all('/href\s*=\s*[\"\']([^\"\']+)/', $post->post_content, $links);                 return $links[1][0];                  }             $first_link = get_first_link();                  add_post_meta($post_id, 'link', $first_link, true);             add_post_meta($post_id, 'users', $user_info->user_login, true);     }


title: Confused about customising widgets

text: I am fairly new to wordpress but im having trouble working out how to customise the widgets. I have customised the search widget like so (in the functions.php file)               function widget_search() {         echo '<form role="search" method="get" class="search" action="'.home_url( '/' ).'">         <input type="search" name="s" placeholder="Search then hit enter" />         </form>';     }     if ( function_exists('register_sidebar_widget') )         register_sidebar_widget(__('Search'), 'widget_search');      But i want to customise the recent posts widget and other but how to i do this. Do i just do the same method like the search on? Iv looked at the codex but i cant seem to find the answer


title: Widget Select Options not saving

text: I have a widget where there is a select dropdown, with a list of all the pages on the site. I am trying to get my code correct so that when a user chooses a page, after clicking Save in the widget, the select box doesn't revert back to 'Select a page' value. This is the snippet I have now but it's not working correctly. There are no errors being displayed either. Any help would be welcome. Thanks               <p>     <label for="<?php echo $this->get_field_id('read_more_link'); ?>"><?php _e('Read More Link', 'iw_widget_plugin'); ?></label>          <select name="<?php echo $this->get_field_name('read_more_link'); ?>" id="<?php echo $this->get_field_id('read_more_link'); ?>" class="widefat">              <option value="Select A Page">             <?php echo esc_attr( __('Select A Page') ); ?>         </option>         <?php             $pages = get_pages();             foreach ($pages as $page) {                echo '<option value="' . get_page_link($page->ID) . '" id="' . $page->post_title . '"', $read_more_link == $page ? ' selected="selected"' : '', '>', $page->post_title, '</option>';             }             ?>     </select>


title: Scroll over to get definition

text: I need to have content appear when I scroll over certain words or groups of words. Eg. If I scroll over the word pastor. I should see a definition of Pastor appear next to the word.I would like to write in the definition myself.


title: Is it possible to include the add_filter() function within a shortcode function

text:
I am trying to pass content to the 'google_dfp_ad_slot' filter. Can this be done within a shortcode funcion?               /**          * Shortcode function to dynamically add google dfp ads to inline content and widgets          *          * [fopconnect_ad is_page="true" page="about"]          *   {JS}googletag.defineSlot('/6111408/FOPC_All_LeaderBoard_728x90', [728, 90], 'div-gpt-ad-1398288352265-0').addService(googletag.pubads());{/JS}          *   {HTML}

{/HTML}          * [/fopconnect_ad]          *          * @param  array $atts    shortcode attributes          * @param  string $content          * @return sting          */                        add_shortcode( 'fopconnect_ad', 'fopconnect_ad_func' );         function fopconnect_ad_func( $atts, $content ) {             extract( shortcode_atts( array(                 'is_page' => false,                 'page' => '' // can be title, slug, or id             ), $atts ) );                  preg_match("#\\{JS\\}(.*?)\\{/JS\\}#s", $content, $matches);             $js = ( !empty( $matches[1] ) ? $matches[1] : '' );                  preg_match("#\\{HTML\\}(.*?)\\{/HTML\\}#s", $content, $matches);             $content = ( !empty( $matches[1] ) ? $matches[1] : '' );                  if ( $is_page && is_page( explode(', ', $page) ) ) {                 add_filter( 'google_dfp_ad_slot', function( $js ) { return $js; } );             }                  if ( $is_page && is_page( explode(', ', $page) ) ) {                 return $content;             }              }


title: Is saving multiple options or saving multiple items in one option better?

text: I have added multiple fields to a custom taxonomy. I followed Pippin's tutorial. This method creates a single option per taxonomy item. The multiple fields are saved in `taxonomy_id`. I was not sure if just creating only a single option and having a multi directional array with the taxonomy id in the option would be better. What are the performance and database implication for the two different methods? Edit: The information will normally only be pulled for a single taxonomy. Here are the two code examples.               /**      * Save extra taxonomy fields callback function.      *      * Single Array      */     public function save_taxonomy_custom_meta( $term_id, $tt_id ) {         if ( isset( $_POST['term_meta'] ) ) {                  $term_meta = get_option( 'playlist_' . $term_id );             $cat_keys = array_keys( $_POST['term_meta'] );                  foreach ( $cat_keys as $key ) {                 if ( isset ( $_POST['term_meta'][$key] ) ) {                     $term_meta[$key] = sanitize_text_field( $_POST['term_meta'][$key] );                 }             }             // Save the option array.             update_option(                 'playlist_' . $term_id,                 $term_meta             );         }     }          /**      * Save extra taxonomy fields callback function.      *      * Multi-directional array      */     public function save_taxonomy_custom_meta( $term_id, $tt_id ) {         if ( isset( $_POST['term_meta'] ) ) {                  $term_meta = get_option( 'playlist_' . $term_id );             $cat_keys = array_keys( $_POST['term_meta'] );                  foreach ( $cat_keys as $key ) {                 if ( isset ( $_POST['term_meta'][$key] ) ) {                     $term_meta[$key] = sanitize_text_field( $_POST['term_meta'][$key] );                 }             }             //             $term_meta[$term_id] = $term_meta;             // Save the option array.             update_option(                 'plugin_name_playlist',                 $term_meta             );         }     }


title: How to stop _wpnonce and _wp_http_referer from appearing in URL

text: I am trying to develop a plug-in that has a search field and uses WP_List_Table. The plug-in is strictly for the backend and searches the users in the database and returns them along with some other meta from an additional plug-in. When I do a search for the user the hidden input fields of _wpnonce and _wp_http_referer are added to the url string. The _wpnonce is not that big of a deal but the _wp_http_referer is a problem. If the person using the plug-in keeps doing multiple searches the _wp_http_referer string becomes so long in the URL that it gives an error: Request-URI Too Large The requested URL's length exceeds the capacity limit for this server. So how do I either stop the hidden values from appearing in the URL or reset _wp_http_referer each time the search button is clicked?


title: Recent posts with comment count in "Sidebar" template

text:
I tried this code, but it totally broke my site. I suppose it's because I'm doing something wrong in the WP_Query's sacred posts context in the sidebar template. Could some WP guru please correct this code?               <?php           $args = array(         'orderby' => 'date'         ,'order' => 'DESC'         ,'showposts'=>6     );          $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {            echo "
";            while ($my_query->have_posts()) : $my_query->the_post();             $recent_title = get_the_title();       $recent_link  = get_the_permalink();       $recent_date  = get_the_date();       $recent_count = $post->comment_count;       if ($recent_count < 1)        { $recent_count = 'Leave a Comment '; }       else                          { $recent_count = "$recent_count Comments "; }                 echo "
$recent_date   /   $recent_count

$recent_title
"            echo "
";            endwhile;     }     wp_reset_query();  // Restore global post data stomped by the_post().          ?>      Just in case this doesn't appear properly formatted, here's the code on Gist I really do NOT want to use a plugin for this simple functionality.


title: displaying a fall back query if there's nothing in the post-type category

text: I'm stuck trying to figure out the best way to manipulate my query so that if there's nothing in the category it will display the latest post-type. Here is the query I've got that pulls in the posts from the category at the moment. http://pastebin.com/uvpMUpFt


title: How can i get count from query post

text: How can i get the row counts in query post like mysql count(*).               $obj_name = new WP_Query($args);          while ($obj_name->have_posts()) : $obj_name->the_post();           // here i want to predict looping counts          endwhile;      How can i do this.


title: What hooks/filters are there to alter selected terms on post save?

text: Very simple, where would I hook/filter to alter the users selection of terms when they save a post (Update or Add)? I need to hook in all instances; such as when saving a post via AJAX, saving when JavaScript is disabled and a normal POST is done and when posts are saved via quick edit.


title: I'm using the offset parameter and dynamically loading posts via waypoints, how do I reset the offset?

text: I have posts that load when I hit the bottom of a container, lazy load, infinite scroll etc. using the jquery waypoint plugin. I have a button that dynamically loads the first 3 posts again, so I can scroll to load the posts again. The problem is that it appears I run out of posts, as I'm running offset +3 each time I hit a waypoint. Ajaxing that number and retrieving a loop with offset => $offset. It works fine if I refresh the page, so is there a funtion I can tie to the button that tells wordpress to make revert the offset back to zero without reloading the page? Here's the JS I'm using and the loop I'm calling: JS               jQuery(document).ready(function($){         $("a.sort-all").bind("click", function(e) {             load_posts(this);             e.preventDefault();                          });              function load_posts() {             var ajax_url = $('.sort-all').attr('data-all-url');             $.ajax({                 dataType: "HTML",                 url: ajax_url,                 type:'POST',                 data:{                     action: 'data_click_all'                 },                 success:function(data) {                     $('#content').html(data);                 }             });              }              var ajax_url = $('.sort-all').attr('data-all-url');         var offset = 0;         $('#content').waypoint(function(direction) {             if(direction === 'down'){                 offset = parseInt(offset) + 3;                 $.ajax({                     dataType: "HTML",                     url: ajax_url,                     type:'POST',                     data:{                         action: 'data_scroll_all',                         offset: offset                     },                     success:function(data) {                         $('#content').append(data);                         $.waypoints('refresh');                     }                 });             }         }, {             offset: 'bottom-in-view'         });     });       PHP               function data_scroll_all(){                 $offset = $_POST['offset'];                 $args = array('posts_per_page' => 3, 'category__not_in' => 1, 'offset' => $offset, 'orderby' => 'date');                 $loop = new WP_Query($args);                 if($loop->have_posts()) {                     while($loop->have_posts()){                         $loop->the_post();                         get_template_part( 'content-archive' );                     }                 } wp_reset_postdata();                 die('');             }


title: Extracting gallery images in Wordpress 3.5 on index.php

text: I'm trying to add a slider on my front blog page for every gallery post, but I have some trouble extracting the images from the post gallery, using the following code:               $post_content = get_the_content();     preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);     $array_id = explode(",", $ids[1]);      The problem is that each gallery post consists of paragraph with text, "read more" break and a gallery after the break and thus **get_the_content()** skips the images because they are after the break. How can I make it get the whole content, regardless of breaks? I use "read more" because I want short description about the gallery post before clicking on it to read it.


title: Ways to have multiple front-page.php templates that can be swapped out?

text: I essentially want to create several different front-page.php templates with different loops and layouts and then present an option in the admin panel to select one template on one day and a different template on another day. This can be done, I suppose, by fooling Wordpress and selecting a static page to appear as the front page and selecting a custom page template from the page edit screen which really is not a "static" page, but instead a page with a full loop – one of the several custom page templates that _would_ have been my front-page.php options. Another way would be to have all my loops and custom layouts enclosed in if statements in the one front-page.php and presenting options that engage one of the if statements each time. (This seems reasonable – though a bit clumsy to me – but I have a feeling it's not so great and that there are problems, like load times increasing.) Are there any options I'm missing? Or perhaps plugins which do this for me? I must admit I'm surprised that I haven't been able to find a plugin which allows you to select from a list of templates to display as the front- page.php/index.php page without having to resort to the static page hack – variations of loops and homepage layouts must be a common request.


title: There is no section of plugin

text: there is no section about plugins in my blog's dashboard. I would like to put music on the background.Thank you


title: different theme in one website

text: Assume this is my site name : `www.example.com.` I saw different websites have different themes in a site. For example I want to have different themes for `www.example.com` and `www.example.com/othertheme.` I know it should have different database for that. But how?


title: Query posts WITHOUT a custom meta field

text: I'm trying to build a custom query that will return all posts that **DON'T** have the associated post meta. I'm not quite sure how to do this...here is what I am working with, and for your reference "score" is a custom column that I have added to the posts table.                   $querystr = "             SELECT $wpdb->posts.ID              FROM $wpdb->posts, $wpdb->postmeta             WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id              AND $wpdb->posts.post_type = 'post'             AND $wpdb->posts.post_date < NOW()             AND $wpdb->postmeta.meta_key != '_social_'             ORDER BY $wpdb->posts.score DESC             LIMIT 1          ";              $result = $wpdb->get_row($querystr, ARRAY_A);         add_post_meta($result["ID"], "_social_", date("Y-m-d-H-i"), true);      The above example does not work. The context of this is that I'm running a cron to auto publish a single post to my social networks each half hour, and after I do this, I want to add the post meta `_social_` so that on my next cron, I do not add it to my social networks a second time. This query, I hope, will always give me the post with the highest score that has not yet been added to my social networks. Could anyone tell me how to query all posts that exclude the `_social_` custom post meta?


title: Is there a plugin that pushes posts to your Google+ profile?

text: A Google+ equivalent to Simple Twitter Connect that pushes every post you make to your G+ profile - does such a plugin exist?


title: Restrict filter to run only inside specific function

text: I would like to filter `get_terms()`, but I only want to filter `get_terms()` when it is called from the `wp_terms_checklist()` function. I am looking to add a "No term" option to the end of my checklist (radio buttons actually as this pertains to my Radio Buttons for Taxonomies plugin). I have already done this but find it produces some PHP notices in the `restrict_manage_posts` hook, so I was wondering if there was a way to limit the application of the filter.


title: How to remove automatic generated <p> tag in Home page

text: I am new to Wordpress and need some helps here. I am trying to add posts that have written codes for the demonstrated purpose of programming languages. I installed SyntaxHighlighter Evolved plugin. The post looks great when I preview it or view the post under category. However, it seems that Wordpress generated `<p>` tag in my Home page and messed up the codes of the post. I am not sure how to fix this. Any thoughts? Thanks a lot.


title: Rewrite Rules problem when rule includes homepage slug

text:
I have page Example (ID=443, slug=example) that is configured, through `Dashboard->Settings->Reading`, as the home page of my WP site. I also have the following rewrite rule configured:               [(example)/(view-section)] => index.php?pagename=$matches[1]&foo=1&bar=2      I have a shortcode in the Example page that should generate content based on presence and value of `foo`and `bar`query vars. The problem is the query vars are not properly set when I visit the URL `/example/view-section` (and others related, see below). I'm using a test plugin to debug this issue only. The complete code is below:                    <?php          function test_shortcode() {         global $wp_rewrite;              echo '
' . 'foo: ' . get_query_var('foo') . '
';         echo '
' . 'bar: ' . get_query_var('bar') . '
';         echo '
' . print_r($wp_rewrite->rules, true) . '
';     }     add_shortcode('foobar', 'test_shortcode');          function test_rules() {         $rules = get_option('rewrite_rules');         if (!isset($rules['(example)/(view-section)'])) {             global $wp_rewrite;             $wp_rewrite->flush_rules();         }     }     add_action('wp_loaded', 'test_rules');               function test_rewrite_rules($wprules) {         $rules = array('(example)/(view-section)' => 'index.php?pagename=$matches[1]&foo=1&bar=2');         return $rules + $wprules;     }     add_action('rewrite_rules_array', 'test_rewrite_rules');               function test_query_vars($query_vars) {         array_push($query_vars, 'foo');         array_push($query_vars, 'bar');         return $query_vars;     }     add_filter('query_vars', 'test_query_vars');      There are three scenarios that gave me different results:   1. Going to /example/view-section redirects to / and the query vars values are empty.   2. Going to /index.php?pagename=example&foo=1&bar=2 works the way I needed. Showing the content generated by the shortcode and the value of the two query vars passed in the URL.   3. If I use `page_id` instead of `pagename` or `page`: /index.php?page_id=443&foo=1&bar=2, the `page_id` query var is removed and the default homepage is shown again. I would like to know why is WP behaving as described above and, if possible, how to make the first case, at least, work like the second one. Please note that if the Example page is not configured as the homepage, cases 1 and 3 work as the case 2. I appreciate your help and will be happy to provide more details if necessary. **EDIT** The question originally included links to a running WP instance with an example of the problem. However, I can't keep that instance running forever, so I removed the links and tried to explain the situation with words only.


title: Would  to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?

text: I have a slider in my theme. I have a setting in the options which controls whether that slider is set to "slide" or "fade". This slide/fade setting is in the jquery and of course the options setting is in the database. I presume the normal method of getting this setting is via AJAX but I thought I'd ask as I have a number of other similar scenarios on this theme. I always think of AJAX as meaning "change data without having to re-load the page" .... but in this case I just want jquery to have access the data when the page is first loaded ... so it seems my "understanding" is a bit off and jquery is needed for **any time** javascript/jquery needs to get info from the database.


title: Lost admin "manage_link" capability WordPress. No "Links" menu item in admin menu

text: Going slightly mad. In the process of upgrading a client's website to WordPress 3.5.1 we've decided to use the built-in WordPress "Links" system to manage their affiliations. I am using the "Admin Menu Editor" plugin, and I can see the "Links" menu item in there, but it's not showing up in the menu, despite having Administrator privileges. I changed the required capability using this plugin to `administrator` rather than `manage_links` but the attempt to view the Links form gave me the "Cheatin' are we?" page. I have tried deactivating all plugins, installed the "Capability Manager" plugin to check capabilities - all present and correct, including the necessary `manage_links` privilege. I've check the database - both `wp_user_roles` in `wp_options` and that the `wp_user_meta` is correct for my login. What on earth is up?


title: Pass variables from one widget to another widget

text:
I wrote a widget but I need to use the variables from one widget in another...both widgets are in the same dynamic sidebar. This is what I am trying to do: I wrote a widget that adds a footer to the bottom of an image slider widget. When I add the footer widget under the slider widget...the footer shows up. The problem is that I need the footer widget to appear within the slider
 set, not under it. For example:

do slider stuff here

display footer widget here

      However; the footer widget displays right after the slider widget is done.

do slider image show

display footer here

      Otherwise; the bottom css of the slider pushes the footer down and messes things up. If I adjust the css so the footer and slider have a zero bottom margin and padding then the content below the banner has no spacing when the footer widget is not present. This is how I want it to look, flush: http://i50.tinypic.com/15ogq41.jpg (sorry don't have enough point to post an image) ...but widgets are executed in order so this is what happens: http://i45.tinypic.com/2va0f48.jpg I could solve the problem by using two css classes and check if the widget exists and run .yes-widget {} or .no-widget{} but I think it's is a lot cleaner to just be able to pass the variables from one widget to another. How I got the first image to work (but none of the variables form the footer widget are passed)...I included the footer html within the slider's widget like this:

do slider stuff here

             <?php global $ct_on, $child_dir;                 if($ct_on && file_exists($child_dir.'/library/includes/yif-top-banner-section-footer.php')) {                     include_once ($child_dir.'/library/includes/yif-top-banner-section-footer.php');              } ?>

      This is the footer html that is included:

             <a href="<?php echo $fltitle;?>" class="footerbox left-box no-underline">
<?php echo $fltitle;?>

<?php echo $fltext;?>
                               <a href="<?php echo $fmlink;?>" class="footerbox middle-box no-underline">
<?php echo $fmtitle;?>

<?php echo $fmtext;?>
                               <a href="<?php echo $frlink;?>" class="footerbox right-box no-underline">
<?php echo $frtitle;?>

<?php echo $frtext;?>

      Unless you have a better way then included the footer html right where I want the footer to execute...how do I get the variables form the footer widget to work in in the included footer html file? For example, the footer widget saves this variable: $frlink. How do I pass $frlink to the included file? I have tried GLOBAL but I am not sure which function of the slider widget to add it. For example, the function that has the widget Constructor, where it prints the widget, saves the widget, the widget form in the backend , etc.


title: Why am I getting a "Call to undefined function curl_init()" when I try to use the Sociable plugin?

text: I have a wordpress blog at http://www.1000irritatingthings.com I had the sociable plugin working for a while, but now when I try to configure it, I get the following error in the admin panel when I select Sociable classic: > **Fatal error:** Call to undefined function curl_init() in > > `D:\(WEBSITES)\1000irritatingthings.com\www\wp- > content\plugins\sociable\includes\sociable_output.php on line 28` I'm not a PHP guy, so I'm clueless. I promise that I haven't altered anything manually, I'm totally a "Manage it from the Admin Panel and not touch anything below the surface" kind of guy.


title: Wordpress plugin options need to delete after deactivate & uninstall

text: I have developed a wordpress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:               <?php          function WCM_Setup_Demo_on_uninstall()     {     //if uninstall not called from WordPress exit     if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )          exit();          $video-thumbnail1 = 'video-thumbnail1';               // For Single site     if ( !is_multisite() )      {         delete_option( $video-thumbnail1 );     }      }     ?>      And included this in my main plugin file:               register_uninstall_hook('uninstall.php', 'WCM_Setup_Demo_on_uninstall');      This is how i'm registering the option in my main plugin file:               register_setting( 'baw-settings-group', 'video-thumbnail1' );      When I deactivated and deleted the plugin from the dashboard, the plugin gets deactivated but not deleted. When one press delete a blank white page comes up.


title: How to remove duplicate Wordpress site from sub domain after move

text: I followed the instructions below to the T and it worked very well except that now I have a duplicate copy of my wordpress site both on the sub domain and on the root domain. How do I remove the site from the sub domain? Thanks!! Instructions Followed: You can actually just leave your files in that subfolder and follow these steps per the codex.   1. In the general settings, change your Site Address (URL), not the Wordpress Address URL, to http://example.com/ and save.   2. Copy (NOT MOVE!) the index.php and .htaccess files from your subdirectory into the root directory of your site.   3. Open your root directory's index.php file in a text editor   4. Change the line that says: require('./wp-blog-header.php'); to the following, using your directory name for the WordPress core files: require('./test/wp-blog-header.php');   5. Login to the new location. It might now be http://example.com/wordpress/wp-admin/ If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)


title: Multisite, domain mapping and SSL?

text: I have been doing alot of research and everything on the subject seems to be one of areas where everyone is finding some sort of different solution. I am setting up a network something like edublogs.com and some sites will have mapped domains. I need to have some pages secured for the sites. These pages include some custom admin user profiles pages and checkout pages for a simple shopping cart/store system. I am not looking for how to set it up, but if it is possible on a multisite and if anyone here has personaly accoumplished it succsesfully? Thanks


title: Confused by $wpdb->prepare

text: I am attempting to use $wpdb->prepare to protect against SQL injection attacks and am lost. I have the following snippet below which checks the h_transactions table for a transaction id. If it doesn't find the id then it adds it to the table...               <?     global $wpdb;     $table_name = $wpdb->prefix . "h_transactions";     $registered = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE transactionid = '{$transactionid}'" );          if ($registered == 0) {       $wpdb->insert( $table_name, array( 'transactionid' => $transactionid ), array('%s')  );     }     else     ?>      Do I need to use $wpdb->prepare on both the SQL query and the SQL insert?


title: If post_type is This or This

text: I'm basically using this bit of code in my `functions.php` to order my custom post types by title in ascending order.               function set_custom_post_types_admin_order($wp_query) {       if (is_admin()) {              $post_type = $wp_query->query['post_type'];              if ( $post_type == 'games') {           $wp_query->set('orderby', 'title');           $wp_query->set('order', 'ASC');         }         if ( $post_type == 'consoles') {           $wp_query->set('orderby', 'title');           $wp_query->set('order', 'ASC');         }       }     }     add_filter('pre_get_posts', 'set_custom_post_types_admin_order');      Is there a way to combine those two`if` statements, so I'm not repeating code. Something like this:               if ( $post_type == 'games' OR 'consoles') OR {           $wp_query->set('orderby', 'title');           $wp_query->set('order', 'ASC');     }      Thanks!


title: My Email Newsletter plugin will not configure when I try to import the widget

text: I am currently using the "Spun" theme for my website and bluehost as my hosting product. I downloaded and activated the "Email Newsletter" plugin, however when I try to import the widget it does not show up on my website. Is this theme not compatible for email subscriptions? Or is there something I am missing?


title: New User Sessions in Wordpress?

text: Is there any way to create a simple user session on Wordpress, like a mini- membership kind of thing? Would this conflict with WP's general user sessions, or is it possible to set up a simple uesr/pass combo in your database and use this to create a sub-membership system?


title: Custom URL structure with external web service

text: I have WordPress site which displays content from database, but I also want to consume .NET web service hosted on the Windows Azure and fit the content inside the WordPress. URL structure of WordPress site is following:               www.sitename.tld/{category}/{post}      However, there will be two categories (possibly pages):               www.sitename.tld/{specific-category}/{web-service-url}      This **web-service-url** will be the Web API parameter. Let me explain bit further:   1. User navigates to URL: `www.sitename.tld/{specific-category}/{web-service-url}`   2. WordPress makes HTTP GET request to Web API service   3. Web API returns JSON or XML   4. WordPress parses and displays content I was thinking about making AJAX call to Web API service and using JSONP, so the URL structure would be something like:               www.sitename.tld/{specific-category}#web-service-url      This might be easier to code, since I could use some of the JavaScript template engine instead of parsing JSON (XML) with PHP. Website would load and users would have to wait for response from web service before the site is rendered, which could give impression of faster loading times. `www.sitename.tld/{specific-category}` would most probably display list of items, while the `www.sitename.tld/{specific-category}/{web-service-url}` would be the details page.   * I'm developing own WordPress theme for this site   * Those two categories will probably be two templates: `category-specific1.php` and `category-specific2.php`   * Storing the content in the WordPress database **is not an option** **What would be the best approach to solve this problem considering:**   * SEO (is AJAX solution mention above Google friendly?)   * Time to implement I'm leaning towards AJAX, but don't have all the information to make a good decision. What are the cons of that solution considering the SEO?


title: Deletion of shared options using uninstall.php

text: I'm using `uninstall.php` for my plugin to delete all the traces my plugin did to a site on uninstall (delete). I did it in a good way, but even after the deletion there are some fields in the `options` table:   * `uninstall_plugins`   * `recently_activated`   * `_site_transient_update_plugins` in these options there are multiple values from other plugins too. How can I take care of such traces, how can I remove all those traces too? I checked WooCommerce and found they leave no traces after there deletion, if the "delete data" checkbox is checked. How can I do so?


title: Insert Rich Text Editor in theme?

text: I'm building a custom front end form for my theme and I'd like to use the Wordpress TinyMCE Rich Text Editor for it. Is there an easy way to invoke it? Thanks!


title: Find Page Last Modified at Certain Date & Time

text: How can I find the page which was last modified on 2011-07-20T20:48:16+00:00 other than opening every page?


title: Pagination on Single Custom Post Type Pages

text: I have a custom post type called Brands and on the single-brands.php page I have a secondary loop that gets all the posts that are in a taxonomy. Everything works fine except I can't get the page to paginate. If I visit brand/brandname/page/2/ it just redirects me back to the brand/brandname/. This is driving me nuts please help me. Here is my secondary loop if that will help               <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>     <?php $args = array(             'post_type' => 'products',             'paged' => $paged,             'posts_per_page' => 1,             'caller_get_posts'=> 1,             'tax_query' => array(                             array(                                 'taxonomy' => 'brands',                                 'field' => 'slug',                                 'terms' => $slug                             )                         )                 );


title: Large Media Library

text: I'm looking to organize a large WordPress Movies/Actors site, with thousands of posters, screenshots, etc... I currently have the images in a directory structure like /actors/firstname_lastname/filename1, etc.. with a database matching each pathname with a movie. Some names may have thousands of images. I suppose I want to import these into WP media library, and start using them in WP. I don't know whether to attach them to a post, one post per name, or if there's a better approach. How would you solve this problem?


title: How to display serial numbers in foreach loop while querying posts?

text: Ok, I have a custom post type to store list of urls. I would like to print those urls with serial numbers. I used foreach loop.               foreach($urls as $url){     echo $url;         I got n number of urls as output. But i want to print serial numbers in each url like 1,2,3 and so on. I don't want to use unordered list. Because i want to style my serial numbers too. So is there any way to print serial numbers?


title: P2P Plugin: ¿How to show the most connected items?

text: I have **2 Custom Post Types** on my WordPress, that works like **Movies and Actors** , related with the _Posts 2 Posts_ plugin. The relation between them is many-to-many, and I want to show **the actors that are most connected** to movies, so I can show the most prolific Actors on the _database_. Additionally, I would like to do the same, but **only with movies from a certain genre** (that is a Custom Taxonomy). ¿How can I do that? Thank you in advance.


title: Page template with different page and post content

text:
I am using a wordpress theme which has a page template named `roomtypes`. I am not a php pro but as far as I understand this template gets the posts. When I add a Room type, it is created as a post with a `post_type=roomtype`.   So this template gets these posts, adds their title and a thumbnail image. My problem is, when I create a page and enter some text it does not shows when I choose this template.   So with some digging I found out that `the_content();` function does the trick. I tried to add it and it worked:)   The matter is, I cannot use the content where I need it to be. This is the code:               <?php     /*     Template Name: Roomtypes      */     global $wp_query;     get_header();?>            <div class="middle-inner-wrapper" style="background:#e7dfd6 url(<?          php echo TEMPLATE_URL.get_option('tgt_default_inner_background');?>) no-          repeat center top;">

<a href="<?php echo HOME_URL;?>"           style="color:white"> <?php echo get_option('tgt_hotel_name'); ?          >

» <?php _e ('Rooms', 'hotel');?>

                                                                      <?php                                                                  global $post;                             query_posts          ("post_type=roomtype&orderby=name");                             if ( have_posts() ) {                                        ?>

<?php _e ('Rooms',           'hotel');?>

                                       <?php $i=0; while (           have_posts() ) { the_post(); $i++;                               //$thumbnail_id =           get_post_thumbnail_id($post->ID);                             // $link_image =           wp_get_attachment_image_src( $thumbnail_id, 'roomtype-image' );                             //$link_thumbnail =            wp_get_attachment_image_src($thumbnail_id);                              if(has_post_thumbnail()) {                                 $thumbnail_id =           get_post_thumbnail_id($post->ID);                                 $link_image =           wp_get_attachment_image_src( $thumbnail_id, 'roomtype-image' );                             } else {                                   $args = array(               'post_type' => 'attachment',               'numberposts' => -1,                           'post_parent' => $post->ID,                'post_mime_type' => 'image'                                         );                                  $attachments =           get_posts($args);                                 $link_image =           wp_get_attachment_image_src( $attachments[0]->ID, 'roomtype-image' );                                }                                        ?>                                                     <?php if($i%2!=0){  ?>

                                                      <a           href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                                     <?php if           ($link_image[0] != ''){ ?>                                     <img           src="<?php echo $link_image[0]; ?>" />                                     <?php } ?>
                                 <a class="room-          link" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php           the_title(); ?>
                             <?php } else{ ?>

                                     <a           href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">                                     <?php if           ($link_image[0] != ''){ ?>                                     <img           src="<?php echo $link_image[0]; ?>" style="margin-top:3px;" />                                     <?php } ?>
                                 <a class="room-          link" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php           the_title(); ?>
                                  <?php } };                             }else{ ?>

 <?php _e('No Rooms           Available!', 'hotel') ?>

                                 <?php                                     _e('Sorry, but this section           has no rooms!', 'hotel');                                 ?>

                             <?php } ?>                             <?php wp_reset_query(); ?>

                      <?php get_sidebar();?>

                       <?php get_footer();?>      I need the content to be where I'm indicating in the code, but some how when I add
      <?php if (have_posts()) : while (have_posts()) : the_post();?>            <?php the_content(); ?>           <?php endwhile; endif; ?>
      Things gets messy.   If I only add `the_content();` then it gets much more worse,all those posts content is shows:(   How can I add only the content of the page I use the page template?


title: I'm using wp_nav_menu to display my menu, but I want one more link in there that is a hardcoded link. How can I do this?

text: I want to have all my dynamically generated links in my nav menu, but the second last one should be a link to my "Work" for my portfolio, which is just a link to a section on my main page. (Anchor link) How can I do this?


title: get post types and plugin order

text: I write a simple plugin to get all post types by using get_post_types. But it does not work.               $customPost = get_post_types(array(), 'object');      it returns default post types of wordpress. When i install Woocommerce plugin, it does not show the custom post types of woocommerce ? Does it relate to plugin order ?


title: How to detect filter in URL in Category page?

text: I need to add an additional filter based on a category for posts that have a custom post_type. For example, I have a page located at `/category/tasks` that lists all tasks. I need to make it so I can have additional pages that filter even further like `/category/tasks/current`, `category/tasks/future`, `/category/tasks/past`. I can figure out how to get the query to work, I just am not sure how to pick up the type of filter from the URL. (currently it goes to a page not found error when adding the additional word after /tasks)


title: Front end user creation form! How do you keep the user on the same page in event of error?

text:
I've recently tried to add a user registration form to the front end of my site and have used the following form code (based upon http://digwp.com/2010/12/login-register-password-code discovered in an answer by maugly in question Front-end Register Form) in a template file:

Add a child
             <form method="post" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" class="wp-user-form">
                     <?php _e('Child Name'); ?>:                      <input type="text" name="user_login" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" id="user_login" />

                     <input type="text" name="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" id="user_email" />

                     <?php do_action('register_form'); ?>                     <input type="submit" name="user-submit" value="add child" class="user-submit" />                     <?php                           $register = $_GET['register'];                                if($register == true) {                               //now add it to the link database                              echo '
User Added!
';                           } ?>                          <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?register=true" />                            <input type="hidden" name="user-cookie" value="1" />
             </form>
      The redirect_to attribute is set here to the requesting page which is all great when it works by triggering the if block to display an additional success message. The question I have is when an error is detected in wp-login.php (such as the username is already in use) how do I get the redirect to come back to this page as opposed to the wp-login generated login box/error display? I can't see any obvious hook to grab hold of (although I've never used actions yet, so could be missing something!) Help and guidance very much appreciated! Ryan


title: Read more on pages WordPress

text: I'm fairly new to WP but absolutely loving it. And here is my problem. I know that this topic it's already on the Forum but the solution simply don't work for me. I have a few pages where I would like to split content using read more. So I have done recommended hack by adding global               $more; and $more = 0; the_content();      and everything seem to look ok although every time I click on read more link nothing happens and following result appear in my browser http://www.mysite/#more-15 Could anyone help me? Many Thanks in advance dompl


title: Add_meta_box not appearing, but does appear in screen options

text:
I'm adding a meta box to a wordpress admin page. It works fine on my local server but when I upload it to the live server the meta box doesn't appear. Its does, however, appear in the screen options so I know the code is working, to some degree, its just not displaying anything on the edit page. Does anyone have any ideas?               function ila_add_custom_box() {              add_meta_box(             'content-on-page',             'Content On Page',             'ila_render_meta_box',             'page',             'high'         );     }          add_action( 'add_meta_boxes', 'ila_add_custom_box' );          function ila_render_meta_box(){ echo "
Edit Page Options
"; }      Thanks Edit: I've switched all the plugins off and that didn't solve it