How to display categories of my Custom Post Type?

I have a custom post type for a portfolio: Link to the test site. What I'd like to do is to display the project categories just on top of the projects so visitors could then filter projects accordingly. In my functions.php I have:               <?php          require_once('portfolio-type.php');     add_filter('excerpt_length', 'my_excerpt_length');          function my_excerpt_length($length) {     return 25;      }          add_filter('excerpt_more', 'new_excerpt_more');       function new_excerpt_more($text){            return ' ';       }            function portfolio_thumbnail_url($pid){     $image_id = get_post_thumbnail_id($pid);       $image_url = wp_get_attachment_image_src($image_id,'screen-shot');       return  $image_url[0];       }     ?>      In portfolio-type.php:                <?php           if ( function_exists( 'add_theme_support' ) ) {      add_theme_support( 'post-thumbnails' );     set_post_thumbnail_size( 270, 170, true ); // Normal post thumbnails     add_image_size( 'screen-shot', 720, 540 ); // Full size screen      }           add_action('init', 'portfolio_register');             function portfolio_register() {        $args = array(           'label' => __('Portfolio'),           'singular_label' => __('Project'),           'public' => true,           'show_ui' => true,           'capability_type' => 'post',           'hierarchical' => false,           'rewrite' => true,           'supports' => array('title', 'editor', 'thumbnail')          );            register_post_type( 'portfolio' , $args );        }            register_taxonomy("project-type", array("portfolio"), array("hierarchical"  =>  true, "label" => "Project Types", "singular_label" => "Project Type",   "rewrite" => true));      ?>      And finally in my index.php I have:
                                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                                      <?php                                     $title= str_ireplace('"', '', trim(get_the_title()));                                     $desc= str_ireplace('"', '', trim(get_the_content()));                                 ?>
                                      <a class="project-wrp fancybox" title="<?=$title?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>">

f
<?php the_post_thumbnail(array('230','170'),array('alt' => '')); ?>

<?php echo $title; ?>

<?php echo $desc; ?>

                             <?php endwhile; endif; ?>


Show label for value only when value exists, basic php

I currently have this,               <?php     $meta = get_post_meta(get_the_ID(), 'rw_agentPhone', true);     echo "office:";     echo $meta; // if you want to show     ?>      Which is fine provided there is a value for rw_agentPhone, but if the profile has no value entered it still displays office:, how can I rewrite this so that office: only dispalys if there is a value for rw_agentPhone. I know this is basic php but I just haven't been able to crack this.


Custom Taxonomy link out the loop

how can i get Custom taxonomy URL by taxonomy ID outside the loop like get_category_link();


Jquery checkbox -show posts with checked tags

Using jquery, How do I show a checkbox with the list of tags in the sidebar, and only show posts of the checked tag? I cant seem to find this anywhere


Relative URLs and hide /wp-content/themes/

in my header and other sections I would like to use               <script src="/incs/js/script.js"></script>      While maintaining the default theme folder structure in server as below               /wp-content/themes/theme-name/incs/js/script.js      file need to be accessed via browser/html source if need be so that it hides **/wp-content/themes/theme-name**               http://website.com/incs/js/script.js      This is also applicable to images I may have under /incs/images/imagname.jpg I've seen solutions where defining the directory located outside of theme folder... but need a solution that does this within. Is this possible? Thanks


Enqueue Wordpress jQuery after it's been deregistered by a plugin

I'm looking after a Wordpress install that makes use of a plugin that deregisters jQuery and replaces it with it's own ancient version. I'm aware of why loading your own jQuery is irresponsible and would like to use the version of jQuery bundled with Wordpress. I'm currently deregistering the plugin's version of jQuery and enqueuing the Wordpress version. However my approach makes some assumptions about the location and version of jQuery. Is there a better way to do this and ensure things don't break when Wordpress is updated?               wp_deregister_script( 'jquery' );     wp_enqueue_script( 'jquery', '/wp-includes/js/jquery/jquery.js', array(), '1.10.2', false );


Redirect to first child on Custom Post Type (without template)

I need to redirect to the first child page in a hierarchical Custom Post Type. For the love of me I have scoured high and low, but all the solutions seem to involve applying a template to the parent that kicks off redirection. I need to bypass the template and redirect to the first child with a nice, clean bit of code in functions.php. Can someone help? Thanks!


Plugin Not Working, But Only On GoDaddy Hosted site

I'm creating a plugin for a friend to log search terms on his site. It's very basic. It creates a new table to store terms entered in the search box. It converts the search term to lower case, checks the database for a matching term and either inserts the term into the database or increases the count of a matching term. It was working as expected on my hosting account. Then I installed it on a WP install on a GoDaddy hosting account... As long as I'm logged in it seems to work whether or not there is a matching term in the database. When I search the site as a guest, it will add a new unique search term to the database but if there is an existing term it does nothing. Well, that's not entirely true. I've seen it increase the count a few times but not by 1, by 2. It seems to function very sporadically on GoDaddy. I can't make sense of this. The actual plugin can be found here. I appreciate any time spent looking at this. Thanks               // Register function to be called when plugin is activated     register_activation_hook( __FILE__, 'mac_search_log_activation' );          function mac_search_log_activation(){         global $wpdb;         $prefix = $wpdb->prefix;         $creation_query =             'CREATE TABLE ' . $prefix . 'mac_search_log (                 `id` mediumint(8) NOT NULL AUTO_INCREMENT,                 `full_search_term` text NOT NULL,                 `count` mediumint(8) NOT NULL,                 PRIMARY KEY (`id`)                 );';              require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );         dbDelta( $creation_query );     }          // Register function to be called when administration pages init takes place     add_action( 'admin_init', 'mac_search_log_admin_init' );          function mac_search_log_admin_init(){         add_action('admin_post_delete_mac_search_log_term', 'delete_mac_search_log_term');     }          // Register function to be called when admin menu is constructed     add_action( 'admin_menu', 'mac_search_log_settings_menu' );          // Add new menu item for Search Term History     function mac_search_log_settings_menu() {         add_menu_page( 'Search Term History',             'Search Term History', 'manage_options',             'search-term-history',             'mac_search_log_config_page',             null,             4.7);     }          // Function to render plugin admin page     function mac_search_log_config_page() {         global $wpdb;         ?>

Searched Terms
                  <form method="post"                   action="<?php echo admin_url( 'admin-post.php' ); ?>">                 <input type="hidden" name="action" value="delete_mac_search_log_term" />                 <?php wp_nonce_field( 'mac_search_log_term_deletion' ); ?>                  <?php             $term_query = 'select * from ';             $term_query .= $wpdb->prefix;             $term_query .= 'mac_search_log ORDER by count DESC';                  $term_items = $wpdb->get_results( $wpdb->prepare( $term_query ), ARRAY_A );             ?>

                     Delete	Search Term	Count

                      <?php                 // Display search terms if query returned results                 if ( $term_items ) {                     foreach ( $term_items as $term_item ) {                         echo '
';                              echo '<input type="checkbox" name="terms[]" value="';                         echo esc_attr( $term_item['id'] ) . '" />	';                              echo '' . $term_item['full_search_term'] . '	';;                         echo '' . $term_item['count'] . '
';                     }                 } else {                     echo '
';                     echo 'No Searches Yet
';                 }                 ?>

                      <input type="submit" value="Delete Selected"                        class="button-primary"/>             </form>
         <?php }              add_filter('pre_get_posts','MACSearchLog');              function MACSearchLog($query) {             if ($query->is_search) {                 global $wpdb;                 $term = strtolower($query->query_vars['s']);                      $term_query = 'select * from ';                 $term_query .= $wpdb->prefix;                 $term_query .= 'mac_search_log';                 $term_query .= ' WHERE full_search_term = "'.$term.'"';                      $term_items = $wpdb->get_row( $wpdb->prepare( $term_query ), ARRAY_A );                      if(empty($term_items)){                     // insert term and set count to 1                     $term_item = array(                         'full_search_term' => $term,                         'count' => 1                     );                     $wpdb->insert($wpdb->prefix.'mac_search_log', $term_item);                      }else{                     // update existing row count++                     $new_query = 'UPDATE ';                     $new_query .= $wpdb->prefix;                     $new_query .= 'mac_search_log';                     $new_query .= ' SET count = count+1 ';                     $new_query .= 'WHERE id = '.$term_items['id'];                     $wpdb->query($wpdb->prepare($new_query));                 }                  }              }              function delete_mac_search_log_term(){             $deleted_terms = array();             // Check that user has proper security level             if ( !current_user_can( 'manage_options' ) )                 wp_die( 'Not allowed' );             // Check if nonce field is present             check_admin_referer( 'mac_search_log_term_deletion' );             // If search terms are present, cycle through array and call SQL             // command to delete entries one by one             if ( !empty( $_POST['terms'] ) ) {             // Retrieve array of search term IDs to be deleted                 $terms_to_delete = $_POST['terms'];                 global $wpdb;                 foreach ( $terms_to_delete as $term_to_delete ) {                     $deleted_terms[] = get_search_term_by_id(intval($term_to_delete));// TO GET SEARCH TERMS FOR EMAIL                     $query = 'DELETE from ' . $wpdb->prefix;                     $query .= 'mac_search_log ';                     $query .= 'WHERE id = ' .                         intval( $term_to_delete );                     $wpdb->query( $wpdb->prepare( $query ) );                 }             }             // UNCOMMENT THE FOLLOWING 2 LINES TO DISPATCH EMAIL WITH DELETED SEARCH TERMS         //    $terms = print_r($deleted_terms, true);         //    wp_mail( get_option('admin_email'), 'Search Terms Deleted', $terms);                  // Reload the search term history page             wp_redirect( add_query_arg( 'page', 'search-term-history',                 admin_url( 'admin.php' ) ) );             exit;         }              function get_search_term_by_id($id){             global $wpdb;             $term_query = 'select * from ';             $term_query .= $wpdb->prefix;             $term_query .= 'mac_search_log ';             $term_query .= 'WHERE `id` = '.$id;                  $term_item = $wpdb->get_row( $wpdb->prepare( $term_query ), OBJECT );                  if($term_item){                     return $term_item->full_search_term;             }else{                 return null;             }         }      Edit: I've been logging queries and everything else involved. Nothing looks off. I replaced the SQL query with $wpdb->update() and replaced `if(empty($term_items)){` with `if($term_items)` while swapping the associated actions, and that seems to have cleared up some of the anomolies with the count, but it just will not update on the GoDaddy account unless I am logged in. On one hand I find it hard to believe that a different hosting account would have an effect on this, but I've seen stranger things from GoDaddy in the past.


How to change author base without front

I am currently using this code:               function change_author_permalinks() {         global $wp_rewrite;         $wp_rewrite->author_base = 'connect/member';     }     add_action('init','change_author_permalinks');      but my current `front` set on my blog is: `share` So the above generates a URL like so: `http://example.com/share/connect/member/john-smith` But I don't want `/share/` as part of this author URL. I cannot remove the `/share/` front as it is needed for other parts of the site. How do I set the author URL to not use `front`?


Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category

I'm trying to get the terms of a taxonomy (kind) and the number of content they have but only for a specific category (get_parent_page_slug() = city name = category slug). This is what I have so far:                   $args = array(         //          'taxonomy' => 'tipo',                     'hide_empty' => 1,                 );         $terms = get_terms('kind', $args);              //var_dump($terms);exit;              $count = count($terms);         echo '
';         echo '
name) . '">Todos (' . $count . ')
';         foreach ($terms as $term) {             echo '
slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . ' ('. $term->count .')
';         }         echo '
';      Just in case I clarify: I'm doing this in a page template. The results I expect are these: > Accommodation in City Name > >   * All (5) >   * Hotel (1) >   * Inn (2) >   * Log cabin (1) >   * Camping (1) > Thanks in advance


Why am I getting and error from wp_get_attachment_image_src?

This Code:     <div id="canvas" class="plan-page"               style="background-image: url('<?php echo wp_get_attachment_image_src( stripslashes($options['sitePlan']), 'full')[0]; ?>');">
           is causing a Parse error: syntax error, unexpected '[' in C:\wamp\www\wordpress\wp-content... any help appreciated!


Showing a post depending on the Custom Field value

<?php if (get_post_meta($post->ID, 'coach_location', true) == "Austria"): ?>      ...this works, but manually checking each country and repeating the post content code is getting arduous, is it possible to do the country check automatically show the post content? So instead of checking each country like so:               if austria: echo title & the_content     if australia: echo title & the_content     if south_africa: echo title & the_content     ... all 196 countries of the world      is it possible to automate this so I echo the title and content just once?


A call to list all Custom Post Types?

My theme currently uses this code to call all Categories into a list to pull posts from (in the backend) for a thumbnail widget.               $mx_categories_obj = get_categories('hide_empty=0');     $mx_categories = array();     foreach ($mx_categories_obj as $mx_cat) {     $mx_categories[$mx_cat->cat_ID] = $mx_cat->slug;     }     $categories_tmp = array_unshift($mx_categories, "Select a category:");      How could I arrange this so that it lists all custom post types instead? I tried using this and it did not work:               $cpt_post_types_obj = get_post_types('hide_empty=0');     $cpt_post_types = array();     foreach ($cpt_post_types_obj as $cpt_apt) {     $cpt_post_types[$cpt_apt->apt_ID] = $cpt_apt->slug;     }     $post_types_tmp = array_unshift($cpt_post_types, "Select a category:");


Best way to pass arguments to another page in Wordpress

What is the best way to pass arguments to another page in wordpress. I did it this way :               <a href="get_permalinka(id_of_page).'/&i=2&j=3&k=4'">Link/a>      I get this arguments with $_GET['i'],$_GET['j'],$_GET['k'],problem is : this works just with default permalinks,but when I change it to some other permalink type,it does not work any more.Note - I'm passing these arguments from homepage to another page(template page). Thank you for your time.


How is the `get_sidebar` function meant to be used to call a 2nd sidebar?

What's the proper way to call a second sidebar in the main home of my blog? And I mean 2 sidebars at the same time.... I might edit the question when I get further info, but now I'm feeling completely lost.


Using hooks to place content in theme dynamically

Alright, so I think I may be getting a little too complicated on this, but I basically want to know if this is possible. I am using a content slide function where I display some thumbnails within the main content area, but after the #container ID, I need to put almost the same information, and a little bit more, and I thought maybe I could do a custom action hook for this. so I have this               <?php          function the_maps() {     while( $maps->have_posts() ) : $maps->the_post();              $content .= "
";             $content .= '';                 $content .= get_the_post_thumbnail( get_the_ID(), 'featured-map', $attr );             $content .= '';             $content .= "
" . get_the_title() . "
";                $content .= "
";                                     // ADD CUSTOM HOOK HERE TO DISPLAY ADDITIONAL DATA AT A SPECIFIC PART OF THE THEME         // stuck here              $footer_content = get_the_post_thumbnail( get_the_ID(), 'featured-map', $attr );             // This is where I would like to use an action or hook to push the $footer_content on the footer.php file         add_action( 'after_wp_footer', 'slide_content', 10, 1);         do_action( 'after_wp_footer', $footer_content );                   endwhile;          }          function slide_content( $arg ) {     // stuck here too     }      So at the end of it all, I want the html to look like this. It's dumbed down, but hopefully you'll get the picture.

title

                                                This is based off the following demo: http://tympanus.net/Development/FullscreenOverlayStyles/index7.html I am trying to push myself more on wordpress, and just wanted to know if any WP experts would know if this can be done. I am sure this are many techniques to accomplish this, but I just wanted to know if I could push content to a hook or function in my theme files TIA!


The best place of the code for creating a robots.txt file

I'm using the Option-Tree framework for the options of my theme. Now I want to add the option to create and edit the robots.txt file. First, I have the function to get the content of the file or create it with a default content; is this:               function get_robots($path)     {     $robots_file = $path . DIRECTORY_SEPARATOR . 'robots.txt'; //The robots file.     if(file_exists($robots_file)){         return file_get_contents($robots_file);          } else {         $default_content = "User-agent: *\nDisallow:";         file_put_contents($robots_file, $default_content);         return $default_content;     }     }          get_robots(getcwd());      If I use this function on `functions.php`, it will run on every page load, and that's a tiny waste. I'm planning to use this function on `robots.php` and then I will call it when I need it. But, when it's the best moment, where is the best place of the code to run it once? Every time when I load the options page, for example? Edit: No, it's not working, because the options settings are included on `functions.php` so it creates the file on every page view.


Wordpress Update Plugin Hook/Action? Since 3.9

I've researched this a few times, yet my searching does not reveal much except custom code which may or may not be good wordpress practice. As of the latest releases, **has a hook been added to the plugin update process?** I'm asking because its a very basic need, yet I do not see it added to the codex (yet). If not, what is the common and best practice developers employ? EDIT: Just to clarify, I'm not talking about activation - but about updating - that way if there are changes in database or otherwise it can be addressed.


custom configuration for a mathjax-latex installation

I'm experimenting with a bitnami wordpress service on an amazon hosted VM, and have installed the mathjax-latex plugin. This works when I configure it to use the 'Use MathJax CDN Service', but I'd like to have some of my own macros. Per the readme, I put a copy of the MathJax tree under plugins/mathjax- latex/MathJax:               wget https://github.com/mathjax/MathJax/zipball/v2.3-latest     mv v2.3-latest ~/tmp/mathjax-v2.3-latest.zip     unzip ~/tmp/mathjax-v2.3-latest.zip     mv mathjax-MathJax-78ea6af MathJax      so that it sits here:               /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/mathjax-latex/MathJax      Under 'Custom MathJax location, if you are not using the CDN' in the mathjax- latex plugin configuration I have tried all of:               /wp-content/plugins/mathjax-latex/MathJax/default.js     /wp-content/plugins/mathjax-latex/MathJax     http://localhost/wp-content/plugins/mathjax-latex/MathJax     http://localhost/wp-content/plugins/mathjax-latex/MathJax/default.js     /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/mathjax-latex/MathJax/default.js     /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/mathjax-latex/MathJax      with default selected under 'MathJax Configuration', but my downloaded version of MathJax fails to load when I access a page with some mathjax markup. I presume that I'm specifying the 'Custom MathJax location' incorrectly. Anybody know how to properly specify this, or if anything else is required to install my own customized mathjax configuration?


Is it possible for a child-site of a multisite to be a multisite itself?

I have a multisite with a sub-directories structure like this: HQ-domain/site1/ HQ-domain/site2/ HQ-domain/site3/ etc. and I am trying to find a way to get a sub-directories structure like this: HQ-domain/site1/branch1 HQ-domain/site1/branch2 HQ-domain/site1/branch3 HQ-domain/site2/branch1 HQ-domain/site2/branch2 HQ-domain/site2/branch3 HQ-domain/site3/branch1 HQ-domain/site3/branch2 HQ-domain/site3/branch3 etc. Super Admin will be able to access everything, site-Admins will be able to access their own site and all the branches, branch-Admins will be able to access only their own branch's site. I have already tried the WP Multi Network plugin (https://wordpress.org/plugins/wp-multi-network/) but it doesn't do what I wish to, which is to create that 2nd nesting of branches. Hope I explained my question logically and thank you in advance.


Can I use multi (sub) levels of relation (AND | OR) on custom query?

I'm tryng to do the equivalent of:               $args = array(         'post_type' => 'post',         'tax_query' => array(             'relation' => 'OR',             array(                 'relation' => 'AND',                 array(                     'taxonomy' => 'movie_genre',                     'field' => 'slug',                     'terms' => 'action'                 ),                 array(                     'taxonomy' => 'actor',                     'field' => 'id',                     'terms' => 103,                 )             ),             array(                 'relation' => 'AND',                 array(                     'taxonomy' => 'movie_genre',                     'field' => 'slug',                     'terms' => 'horror'                 ),                 array(                     'taxonomy' => 'actor',                     'field' => 'id',                     'terms' => 14                 )             )         )     );      Can I use these kind of multi levels of relation (AND | OR)? It doesn't seem to work on my code. I want to request posts with `(genre action AND author 103) OR (genre horror AND author 14)`. The following query:               $args = array(         'post_type' => 'post',         'tax_query' => array(             'relation' => 'AND',             array(                 'taxonomy' => 'movie_genre',                 'field' => 'slug',                 'terms' => array( 'action', 'horror' )             ),             array(                 'taxonomy' => 'actor',                 'field' => 'id',                 'terms' => array( 103, 14 ),             )         )     );      It is wrong because it would give me `(genre action AND author 14) OR (genre horror AND author 103)` beyond `(genre action AND author 103) OR (genre horror AND author 14)` The Codex doesn't show anything about it. Only one level:               $args = array(         'post_type' => 'post',         'tax_query' => array(             'relation' => 'AND',             array(                 'taxonomy' => 'movie_genre',                 'field' => 'slug',                 'terms' => array( 'action', 'comedy' )             ),             array(                 'taxonomy' => 'actor',                 'field' => 'id',                 'terms' => array( 103, 115, 206 ),                 'operator' => 'NOT IN'             )         )     );      If it really doesn't work, what is the solution? It will need to code a 'the Loop' after another 'the Loop'? Sorry if it is duplicated, I tried several searchs but I think I don't know how to look for it. **EDITED** If it really doesn't work, I've thought a better solution than Loop after Loop is convert everything to a MySQL query and use **Custom Select Query** as described here: Displaying Posts Using a Custom Select Query. Is that the way?


No comments on static front page

I have had this problem before. I want my homepage to be very simple, and I don't want it to be a discussion forum or a place where you can leave your comments. I wrote yesterday and got some good answers. However, I had to change the theme, because what I wanted to do, wasn't possible with the theme Alexandria. I have made a very simple front page, but when I want to erase the comment area from my page 2, it's just not possible. I have chosen a static page, I have unchecked all the markings in discussion. But nothing helps. Underneath the comments area there is a lot of writing about the HTML and what attributes and codes are legal. I would love to be able to remove it all. What can I do to remove it all?


Directly open page in text editor

In wordpress, currently I am facing one problem that, when I'm clicking on page edit the editor directly opens in visual tab so, How to directly open page editor in text tab??? Does anyone have a solution for this.


Proper way to run wp_query from inside a plugin

I am developing a plugin that needs to make a query of a custom post type and retrieve data and meta data from these posts. But anytime I run that query inside my plugin, no matter what admin new post page I pull up (in any post, custom post type, or page) there is data that is pre-filled in, and it is from the first custom post type I am querying in my plugin. So, for example, inside my plugin I have:               add_action('wp','myfunction');     function myfunction(){     $mcpt_query = array();          $the_query = new WP_Query('post_type=mcpt');          if ( $the_query->have_posts() ) :     while ( $the_query->have_posts() ) : $the_query->the_post();         $mcpt_query[] = array(             'id'       => get_post_meta(get_the_ID(), 'idkey', true ),             'field1'   => get_post_meta(get_the_ID(), 'field1key', true ),             'title'    => get_the_title($post->ID)         );     endwhile;     endif;     return $mcpt_query;     wp_reset_postdata();     }          And if the above is in my plugin, any post-new.php page pulled up in admin will be prefilled with the first post from that custom post type (mcpt), instead of giving me a blank new post page to fill out. Any ideas what is causing this?


Add version parameter to all scripts/stylesheets

I want to add a custom value as parameter to every script/stylesheet that is loaded, this to cache and get rid of the caching whenever I want to. Is there an easy way to achieve this?


Cannot publish posts, but can create new pages

I am building a site on WordPress. I can't publish posts: when I attempt to do so, the site just hangs and then I get a time out page. However, I can add new pages without a problem. I have tried:   * Upgrading the WP build.    * Switching my theme to Twenty Ten. I still cannot publish posts.   * Deleting all plugins and the plugin folder. None of this has resolved the issue. Should I contact my host or is this a WP issue? Thank you for any help, Jeff


Conditional Meta Boxes

I am creating multiple meta boxes in WordPress, and I want the user to be able to toggle certain boxes on or off. So, they click a radio button (in a separate meta box), update the options, and an additional meta box attached to that radio value will appear. So it basically goes from one meta box (the selector box) to two meta boxes (the selector box, AND the new box they just selected). In my code, you can create a meta box by setting something like this up (this is the radio box where the user selects for other meta boxes to toggle on/off):               // Create meta box that gives user ability to select additional meta box,        which will then show upon saving the post          $meta_boxes[] = array(         'id' => 'meta_box_id',         'title' => 'Box title',         'pages' => array('page'),         'context' => 'side',         'priority' => 'low',         'fields' => array(             array(                 'name' => 'Select:',                 'id' => $prefix . 'meta_box_id',                 'type' => 'radio',                 'options' => array(                     array('name' => 'Value 1', 'value' => 'value_one'),                     array('name' => 'Value 2', 'value' => 'value_two'),                 )             )         )     );      Here is what it looks like in WordPress: http://i.stack.imgur.com/xR69s.png And here is another meta box that, once selected in the meta box above (let's say value_one is selected), will appear on the post screen:               // This meta box will only show if 'value_one' is selected from      the radio box above          $meta_boxes[] = array(         'id' => 'standard_lead',         'title' => 'Standard Lead',         'pages' => array('page'),         'context' => 'normal',         'priority' => 'high',         'lead' => 'value_one',         'fields' => array(             array(                 'type' => 'text',                 'id' => $prefix . 'standard_title',                 'name' => 'Lead Title',                 'desc' => 'The title of your Standard Lead',                 'width' => '100'             ),             array(                 'type' => 'textarea',                 'id' => $prefix . 'standard_content',                 'name' => 'Lead Content',                 'desc' => 'The content of your Standard Lead (you can use HTML)',                 'width' => '100'             )         )     );      The important piece from that code is this:               'lead' => 'value_one',      My plan was to have the ['lead'] value (from the meta box code directly above) to match the ['value'] value (from the radio meta box), so they could be connected, and then test with an IF statement to make sure they equal the same thing, and then display ONLY if they both equal value_one. The function below is what actually adds the meta boxes into WordPress. Within that function, I tried creating this IF statement to match those two together:               if($this->_meta_box['value'] == $this->_meta_box['lead'])      ...but it doesn't work, and I'm not sure how to target ['value'] as it's nested within multiple arrays (or I assume, is the problem). Here's the full function:               function add_meta_boxes()     {         $this->_meta_box['context'] = empty($this->_meta_box['context']) ? 'normal' : $this->_meta_box['context'];         $this->_meta_box['priority'] = empty($this->_meta_box['priority']) ? 'high' : $this->_meta_box['priority'];              foreach($this->_meta_box['pages'] as $page)         {             if($this->_meta_box['value'] == $this->_meta_box['lead'])             {                 // adds meta box to WP                 add_meta_box($this->_meta_box['id'], $this->_meta_box['title'], array(&$this, 'show_meta_boxes'), $page, $this->_meta_box['context'], $this->_meta_box['priority']);             }         }     }      Hope I explained well enough what the issue is. I have looked all around and have tried hacking a few things around, but I'm not sure if this a problem I can solve myself. Any input on this, or a nudge in the right direction would be a HUGE help. Thank you! PS: I was also thinking of doing this through JS instead, but not sure where to start from there.


Check if post has specific tag_ID in custom post type

I am using Event Manager and they have a custom post type of events, with a taxonomy of event-categories (separate from regular post categories). In that taxonomy I have created terms(?) or event categories, "Education" and "Research". I want a specific `<div>` to show up if a post is in the event- categories taxonomy with the term/category of "Education". The slug is "education" and the tag_ID is 8. Currently I'm trying to use this code snippet, but I'm not getting it. I know there's more to it, but I haven't been successful with other tutorials. Most are for category archives. I need it conditionally for single posts.               <?php        if(in_category('education')) {           echo '
test
';        }     ?>


Simple Math Quiz or Captcha to hide whois query form

I have a whois form in my site that enables users to query for domain name availability and if available gives them the option to request for registering it. The whois form is inserted via shortcodes. My problem is that I want to protect this form from spam bots by hiding the form until the user solves a simple math question or enters a captcha. I made a lot of research on the internet but found nothing on hiding content for visitors until they prove their humanity. All I found is to hide content for un-logged-in users, which is not my case, because I want to give general visitors (not members) the ability to use the whois form and prevent spam bots at the same time. Any help or guide lines is greatly appreciated. Many Many Thanks, Kri Kab


How to use a newly registered setting with a checkbox and the default value 'true'

I'm currently working on a plugin in which I would like to have a new setting (called 'show_introduction') that has the default value 'true'. I did this by the following which is hooked into 'admin_init'               register_setting('tf-song-list-settings-group', 'show_introduction');     if (get_option('show_introduction') == '') update_option('show_introduction', 'true');      On the settings page I have the following to incorporate the above setting into a checkbox               <input name="show_introduction" type="checkbox" id="show_introduction" value="true" <?php checked('true', get_option('show_introduction')); ?> />      Now the problem is that I cannot UNcheck the checkbox and thus set the value to false. What am I doing wrong, and how is it done right? If I give the setting 'false' by default, all is working nicely. But that's not what I want the default value to be. Of course, I could rename the setting from 'show_introduction' into 'hide_introduction', give the input the value 'false', check for 'false', and hence do it all the other way around. Most probably, that would work. But that's more like a workaround to the actual problem, isn't it? Thanks in advance. **// edit** I think I got what I wanted. Here's the code               if (!class_exists('tf_song_list')) {         class tf_song_list {             public function __construct() {                 add_action('admin_init', array(&$this, 'init_options'));             } // public function __construct                  function init_options() {                 register_setting('tfsl_options', 'tfsl_options', array(&$this, 'validate_options'));                 $options = get_option('tfsl_options');                 if (false === $options)                     $options = $this->get_default_options();                 update_option('tfsl_options', $options);             } // function init_options                  function get_default_options() {                 $options = array(                     'show_introduction' => 1                 );                 return $options;             } // function get_default_options                  function validate_options($options) {                 $validated_options['show_introduction'] = ($option = $options['show_introduction']) ? $option : 0;                 return $validated_options;             } // function validate_options         } // class tf_song_list     } // if (!class_exists('tf_song_list'))      The clue, I guess, is   A) to use a validation/sanitizing function to set the specific values in case it is not the default value,   and B) to check with (false === MY_OPTIONS) and only then set default values. Now, I can use the following on my settings page and all is working fine:               <input name="tfsl_options[show_introduction]" type="checkbox" id="tfsl_options[show_introduction]" value="1" <?php checked(1, $options['show_introduction']); ?> />      Thanks for your input! BTW, if there's something wacky with my above code, feel free to enlighten me. I didn't use the settings API until two days ago.


Show two random posts from custom post type

I've set the code below to show info from the latest two posts of a custom post type (it also loops through and adds a class of first to alternate items for layout purposes). How would I amend this to show two random posts?               <?php     $counter = 1;     $args = array( 'post_type' => 'custom_advert', 'posts_per_page' => 2 );     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();     echo '

';     $counter++;     endwhile; ?>


mod_rewrite loop, redirecting http to https on certain section of wordpress blog

I'm trying to rewrite 3 sections of a wordpress site to https if they are accessed over http:               /cart/          /my-account/          /checkout/      As well as these rewrite's worpress has added a rewrite to remove index.php out of the url. The index.php rewrite is about the only thing that is working. here is my .htaccess               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /          RewriteCond %{HTTPS} off     RewriteCond %{REQUEST_URI} (checkout|cart|my-account)     RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=302,L]          # BEGIN WordPress     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     # END WordPress          </IfModule>          # END WordPress      ## Some Curl tests In the below you can see my access the http version of /cart to be rightly told that this has moved to https /cart, So I then try the https version to be told that it has moved to the very same https version thus a loop.               PS C:\Users\Stephen> C:\Users\Stephen\Downloads\curl-7.23.1-win64-ssl-sspi\curl.exe -k -i http://www.mysite.com/cart     HTTP/1.1 302 Found     Date: Wed, 20 Feb 2013 09:07:06 GMT     Server: Apache     Location: https://www.mysite.com/cart     Vary: Accept-Encoding     Content-Length: 285     Content-Type: text/html; charset=iso-8859-1          <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">          <title>302 Found</title>
Found

The document has moved here.

     <address>Apache Server at www.mysite.com Port 80</address>               PS C:\Users\Stephen> C:\Users\Stephen\Downloads\curl-7.23.1-win64-ssl-sspi\curl.exe -k -i https://www.mysite.com/cart     HTTP/1.1 302 Found     Date: Wed, 20 Feb 2013 09:07:06 GMT     Server: Apache     Location: https://www.mysite.com/cart     Vary: Accept-Encoding     Content-Length: 285     Content-Type: text/html; charset=iso-8859-1          <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">          <title>302 Found</title>
Found

The document has moved here.

     <address>Apache Server at www.mysite.com Port 80</address>           It redirects to the https but then gets stuck in a loop and the browser will complain of a loop. Any rewrite guru's in here.


Placing a featured image into header

1. How can I place featured images into the header, so each post has it's featured image within the main header?   2. Also on category archive pages and the main news page, the featured images are being used in the traditional way, using the custom post image so is there a way around that too, where I can use the featured image for both posts and header.   3. Maybe there is a way of having two custom thumbnail images and calling one up for the featured image and the other for the header?


How can I tell what category I'm in-- in the header?

How can I identify what category the current page is showing in the `<head>`? Here's the code I have now:               <?php if ( is_home() ) { ?>         <!-- set up for home page ad -->     <?php } elseif ( in_category( 'Restaurant Reviews' )) { ?>         <!-- set up for restaurant reviews ad -->     <?php } else { ?>         <!-- set up for run of site ad -->     <?php } ?>      This code fails on my "Restaurant Reviews" page... it always selects the "run of site" option. As a test, lower down in the page, I used `the_category()` to see what categories WP thought the current page used, and I got "Chelsea, Manhattan, New York, Restaurant Reviews". And of course, the `in_category()` command works correctly there in the lower part of my page, and properly recognizes when it's in the "Restaurant Reviews" category. So-- up there in the `<head>`, how can I tell when I'm in the "Restaurant Reviews" category?


Upload button in metabox not working

The upload button is not working when put inside javascript, but it works when I put it outside the javascript.               /* -----------------------upload button------------------ */     function multiple_media_upload_js() {         $js_path = get_bloginfo('template_directory');         wp_enqueue_script('thickbox');         wp_register_script('my-upload', $js_path .'/assets/js/admin.js', array('jquery','media-upload','thickbox'));         wp_enqueue_script('my-upload');     }          function multiple_media_upload_css() {wp_enqueue_style('thickbox');}          add_action('admin_print_scripts', 'multiple_media_upload_js');     add_action('admin_print_styles', 'multiple_media_upload_css');                    /*  -----------------------MeTA Box-------------------------- */     add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );          /* Do something with the data entered */     add_action( 'save_post', 'dynamic_save_postdata' );          /* Adds a box to the main column on the Post and Page edit screens */     function dynamic_add_custom_box() {         add_meta_box(             'dynamic_sectionid',             __( 'Client Information', 'myplugin_textdomain' ),             'dynamic_inner_custom_box',             'page');     }          /* Prints the box content */     function dynamic_inner_custom_box() {         global $post;         // Use nonce for verification         wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );         ?>
         <?php              //get the saved meta as an arry         $ourwork = get_post_meta($post->ID,'ourwork',true);              $c = 0;         if ( is_array( $ourwork ) ) {             foreach( $ourwork as  $track ) {                 if ( isset( $track['thumb'] ) || isset( $track['client-img1'] ) || isset( $track['client-img2'] ) || isset( $track['client-img3'] ) || isset( $track['client-img4'] ) || isset( $track['client-desc'] ) ) {                     printf( '
Thumb Image  : <input type="text" name="ourwork[%1$s][thumb]" value="%2$s" size="50" /> <input class="upload_image_button" id="_btn" type="button" value="Upload" />

Client Image 1 : <input type="text" name="ourwork[%1$s][client-img1]" value="%3$s" size="50" /> <input class="upload_image_button" id="_btn" type="button" value="Upload" />

                     Client Image 2 : <input type="text" name="ourwork[%1$s][client-img2]" value="%4$s" size="50"/> <input class="upload_image_button" id="_btn" type="button" value="Upload" />

                     Client Image 3 : <input type="text" name="ourwork[%1$s][client-img3]" value="%5$s" size="50" /> <input class="upload_image_button" id="_btn" type="button" value="Upload" />

                     Client Image 4 : <input type="text" name="ourwork[%1$s][client-img4]" value="%6$s" size="50" /> <input class="upload_image_button" id="_btn" type="button" value="Upload" />

                     client Description :
<textarea name="ourwork[%1$s][client-desc]" cols="75" rows="6" >%7$s</textarea>
                     %8$s
', $c, $track['thumb'], $track['client-img1'], $track['client-img2'] , $track['client-img3'] , $track['client-img4'], $track['client-desc'],  __( 'Remove Section' ) );                     $c = $c +1;                 }             }         }              ?>          <?php _e('Add Section'); ?>
<?php          }               /* When the post is saved, saves our custom data */     function dynamic_save_postdata( $post_id ) {         // verify if this is an auto save routine.         // If it is our form has not been submitted, so we dont want to do anything         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )             return $post_id;              // verify this came from the our screen and with proper authorization,         // because save_post can be triggered at other times         if ( !isset( $_POST['dynamicMeta_noncename'] ) )             return;              if ( !wp_verify_nonce( $_POST['dynamicMeta_noncename'], plugin_basename( __FILE__ ) ) )             return;              // OK, we're authenticated: we need to find and save the data              $ourwork = $_POST['ourwork'];              update_post_meta($post_id,'ourwork',$ourwork);     }


Prevent users from adding taxonomy terms

I'm trying to prevent people from adding terms to some, but not all of my taxonomies. There are four taxonomies in a certain post type. I need to prevent people from adding to two of those. I used jQuery to prevent people from adding them on the taxonomy page, but I'm having trouble with the new post/edit post page. I can't just hide the box, because I need them to be able to search and select from existing items. I don't know if jQuery will do the trick, because I'd like that input box to still be available for searching for existing terms. So, does anyone know if this is possible?


Split a database will improve performance?

Hi to all I'm running a Wordpress MS installation and I would like to move a couple of heavy "sub" blogs on a different DB, will it encrease my performances? Actually I'm on a dedicated server with quadcore 2.5 Ghz, 6GB ram and a few nice stuff like Lightspeed eaccelerator and so on. I'm a "self made webmaster" so I need an easy to follow guide that can teach me how to split safely my DB and improve my performance. Thank you very much for this! (just read: Split WP install between 2 databases? is this the only solution available or there is an easier one?)


Created custom post type but selected template not staying selected

I have registered a new post type called Resources. I specify 'page- attributes' as a supported feature. When I go to create a new Resource post I see under Template that I can pick from a number of custom templates I have defined. But after I choose this and click update the setting isn't saved and the template isn't used. Any ideas?               function create_post_type() {     register_post_type( 'foo_resources',         array(             'labels' => array(                 'name' => __( 'Resources' ),                 'singular_name' => __( 'Resource' )             ),         'public' => true,         'has_archive' => true,         'hierarchical' => true,         'show_ui' => true,         'show_in_menu' => true,         'menu_position' => 5,            'supports' => array('title','editor','author','page-attributes'),         'rewrite' => array(             'slug' => 'resources',             'with_front' => false         ),               )     );      }


Setting a post's category

I'm creating new categories with **galleries** taxonomy :               $wpdb->insert("wpem_terms", array(         'name'=>'Custom Category',         'slug'=>'customcategory',         'term_group'=>0,     ));          //id of term     $id = $wpdb->insert_id;          $wpdb->insert("wpem_term_taxonomy", array(         'term_id'=>$id,         'taxonomy'=>'galleries',         'description'=>'',         'parent'=>'',         'count'=>'',     ));      It's working. And then i'm trying to publish a new post with this newly created category :               wp_insert_post(array(         'post_author'=>1,         'post_date'=>date('Y-m-d H:i:s'),         'post_date_gmt'=>date('Y-m-d H:i:s'),         'post_content'=>'',         'post_title'=>'',         'post_excerpt'=>'',         'post_status'=>'publish',         'comment_status'=>'closed',         'post_name'=>'',         'post_parent'=>0,         'post_type'=>'portfolio', // with 'portfolio' custom post type         'post_category'=>array($id),          ));      This is publishing post , it's OK but post's category isn't **Custom Category** . I think this line invalid :               'post_category'=>array($id),      Any ideas? Also i tried this :               'post_category'=>array(get_cat_ID("Custom Category")),


working with result of wp_dropdown_pages()

With `wp_dropdown_pages();` it's able to make a dropdown list with the pages of the blog. How can I work with this function? I want to get a specific custom field of the "dropdown-selected page". Don't know the way so solve this problem.


Export SQL query based on post type

I'm looking to export only wp_posts where post_type = post. Is that possible?


Custom Select Query - Selecting the Year?

I have a query were I'm grabbing all post types of "news" in 2010, but it doesn't select the posts from that year. What am I doing wrong?               $querystr = "         SELECT $wpdb->posts.*         FROM $wpdb->posts, $wpdb->postmeta         WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id         AND $wpdb->posts.post_status = 'publish'         AND $wpdb->posts.post_type = 'news'         AND year($wpdb->posts.post_date) = 2010,         ORDER BY $wpdb->posts.post_date DESC      ";      Taking this line out does fetch the news posts, but really I want them from a particular year.               AND year($wpdb->posts.post_date) = 2010,


How to apply style to the body tag of a particular page?

I have the following code:               <?php      if ((is_home()) OR (!is_single()) OR (!is_page('171'))) : ?>         <body>     <?php else: ?>         <body class="last-page">     <?php endif; ?>      However it doesn't seem to work as expected. I want the class "last-page" to be applied to the body of the page with the id of 171 and pages that display single posts. If I take the third condition out, the "last-page" class is applied correctly to single post pages but with the third condition there it doesn't get applied to any of the two. I want the "last-page" class to be applied to both single post pages and page 171. Appreciate the help.


Instructions/Rules Inside Text Area

I know it is possible to change the "Enter Title Here". But is there’s a function to add text (“how to...”, “simple rules to post...”) inside the post text/input area! Any help?


how can I make $ work in wordpress for jQuery?

I have a plugin I want to use, but it depends on the $ identifier, as apposed to using jQuery. Is it possible to enable the $, to save me recoding the plugin? **EDIT** The plugin automatically adds the javascript, therefore I can't wrap it.


Recently I notice a tip on my site 008soft.com at the bottom of the source code:               <!-- This site is patched which an important unfixed problem since WordPress 2.5+ to 3.9+ -->      ![enter image description here](http://i.stack.imgur.com/XIA8h.gif) I do not know what causes it, and it is my first time encountered such a problem I have not got a clue, and I do not know how to get started, please help me and thx a lot


get all tags from category

i'm displaying all posts by category in my template and i was wondering: is it possible to get a list of all tags used by that category? i only found out how to make a tag-dropdown but it's from all articles, i couldn't find out yet how to filter it by category - any ideas? here's the link http://wphacks.com/how-to-display-wordpress-tags-dropdown- menu/ thx in advance


Modify CSS via Theme Control Panel

Hi to all I'm trying to create an advanced control panel for my first Wordpress template but I'm not able to add a function that I will need. The function that I'm trying to add is the possibility to choose the position of a DIV (left and bottom) via Admin Panel. (Apologize me for my really bad english) Here is the code I have in my functions.php               $shortname = appacqua     array( "name" => "Point on the map",         "type" => "section"),     array( "type" => "open"),     array(  "name" => "Have I to activate zona 1?",             "desc" => "Select if you want to show the first zone",             "id" => $shortname."_zona1c",             "type" => "checkbox",             "std" => "false"),     array( "name" => "Zona 1",         "desc" => "Choose the position",         "id" => $shortname."_zona1x",         "type" => "text",         "std" => "Left:???"),     array( "type" => "close"),      I can see "box" in my Admin Panel and I have no problems with Checkbox, if I echo $shortname."_zona1x" It shows the number, the only problem I have is when I try to add this to my style.css:               .zona1{width:27px;height:27px;background:url(icone/1.png) no-repeat;position:absolute;bottom:0;left:<?php echo $appacqua_zona1x;?>px;}      It doesn't work... If I use Google Chrome to Ispect the element it gives me something like this:               width: 27px;     height: 27px;     background: url(icone/1.png) no-repeat;     position: absolute;     bottom: 0;     left: <?php echo $appacqua_zona1x;?>px;      What am I doing wrong? Thank you very much for you help. Do you know if there is a way to create also a preview of this modification INSIDE the control panel (like inside an iFrame or stuff like this). Let's say that I'm a "self-made programmer" :P so please write "slowly" (lol) and be kind with me, thank you a lot!


No input file specified after enabling multi site

I am getting this error after enabling Multisite "No input file specified.", I can't find a solution in the internet, I hope you can help me. I have this in my htacces               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^wp-admin$ wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^(wp-(content|admin|includes).*) $1 [L]     RewriteRule ^(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      and on my wp-config.php               define('WP_ALLOW_MULTISITE', true);     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', true);     define('DOMAIN_CURRENT_SITE', 'testdomainforrevol8.dk');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);      Here's my website


I get 404 when I try to login ever since I changed the permalink

This is the website This is what the login http://wayfaroutadventures.com/blog/wp- admin/&reauth=1">looks like now Basically here's what happened: I had `www.mysite.com/blog` as the permalink instead of `www.mysite.com`, and `/blog` wouldn't go away. So then I changed it so it was `.com` without blog and it not won't let me login or anything, gives me a 404. I'm scared because I think I seriously screwed up and I don't know how to fix it! How do I get it so I can login again. I don't even care if its `/blog` anymore. I just want my site back.


How customizable is a self-hosted WordPress blog compared to a Blogger blog?

I currently have a **Blogspot** blog and I'm thinking of making the leap to a _self-hosted_ **WordPress** one instead. Everything I've seems to suggest this is the best way to go for the best possible experience, but main concern is customizability. I've messed around with a few Blogspot blogs and I know that you're given pretty much full access in terms of changing the look of your blog. I can get in there pretty "deep" and do whatever I like. When I've read about WordPress, though, a lot of people complain about the lack of customization. Is this true? Are they getting confused with the non- self-hosted version? Just how much visual customization will I get in a _self- hosted_ WP blog? I'd really like to know that I have full control over how things look before I take the plunge! Thanks a for any help.


Custom Post Type Images on Pages

how would I go about displaying Custom Post type Titles and or Images from all custom post types in a template (they would also need to link respectively.) Thanks! Here is what I have so far. > >     $args = array( 'posts_per_page' => 115, 'offset'=> 1, 'category' => > "post-formats" ); >   >     $myposts = get_posts( $args ); >     foreach ( $myposts as $post ) : setup_postdata( $post ); ?> >
 >           <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php > echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail'); ?> >
 >     <?php endforeach; >     wp_reset_postdata(); >   >
 >


Get current menu_order

WordPress implements a simple order functionality by default. What's the common method, to retrieve the `menu_order` for the current post or page?


Relationship with 2 custom post types

i want to relation to custom post types. I register post types with this code               add_action('init', function(){          $args = array(       'public'             => true,       'query_var'          => true,       'rewrite'            => array( 'slug' => '/' ),       'supports'           => array( 'title', 'excerpt'),       'query_var'          => true,       'label'              => 'Series'     );     register_post_type('series', $args);          $args = array(       'public'             => true,       'query_var'          => true,       'rewrite'            => array( 'slug' => '%series%', 'with_front' => false ),       'supports'           => array( 'title', 'excerpt'),       'query_var'          => true,       'label'              => 'Episode'     );          register_post_type('episodes', $args);          });      I have a serie named "Game of Thrones" it's work like this > http://wordpress.dev:8888/game-of-thrones Also i have a episode named "Test", and i want to relation like this > http://wordpress.dev:8888/game-of-thrones/test How can i do this? Thank you, and sorry for my bad english :)


Gallery image archive page

I need to create an image gallery archive page. Actually I need something like where user will be able to create an image gallery with a few images and with a title through admin panel. The gallery image archive will just show only one image with the gallery title. Please consider that an user is going to create galleries randomly, so at least 10 galleries will be shown from the user's latest created gallery. The other 10 galleries will be be shown by date like today's gallery, 14 July, 12 July etc. How can I achieve this? Any suggestions?


Select column name dynamically mySQL Query

$country="USA";     $dr=$wpdb->get_results("SELECT $country FROM wp_shipping WHERE ID=$ids");      I want the above query in WordPress file, where country name is given dynamically but I am not getting how to do this. When I execute the above query, the result is nothing.


How to create a profile page for users?

Is there way to create a profile page for all users( including who have not written any post)? Ex1: example.com/profile/alex >> ex2: example.com/profile/john I need to do something like this.


Can't use get_option function in PHP file located inside plugin folder

I am currently developing a small plugin which queries an API for some XML data. The XML data is then used to display a page. I wanted to do most of the display and formatting related stuff in client-side Javascript, because it was what I was comfortable with, but because the API was on another server, I was receiving _Not Same Origin_ errors. So I decided to create a PHP file (a "wrapper" for the API) in my plugin's directory which requests the data, and then echos the result. Then all I had to do was request the PHP file from inside the Javascript file, and I got access to the XML data without having the Same Origin policy causing errors. This all worked fine, but recently I've been working towards making the plugin not hard-coded with our API auth key, but instead use a Settings page. I set it up, and verified that all of the settings saved correctly. **The problem** I have is that my "API wrapper" PHP file does not know what the function get_options is (the error says it is "Not Defined"), and all the solutions I've read have suggested using include_once('wp-content/options.php), but that is also shooting out an error about not being able to find the file (Failed to Open Stream: No such file/directory). In summary, I need a way to access get_options from inside a PHP file which is inside my plugin's directory, but is NOT the main plugin file.


How Would You Enqueue A Google Web Font?

I'm using the Rosario font from the Google Web Fonts in my theme and I want to enqueue the font so that if there was ever a plugin that used a fancy font that there wouldn't be any conflicts or wasted bandwidth. I want to use the Normal 400, Normal 400 Italic, and Bold 700 in my theme. How should I enqueue the font? Is it worth including the last font variant in case the other script uses it? Several options I've been thinking about:   * Single              wp_register_style( 'rosario', "http://..." );        * Combined with Handle              wp_register_style( 'rosario_400_400-italic_700', "http://..." );        * ALL together              wp_register_style( 'rosario_400', "http://..." );     wp_register_style( 'rosario_400-italic', "http://..." );     wp_register_style( 'rosario_700', "http://..." );`      The third option looks the most explicit and but the multiple calls for same font will probably be more inefficient than simply loading the font twice. Thoughts?


List a custom taxonomy's terms, with links, on the taxonomy page

I have registered a custom post type in my functions.php file for "Wines", with this code:               function customposttype_wines() {          $labels = array(         'name'                => 'Wines',         'singular_name'       => 'Wine',         'menu_name'           => 'Wines',         'parent_item_colon'   => 'Parent Wine',         'all_items'           => 'All Wines',         'view_item'           => 'View Wine',         'add_new_item'        => 'Add New Wine',         'add_new'             => '+',         'edit_item'           => 'Edit Wine',         'update_item'         => 'Update Wine',         'search_items'        => 'Search Wines',         'not_found'           => 'No Wines found',         'not_found_in_trash'  => 'No Wines found in Trash',     );     $args = array(         'label'               => 'wines',         'description'         => 'Wine Reviews',         'labels'              => $labels,         'supports'            => array( 'title', ),         'unset'            => array ('date'),         'hierarchical'        => false,         'public'              => true,         'show_ui'             => true,         'show_in_menu'        => true,         'show_in_nav_menus'   => true,         'show_in_admin_bar'   => true,         'menu_position'       => 5,         'can_export'          => true,         'has_archive'         => true,         'exclude_from_search' => false,         'publicly_queryable'  => true,         'capability_type'     => 'post',     );     register_post_type(                      'wines',                     $args                      );          }     add_action( 'init', 'customposttype_wines', 0 );      And registered 9 custom taxonomies (brand, region, grape, etc.) with this code (repeated 9 times with only the `<XXX>` changing for each):               function customtaxonomy_<XXX> ()  {          $labels = array(         'name'                       => '<XXX>',         'singular_name'              => '<XXX>',         'menu_name'                  => '<XXX>s',         'all_items'                  => 'All <XXX>s',         'parent_item'                => 'Parent <XXX>',         'parent_item_colon'          => 'Parent <XXX>:',         'new_item_name'              => 'New <XXX> Name',         'add_new_item'               => 'Add New <XXX>',         'edit_item'                  => 'Edit <XXX>',         'update_item'                => 'Update <XXX>',         'separate_items_with_commas' => 'Separate <XXX>s w/commas',         'search_items'               => 'Search <XXX>s',         'add_or_remove_items'        => 'Add or Remove <XXX>s',         'choose_from_most_used'      => 'Choose from the most used <XXX>s',     );     $args = array(         'labels'                     => $labels,         'hierarchical'               => true,         'public'                     => true,         'show_ui'                    => true,         'show_admin_column'          => true,         'show_in_nav_menus'          => true,         'show_tagcloud'              => true,         'query_var'                  => true,     );     register_taxonomy(          '<XXX>s',         'wines',         $args      );     }     add_action( 'init', 'customtaxonomy_<XXX>', 0 );      Now I am trying to display the lists of custom taxonomy terms on the parent page of each, so when visiting www.mywebsite.com/wines/`<XXX>` there is a list, with links, to all the terms that have been entered. Right now when I visit www.mywebsite.com/wines/`<XXX>` I just see the 404.php error page. But if I visit a taxonomy term page I see the posts within there fine, ie: www.mywebsite.com/wines/`<XXX>`/term I tried using a taxonomy template hierarchy page, `taxonomy-<XXX>.php` but it will not load, still just shows the 404.php. Pulling hair here, any help is very appreciated.


Mixing custom post type and taxonomy rewrite structures?

Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that: The main glossary URL: `http://example.com/glossary/` Glossary terms starting with letter **A** : `http://example.com/glossary/a/` The URL for a single glossary term: `http://example.com/glossary/a/atomic/` I actually achieved this using the code below but I'm sure that it's a very awkward way to do it and I know it's malfunctioning somewhere as the wrong templates are called when viewing the pages. Except for http://example.com/glossary/, where archive-sumo-glossary-term.php gets called as expected, the other two just activate index.php in my theme. Here goes (`functions.php` in the theme):               add_action('init', 'create_glossary');     function create_glossary()     {         register_post_type         (             'sumo-glossary-term',             array             (                 'labels' => array                 (                     'name' => _x('Glossary Terms', 'post type general name'),                     'singular_name' => _x('Glossary Term', 'post type singular name')                     # And so on …                 ),                 'supports' => array('title', 'editor', 'thumbnail'),                 'public' => true,                 'rewrite' => array                 (                     'slug' => 'glossary',                     'with_front' => false                      ),                 'query_var' => 'glossary-term',                 'has_archive' => true             )         );              register_taxonomy         (             'sumo-glossary-letter',             'sumo-glossary-term',             array             (                 'hierarchical' => true,                 'labels' => array                 (                     'name' => _x('Letters', 'taxonomy general name'),                     'singular_name' => _x('Letter', 'taxonomy singular name')                     # And so one                 ),                 'show_ui' => true,                 'query_var' => 'glossary-letter',                 'rewrite' => false             )         );     }          add_filter('post_type_link', 'glossary_term_permalink', 10, 4);     function glossary_term_permalink($post_link, $post, $leavename, $sample)     {         if ($post->post_type == 'sumo-glossary-term')         {             $permalink = str_replace('glossary/', 'glossary/' . $post->post_name[0] . '/', $post_link);         }         return $permalink;     }          add_rewrite_rule('^glossary/([^/]*)?$','index.php?glossary-letter=$matches[1]','top');     add_rewrite_rule('^glossary/([^/]*)/([^/]*)?$','index.php?glossary-term=$matches[2]','top');


Constructing a Pay to Download music website with wordpress

Hi i searched the complete archive of wordpress plugins but couldn't find the right plugin to enable Paid downloads. The website is just a Pay to download "Full Music" site. Visitor is provided with a sample music to hear and if he decides to download the music he should pay to dowload via Payment gateway like Paypal, Alertpay etc. I would love to hear from your experiences and thoughts about this


How can I detemine the parameters needed by the_widget()?

I'm working with an old (now unmaintained) widget, which only allows one instance. Since I want to have a different sidebar on the homepage and I want this widget on both sidebars, I figure I need to do one of two things:   1. Update the plugin to use the new widget API   2. Use `the_widget()` to manually drop the widget into the custom sidebar I've opted to do the latter as a quick fix, but can't figure out the parameters needed to get it to display. Any suggestions would be greatly appreciated.


Is there a Twitter Wordpress plugin that changes https to http?

I log in and do all the administration over https in my wordpress blog (my own installation). When I publish something, I have the problem that the twitter plugins normally pick the current URL, with https:// instead of http:// (I'm currently using WP->Twitter). When accessed over https:// my page issues some warning and the disqus comments don't work. I really don't care because I should be the only one using https for my blog, but due to the twitter plug in, everybody sees it broken. Is there some other plug in that solves that? Or some other way to do it?


Default Permalink Structure for Pages

I'm trying to figure out a permalink structure for my pages (not posts) in Wordpress. Right now, I can add a "Category Base" for posts... so, something like www.mysite.com/categorybase/post1/ or www.mysite.com/categorybase/post2/ But, if I wanted to do something similar for pages, how would I do that? For example, www.mysite.com/pagebase/page1/ or www.mysite.com/pagebase/page2/ Anyone tried this before?


Send automatic mail to Admin when user/member changes/adds profile

Is there a way to send the updated/added values from profile, when a member/user updates his/hers data, to the admin of the site or another emailadress? Can this be the first step?               /* do something when user edits profile */     add_action('personal_options_update', 'notify_admin_on_update');     function notify_admin_on_update(){       // send a mail with the updated values to admin@mysite.com       exit;     }      What is best pracice to send emails from within WordPress?


How to find out who handles a permalink?

My previous question isn't faring too well. I guess it may be too specific. Let me approach the problem from another direction. There's an URL within my Wordpress site. It's occupied - sending the visitor to some resource. How can I identify the type of resource is associated with this URL, and then find the actual resource - page, category, post, whatever else might be holding up that URL? The link is not specific, no `/tag/`, `/category/` or such on the path. It's probably a custom permalink attached to some entity. I need to find that entity.


Editing URL character replacement

Whereabouts can I edit which characters in permalinks are replaced? For example apostrophe's are replaced with nothing, and I would like to have them replaced with hyphens instead. Thanks.


Cannot Use is_single() and is_admin in functions.php

I'm using a Thematic childtheme for my wordpress website, and instead of putting all my functions into the functions.php file, I thought I make it more organised by creating multiple other function files (admin_functions.php, single_functions.php ...) and included these files in my childtheme's functions.php file as follows:               require_once ('my-functions/admin-functions.php');     require_once ('my-functions/single-functions.php');      This works perfectly fine. However, I'm trying to make wordpress load only the needed files by using the conditional tags as follows:               if(is_admin())        require_once ('my-functions/admin-functions.php');     elseif(is_single())        require_once ('my-functions/single-functions.php');      and this just won't work. I can't seem to find a reason why. I thought that maybe there are some wordpress functions that must be called first before the conditional functions (is_single and is_admin) are usable. I can't seem to get anywhere though. Any help is most appreciated. Thanks


How can I edit the 'Most Used' tab in the categories meta-box to show another custom taxonomy?

The 'Most Used' tab in the categories meta-box is the one that can be seen in the Edit Post section. I want to replace the Most Used tab, with a tab that lists another Custom Taxonomy, or edit the existing tab to display the Custom Taxonomy. I have already created my custom taxonomy, and have spent a lot of time trying to modify this little section in wp-admin/includes/meta-boxes.php that pertains to wordpress' meta-boxes, and can be found at https://developer.wordpress.org/reference/functions/post_categories_meta_box/, and I have gathered that I need to make a change at line 440 where               $popular_ids = wp_popular_terms_checklist($taxonomy);      I suppose I might have to change $taxonomy to something else, possibly the custom taxonomy that I have created, but I am clueless about the syntax or the variable that might replace it. Any help would be appreciated, even something that might point me into the right direction.


Rewrite url for custom post type not working

I have a Custom Post Type and i want to rewrite the URL. nothing is working though. This is the adress i have now /?portfolio=adidas. When I rewrite the numerous ways i tried i always get this instead: feeds/active/ which seems to be a template for blogs in my theme. I think this can be due to me using the wp rss aggregator to pull rss feeds, who i call with a shortcode in my custom post, but seems to be stored somehow with the url Feeds/post_slug, and this is where i get directed. How can I change this? Tried pretty much every plugin on the market and all the code snippets i can found.. The custom post type is registered in my theme, and not in the functions. This is the code for that:               $args = array(     "singular_label"                => __("Portfolio Category", "swiftframework"),      'public'                        => true,     'hierarchical'                  => true,     'show_ui'                       => true,     'show_in_nav_menus'             => false,     'args'                          => array( 'orderby' => 'term_order' ),     'rewrite' => array('slug'=>'','with_front'=>false),     'query_var'                     => true     );          register_taxonomy( 'portfolio-category', 'portfolio', $args );               add_action('init', 'portfolio_register');            function portfolio_register() {            $labels = array(         'name' => _x('Portfolio', 'post type general name', "swiftframework"),         'singular_name' => _x('Portfolio Item', 'post type singular name', "swiftframework"),         'add_new' => _x('Add New', 'portfolio item', "swiftframework"),         'add_new_item' => __('Add New Portfolio Item', "swiftframework"),         'edit_item' => __('Edit Portfolio Item', "swiftframework"),         'new_item' => __('New Portfolio Item', "swiftframework"),         'view_item' => __('View Portfolio Item', "swiftframework"),         'search_items' => __('Search Portfolio', "swiftframework"),         'not_found' =>  __('No portfolio items have been added yet', "swiftframework"),         'not_found_in_trash' => __('Nothing found in Trash', "swiftframework"),         'parent_item_colon' => ''          );          $args = array(           'labels' => $labels,           'public' => true,           'show_ui' => true,         'show_in_menu' => true,         'show_in_nav_menus' => false,         'menu_icon' => 'dashicons-format-image',     'rewrite' => array('slug'=>'','with_front'=>false),         'supports' => array('title', 'editor', 'thumbnail'),         'has_archive' => true,         'taxonomies' => array('portfolio-category')             );            register_post_type( 'portfolio' , $args );       }            add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");             function portfolio_edit_columns($columns){           $columns = array(               "cb" => "<input type=\"checkbox\" />",               "title" => "Portfolio Item",             "description" => "Description",             "portfolio-category" => "Categories"           );                return $columns;          }               add_action("manage_posts_custom_column",  "portfolio_custom_columns");              function portfolio_custom_columns($column){           global $post;           switch ($column)           {               case "description":                   the_excerpt();                   break;             case "portfolio-category":                 echo get_the_term_list($post->ID, 'portfolio-category', '', ',,'');                 break;         }       }


Not able to export large no. of posts in csv

I have custom post type `product` like wp ecommerce. There are 30k posts in it. Also have relate custom taxonomy. Basically am trying to export those posts in csv, but query_posts with so many records is giving me trouble... Any tips???


Migrating a website using custom image tags to use featured images instead

I have a site that was built using a Wordpress 2.x era theme that uses a custom field "image" to hold the URL to use as a featured image for each post. I am migrating to use the PageLines Platform Pro theme, which uses the now standard Featured Images feature - and I am looking for a way to automatically migrate the thousands of old posts to work with this new theme without losing their featured image. This other similar Stack Exchange question has an accepted answer that solves this problems by using the Get The Image plugin to fall back to a custom field if there is not a featured image set. The problem with Get The Image however is that it requires modifying the theme to add a function call. This will break with every upgrade to PageLines, and makes it harder to change themes in the future. I am looking for a way to do a one-time migration, but I haven't found any simple instructions how to manage this. Any ideas?? UPDATE: This tutorial seems to indicate one way to do this: http://pmg.co/migrating-post-thumbnails-on-old-wordpress-themes Is this the best way? Are there any other techniques I should pursue?


Get all categories and posts in those categories

I am looking for a solution that allows me to print the following:               Cat 1        Cat 2        Cat 3      Post 1       Post 1       Post 1      Post 2       Post 2       Post 2      Post 3                    Post 3                                Post 4      **EDIT** I am looking for something that will only require _one_ database query! So if you have a `foreach` in your code followed by a `new WP_Query` then that is not what I am looking for (I am planning to put this onto my website's homepage).


Pagination for sub-pages

I have a top level page with a lot of subpages.   When a user visits the top level page they currently see the titles/thumbnails/excerpts of **all** of the subpages.   How can I paginate the display of the subpages so that **only** 3 are displayed at a time, giving the user the ability to navigate via the typcial "< Previous 1,2,3,4,5 Next >" pagination menu? Any help would be greatly appreciated. Thanks!


Pagination Help on Crazy Custom Authors Page

I've got a custom authors page for a multi-author blog. http://blog.securitytechnologies.com/meet-the-team/ Here's the code I'm using to generate the page (thanks to other folks in the support forums for providing it):               <?php     $excluded = "1,2,3,7,20,21";  // To exclude external admin author IDs     $sql = "SELECT DISTINCT post_author, umeta.meta_value as last_name     FROM $wpdb->posts     JOIN $wpdb->usermeta umeta ON ($wpdb->posts.post_author = umeta.user_id     AND umeta.meta_key = 'last_name')     WHERE post_author NOT IN ($excluded)     AND post_status = 'publish'     AND post_type = 'post'     ORDER BY last_name, post_author     ";     $authors = $wpdb->get_results($sql);         if($authors):     foreach($authors as $author):     ?>          What I can't figure out is how to set a maximum number of authors per page and paginate. I've got WP-PageNavi installed, but I'm not having any luck implementing it here on a custom template page. Thanks in advance.


How do I get thumbnail generator to recognize the_permalink tag?

Help! I am trying to create a Digg-clone by integrating "BM Shots" (a webpage thumbnail generator) with "Recommended Links" (a social voting plug-in for Wordpress). Recommended Links allows for user submitted URLs to be displayed via "the_permalink" tag. I'm trying to use BM Shots to generate web page thumbnails based on user submitted URLs. BM Shots work just fine, but I can't get BM Shots to recognize "the_permalink". The default usage of BM Shots looks like this...                           <?php                 $url = 'http://www.binarymoon.co.uk/';                 $width = 300;                 echo bm_mshot ($url, $width);                 ?>      But I want it to work like this...                           <?php                 $url = the_permalink;                 $width = 300;                 echo bm_mshot ($url, $width);                 ?>      I'm able to get it to work with other Wordpress tags, which is useless, but not "the_permalink." I'm not a coder, so I could use some suggestions, even if they seem obvious. EDIT// Here is what the loop looks like                           global $wp_query;                 $plugin_settings = get_option( 'reclinks_plugin_settings' );                 $start =  ( $wp_query->query_vars['paged'] ) ?                  ( ( $wp_query->query_vars['paged'] -1 ) * $wp_query->query_vars['posts_per_page'] + 1) : 1;                 ?>                 <?php if ( have_posts() ) : ?>                 <ol style="list-style-type:none; margin-left:-22px;" start="<?php echo $start; ?>">                 <?php while ( have_posts() ) : the_post(); ?>
                 <img src="<?php                 $url = the_permalink;                 $width = 300;                 echo bm_mshot ($url, $width);                 ?>" width="100"  style="float:left;">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                  <?php reclinks_favicon(); ?> <?php reclinks_domain(); ?>
<?php reclinks_votebox(); ?>
                 <?php endwhile; ?>
                 <?php else : ?>
<?php _e( 'No recommended links yet. Add one?', 'gad_reclinks' ); ?>
                 <?php endif; ?>        * http://wordpress.org/extend/plugins/recommended-links/   * http://www.binarymoon.co.uk/projects/bm-shots-automated-screenshots-website/


How to create a Wordpress options page

I've followed this guide precisely: http://codex.wordpress.org/Creating_Options_Pages However when I do `do_settings_fields`, it says: `Missing argument 2 for do_settings_fields()` Even though it says to put only one argument in there. Strangely, the example given on that very same page says to use `do_settings()` \- which appears to not even be a function! Something tells me I need to create a 'section' as described here: http://codex.wordpress.org/Function_Reference/add_settings_section But I'd rather find a quick fix for what I've already done. :) **EDIT** I've been messing around with it for the past hour, and discovered several wordpress functions which apparently don't exist.. This is my latest code, which doesn't give me an errors, but also doesn't do anything apart from register the menu page:               <?php     // Register the menu     add_action('admin_menu', 'bang_menu');     function bang_menu() {         add_menu_page( 'BANG! Dashboard', 'BANG!', 'administrator', 'bang-admin', 'bang_dashboard');     }          // Register settings     add_action('admin_init', 'bang_settings');       function bang_settings() {     register_setting( 'bang-options-group', 'joinform_api_url' ); // Register the setting     add_settings_section( 'bang_section', 'Joinform configuration', null, 'section_options_page_type' ); // Register the section     add_settings_field( 'api_url', 'API URL', 'field_joinform_api_url', 'section_options_page_type', 'bang_section' ); // Define callback function for setting     }               function field_joinform_api_url() {         echo 'field here...';     }               function bang_dashboard() {              echo '

Joinform configuration
                          <form action="options.php" method="post">';                     settings_fields( 'bang-options-group' );                     do_settings_sections( 'bang_section');     etc...


How to remove the RichText Meta Box

How can I remove the rich text box editor in WordPress? I have used the `remove_meta_box` function specifying the boxes ID, but it does not work like it does for other core meta boxes: The code I tried:               function remove_rich_box()     {         remove_meta_box('postdivrich', 'client', 'normal');       }     add_action( 'do_meta_boxes', 'remove_rich_box' );      Where the second paratmeter "client" is my custom post type.


Images are not showing up in "Uploaded to this post"

I had to delete all my files of web site for some reasons. Then I've restored the files back to host. But the problem is that; Firstly, I uploaded all the images (about 4000) to upload folder via FTP. Then I realised that images are not showing up in media library. Than I used some plugins such as, Add from Server, Media Tools, but they coludnt operate all the files. I dont know why. Then I deleted all the files again and uploaded via Wordpress Library -> Add new. After uploading all images they showed up in media library BUT they are not attached to "Uploaded to this post" of posts. If anyone knows the solution, could you please help me about this. Thanks.


I keep getting logged out in Firefox

For some reason, tonight when I have gone to work on my Wordpress installation I firstly found myself logged out, even though there was a few cookies left in Firefox relating to the website and when I looked on the Simple:Press forum it had remembered my user name but knew I wasn't logged in. Nevertheless, I logged in again and it worked perfectly... until I navigate to a different page when it seems as though I never logged in; furthermore if I try to go directly to the Admin Dashboard from the page when it says I am logged in, it asks me to login again and the URL says `reauth=1` at the end. Strangely, this only occurs in Mozila Firefox and it works perfectly on the same computer using Internet Explorer! Also, I can recall me doing anything to the installation yesterday for it to invoke this kind of behaviour today! Any ideas would be much appreciated. Thanks In Advance.


Why are xmlrpc.php and wp-cron.php being called so often?

I'm running a Wordpress website and I have found from the server logs that xmlrpc.php and wp-cron.php are being requested (POST requests, of course) very frequently--including some suspicious ips that reek of malicious activity or attempts. My understanding is that xmlrpc.php provides an "API" for others to interact with the site. wp-cron.php is for periodic tasks. So why do I see so many requests that those pages? Are hackers looking for some kind of backdoor or security hole?


Custom Post Type UI

I'm using the plugin custom post type ui to create a post type says movie. Everything is ok. I create a movie and its viewable at               http://localhost/wordpress/movies/test/      however, when i go on http://localhost/wordpress/movies/ I was expecting to see test as a movie in all the list of movies but nothing is displayed Code generated by the plugin:               register_post_type('movies', array(         'label' => 'Movies',         'description' => '',         'public' => true,         'show_ui' => true,         'show_in_menu' => true,         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => array('slug' => ''),         'query_var' => true,         'supports' => array(                 'title','editor','excerpt','trackbacks',                 'custom-fields','comments','revisions','thumbnail','author',                 'page-attributes',),         'taxonomies' => array('category','post_tag',),         'labels' => array (               'name' => 'Movies',               'singular_name' => 'Movie',               'menu_name' => 'Movies',               'add_new' => 'Add Movie',               'add_new_item' => 'Add New Movie',               'edit' => 'Edit',               'edit_item' => 'Edit Movie',               'new_item' => 'New Movie',               'view' => 'View Movie',               'view_item' => 'View Movie',               'search_items' => 'Search Movies',               'not_found' => 'No Movies Found',               'not_found_in_trash' => 'No Movies Found in Trash',               'parent' => 'Parent Movie',     ),) );


Best way to insert something directly after <head>

Could someone perhaps tell if it would be possible to insert -in this case- a `<script></script>` directly after `<head>`, but before:               <script type="text/javascript">     addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};     var userSettings = {             'url': '/html5/',             'uid': '1',             'time':'1332528635'         },         ajaxurl = '/html5/wp-admin/admin-ajax.php',         pagenow = 'dashboard',         typenow = '',         adminpage = 'index-php',         thousandsSeparator = '.',         decimalPoint = ',',         isRtl = 0;     </script>


PHP Template way of coding for wordpress theme development

here is the simple PHP template system i have found The Class (template.class.php)                        <?              class Template {              public $template;              function load($filepath) {               $this->template = file_get_contents($filepath);               }              function replace($var, $content) {               $this->template = str_replace("#$var#", $content, $this->template);              }              function publish() {               eval("?>".$this->template."<?");                }               }              ?>      The Template File (design.html) This file will contain the design of your web site and the blank fields that will be merged with content data.                                                              <title>#title#</title>
Hello #name#!

The time is: #datetime#
               <? echo "
Embedded PHP works too!
"; ?>                                   Usage (index.php) Now we will create a script that load the template and use the class to merge the data.                      <?             include "template.class.php";                  $template = new Template;             $template->load("design.html");             $template->replace("title", "My Template Class");             $template->replace("name", "William");             $template->replace("datetime", date("m/d/y"));             $template->publish();              ?>      Now for a simple wordpress post loop index.php                          <?php               get_header();             if (have_posts()) :              while (have_posts()) :              the_post();                the_content();               endwhile;               endif;                    ?>      Question is, how to use above wordpress loop and the top PHP template system together, this is to convert an html template into a wordpress theme.


Passing custom args in paginate_links

For example i've `domain.com/about?project=1` but i've permalinks enabled and i'm using thins to generate the pagination paginate_links. The proble is that the links generated are like this `domain.com/about?project=1/page/1` and it breaks everything because the project is taken as `1/page/1` There is a way to get `domain.com/about/project/1/page/1` in the paginations links? I'm submitting that from a form using get to display the project.


Broken markup when using the_excerpt() in a widget?

The text returned by the_excerpt() does not respect my widget format. I couldn't explain it better so I will just show you my code:               function widget($args, $options) {         extract($args);              $post_type = $options['post_type'];         $num_of_posts = $options['limit'];              // Create a new instance         $second_query = new WP_Query( array(                             'post_type' => "$post_type",                             'posts_per_page' => "$num_of_posts",                             'post_status' => 'publish',                         ) );               // The Loop         if ($second_query->have_posts()) :           while( $second_query->have_posts() ) : $second_query->the_post();               $byh_content .= "
" . the_excerpt() . "
";           endwhile; else :               $byh_content = "
No " . $options['post_type'] . "s found.
";         endif;         wp_reset_postdata();              $title = "
" . $options['title'] . "
";         $content = $byh_content;              echo $before_widget.$title.$content.$after_widget;     }      The result isn't what I expected. Here's what it looks like when rendered: ![widget rendered](http://i.stack.imgur.com/KwfXJ.png) The title should be at the top. The reason is that, the excerpt isn't where it is supposed to be: ![enter image description here](http://i.stack.imgur.com/Ol8XO.png)


Migrating from metaboxes to wp_editor()

I got a client requirement where the editing facilities available in wordpress had to be available for content that was meant to be displayed on the sidebar of a particular post/page. The content to be displayed was implemented originally using metaboxes which contained a single textarea where content was input as raw HTML and did not have insert/upload facilities. I have decided to migrate this design to use `wp_editor()` as it gives all the wordpress native editing facilities (without using a metabox as it is not recommended). But I am not sure how to get the entered data and POST it to the backend and then tie into the following action to save the data: `add_action( 'save_post', 'save_sidebar_content' );` I was also using the following helper functions:               get_post_meta();     add_post_meta();     update_post_meta();     delete_post_meta();      I would like to know if there are any such functions to ease the CRUD operations related to this data when using wp_editor(). Thanks in advance. nav


Use one Wordpress database with multiple instances of one site

Is there a way to use the same database, tables and all, with two different domains? For example, two employees each have thier own subdomain to develop / test with, so there may be two instances of a site:               jack.example.com/test_blog/     jill.example.com/test_blog/      however, since the base url is stored in the database, it seems that it would require two distinct databases for this set up to work properly. Is there any way around this?


excluded_categories parameter in next_post_link() behaving unexpectedly

I have a Wordpress template with a single.php page. The page has "next" and "previous" arrows to allow navigating through all posts. I want to exclude posts from some categories from being included in the "next" and "previous" calculation. I have this code:                // in single.php      next_post_link( '%link', '← Previous', false, '11 and 13 and 15');       This should show the link to the next post. Posts in categories 11, 13, and 15 should not be considered as per the `$ignore_categories` parameter. This works for posts that have **only** one of the categories listed set, e.g. `15`. But posts that **additionally** have a non-excluded category (like `16` or `23`), do **not** get excluded and they show up as the next post link. Is this the intended behaviour? It doesn't seem to make sense to me. Is there anything I can do to change it so a post gets excluded whenever it has one of the excluded categories, short of rebuilding the entire functionality?