Verify Submitted Form Values and Show Warning Messages with Setting API

I'm making a plugin administration page with the settings API. I'd like to know a way to display a warning message when the user submits an invalid value. For example, with the below code, if the user sends an empty value for Option A, the first input field, I'd like to show a message that says it's invalid and please fill the form. And the other submitted option values should not be saved to the database but remain in the input fields with the message on the page.               <?php     /*     Plugin Name: Demo Verification Notice with Settings API     Description: Learning how to warn invalid values when submitting the form and take back the user to the setting page without saving the options.     Author: Teno     */          add_action('admin_init', 'settingsapi_init');     function settingsapi_init(){         register_setting( 'settingsapi_optiongroupname', 'settingsapi_optionname');         add_settings_section('plugin_main', 'Section 1', 'settingsapi_sectiondescription', 'settingsapi_pageslug');         add_settings_field('plugin_text_string_a', 'Option A', 'settingsapi_setting_string_a', 'settingsapi_pageslug', 'plugin_main');         add_settings_field('plugin_text_string_b', 'Option B', 'settingsapi_setting_string_b', 'settingsapi_pageslug', 'plugin_main');     }          function settingsapi_sectiondescription() {         echo '
This is a section description.
';     }     function settingsapi_setting_string_a() {         $options = get_option('settingsapi_optionname');         echo "<input id='plugin_text_string' name='settingsapi_optionname[option_a]' size='40' type='text' value='{$options['option_a']}' />";      }      function settingsapi_setting_string_b() {         $options = get_option('settingsapi_optionname');         echo "<input id='plugin_text_string' name='settingsapi_optionname[option_b]' size='40' type='text' value='{$options['option_b']}' />";      }     // admin menu     add_action('admin_menu', 'plugin_admin_add_page');     function plugin_admin_add_page() {         add_options_page('Custom Plugin Page', 'Demo Settings API Menu for Verification', 'manage_options', 'settingsapi_pageslug', 'settingsapi_adminpage');     }          function settingsapi_adminpage() {         ?>
             <?php screen_icon(); ?>
Demo Plugin for Settings API
             <form action="options.php" method="post">                 <?php settings_fields('settingsapi_optiongroupname'); ?>                 <?php do_settings_sections('settingsapi_pageslug'); ?>                 <?php submit_button(); ?>             </form>
         <?php     }     ?>      Is that possible with the settings API? The register_setting() function accepts the third parameter as validation function call. However, it can be used to just fix the passed value but it accepts the form submission and saves the options. That is not what I'm looking for. [Edit] Okey, I'm almost there. This validates the submitted value with the callback function set in the register_setting() function. And if the value is invalid it leaves a flag, invalid, in the option array and displays a warning message. However, there is one remaining issue. Otherwise, it is almost done.   1. Once an empty value is set to the first input option, it shows the warning message. It is what we've achieved so far. And if the user leaves the page showing the warning, somehow the empty value is saved to the option. It should revert the previous value.  The code below is ready to use as a plugin. If you run it, you'll see what I'm talking about.               <?php     /*     Plugin Name: Demo Verification Notice with Settings API     Description: Learning how to warn invalid values when submitting the form and take back the user to the setting page without saving the options.     Author: Teno     */          add_action('admin_init', 'settingsapi_init');     function settingsapi_init(){         register_setting( 'settingsapi_optiongroupname', 'settingsapi_optionname','validation_callback');              add_settings_section('plugin_main', 'Section 1', 'settingsapi_sectiondescription', 'settingsapi_pageslug');         add_settings_field('plugin_text_string_a', 'Option A', 'settingsapi_setting_string_a', 'settingsapi_pageslug', 'plugin_main');         add_settings_field('plugin_text_string_b', 'Option B', 'settingsapi_setting_string_b', 'settingsapi_pageslug', 'plugin_main');     }          function settingsapi_sectiondescription() {         echo '
This is a section description.
';     }     function settingsapi_setting_string_a() {         $options = get_option('settingsapi_optionname');         ?>         <input type="hidden" name="settingsapi_optionname[submitted]" value="1" />     <? print_r($options); ?>
         <input id="plugin_text_string" name="settingsapi_optionname[preview][option_a]" size="40" type="text" value="<?php echo $options['submitted']  ? $options['preview']['option_a'] : $options['valid']['option_a']; ?>" />         <?php echo ($options['invalid'] && $options['submitted'] ) ? '* cannot be blank.' :'' ?>         <?php     }      function settingsapi_setting_string_b() {         $options = get_option('settingsapi_optionname');         ?>     <? print_r($options); ?>
           <input id="plugin_text_string" name="settingsapi_optionname[preview][option_b]" size="40" type="text" value="<?php echo $options['submitted'] ? $options['preview']['option_b'] : $options['valid']['option_b']; ?>" />         <?php     }     // admin menu     add_action('admin_menu', 'plugin_admin_add_page');     function plugin_admin_add_page() {         add_options_page('Custom Plugin Page', 'Demo Settings API Menu for Verification', 'manage_options', 'settingsapi_pageslug', 'settingsapi_adminpage');     }          function settingsapi_adminpage() {         ?>
             <?php screen_icon(); ?>
Demo Plugin for Validation Message with Settings API
                  <?php             $options = get_option('settingsapi_optionname');             print_r($options);      // for debugging purpose             if (!($options['invalid'] && $options['submitted'])) {                      // update the correct option values                 $options['valid'] = is_array($options['valid']) ? $options['valid'] : array();  // if the options['valid'] is called for the first time, make it an array                 $options['valid'] = array_merge($options['valid'], $options['preview']);                 // $options['preview'] = '';    // initialize the preview option data. //<-- this seems to cause a problem                 update_option('settingsapi_optionname', $options);             }             ?>                  <form action="options.php" method="post">                 <?php                  settings_fields('settingsapi_optiongroupname');                 do_settings_sections('settingsapi_pageslug');                       // after displaying the form content, set the invalid flag and the subbmited flag to false                 $options['invalid'] = False;                 $options['submitted'] = False;                       update_option('settingsapi_optionname', $options);                        submit_button();                 ?>                       </form>
             <?php                  print_r($options);             ?>           <?php     }          function validation_callback($input){         if (strlen(trim($input['preview']['option_a'])) == 0 && $input['submitted']) {             // $input['preview']['option_a'] = '';             unset($input['preview']['option_a']);             $input['invalid'] = True;   // <-- this one is the problem. It seems to be called multiple times and setting the invalid flag to true when it's not necessary.             add_settings_error('unique_identifyer',esc_attr('settings_updated'),__('Settings NOT saved.'),'error');             add_action('admin_notices', 'print_errors');         } else {             $input['invalid'] = False;         }         return $input;     }          function print_errors(){         settings_errors( 'unique_identifyer' );     }          ?>      [Edit] It might be easier to do it without the Settings API. Here is a working example.               <?php     /*     Plugin Name: Demo Verification Warning without Settings API     Description: Demo plugin demonstrating how to display a warning message when the user tries to save an invalid value in the option page.     Author: Teno     */          // define constants     define("DEMOVERIFICATIONKEY", "demo_verification_option");          // create an option array     $arrOption = get_option(DEMOVERIFICATIONKEY);     if (!(is_array($arrOption))) {         $arrOption = array(             "tab1" => array(),             "tab2" => array(),             "tab3" => array()         );         update_option(DEMOVERIFICATIONKEY, $arrOption);     }          // admin menu     add_action('admin_menu', 'demo_verification_adminmenu');     function demo_verification_adminmenu() {         add_options_page('Demo Plugin Menu for Verification without Settings API', 'Demo Plugin Menu for Verification without Settings API', 'manage_options', 'demo_verification_admin_menu', 'demo_verification_adminpage');     }     // admin page     function demo_verification_adminpage() {         $options = get_option(DEMOVERIFICATIONKEY);         print_r($_POST); // for debugging         echo '
';         if(isset($_POST[DEMOVERIFICATIONKEY]['tab1']['submitted']) && $_POST[DEMOVERIFICATIONKEY]['tab1']['submitted'] == 1){             if (strlen(trim($_POST[DEMOVERIFICATIONKEY]['tab1']['option_a'])) == 0) {                 $options['tab1']['invalid'] = True;                      echo '

Options are not saved.

';             } else {                     $options = array_merge($options, $_POST[DEMOVERIFICATIONKEY]);                 update_option(DEMOVERIFICATIONKEY, $options);                 echo '

Updates are saved.

';             }         }            ?>
             <?php screen_icon(); ?>
Demo Plugin for Validation Message without Settings API
             <form method="post" action="">  <?php // 'action=""' means to send the form post data to this page itself. ?>                 <input type="hidden" name="<?php echo DEMOVERIFICATIONKEY; ?>[tab1][submitted]" value="1" />

                         Option A	                                                      <input name="<?php echo DEMOVERIFICATIONKEY; ?>[tab1][option_a]" size="40" type="text" value="<?php echo $options['tab1']['invalid']  ? $_POST[DEMOVERIFICATIONKEY]['tab1']['option_a'] : $options['tab1']['option_a']; ?>" />                             <?php echo ($options['tab1']['invalid'] && $options['tab1']['invalid'] ) ? '* cannot be blank.' :'' ?>

                         Option B	                                                      <input name="<?php echo DEMOVERIFICATIONKEY; ?>[tab1][option_b]" size="40" type="text" value="<?php echo $options['tab1']['invalid'] ? $_POST[DEMOVERIFICATIONKEY]['tab1']['option_b'] : $options['tab1']['option_b']; ?>" />

                 <?php submit_button(); ?>                </form>
         <?php     }     ?>      But in case if somebody can figure it out with the Settings API, please post the solution.


How do you remove plugin edit option?

I would like to remove the edit option for all plugins on a wordpress site. Is there a hook/filter for doing this? It would be preferred to do it from the theme's functions file, rather than try to disable it within each plugin. Ideally, it could be removed for users without admin privileges, but that is a secondary concern. ![enter image description here](http://i.stack.imgur.com/Z43H5.jpg)


Action hook on Edit custom post type?

Is there an explicit action hook that will fire when (or just before) the admin Edit page renders for a custom post type? Something similar to {$new_status}_{$post->post_type}? I'm trying to find the least obtrusive place to insert my add_meta_box() registration so that it's not calling that function on every page refresh, but only when it's needed (ie: the user wants to create a new custom post or edit an existing custom post). Thanks for your thoughts / code snippets!


BuddyPress: What's the use of wp_bp_xprofile_data table and how does it get updated?

I have a questions related to BuddyPress:   What's the use of `wp_bp_xprofile_data` table? How does the data in the table get updated?   And when any user updates his information - does the data in this table get updated?


get_terms function not returning anything

This has had me baffled for days so any help would be appreciated. I cannot get the function `get_terms` to return anything. I've tried the following code in the **index.php** , **single.php** and **page.php** , inside and outside the loop, of the default Twenty Thirty theme as well as my custom theme and no category terms are returned. I've created 10 test category terms and applied them to different test posts and still nothing. It's not working on the live site or the local development site. I've also tried flushing the rewrite rules by going to the Permalink Settings page and re-saving, just to see if that helped. Researching and finding any similar problem online has the same answer: add the `hide empty` part. So I did, to no avail. Any ideas why this function would not be working? `<?php get_terms("category") ?>` `<?php get_terms("category", array("hide_empty" => 0)) ?>`


How to link keywords in custom fields?

I have come across different WordPress plugins that will automatically link/hyperlink keywords--to external links--every time they appear throughout posts. Here's an explanation of what I mean: **Site page 1 content:** Georgio went to the store after he stopped by to see how Nichols was doing. **Site page 2 content:** The cat was afraid of Georgio and his dog. **Site page 3 content:** My best friend is not a friend of Nichols, who is the best friend of Georgio, but is a friend of Georgio. **What I need done:** On each page (1, 2, 3) and each time it appears on each page, I want "Georgio" to be linked to the same external website (like http://geethr33whiskers.net <---I just made that up), but without me having to manually link each "Georgio". I want to be able to link "Georgio" once and then automatically the other instances will be linked to the same external website. On each page (1, 3) and each time it appears on each page, I want "Nichols" to be linked to the same external website (like http://www.nichols2zzz4wedding.com <---I just made that up), but without me having to manually link each "Nichols". I want to be able to link "Nichols" once and then automatically the other instances will be linked to the same external website. **END OF EXPLANATION** Now back to what I was saying before the explanation... All the plugins that I've found are only linking the specific keywords found within the post_content area of the posts. My content is not found within the default WP post_content area, though. I am using the 'custom fields' feature of WP to enter the content for every one of my posts (I do this so I can have better control of where the content appears on the site). How do I get the plugins to look within the 'custom fields' for the keyword to link? Is there a 'custom fields' code I need to add to the plugin files? Thanks.


Common side bar for multiple websites

I have 5 WordPress sites and each site should have the same sidebar content. It is dynamically posted from userend and it should be common to all my WordPress sites. Without using iframe, how can I repost the same content that is in the right sidebar?


Table truncated on Mobile theme

I have a problem with tables into posts, I not able to see all the data in the tables on wptouch mobile theme, because they are truncated on the right on mobile screen. Plugin used: WPTouch, CKeditor for tables. But I have the same problem with any tables editor. can you help me ? It's very hard to have support from Wptouch, and I found this very good website ;). * * * Here their answer to my problem: Tables often use fixed dimensions. By definition, fixed dimensions override any scaling capabilities of iOS or WPtouch. Choose to use flexible dimensions whenever possible to allow page elements to resize for various mobile screen sizes. If you are unable to change these dimensions at their source, you may add custom styling in the Stats & Custom Code area of your WPtouch admin panel. (In your case, the table widths appear to be set inline). The tool tip there will give you additional information if you want to use a stylesheet otherwise simply include your custom CSS inside style tags. * * * Could you advice a sample code to add into Stats & Custom Code area of WPtouch panel to to use flexible dimensions ? I have no idea how change the flexible dimensions at the source and what code I can use in WPtouch. Thank you very much, looking forward to your reply. Website page sample with tables: http://gt-scuderia.net/2013/03/27/coppa- gtscuderia-seca-il-02042013/ here one screenshot of my problem: ![Table](http://i.stack.imgur.com/UCgAL.png) Angel.


edit_form_after_editor only in post edit pages

I want to show some information in post edit screen. I found 2 hooks which allow to do this after title or after editor. Heres code with second one:               add_action( 'edit_form_after_editor', 'myprefix_edit_form_after_editor' );     function myprefix_edit_form_after_editor() {         global $post;         $author_id=$post->post_author;         $email = get_the_author_meta( 'user_email', $author_id);         $imie = get_the_author_meta( 'first_name', $author_id);         $nazwisko = get_the_author_meta( 'last_name', $author_id);         $nip = get_the_author_meta( 'nip', $author_id);         $login = get_the_author_meta( 'user_login', $author_id);         $firma = get_the_author_meta( 'nazwa_firmy', $author_id);         echo '
DANE FIRMY
';         echo 'Nazwa firmy: ', $firma;         echo '
Imię: ', $imie;         echo '
Nazwisko: ', $nazwisko;         echo '
NIP: ', $nip;         echo '
E-mail: ', $email;         echo '
Login: ', $login,'

';     }      I want this information to show only on post edit pages - now it shows everywhere (custom post type edit pages, pages edit screens etc.). Maybe theres hook which allows to show this info under featured image (right part of edit screen).


Restrict categories to a custom post type

In the WP-Admin when creating a post or a custom post type I want to restrict certain categories to a custom post type. For example, Posts will only be able to select Category A and B. And custom post type A will only be able to select Category C and D. Would I have to write some code to hook into somewhere or is there a function built-in to the framework? Thanks in advance.


how to properly list child pages in sidebar?

My pages menu is maximum 3 levels deep and I am having a hard time figuring out how to properly list the child pages in the sidebar. If a page is a parent I want to list it's direct child pages and the title should be this parent. If a page is a child AND has children of itself, I want to list only it's children and the title should be this page If a page is a grandchild, I want to list it's siblings and the title should be this grandchild. For now I am using (from the Codex):               <?php if($post->post_parent) {     $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1&sortcolumn=menuorder");     } else {     $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1&sortcolumn=menuorder");     }     ?>     <?php if ($children) { ?>

<?php _e('More ','sunchine') ?><?php echo get_the_title($post->post_parent);?>

     <?php echo $children;?>

     <?php     }     ?>      And this is almost correct. Almost, because my it doesn't do my 2nd criterium. The Codex has heaps of options, but I cannot figure out which would be applicable to what I want to accomplish. Using widgets and/or a plugin is not an option. Any help is much appreciated.


How to set ipv6 address as siteurl?

I have try to set ipv6 ip address as home and site url, but it seems not work perfectly. From there: `http://[2001:da8:d800:71::250]/wordpress/` (if you view the source) we see that some url, such as `pingback` (line 16) where correct, but others, such as `rss` (line 20) were lost `[` and `]`, how to fix this? (if I don't have an domain which point to this ipv6 address.)


In the fv wordpress flowplayer plugin , i cannot stop the autoplay option

I am using fv wordpress flowplayer plugin , i cannot stop the autoplay option. i have used the coding.               <?php       $videourl =" [flowplayer src='https://s3-eu-west-1.amazonaws.com/brightstartvideos/Tester+2.mp4' splash=image.jpg autoplay=false]  " ;     echo $videourl; ?>      I put autoplay=false but it is still autoplaying the video. Please advise me..........


change captcha design in Fast Secure Contact Form plugin

I am using  Fast Secure Contact Form plugin to create contact form widget.It working fine . Now i like to change captcha appearance. Original captcha generated by plugin ![fs contact form generates captcha](http://i.stack.imgur.com/g9atG.png) But, I need to change it design like below ![enter image description here](http://i.stack.imgur.com/4zTTt.png) Any option available or any other ways to do this ! Thanks in advance


Transients and WP Super Cache?

Is it worth using Transients when running WP Super Cache? We have a website that get's updated 20 times a day with new post, so I set a lot transients for queries that don't reflect those updates. My reasoning is that every time we post, it clears WP Super Cache cache. Is this overkill?


I have a question in Basic HTML

What does it mean to edit a website directly? My professor tells us not to use an editor. I'm not sure how to do so either.


Using My Own Classes On Wp Unit Tests

(I'm trying to solve style problems of code samples) I'm developing a theme but I have some classes which developed for this theme. I want to run unit tests on my theme. I've followed this steps:   1. Checked out test repo to my root web folder:              svn co http://develop.svn.wordpress.org/trunk/ wordpress-develop        2. Copied my theme folder to _wordpress-develop/src/wp-content/themes_   3. Created an empty database and set up _wp-tests-config.php_ file. Also added this line to _wp-tests-config.php_              define( 'WP_DEFAULT_THEME', 'THEMENAME' );        4. Created _wordpress-develop/tests/phpunit/tests/konser.php_ file with this content:              <?php     class Test_Konser extends WP_UnitTestCase {          public function test_firstTest(){          // Arrange             $id = $this->factory->post->create(array(                     'post_type' => 'konser',                 ));             add_post_meta($id, "konser_tarih", time());          $ids = get_posts(array(                 'post_type' => 'konser',                 )             );          foreach ($ids as $id) {          $this->assertInstanceOf('WP_Post',$id);         $ss = get_post_meta($id->ID, "konser_tarih", true);         $this->assertTrue($ss!='');         }     }     }      ![enter image description here](http://i.stack.imgur.com/cxE58.png)   5. But I want to use my `Konser` and `PostType` classes.              function setUp() {             $this->post_id = new Konser(410);        parent::setUp();     }     function test_ID() {         $this->assertInternalType("int", $this->post_id);     }        6. Added this 2 lines to _/wordpress-develop/tests/phpunit/includes/functions.php_                require_once('src/wp-content/themes/THEMENAME/include/PostType.php');       require_once('src/wp-content/themes/THEMENAME/include/Konser.php');        7. But I'm getting **Call to undefined function get_post() in konsertv-develop/src/wp-content/themes/THEMENAME/include/PostType.php** Can you tell me what I'm missing? CONTENT OF PostType.php                 <?php       class PostType       {     public $post;     public $ID;          function PostType($ID) {         $this->post = get_post($ID);         $this->ID = $ID;     }     function getPost()     {         return $this->post;     }     function getTarih()     {         return get_post_meta($this->ID, "konser_tarih", true);     }     function getID()     {         return $this->ID;     }      }


How can i make a search box to search by custom field

Hy i am trying to make a search box for a week to search for post that have a specific custom field. I have a post_type - **produse** with 2 custom field   * > CF1- culoare / alb,maro,verde    * > CF2- marime / 120x200, 200x300 Ok i want to make a checkbox form and select, after i select wath i want and push search i want to retrive the post that i have atached the custom field. This i have made this from search around web.. but this is not working.. it load the cpu on my web hosting..               <?php      $field = get_field_object('culoare');     $values = explode (',', $_GET['culoare']);     ?>          <form>         <fieldset>             <legend>Cauta dupa culoare:</legend>             <?php if (!empty($field['choices'])) : $i = 0; foreach( $field['choices'] as $choice_value => $choice_label ): ?>             <?php $culoareIndex = strtolower($choice_value); $i ++; ?>             <input type="checkbox" name="culoare" value="<?=$choice_value?>" id="checkbox-1-<?=$i?>" class="regular-checkbox-<?=$culoareIndex?>"             <?php if( in_array($choice_value, $values) ): ?> checked="checked" <?php endif; ?> />             <label for="checkbox-1-<?=$i?>"></label>              <?php endforeach; endif; ?>             <input type="submit" value="Search" />         </fieldset>     </form>      Functions.php               add_action('pre_get_posts', 'my_pre_get_posts');          function my_pre_get_posts( $query ) {         if( is_admin() ) { return; }         $meta_query = $query->get('meta_query'); // get original meta query              // validate type         if( (empty($_GET['culoare'])) )         {             return;         }              // get types as an array         // - use explode to get an array of values from type=a|b|c         $culori = explode('|', $_GET['culoare']);              // set compare for the meta_query         // - http://codex.wordpress.org/Class_Reference/WP_Query         $meta_query['relation'] = 'OR';                   foreach( $culori as $culoare )         {             $meta_query[] = array(                 'key'       => 'culoare',                 'value'     => '"' . $culoare . '"',                 'compare'   => 'LIKE',             );         }                   $query->set('meta_query', $meta_query); // update the meta query args              return; // always return     }      Can somebody show me how is done,please, and point me in the right direction, i'm not so good with php and i want this to be made. Thanks


Limit to One Custom Taxonomy Selection, Including Most Used

I've got a bit of code that limits my custom taxonomy to only allow the user to select one category, by turning the checkboxes in to radio buttons. See the screenshot below for example: ![](http://i.imgur.com/XDYyViK.jpg) I need the Most Used section to also display as radio buttons, but the code I have only affects the All Categories field. See the below screenshot: ![](http://i.imgur.com/X0Y2FwO.jpg) So, how can I extend this code to also cover the Most Used section?               // limit number of categories a product can have     add_filter('wp_terms_checklist_args', 'htmlandcms_select_one_category');     function htmlandcms_select_one_category($args) {         if (isset($args["taxonomy"]) && $args["taxonomy"] == "product-category") {             $args["walker"] = new Walker_Category_Radios;             $args["checked_ontop"] = false;         }         return $args;     }     class Walker_Category_Radios extends Walker {         var $tree_type = "category";         var $db_fields = array ("parent" => "parent", "id" => "term_id");         function start_lvl(&$output, $depth = 0, $args = array()) {             $indent = str_repeat("\t", $depth);             $output .= "$indent
\n";         }         function end_lvl(&$output, $depth = 0, $args = array()) {             $indent = str_repeat("\t", $depth);             $output .= "$indent
\n";         }         function start_el(&$output, $category, $depth, $args, $id = 0) {             extract($args);             if (empty($taxonomy)) {                 $taxonomy = "category";             }             if ($taxonomy == "category") {                 $name = "post_category";             } else {                 $name = "tax_input[" . $taxonomy . "]";             }             $class = in_array($category->term_id, $popular_cats) ? " class=\"popular-category\"" : "";             $output .= "\n
term_id}\"$class>" . "<input value=\"" . $category->term_id . "\" type=\"radio\" name=\"" . $name . "[]\" id=\"in-" . $taxonomy . "-" . $category->term_id . "\"" . checked(in_array($category->term_id, $selected_cats), TRUE, FALSE) . disabled(empty($args["disabled"]), FALSE, FALSE) . " /> " . esc_html( apply_filters("the_category", $category->name)) . "";         }         function end_el(&$output, $category, $depth = 0, $args = array()) {             $output .= "
\n";         }     }      Original code taken from this answer. **UPDATE** ~~I'm thinking this has something to do with`$tree_type`, but I can't seem to find any documentation about valid values for this.~~ Commenting that out does absolutely nothing, so I don't think that's relevant at all. I'm thinking the walker's just not getting run on Most Used.


How to display post tags

I'm converting an HTML template into a wordpress theme and I'm having some trouble displaying the post tags within the functions.php file. What I would like to do is add the following code into the functions file with the HTML code. I have been trying for a few days now and I have already been to the codex but nothing I try is working.
     tag 1 tag 2 tag 3 tag 4
      Can anyone please help with this?


jQuery.accordion isn't a function even when enqueued

I'm trying to implement a jQuery accordion for a client of ours. Basically, it's this tutorial (http://wp.tutsplus.com/tutorials/creative-coding/create- an-faq-accordion-for-wordpress-with-jquery-ui/) but having problems enqueuing the jQuery. Basically, this is the code that is trying to enqueue the accordion script from the tutorial:-               add_action( 'wp_enqueue_scripts', 'fl_enqueue' );          function fl_enqueue() {             wp_register_style('fl-jquery-ui-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/south-street/jquery-ui.css');             wp_enqueue_style('fl-jquery-ui-style');             wp_register_script('fl-custom-js', get_template_directory_uri() . '/faq/faq.js', 'jquery-ui-accordion', '', true);             wp_enqueue_script('fl-custom-js');     }      When loading the page with Firebug, I'm getting the error TypeError: jQuery(...).accordion is not a function. I also cannot seem to see the accordion script being enqueued. However, the faq.js IS being loaded (which I think is odd, as it's a dependancy of the accordion script). Baffled by this, any ideas?


Add comments from the admin panel?

I'm using WordPress as an Authoring tool. Hence I do not use the front end. Now I wanna add the functionality making internal comments. As it is now, you are only allowed to read comments from the Edit Post page, not to write them. Got any hints or good ideas on how to make this possible?


What is wrong with this code to remove wp admin bar from one page

I'm just trying to turn off the wp admin bar on one page, but this function removes it from every page. What am I missing?               <?php        if ( !is_page('image-upload') ):         show_admin_bar(false);       endif;     ?>


Comments not displaying after changing theme

The 'Leave a Reply' section at the end of my posts are not displaying after changing to the 'The Morning After' theme. Comments and reply sections are displaying when I revert to the Twenty Eleven theme. I have tried re- installing the theme but it is still not working. Example post at: http://richashworth.com/testing/


Give each post type label a different color?

On my homepage I am using a code to call different post type labels. Example: > TV Series: "Once Upon A Time" Here is the code I use to call the label:               <a href="<?php echo get_post_type( $post->ID ); ?>">         <?php $post_type = get_post_type_object( get_post_type( $post ) );         echo $post_type->label; ?>     </a>      I want to place each post type in a div with different background colors. Example: ![Example](http://i.stack.imgur.com/yjwk4.jpg) Do you see how once upon a time has a different background from pretty little liars? I also want to be able to make the link color different.


WP 3.5 - How to remove permalink from images

In previous versions of WP, we were able to remove permalink from images while we were inserting images into post. But, now there is no obvious option to do so. How can it be achieved? Thanks.


how to create add-able metaboxes in wordpress post edit screen?

Is there anyone who knows how to create add-able multiple metaboxes, easy enough for a user to add a meta box on demand in a single post edit screen ?


get_the_post_thumbnail($post->ID, 'thumbnail'); not working. How can I solve this?

I am using the following code to display the posts on my home page. But I could not print **thumbnails** using `get_the_post_thumbnail($post->ID, 'thumbnail');` any help to solve this will be very much appreciated..               while (have_posts()) : the_post();                     $excerpt = get_the_excerpt();                        $date = explode(",", get_the_time("F,j,Y", "", "", false));                     print('

');                                      print('
                                                                              ' . $date[1] . '
' . substr($date[0], 0, 3) . '
');                         print ('
');                                 the_title('
', '
');                         print ('
');                                                            print ('
');                         print ('

');                             if (strlen(get_the_content()) > 100) {                                 $content = get_the_content();                                 echo str_replace(' ', '

', substr($content, 0, 300)). "....";                                    echo '
Read More';                                 echo get_the_post_thumbnail($post->ID, 'thumbnail'); // post image thumbanails                             }                             else { the_content(); echo "
"; }      ** if I use the `feature image` then it prints twice. Thanks.


External Authentication

I currently have a website with its own user authentication. It also has 3 separate installations of WordPress in its subdirectories, each loading data from 3 separate databases. What I would like to do is load wp- includes/pluggable.php when authenticating users on the main site in order to carry out WordPress authentication at the same time, as outlined in the following answer: http://wordpress.stackexchange.com/a/11472 However, as I have 3 WordPress installations that I would have to authenticate users for and generate cookies, this would be extremely difficult. Does anyone have any pointers/ideas on how I would do this? Thanks


Password Protected Post is invisible until you login

I added a post and made it password protected. The post does not show up in a category list I placed on the Courses page, nor does it show up in the search unless you go directly to the page and then login. It then starts appearing on the Courses page. Any idea how to have the link to the post visible? The page they should show up are on: http://www.andrewruis.com/course/. If you search for "asb 129" nothing shows up in the search.


how to include javascript file and css file in wordpress

I am creating new plugin so i need add a java script file and css file. These are my javascript files   1. jquery.min.js   2. jquery-1.3.2.min.js   3. jquery.tabify.js Css file:   1. newstyle.css


getting a js file for one page

wp_register_script('SliderViewer', '/js/SliderViewer-1.2.js');     wp_enqueue_script('SliderViewer');          get_header();      however, `mydomain.com/js/SliderViewer-1.2.js` doesn't exist. My js is in the ftp at               thewebsite -> wp-content -> themes -> BLANK-Theme -> js      What's the path of that? Thanks-


Are Categories, Tags and Custom Taxonomies any different in regards to SEO?

Simple question, really. I know pretty much nothing about SEO, and i'm trying to define a good structure for this clients online magazine. I already know i'll be using a few custom taxonomies along with categories and tags, but the question is: if not using any SEO plugin, are either Categories, Tags and Custom Taxonomies any more "searchable" or "optimized" than their counterparts? eg.: Is the category Adamantium any more "relevant" than the adamantium tag or the adamantium custom term just because it's a category (or b/c it's hierarchical)? Does this even make any sense?


Embed tag length issues

I have a pdf in my media library that I am trying to embed on a page. The width works fine but the length does not. I am trying to basically represent 8.5 x 11 on the screen. As it is only about 3-4 inches in screen length are shown and the rest is scroll bar.               <embed src='http://example.com/wp-content/uploads/.../somefile.pdf' width='1000px' length='1200px' />      I have even tried using length='100%'.


Conditionally write open graph meta property in header

Have a function I use to print Open Graph tags in the header of each page I also have a plugin I use to post to Facebook which also puts in it's own set of basic OG Tags. Facebook doesn't like if a page as more than one og:url tag. The plugin only works on single pages so I want to not print my og:url tag when it is on a single post page. I want to test for is_home and is_tag and if those are true the function will print the og:url tag. The other problem is the home page has a completely different url than the tag page. I tried doing the conditional inside the meta tag but Facebook vomits if the og:url line even exists. Here is the code I currently have and everything except the conditional for the og:url tag is working:                   function wpc_fb_opengraph() {     $wpc_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(),     'large');     ?>     <?php echo "\n<!-- Start of OG Tags from DougTheme 2013 -->\n"; ?>     <meta property="og:image" content="<?php if (function_exists('catch_that_image')) {echo catch_that_image(); }?>" />     <meta property="fb:admins" content="XXXXX"/>     <meta property="fb:app_id" content="XXXXXXXXXX">     <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />     <meta property="og:description" content="<?php if ( is_singular() ) { echo strip_tags(get_the_excerpt()); } else { echo "comments about everything"; } ?>" />     <meta property="og:title" content="<?php if ( is_singular()) { echo esc_attr( get_the_title() ); } elseif (function_exists('is_tag') && is_tag()) {single_tag_title('Tag Archive for "'); echo '" - '; echo get_bloginfo('name');} else { echo get_bloginfo('name'); } ?>">     <meta property="og:type" content="<?php if ( is_singular() ) { echo "article"; } else { echo "website";} ?>">             if (is_home()) {             <meta property="og:url" content="<?php bloginfo('url'); ?>" />     <?php } //end if home          elseif ( is_tag() ) {         <meta property="og:url" content="<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];  ?>">     <?php }                     <?php echo "\n<!-- End of OG Tags from DougTheme 2013 -->\n"; ?>     <?php }          add_action('wp_head', 'wpc_fb_opengraph');      I get a syntax error in either of the lines testing for the page. I'm stumped.


How to get all posts (in chunks) via XML-RPC?

**I would like to retrieve all posts of a blog via the XML-RPC API of Wordpress.** There are the methods of `blogger.getRecentPosts` and `metaWeblog.getRecentPosts` which - given a sufficiently high value as number of posts (or -1) in theory should return all posts. However, this does not work for very large blogs or very weak servers that cannot hold the whole blog in memory. In that case, these functions will not return anything at best or throw an error into the response XML. A solution would be to retrieve smaller chunks of, e.g. 50, posts at a time and put it all together on the receiving side. For this to work one would need to specify an offset for the posts to get. I was not able to find a way to specify such an offset in the documented API. **Is there any way to make this work, either by specifying an offset or by using other than the methods mentioned above?** I'm not looking for a description on how to write a plugin or modify Wordpress itself in any way. I can do that, sure, but I'm talking about authorized retrieval of data of arbitrary Wordpress blogs. **Edit:** I've opened a trac ticket at Wordpress with a suggestion for solution: http://core.trac.wordpress.org/ticket/16316


IE Jquery Access Denied

Below code i am using it to open print window with some html content in some div. This code is working perfectly fine with Chrome and Firefox however when I run it on IE 8,9 it is opening a window with URL: [http : / / /] and getting crashed. what am i missing. document.domain is required for iframes. I am not able to find out what is the issue here.               jQuery(function ($) {         $('a.certificate-window').click(function () {                 var btn = $(this),                     icsCertificate = btn.find('.em-certificate').html(),                                 recipecert =  window.open('','PrintWindow','width=925,height=725'),                     html = '' + icsCertificate + '';                 recipecert.document.open();                 recipecert.document.write(html);                 recipecert.document.close();                 return false;             });     });      Thanks, B


How to conditionally add a wp_filter

I have a WP filter I created that I only want to run on certain menu items. I am attempting to use -               function add_nav_class($output) {     $output= preg_replace('/<a/', '<a class="lsbb"', $output, -1);     return $output;     }          function wp_nav_menu_conditionals() {        if(!wp_nav_menu('theme_location' => 'footer_menu')) {           add_filter('wp_nav_menu', 'add_nav_class');        }     }     add_action('wp', 'wp_nav_menu_conditionals');      I want to add_filter on all menus that are not listed as theme_location footer_menu. Is there a way to do this in WP? If the menu is using theme_location footer_menu I want it to NOT use add_filter. Can anyone tell me how to use add_nav_class conditionally?


Alter query on edit.php

What's the best way to alter the query being run on the Posts Edit screen (edit.php)? The current method I'm using is by passing an argument to the global $wp_query like so:               $wp_query->query( array ('category__in' => array(14,9,2) ) );      However, this doesn't really work as expected once the user pages back and forth, filters, or searches.


Limit action in comment according to IP

I've been trying to set something that might be really easy (but I never had to do this before) :               add_filter('pre_comment_user_ip', 'limit_commentator');     function limit_commentator( $comment ) {         $comment_field_value = get_comment_meta( $comment->comment_ID, 'some_custom_field', true );         //my code          }      I think this is the right hook but how can I limit the ability for commentators to post comment WITH this custom field? Actually I just want one value per IP. Got another question : Is it really worthy to limit per IP? I've been thinking about a limit on a daily basis. What do you think about this?


loop through custom post types with meta data

I'm really curious as to how might be the quickest way to loop through a custom post type with meta data. I have some code that works but it's slow. I'm using wp_query and it works. I have also a bunch of conditionals that check whether meta data exists and if so, to do something which is usually display it and a few times display a small image. There are 47 custom post types but maybe I'm just doing too much on one page? I've thought about using ajax to load them (kind of like infinite scrolling) but I'm not sure of the best method. I was wondering that what is "cost" of looping though custom post types with over 30 different meta data fields? Is there a better way to scan through the tables or is there other methods that don't have the high overhead? Thanks! Here is my code and I'll check out those tools as well.                                       <?php $count = 0; ?>                     <?php $args = array(                          'post_type' => 'property',                          'posts_per_page' => 100,                          'orderby' => 'meta_value',                          'meta_key' => 'random_775',                          'order' => 'ASC'                         );                                   $loop = new WP_Query( $args );                         while ( $loop->have_posts() ) : $loop->the_post(); ?>                              <div class="<?php wpp_css('property_overview::row_view', "wpp_row_view wpp_property_view_result"); ?>">                           <div class="<?php wpp_css('property_overview::all_properties', "all-properties"); ?>">                                  <?php $countyCheck = $theCounty;                              $theCounty = get_post_meta( get_the_ID(), 'random_775', true );                                  if ($theCounty != $countyCheck ){                             echo '
' . $theCounty . ' County
';                             } ?>                              <a href="<?php the_permalink(); ?>">                         <div class="<?php wpp_css('property_overview::property_div', "property_div {$property['post_type']} clearfix"); ?>">                                               <ul class="<?php wpp_css('property_overview::data', "wpp_overview_data"); ?>">                                          <?php $sArea = get_post_meta( get_the_ID(), 'area', true );                                     $nArea = preg_replace('/[^0-9]/','',$sArea);                                     $nArea = $nArea / 43560; // convert square feet area into acres                                     $sArea = number_format($nArea,1,'.',',');                                     echo '
';                                         echo '
';                                             echo '

' . get_post_meta( get_the_ID(), 'total_acres', true ) . ' acres +/- for sale

';                                             echo '
';                                                 $first_bullet_point_check = get_post_meta( get_the_ID(), 'first_bullet_point', true );                                                 if (isset($first_bullet_point_check[0])) {                                                     $firstPost = $first_bullet_point_check;                                                     $firstPost = substr($firstPost, 0, 30);                                                      echo '

· ' . $firstPost . '...

';                                                 }                                                 $second_bullet_point_check = get_post_meta( get_the_ID(), 'second_bullet_point', true );                                                 if (isset($second_bullet_point_check[0])) {                                                     $secondPost = $second_bullet_point_check;                                                     $secondPost = substr($secondPost, 0, 30);                                                     echo '

· ' . $secondPost . '...

';                                                 }                                                 $third_bullet_point_check = get_post_meta( get_the_ID(), 'third_bullet_point', true );                                                 if (isset($third_bullet_point_check[0])) {                                                     $thirdPost = $third_bullet_point_check;                                                     $thirdPost = substr($thirdPost, 0, 30);                                                     echo '

· ' . $thirdPost . '...

';                                                 }                                                 $turn_key_check = get_post_meta( get_the_ID(), 'turn_key', true );                                                 if ( $turn_key_check == 'true' ) {                                                     echo '

';                                                 }                                             echo '
';                                         echo '
';                                         echo '
';                                             //display image                                             the_post_thumbnail();                                             $pending_check = get_post_meta( get_the_ID(), 'pending', true );                                             if ( $pending_check  == 'true' ) {                                                 echo '

';                                             }                                             $sold_check = get_post_meta( get_the_ID(), 'sold', true );                                             if ( $sold_check == 'true' ) {                                                 echo '

';                                             }                                         echo '
';                                     echo '
';                                     $sAddress = get_post_meta( get_the_ID(), 'address', true );                                                      $asAddress = explode(',',$sAddress);                                 if (is_array($asAddress)) { // remove country                                     array_pop($asAddress);                                 }                                 if (is_array($asAddress)) { // remove zip                                     $sStateCode = array_pop($asAddress);                                     $sStateCode = preg_replace('/[^A-Z]*/','',$sStateCode);                                 }                                 $sCounty = get_post_meta( get_the_ID(), 'random_775', true );                                 $sAddress = "$sCounty, $sStateCode";                                      echo '
';                                     echo '
' . get_post_meta( get_the_ID(), 'random_775', true ) . ' Co.
';                                      echo '
PRICE
';                                     echo '
' . get_post_meta( get_the_ID(), 'price', true ) . '
';                                     echo '
';                                         $tillable_check = get_post_meta( get_the_ID(), 'tillable', true );                                         if ( $tillable_check == 'true' ) {                                             echo '

';                                         }                                         $tillable_check = get_post_meta( get_the_ID(), 'reduced_price', true );                                         if ( $tillable_check == 'true' ) {                                             echo '

';                                         }                                     echo '
';                                 echo '
';                                 ?>                                          <?php                                      $children_check = get_post_meta( get_the_ID(), 'children', true );                                     if($show_children && $children_check): ?>

<?php echo $child_properties_title; ?>

                                             <?php foreach($children_check as $child): ?>
                                                 <a href="<?php echo $child['permalink']; ?>"><?php echo $child['post_title']; ?>	                                                 <?php echo $child['price']; ?>
                                             <?php endforeach; ?>

                                     <?php endif; ?>                                          <?php if(!empty($wpp_query['detail_button'])) : ?>
<a <?php echo $in_new_window; ?> class="button" href="<?php echo $property['permalink']; ?>"><?php echo $wpp_query['detail_button'] ?>
                                     <?php endif; ?>


How can I prove if wp cron is running my task if I have DISABLE_WP_CRON set to true

I am trying to trigger a wp cron task via a real (linux) server cron and have followed online instructions to add this to wp-config:               define('DISABLE_WP_CRON', true);      My cron job does this :               wget -O - http://www.mysite.co.uk/wp-cron.php?doing_wp_cron=1      I have proved that the server's cron job is working (i receive the cron emails from the server when I remove > /dev/null 2>&1) but am unsure if my actual scheduled task is running. How can I prove this?


Copyright messages for a particular set of pages

I have created some pages (not post) in wordpress related to my college notes. I would like to display a copyright message of the college on this pages, but I don't want do this manually every time. So is there any plug-in or tweak available to achieve this?


Move title "meta box" in post mode

I've created a custom post type with my own custom meta boxes. Now I want to move the title box to the side or simply remove it and place the same content in a custom meta box. How do I go about to do this? Thanks


Use Same Settings for All Inserted Media?

When you insert a bunch of images into a Wordpress post via "Add Media," you can hit Shift or Ctrl and select several of them at the same time. But is there a way to be able to set the same "Attachment Display Settings" for all of these images? Like, you highlight all of the images you want, select "Medium," and then that setting gets applied to all of the images you have selected so that they're all "Medium" for their individual dropdown? Thanks!


Targeting specific menu with wp_nav_menu_items

Hey! I have added a wp_loginout() to my header using a snippet in my functions.php:                   add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);     function add_login_logout_link($items, $args) {                  ob_start();             wp_loginout('index.php');             $loginoutlink = ob_get_contents();             ob_end_clean();                  $items .= '<li>'. $loginoutlink .'</li>';              return $items;     }      The thing is that it shows the login link in every one of my three menues:                   function register_main_menus() {        register_nav_menus(           array(              'primary-menu' => __( 'Primary Menu' ),              'secondary-menu' => __( 'Secondary Menu' ),              'footer-menu' => __( 'Footer Menu' ),           )        );     };      I would like to target the wp_nav_menu_items filter to only include the login link in the primary menu. Ideas? Thanks in advance


Query with pre_get_posts to get pagination

After pretty much getting everything working with `query_posts`, I noticed my pagination wasn't running. I was told `pre_get_posts` should be the solution. My problems:   1. I don't know how to pass all my criteria `(query_posts(array('post_type' => 'trips', 'types' => $types, 'paged' => $paged,)`in to `pre_get_posts`   2. I can't get it working on (just) the template I want, which is used on a page (`is_page` doesn't work) Any help would be appreciated. This is what's inside functions.php               function bwpm_pre_get_posts($query){         if(!$query->get('posts_page_page'))         $query->set('posts_per_page',1);         }         add_action('pre_get_posts','bwpm_pre_get_posts');      This is what's in the template that is used on the page.               <?php     /*     Template Name: Generic Trips Template     */     ?>     <?php get_header(); ?>                  <?php get_template_part( "beforeloop", "page" ) ?>                                         <?php $types = $post->post_name; ?>               <?php if (have_posts()) : ?>         <?php              $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             query_posts(array(                  'post_type' => 'trips',                  'types' => $types,                  'paged' => $paged,             ) );         ?>     <?php while (have_posts()) : the_post(); ?>         <article id="post-<?php the_ID(); ?>" class="post">
          <?php endwhile; ?>
     <?php posts_nav_link(' · ', 'previous page', 'next page'); ?>
          <?php endif; wp_reset_query(); ?>             <?php get_template_part( "afterloop", "page" ) ?>           <?php get_footer(); ?>      Update: 11/06/2012 After updating the code to @chipbennet example, the problem still isn't solved as I don't get properly working pagination. The previous link will never appear, and the next link will show the same content on every page. Full page code can be found on http://pastebin.com/NiuSEWia.


Can I remove an image from the Gallery without deleting it from the Media Library?

From what I've looked, I don't think is built-it. Is there a plugin that implements this feature or a workaround for this? Thanks


$wpdb won't insert NULL into table column

When i try something like this                   $status = NULL;              $wpdb->update(                 'table',                 array(                      'status' => $status,                 ),                  array( 'id' => 1 )          );      In the 'status' column now i have an empty string `''`, it simply won't set it to NULL. The column can be NULL of course. I've also tested $wpdb->query and $wpdb->prepare and the results are the same. Am i doing something wrong?


Front End submission with meta key

I'm working to create a front end custom post type submission from. I already coded checking different tuto. But the form returned not found page upon suvmission, again not inputing any data. Please help me to find out the error if possible.               <?php     if (!isset($_POST['submit'])) {          ?>     <form method="post" action="<?php the_permalink(); ?>">

Mobile No:	<input id="id_meta" type="text" name="wpcf-mob_no" maxlength="100" />

Amount To Load:	<input id="id_meta" type="text" name="wpcf-mob_amount" maxlength="100" />

Connection Type	<select id="id_meta" type="text" name="wpcf-mob_type" maxlength="100" />               <option value="pre_paid">Pre Paid</option>               <option value="post_paid">Post Paid</option>

	<input id="id_meta" type="hidden" name="wpcf-mob_status" maxlength="100" value="pending"/>

	<input id="id_title" type="hidden" name="post_title" maxlength="100" value="<?php echo date('r'); ?>"/>

                       	     <input type="hidden" name="post_type" id="post_type" value="loads" />          <input type="hidden" name="action" value="post" />          <?php wp_nonce_field( 'new-post' ); ?>                      <input type="submit" value="Submit" name="submit"/>

                    </form>          <?php }          else {                  $title = $_POST['post_title'];             $meta_box1 = $_POST['wpcf-mob_no'];             $meta_box2 = $_POST['wpcf-mob_amount'];             $meta_box3 = $_POST['wpcf-mob_type'];             $meta_box4 = $_POST['wpcf-mob_status'];                  $new_post = array(                 'post_title'    => $title,                 'post_status'   => 'publish',           // Choose: publish, preview, future, draft, etc.                 'post_type' => 'loads'  //'post',page' or use a custom post type if you want to         );         //save the new post         $pid = wp_insert_post($new_post);              /* Insert Form data into Custom Fields */         add_post_meta($pid, 'wpcf-mob_no', $meta_box1, true);         add_post_meta($pid, 'wpcf-mob_amount', $meta_box2, true);         add_post_meta($pid, 'wpcf-mob_type', $meta_box3, true);         add_post_meta($pid, 'wpcf-mob_status', $meta_box4, true);                   print '
';         var_dump(array($new_post, $pid));         print '
';     }          ?>


RSS Feed has no styles in chrome - function to add one?

This is a really bizarre problem. For some reason Chrome does not have any RSS feed formatting? Where as most other browsers do! So it seems from I read online that I have to create my own style sheet for it :/ That's fine, but how can I add my RSS stylesheet to my wordpress RSS feed without manipulating the core files. Is there a function that will allow me to add this style sheet? Thanks for any tips :-)


Forum plugin that allows private groups that are invite only

I'm looking for a plugin that would allow me to create private groups for discussion that are invite only. These would be for people who have taken a workshop and want to remain in communication with their cohort afterwards. They would need to be invited/added by admin after each workshop and would not communicate with other participants. Anyone have any ideas? Appreciate the help!


I would like to remove the url and description from about the header

I am using the twenty ten theme. Could someone kindly tell which line / lines to axe to remove that URL and description and move the banner picture to the top of the page. Thanks in advance. Brandon


Custom headers in WordPress, are there also custom footers?

I’m new to WordPress. I saw a custom header file in the `inc` folder of Twenty Twelve theme. I understand that we can use this custom header in any custom page template instead of header. I have a doubt now, is there any custom footer that also can be used? Why this custom files should be stored in `inc` folder?


shortcode not working

I m working on content-product of woocommerce and doing shortcode in the template as `echo do_shortcode ('[product_attribute attribute="Grams"]');` where Grams are in my backend as attribute and it hasvalues, but nothing get printed out.Is it a wrong query or i need to do something else?


WP redirects pretty permalink to query string

I have a custom post type `artist` and a taxonomy `kind_of_art`. I want their permalinks to be like: `%kind_of_art%/%artist%` Therefore I created following rewrite rules:                 add_rewrite_rule(         '([^/]+)/([^/]*)/?',         'index.php?kind_of_art=$matches[1]&post_type=artist&artist=$matches[2]',         'top'         );      If I go to `photography/sam-sample` for example, I am redirected to `?artist=sam-sample`. If I add a front base to my rewrite rule it works. ## Additional info An `artist` post consists of multiple textareas with different content. I use this technique to create virtual subpages (e.g. `press`, `gallery`, `biography`). Of course I need rewrite rules again:                 add_rewrite_tag('%artist_sub_page%', '([^&]+)');       add_rewrite_rule(         '([^/]+)/([^/]*)/([^/]*)',         'index.php?artist=$matches[2]&artist_sub_page=$matches[3]&kind_of_art=$matches[1]',         'top'       );      Funnily enough, _this_ works even without that front base. Any ideas whats wrong? I assume this is an easy issue, but I am no expert in rewrite rules. ## EDIT: I just discovered two things: If I visit my `/photography/sam-sample/` I will be redirected to `?artist=sam- sample`. But if I enter my wanted URL again, I am not redirected and it "works". I guess this is why I already thought a few times that I got it working but a minute later it wasn't ;-) If I visit append any string to my wanted URL structure – e.g. `photography/sam-sample/foo` or `photography/sam-sample/foo/bar` – I am also not redirected. ## EDIT #2: I got it working now with this regex:               ([^/]+)/([^/]*)      By working I mean I can visit `/photography/sam-sample` and it will work. One problem to solve still: In my navigation I create the links dynamically with `get_permalink()`. This function still outputs `?artist=sam-sample` instead my wanted structure.


Prepend meta_value to permalink of post

I have 2 custom post types `movies` (non-hierarchical) and `series`(hierarchical). Each post from `series`type has a meta field `_movie` which contains a movie ID. I want to specify a custom permalink structure for `series`. What I need to achieve is a link `http://example.com/series/movie_slug/parrent_series_slug/series_slug` (parent_series_slug is the slug of the parent of the series, they are hierarchical, if there isn't any parent, `parrent_series_slug` is omitted). What I have achieved at the moment is `http://example.com/series/parrent_series_slug/series_slug`, which is handled by Wordpress. The question is how to insert `movie_slug` (slug of the post with the ID from meta `_movie`) in the permalink before series slug?


How can I change a submenu-item in the WordPress-dashboard to a mainmenu-item?

I want to create a custom WordPress-dashboard for one of my cliënts. Now I want to hide the "appearance"-menu in the dashboard, but I want the submenu "Menus" to be visible as a mainmenu-item. The "appearance"-menu is normally automaticly hidden since the client's profile has an editor-role. So I bring the "appearance" menu back for editors like this:               // get the the role object     $role_object = get_role( 'editor' );     // add $cap capability to this role object     $role_object->add_cap( 'edit_theme_options' );      I can hide the other submenu-items with CSS, but then I still got the "appearance"-menu and I don't want the cliënt to change the theme. Is there any solution to make the submenu "Menus" visible as a mainmenu-item?


Matching Serialized Arrays with meta_query

I've asked a related question previously, but I think I've finally worked out the crux of my issue. I'm using Advanced Custom Fields and have a number of custom fields attached to my post type. I'm trying to alter the URL to receive posts via their custom field and value. And I'm getting really close. This is what's currently in my **functions.php** :               add_action('pre_get_posts', 'my_pre_get_posts');          function my_pre_get_posts( $query ) {         if( is_admin() ) { return; }              $meta_query = $query->get('meta_query'); // get original meta query                  if( isset($_GET['type']) ) {                                          $type = '"' . $_GET['type'] . '"';                        $meta_query[] = array(                 'key'       => 'type',                 'value'     => $type,                 'compare'   => 'LIKE',             );         }         $query->set('meta_query', $meta_query); // update the meta query args         return; // always return     }      Now because ACF uses serialized arrays when dealing with multiple values in custom fields, I'm using the `LIKE` query. The `type` custom field actually accepts multiple values, and I'm able to display posts by one `type` (i.e: women) successfully. > website.com?type=women But when trying to retrieve multiple `type`s (i.e: women,men,boys), this doesn't work. > website.com?type=women,men,boys Now I realise I'm working with serialized arrays here, and if I wanted it to query multiple `type`'s I'd have to explode that `$type` variable, but that doesn't seem to be working either. If anyone can help, I'm desperate for a solution. Thanks! **EDIT | Multiple times for each type:**               $meta_query[] = array(         'relation'  => 'OR',         array(              'key'       => 'type',             'value'     => 'men',         ),         array(              'key'       => 'type',             'value'     => 'women',         ),         array(              'key'       => 'type',             'value'     => 'boys',         ),     );


Is it possible to create more than one design in a WordPress theme?

I have a HTML website that I need to convert to WordPress. It has three layouts, and each layout has a different menu and design. How I can do this in WordPress?


Extract array from custom field

I'm using woocommerce product bundles extension. I need to manipulate some informations about bundled post. Actually I found the bundled product container has a hidden custom field named _bundled_ids which in the database has this value a:3:{i:0;i:105;i:1;i:80;i:2;i:70;} For what I understand this value is the list of the ids of the products bundled. How can I extract this infos in a comma separated list of ids (i.e. 105,80,70)? I have tried with get_custom_post_meta() but everything I can get is ARRAY. Hope you can help. Best regards and thanks Carlo EDIT As I already stated I need to get the data stored in this custom field as a comma separated list of numbers. I tried to create a shortcode with this code inside my functions.php file:               add_shortcode('bundled_ids','bundled_ids_func');     function bundled_ids_func() {             $meta_values = get_post_meta( $post->ID , '_bundled_ids' );             $mydata = unserialize($meta_values);              return $mydata;     }      But I get nothing EDIT 2               add_shortcode('bundled_ids','bundled_ids_func');     function bundled_ids_func() {         $meta_values = get_post_meta( get_the_ID() , '_bundled_ids', true );         $id_list = print_r($meta_values, true);              return $id_list;     }      with this code I get this result: Array ( [0] => 105 [1] => 80 [2] => 70 )


Display update notification messages like 'What's New'

I am about to push out a new update for my plugin. I've used a few functions only available to WordPress 3.8, which is fine because I want to support the latest version. How do I display a message to the user before they update the plugin with a list of _What's New_ , or just a general warning that WordPress 3.8 is required to run the latest version of the plugin? I have attached a screenshot of where I'd like the message to display. Is this something that is displayed based on what you put in the change log of your `readme.txt` in trunk? ![enter image description here](http://i.stack.imgur.com/dlszO.png)


Custom taxonomy page uses index.php

Read a couple of tutorials (here's one) but I don't understand why I can't make it work. I'm trying to create a page for custom taxonomy terms. Like mysite.com/tag/term or mysite.com/category/term but for my taxonomy. **This is what I've done so far:**   1. I registered the new taxonomy              add_action( 'init', 'register_taxonomy_author' );          function register_taxonomy_author() {          register_taxonomy(  'author', 'post',   //Let WordPress know that the artist   taxonomy has posts     array(         'hierarchical' => false,         'label' => 'Authors', // This tells WordPress how to label the various user interface outlets for the artist taxonomy         'query_var' => true,         'rewrite' => array( 'slug' => 'author', 'with_front' => false ))         );     }        2. Added a new file called taxonomy-author.php and copied+pasted the codes from category.php into it. * * * Now, when I try to view the taxonomy terms (Admin Panel > Posts > Authors > View) I get directed to mysite.com/author/term, which is great. But that page uses index.php instead of taxonomy-author.php. What did I miss? Codex states that index.php should be at the bottom, yet it ignores both taxonomy- author.php and my archive.php.


How can I add a Description column to the media library browser screen?

I'm trying to display the description of each file on the media library browser screen. I've found some code that adds a filename column, but I'm trying to modify it so that it will display the description field instead of the filename. I'm not quite sure of how to do this. The description column displays, but doesn't actually show the description data for each file. I think I'm getting hung up on this line:               echo substr(strrchr($meta['attachment_content'], '/' ), 1);      but it's possible that there are other issues. Below is the full code:               function description_column($cols) {         $cols["description"] = "Description";         return $cols;     }          function description_value($column_name, $id) {         $meta = wp_get_attachment_metadata($id);         echo substr(strrchr($meta['attachment_content'], '/' ), 1);     }          function description_column_sortable($cols) {         $cols["description"] = "name";         return $cols;     }           function hook_new_media_columns() {         add_filter('manage_media_columns', 'description_column');         add_action('manage_media_custom_column', 'description_value', 10, 2);         add_filter('manage_upload_sortable_columns', 'description_column_sortable');     }          add_action('admin_init', 'hook_new_media_columns');      Thanks for your help!


How to exclude a taxonomy term using url alone

This may have been answered somewhere but I may not be searching for the right wording or my concept is just way off :-) In a nutshell: If I have a url like this:               http://mysite.com/?taxname=termvalue      wordpress dutifully parses that to arrive at http://mysite.com/taxname/termvalue and shows all posts having that taxonomy term equal to that term value. But I would like to construct a url something like one of these:               http://mysite.com/?taxname=-termvalue     http://mysite.com/?taxname!=termvalue     http://mysite.com/?taxname<>termvalue     http://mysite.com/taxname/-termvalue/      which **excludes** any particular term value (or id). (I know the syntax is wrong but wanted my meaning to be clear.) I do know how to make a custom query with all the arguments as described here: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters but am hoping for a shortcut where wordpress can directly parse a constructed url like that to exclude and include taxonomy terms in the same url parameter/argument list. Thanks! (btw: I also asked this question on wp.org since it seems like the audiences there and here are mutually exclusive, so hopefully one of them will get an answer.)


Social Media within Posts

I have a static front page and on that page I have a div where I run a WP Query to retrieve blog posts This is the code:
     <?php $args = array(         'category_name' => 'whats-new',         'posts_per_page'  => 12         );                 $the_query = new WP_Query( $args ); ?>     <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

                 <?php the_post_thumbnail('full',  array( 'class' => "attachment-post-thumbnail")); ?>
                     <?php the_post_thumbnail_caption(); ?>                     <a href="<?php the_permalink() ?>">                         <?php the_title(); ?>

                     <a href="<?php the_permalink() ?>">
 200 SHARES

     <?php endwhile;?>
      It loops correctly and displays the information but I have somewhat of a complicated issue (to me anyway). Within that loop I need to figure out some way to have 3 boxes with social media that would just display the newest post/tweet/upload Here is my current screenshot ![enter image description here](http://i.stack.imgur.com/jcDbZ.png) Where it says Twitter I would have Facebook and Twitter. Right now I just have them as posts with the featured image and the text is coming from the image caption. Probably not the best way but I was/am unsure of the best way. Any help would be appreciated


Update parent post when updating children of that post or assigning children to that post

I have a custom meta box that displays a count of information gathered from the children posts associated with a parent but i need the information within the parent posts meta box to be updated each time a child post is assigned or updated. Is this possible?


How to include the parent page link in this wp_nav_menu walker

I've got a site with a sidebar of 'sub-navigation' I also need to have those links 'parent page' in the navigation also. So, for example I've got Parent child 1 child 2 child 3 but the php only gives me child 1 child 2 child 3 the code is here -               <nav id="sub-navigation">         <?php wp_nav_menu( array('theme_location' => 'main-navigation', 'container' => '', 'walker' => new Related_Sub_Items_Walker(), 'start_depth' => 1, 'include_parent' => 1, 'strict_sub' => 1, 'only_related' => 1, 'filter' => 0, 'filter_selection' => 0, ) ); ?>     </nav>      Any help would be greatly appreciated. I need it 'within' the navigation due to how I've currently styled the look of it.


How can I add a column/s to wp_posts table?

I am trying to sync WP with another service that offers an API that allows me to hook up their table's Update, Create, Delete to my sites. So when they create, update, or delete a row on their server, I get details about that update, including the row ID. The way I am thinking of syncing is by using custom post types, and either add a new separate table with post -> api relation like `post_id:1 = api_id:53`. Or alter `wp_posts` table by adding a column containing the api_id. I know I can add metabox which will add that as post_meta but I am not sure how effective will that be and I am pretty sure if I alter `wp_posts`, querying will be a lot faster. So how can I alter `wp_posts` in the WordPress way? If that's not possible, should I add meta boxes or create an entirely new table just for the relation ?


Widget control - putting a slideshow in the widget area

I am trying to put a slideshow in the widget area of my wordress theme... do you know of anyway to do this instead of html in the widget area? Thanks Kevin


wp_mail function not dispatching emails from plugin

I am working on a plugin that needs to dispatch an email to the user after they submit a form. I have tried quite a few different things but none of them are working. I have also tested from my local wordpress install and also from a live server. My code in my plugin file looks like this:                   function sendMail() {             wp_mail( $email, 'This is the email subject', 'This is the email message');         }         add_action('plugins_loaded', 'sendMail');      it is called when the form is submitted. If anyone knows how I can get this working it would be a huge help Thanks


Error with moving my webhost

I've been developping a wordpress webshop for a while now. This week my webhost almost expired, so I've been looking to move to another company because my old one wasn't that good. Today I got my new webhost with the transferred domainname, but the old one is still running (without the domain name). The first weird thing is, when I surf to my webhost by IP, I don't reach my wordpress site anymore but I get the 'Web server's default page': 94.198.164.46 is the IP. This is weird in my opinion, because I didn't change anything. So I tried to move my wordpress site to my new webhost. I have a back-up from the public_html map and the database. But when I try to reach my wordpress site I get this error: 'Error at creating the database connection'. Although my wp-config file is correct I think. Any idea what I can do?


How to quickly switch custom post type singular template?

I have a custom post type called movies and I need to quickly switch the template that displays the movies cpt on the front end via a link. How can this be done? Files I have: single-movies.php template-movieslanding.php template- movieswholesale.php Functionality: A link group is displayed on each of the three templates as demonstrated below. These links are only displayed to logged in staff. The staff are not technical in the least and need a simplistic solution. Views: Overview | Landing Page | Wholesale When each link is clicked I need to switch to that template. All templates use the same custom post type. Thanks! ~Matt


How do I manually revert back to my old theme?

After changing themes I get               Fatal error: Call to undefined function add_editor_style() in /mydir/wp-content/themes/evolve/functions.php on line 8      I cannot even login to the administration panel


Prohibit saving a post without providing a title

How to prevent saving a post without providing a title? Right now it's possible. I want to prevent that. How to achieve this task?


Search inside a custom taxonomy for multiple words doesn't return anything

My goal is to perform a search inside a custom taxonomy field. The page is an archive including a lot of books and magazines, and they have to be searched through, let's say, 'Authors','Title' and 'All fields'. The structure I built is made of regular posts which have 'Author', 'Title' and 'All fields' as custom taxonomies fields. I was able to create a custom search form which only search inside the selected taxonomy field. Typing single words in the search give correct results. The only problem is with multi-word searches: it doesn't return anything. The code I used inside the custom search form page:               <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">     <?php      $args = array(        'public'   => true,        '_builtin' => false     );      $output = 'objects';     $operator = 'and';      $taxonomies = get_taxonomies( $args, $output, $operator );      $my_tax_array = array('titolo','descrizione','autore'); //make array of your taxonomies     echo "<select id='my_select_taxonomy' name='my_select_taxonomy'>";     if ( $taxonomies ) {       foreach ( $taxonomies as $taxonomy ) {         if (in_array($taxonomy->name, $my_tax_array)){             echo "<option value='{$taxonomy->name}'>{$taxonomy->label}</option>";         }       }     }     echo "</select><br />";     ?>     <input type="text" value="<?php the_search_query(); ?>" name="s" class="s" />     <input name="site_section" type="hidden" value="biblio" />     </form>      And this is what I used in the custom search results page before the loop:               $search_field = $_GET['s'];     $my_select_taxonomy = $_GET['my_select_taxonomy'];          $terms = get_terms($my_select_taxonomy, $args);     $needle = $search_field;          if(!empty($terms)) : foreach($terms as $term) :          if(strpos($term->name, $needle) !== false || strpos($term->slug, $needle) !== false) :     $term_ids[] = $term->term_id;          endif;              endforeach;         endif;              $args = array(         'post_type' => 'post',         'tax_query' => array(             array(                 'taxonomy' => $my_select_taxonomy,                 'field'     => 'term_id',                 'terms'     => $term_ids,                 'operator'  => 'IN'                     )                 )             );         $my_query = new WP_Query($args);      Here is the page: http://www.portaluppi.org/category/biblioteca/ Here you can test easily by typing the last post inserted which is 'Annuari del Politecnico'. If you type, selecting 'title', 'Annuari' you'll get the correct result. If you type 'Annuari del' or 'Annuari del politecnico' you'll get no results. So it works correctly as long as you search for single words, but not for multiple words searches. Any idea why?


wp_enqueue_style for plugin options page

I'm trying to add a stylesheet to the options page for my plugin - code looks like this:               add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' );          function rps_paypal_add_css() {     wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) );     }               add_action( 'admin_menu', 'rps_myplugin_add_page' );          function rps_myplugin_add_page() {     add_options_page(         'My PayPal Plugin',         'My PayPal Plugin',         'manage_options',         'rps-paypal',         'rps_myplugin_option_page'     );     }      Can't figure out why it's not showing up...


Wordpress Contact Form 7: populate the value of a field dynamically with PHP

Well my question is quite simple, I would like to populate a field with the value of a variable that have been passed via a $_GET Request. thanks


How to add another page in appearance tab of admin panel?

Currently I am working on Wordpress and I want to know can I add 1 more page in admin panel appearance menu so that it looks like this: ?               Appearance       Themes       Widgets       Menus       Editor      I want to add one more page after Editor like "Theme option".


Adding callback function for wp_ajax_ has no effect

I was trying to add one more callback function to the WordPress AJAX action `woocommerce_apply_coupon`. This action is defined in the WooCommerce plugin, I want to add my own callback function to this action from my plugin file. What I have tried:               add_action( 'wp_ajax_nopriv_woocommerce_apply_coupon','darn',999);     add_action( 'wp_ajax_woocommerce_apply_coupon', 'darn',999);          function darn(){              print_r($_REQUEST);              exit;         }      Doing this in my `functions.php` is not even showing any error, like I can't see any effect of this code. I want to know if this is even possible to achieve . Thank you.


changing background color depending on parent page

Hopefully it will be an easy question. I created Wordpress template and now i would like to use that template for for several pages, however i would like to have different background color on some of the elements such as footer, header etc. that will be depending on parent. So lets say i have PARENT A (green background) and PARENT B (white background) now when i will create child of PARENT A i would like it to have green background automatically I know something similar could be done with posts using `<div class="post <?php foreach((get_the_category()) as $cat) { echo $cat->cat_name . ' '; } ?>"> </div>` I need some advice what would be the best way to do that. I hope it makes sense, sorry if i made it confusing. Many thanks,


Are there any hook or filter when adding new user in Wordpress?

I'm using a plugin Profile Builder (http://wordpress.org/plugins/profile- builder/) to manage my front-end registration. It works fine, and it warns when a user with a certain username already exists. That would be the usual scenario that you want... BUT I want to modifiy the action to - that when a user already exists - I want to UPDATE some things for that user instead of inserting a new user. How could I achieve that without having to modify the plugin? What I'm really asking if there are any specific hook or filter that I can use for this purpose that is in the core of Wordpress? (or is it only plugin- specific) **Code-snippet:** (`save_user_fields` is only a function that handles saving of specific custom fields. The rest is taken care of by the plugin Profile Builder)               function save_user_fields($user_id) {        if ( !current_user_can( 'edit_user', $user_id ) )         return false;              //Save some extra fields when adding new user (frontend-registration)         if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser'){                 if (isset($_POST['adress'])) {         $adress = $_POST['adress'];         update_user_meta($user_id, 'adress', $adress);                         }             if (isset($_POST['homephone'])) {         $homephone = $_POST['homephone'];         update_user_meta($user_id, 'homephone', $homephone);                         }          if (isset($_POST['cellphone'])) {         $cellphone = $_POST['cellphone'];         update_user_meta($user_id, 'cellphone', $cellphone);         }         if (isset($_POST['postnr'])) {         $postnr = $_POST['postnr'];         update_user_meta($user_id, 'postnr', $postnr);         }         if (isset($_POST['ort'])) {         $ort = $_POST['ort'];         update_user_meta($user_id, 'ort', $ort);         }              if (isset($_POST['description'])) {         $description = $_POST['description'];         update_user_meta($user_id, 'description', $description);         }                }          //Hooks for user (Update/add)     add_action('personal_options_update', 'save_user_fields');     add_action('edit_user_profile_update', 'save_user_fields');     add_action('user_register', 'save_user_fields'); //When adding new users               /* Profile Builder EXTRA Fields front-registration */     add_filter('extraRegistrationField', 'list_courses');          //List courses for registration     function list_courses($user_id) {             //Get all extra user-fields and return content output         $current_user = new WP_User($user_id);         $content = get_user_fields($current_user, true, '');                  $content .= '
Hemtelefon<input id="homephone" class="regular-text" name="homephone" value="" type="text">
';                 $content .= '
Mobil<input id="cellphone" class="regular-text" name="cellphone" value="" type="text">
';         $content .= '
Adress<input type="text" name="adress" id="adress" value="" class="regular-text" />
';         $content .= '
Postnr<input id="postnr" class="regular-text" name="postnr" value="" type="text">
';         $content .= '
Ort<input id="ort" class="regular-text" name="ort" value="" type="text">
';         $content .= '
Övrigt<textarea name="description" id="description" class="description"></textarea>
';              return $content;     }      When posting this code I thought it was all clear to me, but no... I thought I could use http://codex.wordpress.org/Function_Reference/username_exists before saving the actual fields in the function `save_user_fields` but it didn't work, because the function `save_user_fields()` wasn't called before the actual error-handling was done by the plugin. I've discovered that with this code:               function save_user_fields($user_id) {         if ( !current_user_can( 'edit_user', $user_id ) )         return false;              die("wordpress is ded for now");     ....      The code didn't "die" and WP returned "User with username already exists"... I've also tried with several hooks... (before the hooks created above)               function myplugin_check_fields() {         echo 'hello';         die();     }     add_action('register_post', 'myplugin_check_fields');      No death here either ;-) I tried with hook "register_post", "register_form", but I can't figure out what to use? I basically want a hook to execute before the plugin does and when the form is submitted. register_post seemed the most plausible hook to use.


"Template is missing" install error on non-child theme

I understand the first comment in `style.css` dictates the difference between original theme and child theme. Using the following simplest example is throwing the "Themes must have a stylesheet and a template ... Template is missing" error:               /*     Theme Name: Test     Theme URI: http://www.test.com     Description: Test install     Author: Test     Version: 1.0     Tags: Test     */      File structure inside of `themes` directory:               themes        -twentythirteen        -test           -css              -style.css           -index.php      The css seems to parse correctly and has line breaks making each entry in the comment distinct. I've tried creating multiple themes, all with the same result. The default themes are loading fine. Running this locally using MAMP, wp version 3.7.1. Pulling my hair out here... any suggestions?


How do I call posts with a certain tag?

I use this to call posts:               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $per_page = get_option('to_count_archives');     query_posts("posts_per_page=".$per_page."&paged=".$paged."&cat=".$cat);     if (have_posts())     ?>     <?php while (have_posts()) : the_post(); ?>      And it works great for categories. But **on archives pages generated for tags it shows ALL posts, not just posts with a specific tag**. I am going to creates a separate archives.php and category.php. I need to keep the to_count_archives part of the code because it calls the number of posts per page. I appreciate any help rewriting the code above to work correctly.


Outputting Page Content in Two Places

I am working on a site for a client that is going to be structured very similarly to a store (though without the e-commerce capabilities). I am getting a bit hung up on how to output page content in two places. I'll explain. The site structure will be as follows:   * Windows      * Casement Windows     * Double Hung Windows        * Brand A       * Brand B You can see here the windows are organized by _type_ of window. Other navigation will have the opposite (by _brand_ ) where it will go Windows > Brand A > Double Hung Windows. My plan is to have each window product be its own page in WordPress, but I need a way to output it that page content in two places. In one place it will have the _brand_ navigation and the other will have the _type_ navigation. Any ideas on the best way to do this?


One WP install, I need to map a custom domain name to each category

I've read other answers but they weren't satisfactory.   * Multiple blogs, different domain names, one install to rule them all   * Multiple Domain Names - One WP Install (non-Multisite) - Default Each Domain name to Category Archive I did try the second option as it seemed perfect for my needs, however, what happens is that while a category is perfectly mapped to a domain, single articles are not and default to the original domain name. I need to have each category keep its domain name when posts or sub-categories are clicked. **i.e.:** `http://mywebsite.com/gastronomy/` becomes `http://mywebsite-gastronomy.com` **And:** `http://mywebsite.com/2013/10/15/an-article` becomes `http://mywebsite-{FIRST_CATEGORY_OF_THE_ARTICLE}.com/an-article` Is this at all possible with URL trickery or plugins?


How to output topics and replies in bbpress as table?

I need to output the bbpress topic and reply loop in a table format. I'm having trouble finding how one might do this Are there any suggestions on how one might do this? Can this be done using wp_query or am I better off using the topics loop?


How to check if a custom user profile field is empty

i have this code to limit the comments per user.               <!-- #only one comment -->     <?php global $current_user,$post;     $usercomment = get_comments(array('author_email' => $current_user->user_email, 'post_id' => $post->ID));     if($usercomment) {         echo "Thank you!";     }     else {         comment_form();     }      ?>      How can edit this code to also check if a custom user profile field [phone] is empty? If is empty display a message else display the comment form. Thank you.


using wp_insert_attachment() results in guids with file names different to the same file when uploaded via media page in admin

I'm trying to make a plugin that as part of its task uploads csv files to the wordpress install. Deciding to integrate as closely as possible using wordpress functions wherever possible I am saving the uploaded file to the correct current wordpress folder (with the help of the wp_upload_dir() function). I am then adding the upload into the posts table as an attachment so that users can manage it via the media page. This is being done with the build in function wp_insert_attachment(). This is where things seem to go wrong. Basically the file names I parse to the function have spaces in them but when I look at the GUID values in the posts table the spaces have been taken out. If I add the same file via the wordpress media page interface the spaces are replaced with hyphens. I understand why wordpress adds hyphens to make the file url safer in old browsers that couldn't handle spaces well, however why is the space being removed when I parse to wp_insert_attachment? So to confirm; uploading "Work Spreadsheet.csv" via the wordpress interface results in an expected GUID of http://domain.com/wordpress/wp-content/uploads/2013/11/Work-Spreadsheet.csv However via my plugin code http://domain.com/wordpress/wp-content/uploads/2013/11/WorkSpreadsheet.csv Also in the wp_postmeta table the value for meta_key "_wp_attached_file" when uploaded via the wordpress interface is with hyphens added and the relative folder path: 2013/11/Work-Spreadsheet.csv Where as for uploads via my code its without the folder path and the file name is unmodified from my original: Work Spreadsheet.csv Can anyone assist as to why this might be occurring? The code just before I use wp_insert_attachment() is below as a reference.. Just to say; I've tried with other file types such as images in case it was anything to do with uploading text files but the results are the same.               $attachment = array(     'guid' => $upload_dir_array['url'] . '/' . basename( $destination_name ),      'post_mime_type' => $wp_filetype['type'],     'post_title' => preg_replace('/\.[^.]+$/', '', basename($destination_name)),     'post_status' => 'inherit'     );     $attach_id = wp_insert_attachment( $attachment, $destination_name );     // for the function wp_generate_attachment_metadata() to work     require_once(ABSPATH . "wp-admin" . '/includes/image.php');     $attach_data = wp_generate_attachment_metadata($attach_id,$upload_dir.$destination_name );     wp_update_attachment_metadata( $attach_id, $attach_data );


is_page() is not executed

I am making infinite scroll page. I created a page template where posts of certain category are loaded. Everything works fine with a single page and single category. But I have three pages with this page template and each page should load articles from a specific category. I am using the is_page() if elseif block to determine on which page visitor is. But is_page() is not executed. Here is the loop:               $cat = '';     if(is_page(703)){         $cat = 4;     } elseif (is_page(706)) {         $cat = 21;     }     $args = array(         'cat' => $cat,         'paged' => $paged         );     $infinite_news_query = new WP_Query($args);     if ( $infinite_news_query -> have_posts() ) : while ( $infinite_news_query -> have_posts() ) : $infinite_news_query -> the_post();      <?php endwhile; ?>           <?php else : ?>      <?php endif; ?>      <?php wp_reset_postdata();      ?>      This code displays all the posts, regardless of category, and $cat is empty inside the loop. What am I doing wrong?


Listing all selected terms for custom taxonomies on a post

I'm running a query on a custom post type to display on a page. The custom post type has multiple custom taxonomies. Each taxonomy is not required. I want to display only the taxonomy terms selected, and not the others. How would I achieve this?               $args = array( 'post_type' => 'inspirations', 'posts_per_page' => 10 );     $loop = new WP_Query( $args );          while ( $loop->have_posts() ) :         $loop->the_post();              echo '
ID, 'collections') . '">';         the_title();         echo '
';         the_excerpt();         echo '
';         echo '
';     endwhile;      Right now this returns Array() when printed. I'm guessing I need to break apart the array somehow.