Search widget breaks when using multiple loops?

I have created wordpress template that uses two loops via WP_Query object. Everything works fine except **Search widget**. I've been pulling my hairs out for three days now Googling like a madman,but didn't find a solution. For example in my **searchbox** I type: _**First cat**_ (that is the name and content of my post inside "cat" category) and click search and NOTHING happens. Strange thing is this: if I create a "normal" (main Loop) above other two Loops the **Search widget** WORKS, but the problem is that now my "normal" **(main Loop)** is showing **ALL** posts from my other two loops.   Can somebody please help me or give a suggestion how to solve this?   Link to my site if you want to check my non working search widget:(   **Index.php** look's like this:                <?php get_header(); ?>     <?php get_sidebar('Main Sidebar'); ?>

           <?php if (have_posts()) : ?>                 <?php                                      $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;         $paged2 = isset( $_GET['paged2'] ) ? (int) $_GET['paged2'] : 1;         $args=array(              'category_name' => 'cats',         'paged' => $paged1,         'posts_per_page' => 2,         'order' => 'DESC'          );          $temp = $wp_query;          $wp_query= null;          $wp_query = new WP_Query($args);          while ( $wp_query->have_posts() ) : $wp_query->the_post();          ?>

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

                                         <?php the_post_thumbnail(); ?>                 <?php the_content('Read on...'); ?>
                 <?php _e('Filed under:'); ?>
<?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

         <?php endwhile;?>         <?php else : ?>
Not Found

Sorry, but you are looking for something that isn't here.
         <?php endif; ?>
         <?php          $pag_args1 = array(             'format'  => '?paged1=%#%',             'current' => $paged1,                    'total'   => $wp_query->max_num_pages,                   'add_args' => array( 'paged2' => $paged2 )         );         echo paginate_links( $pag_args1 );         ?>
               <?php     $wp_query = null;     $wp_query = $temp;     wp_reset_postdata();     ?>

             <?php                 $args2=array(          'category_name' => 'dogs',     'paged' => $paged2,     'posts_per_page' => 2     );     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query($args2);     while ( $wp_query->have_posts() ) : $wp_query->the_post();     ?>

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

                  <?php the_post_thumbnail(); ?>                 <?php the_content('Read on...'); ?>
                 <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

         <?php endwhile;?>
                 <?php            $pag_args2 = array(             'format'  => '?paged2=%#%',             'current' => $paged2,             'total'   => $wp_query->max_num_pages,             'add_args' => array( 'paged1' => $paged1 )         );         echo paginate_links( $pag_args2 );         ?>
               <?php     $wp_query = null;     $wp_query = $temp;     wp_reset_postdata();     ?>

        <?php get_footer(); ?>      Modified **Index.php** with Main loop that kinda works (Main loop showing all the post's from other two loops,but search widget WORKS..)                <?php get_header(); ?>     <?php get_sidebar('Main Sidebar'); ?>

            //Now Search Widget is WORKING but its's showing posts from             //other TWO LOOPS so it looks like a BIG mess:(          <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

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

                  <?php the_post_thumbnail(); ?>                 <?php the_content(); ?>
                 <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

              <?php endwhile; ?>
         <?php posts_nav_link(); ?>
              <?php endif; ?>

           <?php if (have_posts()) : ?>                 <?php                                      $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;         $paged2 = isset( $_GET['paged2'] ) ? (int) $_GET['paged2'] : 1;         $args=array(              'category_name' => 'cats',         'paged' => $paged1,         'posts_per_page' => 2,         'order' => 'DESC'          );          $temp = $wp_query;          $wp_query= null;          $wp_query = new WP_Query($args);          while ( $wp_query->have_posts() ) : $wp_query->the_post();          ?>

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

                                         <?php the_post_thumbnail(); ?>                 <?php the_content('Read on...'); ?>
                 <?php _e('Filed under:'); ?>
<?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

         <?php endwhile;?>         <?php else : ?>
Not Found

Sorry, but you are looking for something that isn't here.
         <?php endif; ?>
         <?php          $pag_args1 = array(             'format'  => '?paged1=%#%',             'current' => $paged1,                    'total'   => $wp_query->max_num_pages,                   'add_args' => array( 'paged2' => $paged2 )         );         echo paginate_links( $pag_args1 );         ?>
               <?php     $wp_query = null;     $wp_query = $temp;     wp_reset_postdata();     ?>

             <?php                 $args2=array(          'category_name' => 'dogs',     'paged' => $paged2,     'posts_per_page' => 2     );     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query($args2);     while ( $wp_query->have_posts() ) : $wp_query->the_post();     ?>

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

                  <?php the_post_thumbnail(); ?>                 <?php the_content('Read on...'); ?>
                 <?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php  the_author(); ?>
                 <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>

         <?php endwhile;?>
                 <?php            $pag_args2 = array(             'format'  => '?paged2=%#%',             'current' => $paged2,             'total'   => $wp_query->max_num_pages,             'add_args' => array( 'paged1' => $paged1 )         );         echo paginate_links( $pag_args2 );         ?>
               <?php     $wp_query = null;     $wp_query = $temp;     wp_reset_postdata();     ?>

        <?php get_footer(); ?>


Is there a blank theme framework compatible with WP 3.0?

I don't feel like making my own theme from scratch, so I looked for some theme frameworks, but they're all old and when I install them on WP 3.0 they produce loads of errors and don't behave properly. I just need a 3.0 ready blank theme with the bare elements (just text, but functional) to then shape myself into a good looking blog. Thanks in advance.


How to add an alternative style sheet as a theme option?

I'm trying to create a few extra theme options in the "customise" section of the wp admin menu. I would like to offer an option to load an alternative style sheet. Question: How can I adapt the following code to replace the stylesheet name "posts.css" with a user-selected option?               function theme_styles()       {       // Register the style like this for a theme:        // (First the unique name for the style (custom-style) then the src,       // then dependencies and ver no. and media type)      wp_register_style( 'custom-style',      get_template_directory_uri() . '/posts.css',      array(),      '20120208',      'all' );          // enqueing:     wp_enqueue_style( 'custom-style' );     }     add_action('wp_enqueue_scripts', 'theme_styles');      This is the particular line of code I am having trouble with - I have tried this, where 'posts' is a theme option and 'style.css' is a default - but it gives a blank page:               get_template_directory_uri() . '/<?php echo get_theme_mod( 'posts', 'style.css' ); ?>',       And this is how I added the alternative stylesheet option to the wp menu incase it matters:               $wp_customize->add_setting( 'posts', array(         'default'        => 'style.css',     ) );          $wp_customize->add_control( 'posts', array(         'label'   => 'Post Blocks',         'section' => 'themedemo_demo_settings',     'type'       => 'select',     'choices'    => array(         'style.css' => 'Default',         'posts.css' => 'No blocks',                 ),     ) );      Thanks


Custom post type not using it's own single-postname.php

I have a custom post type (that I'm using on a template page), the custom post type is called 'headerhome'. When I post say a gallery there I'm trying to get it to redirect to 'single-headerhome.php', yet it always just goes to 'single.php'. The name of the custom post type itself is arbitrary, the name of the templage page it's on is 'front-page.php'. I'm really confused, I'm not the best at WP yet so when something simple like this doesn't work I have no idea how to fix it, even after pouring over the codex for an hour.               // Add new post type for homepage     add_action('init', 'frontpage_top_init');     function frontpage_top_init()      {         $args = array(             'label' => __('Homepage'),             'singular_label' => __('Homepage'),             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,              'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => 5,             'supports' => array('title','editor'),             'has_archive' => true         );          register_post_type('headerhome',$args);          }      Here's my code on the front-page.php EDIT:-               <?php      /*         Template Name: frontpage     */     ?>     <?php get_header(); ?>

           <?php     $portfolio_query = new WP_Query(array(             'post_type' => 'headerhome',             'showposts' => 1             ) );     ?>           <?php while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?>
<?php the_title(); ?>
             <?php the_content(); ?>

           <?php the_field('showreel'); ?>

             <?php the_field ('gallery-description'); ?>
             <?php the_field('image-1'); ?>

          <?php endwhile; wp_reset_postdata();?>
           <?php get_footer(); ?>      No matter what I try, it always uses single.php and not single-headerhome.php. If my understand of wordpress is correct, and it's probably not - shouldn't creating the template file single-headerhome.php automatically make wordpress use that for this post type?


Wordpress permalink prefix

I have a small ecommerce site in Wordpress and I am having some difficulties in getting the right permalink structure. Basically, for basic pages it should look like : domainname.com/page_title. Other post types should have the structure: domainname.com/post_type_slug/item_title. Well, everything is fine except for the blog posts (I want it to show domainname.com/blog/post_title). Having the permalink setting as %postname%, I get domainname/post_title. On the other hand, /%category%/%postname%/ returns domainname.com/category/post_title. And obviously, entering /blog/%postname% won't work either because that would affect the permalinks of other post types. Any ideas? Thanks in advance.


Lead form that submits to 2 external APIs

I need to add 2 registration forms to my wp website, each form should submit the information in it to 2 different APIs. I don't know even where to begin. Is there a plugin that can help me handle the task? do i need to write a plugin from scratch? any pointer or recommendation will be much appreciated as i'm totally in the dark here. EDIT: Add more info as requested by UBERABUSER (thanks!) The 2 APIs i'm working with are (a) client CRM, a custom API written in perl, handles registration of prospective clients (b) An API of a list management / mailing service called TRACTION Here's a working example of such a form: http://benchmarketing.com.au/k2a/ebook/ Now i need to create a version of the same form with the exact same functionality in wordpress... and this is what i'm in the dark about.


Adding custom css to a theme depending on whether the admin user is logged in or not

Is it possible to add custom css to a stylesheet in a theme depending on whether the user is logged in or not? When I log in, the theme navigation and when viewing the main site bar is hidden behind the wpadminbar and I would like to change the css of the theme nav bar only when an admin is logged in and when the site is being viewed?


Thesis 2 custom Page

I have been installing lately the latest version from Thesis and getting to the point to make a custom landing Page. I have been building a plugin and I would like to link the content of it to my newly created landing Page. How do I do this, where can I upload my custom php code for the thesis landing Page? thanks in advanced


reverse next/prev page order

I think the way wordpress display previous and next posts is basically non sense, with next posts on the left side, and older posts on the right side. I am using the code               <?php posts_nav_link() ?>      is there a way to reverse such order?


How to select a template for a custom post type?

I've created a custom post type and custom taxonomy (all fine so far!) but when I try to view the post it's giving me a page not found. What do I need to do to setup a template which the custom post type below will use?               add_action( 'init', 'create_post_type' );     function create_post_type() {         register_post_type( 'members',             array(                 'labels' => array(                     'name' => __( 'Members' ),                     'singular_name' => __( 'Members' )                 ),             'capability_type' => 'post',             'supports' => array('title','editor','comments'),                'public' => true,             'has_archive' => true,             'rewrite' => array( 'slug' => 'members' ),             )         );     }          function members_init() {         // create a new taxonomy             register_taxonomy(             'members',             'members',             array(                 'label' => __( 'Member Categories' ),                 'sort' => true,                 'hierarchical' => true,                 'args' => array( 'orderby' => 'term_order' ),                 'rewrite' => array( 'slug' => 'members' )             )         );            }     add_action( 'init', 'members_init' );


wordpress multisite... collect all posts on main blog - exclude category?

hey guys, I'm using the sitewide tags Multisite plugin on my wordpress setup. I'm collecting all blogposts of multiple subblogs on my mainblog. Any idea how I could manage to exclude a certain category from this collection? e.g. If a user is writing a blogpost on a subblog and is adding it to the category "private" the mainblog should not show this post! thank you for your help.


I'm having the exact same problem described in this post: add_action('wp_ajax_[action name]', myfunction) problem I set add_action('wp_ajax_my_function_call','my_ajax_function'). If I print_r($wp_filter) immediately after this line, my action is in the $wp_filter array. However, by the time I do my jQuery.post call to admin-ajax.php, my action has disappeared from $wp_filter. I verified this by adding this to line 354 of wp- includes/plugin.php:               if($tag=='wp_ajax_my_function_call') print_r($wp_filter);      According to user1567 in the above-cited post, "the problem was the loading order and the location of the add_action calls." Unfortunately this hasn't helped me track down the problem. I tried setting the priority of the add_action to 99 and to 1. Neither helped. Any other ideas on what might be causing this situation, or at an explanation of why, in general, an action that was definitely in $wp_filter at one point would inexplicably disappear from it without even being triggered?


What's the internal concatenation function for creating Excerpts with Wordpress?

I'm already familiar with the_excerpt() and get_the_excerpt() functions. These two functions relate specifically to some node/taxonomy/whatever (post, page, custom post type) inside of Wordpress, unless I'm mistaken. What if I have some external text, and wanted to pass it through a concatenation function. Does anyone know the function to do that? What I'm trying to avoid, is creating a new function or re-writing an old function to limit words inside of a string. For example, > echo some_excerpt_function($text, $amount_of_words_to_limit); I'm assuming Wordpress has something similar to this, that's why I'm asking.


Selling WordPress sites?

What are the laws concerning developing WordPress sites using other developers' plugins and then selling the sites?


How does one reduce the number of stored revisions?

How does one reduce the number of stored revision (e.g. 5 max) for post types that support revisions?


Make Theme Options Native to Theme Customizer

With the native Theme Customization API it makes no sense to have an independent options panel. So how do I implement my code (below) into the Theme Customizer? Here is the code for my Theme Customizer: code here In my options panel I allow users to select between Next/Previous Links in archives or pagination, the code looks like this:               array( "name" => "Paginate or next/previous links?",     "desc" => "Choose your option",     "id" => $shortname."_next_prev_or_paginate",     "type" => "select",     "options" => array("Next/Previous Links", "Pagination"),     "std" => "Next/Previous Links"),      Here is the function that makes it work:               // Pagination     function my_theme_navigation() {         global $shortname;              if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next/Previous Links' ) :         // the block for next-prev navigation         echo '
';         next_posts_link('Older');         echo '
';         echo '
';         previous_posts_link ('Newer');         echo '
'; else :         // the block for pagination         global $wp_query;         $big = 999999999;         // need an unlikely integer         echo paginate_links(            array(                'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),                'format' => '?paged=%#%','end_size'     => 1,'mid_size'     => 2,                'current' => max( 1, get_query_var('paged') ),                 'total' => $wp_query->max_num_pages            )        );         endif;     }      I then simply call it using this:               <?php my_theme_navigation(); ?>


Navigate by Tags inside a custom Post Type

I want to have the possibility of navigate by 'standard Tags' inside my custom post type 'Car', like the following: > http://www.example.com/car/toyota > > http://www.example.com/car/blue Of course, this will show only post from `post_type` 'car'. Not standard posts. I guess, I need a rewriting function or sort, but I am not good enough to start from scratch. Any suggestions, code, plugins? Or any clue how I can do what? Here my settings: I'm using custom post type + specific custom post type category   * post_type: car   * post_type-category : car_sedan, car_suv , car_supercar   * **standard** Tags : toyota, hummer, blue, red I'm using the Magic fields 2 plugin. _Note: I do not want to create specific`post_type` tags, because I allready have a lot of tags and a lot of tagged posts._


Disable image resizing on specific upload fields

I am using the Options Framework Theme from devinsays, but am having a "small" problem with the Image Upload functionality. Basically, I need to disable resizing on a specific upload-field, but keep it on all others. I do realize that this functionality is not specifically dependent on this framework, but I haven't been able to find any resource on how to achieve this on a case by case basis for specific Theme Options, so I'm hoping someone here could help. Any input would be appreciated!


Media library and posts list problems with Wordpress on IIS

I have Wordpress 3.5 installed on IIS7 and I'm using SQL Server instead of MySql. Some strange "glitches" occur and I think their related to the same problem.   1. I cannot see media library items on the first page. If I'll go to ~/upload.php?paged=2 I am able to see all the media. It basically starts to show the items from the second page.    2. The same problem occurs with the posts list. If I'm going to another page in the posts category, I am able to see them.    3. Settings/Permalinks throws and internal server error, so I can't check what's there even if I'm not sure if I would be able to change permalinks from there.  Any ideas are appreciated, I'm curious what's the reason for the first two points. Update: for point 3, the detailed error sounds like this:               C:\Program Files\PHP\v5.3\php-cgi.exe - The FastCGI process exited unexpectedly     Handler PHP53_via_FastCGI     Error Code  0x00000001


Taxonomies for Wordpress Media Library

> **Possible Duplicate:**   >  How it is possible to use taxonomies on attachments? I know this has been a long debated issue with WP, but I was hoping that since the 3.5 upgrade, there has been some progress in categorizing images in the Media Library. Really, what I am hoping to accomplish is creating a set of categories for the images in the Media Library, and then assigning the current images, or future images, to those categories. Then, later down the road I could call them in a page template based on their category. Any ideas WPA? Many thanks.


How do I output a list of a specific post type in a table?

I've used the Custom Content Type Manager plugin to create a new post type of "Job". It includes a couple custom fields for "Location" and "Job Type". I have a page called "Jobs", and now I'd like to display a table on the Jobs page that shows an HTML table, with eg:               Job Title              Location       Type     Web Developer          Canada         Full-time      Data Entry             USA            Contract     Sales Rep              Switzerland    Full-time      and obviously clickable links to view the job page. I know I can do this by creating a custom template and writing the code, but it seems to me like this is a pretty straight-forward thing, so I was kind of expecting there would be a shortcode or something that I could use to easily display this. Is there a way to do this? A plugin?


What Triggers a Plugin Update Alert

How does WordPress know a plugin has an available update? Is the process handled by the readme.txt file? I am trying to manage 3rd party plugins that I alter in an effort to better fit/meet the needs of my instance of WordPress but I would like to maintain the functionality that alerts the CMS user that an update is available for the 3rd party plugin. If I alter a plugin’s title will WordPress still know if there is an update to that plugin's code base? E.g. ‘Plugin Name’ (changed to) ‘Plugin Name – Modified’


How to assign a WP 3.0 custom nav menu to a theme's navigation menu location via script?

I'm using this script inside a plugin to create a new custom menu on the fly and assign a page to it...               $menu_id = wp_create_nav_menu( 'header-menu' );     $menu = array( 'menu-item-type' => 'custom', 'menu-item-url' => get_home_url('/'),'menu-item-title' => 'Home', 'menu-item-status' => 'publish' );     wp_update_nav_menu_item( $menu_id, 0, $menu );      And this works great. However, what I'm stuck on is how to hook this menu up to one of my theme's "Menu Locations". Since I'm registering a nav location called "header-menu" in my theme's functions.php, I thought that the code above, calling wp_create_nav_menu( 'header-menu' ) would hook my custom menu to the location defined in my theme as "header-menu", but its not. For example, my theme registers two menu locations...               register_nav_menus(       array('header-menu' => __( 'My Header Menu' ),       'footer-menu' => __( 'Footer Menu' ))     );      How can I hook the "Header Menu" I created with wp_create_nav_menu( 'Header Menu' ) to the "My Header Menu" location that i've registered in my theme? I'm sure the answer is somewhere in nav-menu.php, but I can't find it. ie, I can do this manually from the WordPress "Appearance > Menus" Manager and under "Theme Locations > Main Navigation Menu" I select "Header Menu" and click "Save". I'm trying to do this in script.


Pagination doesn't function properly for archive of a custom post type set as the front page

I created a similar question about an hour ago but since then I feel that I've changed things enough so that if someone viewed it for the first time, it'd just be a confusing mess. So I am opening up a new question that is a bit more clear and relevant to my issue. Basically, I have a custom post type called `podcasts` and I have created an archive page for this post type by creating a new file called `archive- podcasts.php`. I have made this page into a custom template and have set it as the front page via `Settings > Reading` in the dashboard. However, even after doing this, the archive page wasn't showing as the front page, so I did a little research and found this gem to drop in my `functions.php` which finally allowed the archive of posts to show up on the front page.               add_action("pre_get_posts", "custom_front_page");     function custom_front_page($wp_query){         //Ensure this filter isn't applied to the admin area         if(is_admin()) {             return;         }              if($wp_query->get('page_id') == get_option('page_on_front')):                  $wp_query->set('post_type', 'podcasts');             $wp_query->set('page_id', ''); //Empty                  //Set properties that describe the page to reflect that             //we aren't really displaying a static page             $wp_query->is_page = 0;             $wp_query->is_singular = 0;             $wp_query->is_post_type_archive = 1;             $wp_query->is_archive = 1;              endif;     }      Awesome, but not quite finished yet. Below is what my `archive-podcasts.php` page looks like:               <?php     /*     Template Name: Podcasts     */     ?>                  <?php get_header();?>

                      <?php                 $paged = (get_query_var('page')) ? get_query_var('page') : 1;                 $args = array( 'posts_per_page' =>5, 'post_type'=> 'podcasts', 'paged' => $paged );                 $postslist = new WP_Query( $args );                      if ( $postslist->have_posts() ) :                     while ( $postslist->have_posts() ) : $postslist->the_post(); ?>
                             <article id="post-<?php the_ID(); ?>">                                 <time datetime="<?php the_time('c'); ?>"><?php the_time('F j, Y'); ?></time>                                 <?php                                      $custom = get_post_custom($post->ID);                                 $buzzsprout_code = $custom["buzzsprout_code"][0];                                 echo do_shortcode($buzzsprout_code);                                      ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="View emails and comment on this episode.">View emails and comment on this episode

                          <?php endwhile; ?>
                         <?php my_paginate_links(); ?>
                          <?php wp_reset_postdata(); ?>                      <?php endif; ?>

                  <?php get_sidebar(); ?>                  <?php get_footer(); ?>      You'll notice that I'm calling the function `my_paginate_links()`. However, calling this function is screwy because it doesn't paginate the archive of posts correctly. When I click on a page number, it goes to the correct page, but the `current` CSS class doesn't match up. Here is what `my_paginate_links()` looks like:               function my_paginate_links() {         global $wp_rewrite, $wp_query;         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;         $pagination = array(             'base' => @add_query_arg('page','%#%'),             'format' => '',             'total' => $wp_query->max_num_pages,             'current' => $current,             'prev_text' => __('&laquo previous'),             'next_text' => __('next »'),             'end_size' => 1,             'mid_size' => 2,             'show_all' => true,             'type' => 'list'         );         if ( $wp_rewrite->using_permalinks() )                 $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );         if ( !empty( $wp_query->query_vars['s'] ) )                 $pagination['add_args'] = array( 's' => get_query_var( 's' ) );         echo paginate_links( $pagination );     }      Can someone help me figure out why the pagination isn't working? Also, is there a better or more efficient way of going about all of this? Also, I should note that the pagination works fine on my main query for my regular posts. They just don't work for this archive of custom post type posts. Is there a way to get the pagination to work for both instances? Edit: Updated the pagination function               function my_paginate_links() {         global $wp_rewrite, $postslist;         $postslist->query_vars['page'] > 1 ? $current = $postslist->query_vars['page'] : $current = 1;         $pagination = array(             'base' => @add_query_arg('page','%#%'),             'format' => '',             'total' => $postslist->max_num_pages,             'current' => $current,             'prev_text' => __('&laquo previous'),             'next_text' => __('next »'),             'end_size' => 1,             'mid_size' => 2,             'show_all' => true,             'type' => 'list'         );         if ( $wp_rewrite->using_permalinks() )                 $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );         if ( !empty( $postslist->query_vars['s'] ) )                 $pagination['add_args'] = array( 's' => get_query_var( 's' ) );         echo paginate_links( $pagination );     }


comment_email hook doesn't seem to work for comment editor field

I am building a plugin that allows users to PPK encrypt their users' IP/email data. Thus, IP/email data is set to dummy values in the comments table and encrypted values are stored in corresponding meta fields. I'm successfully using the `comment_email` hook to lookup email addresses in the admin comments browser from my encrypted meta values. When editing a comment in the admin interface, in the **Author** box the email field is preceded by the label "E-mail (send e-mail)", where the text in brackets is hyperlinked to the email address. My hook appears to operate correctly there, retrieving the encrypted email address from comment metadata and decrypting it before returning it. However in the edit field itself, the real (dummy) contents of `wp_comments.comment_author_email` is revealed. Is there a hook I can use to modify this before the screen opens? I thought perhaps `preprocess_comment` would do it, but it doesn't seem to be called. (I _can_ solve this by adding an AJAX op to this screen and modifying the edit box contents after the screen is rendered. However, that's a bit hacky, and may be impossible if I try to apply it to the Quick Edit AJAX feature).


How to validate the file name of the Media File Uploads?

I want to validate the file name of the files to be uploaded from the Media Library. CASE study: I want to restrict the file name containing '%', '. .', '/' etc..from uploading to the media library. I can restrict the file types but not able to restrict as per the file names. Suggest me any wordpress filter or any procedure to accomplish the solution.


Columns in a "post"

I understand that all of wordpress is structured around certain key "entities". Some of which are,   1. Pages   2. Posts   3. Comments That list is by no means exhaustive because I know wordpress has few other key "entities" Every wordpress site has a "homepage" and when I change any of the "theme" settings, it is this "homepage" that reflects those changes. For example I can configure the home page to have a "sidebar" + "content" + "sidebar" or any variation thereof. What I would like to know is, if I can have my "posts" use columns as well. Because I would like each of my "posts" to open in a new page and present 3 columns to the person browsing the site. The first column having a list of bookmarks into different parts of a video that is being displayed in the second column. And I would like to use the third column to display some pictures. I know my requirement is very specific. I am a very new to wordpress. Any help in this regards would be much helpful. Thanks.


Limit the number of posts in query_posts function with custom post types

I am using the code below to display posts defined as a custom-post-type and filtered by a custom-taxonomy of 'england'. I've tried using 'posts_per_page=5' in the query_posts function but this brings up a completely different set of posts from one of my post categories of type 'news'. When I remove the posts-per-page from the query, it returns the listings I want but it defaults to the default 10 set within the Wordpress Settings. How do I override it in the code below?                       <?php query_posts( array( 'country' => 'event-england') ); ?>             <?php if( is_tax() ) {                 global $wp_query;                 $term = $wp_query->get_queried_object();                 $title = $term->name;             }  ?>
                 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
                      <?php endwhile; else: ?>                 <?php endif; ?>


Query Multiple Custom Taxonomies

I registered 2 taxonomies: `festival_year` and `art_genre`. I would like users to search for a specific year and genre but am not sure the best way to do this. I have tried various plugins but none have worked. I was able to create separate files, like `taxonomy-art_genre-consumable-crafts.php` with the following code:               <?php     $festivalquery = wp_parse_args($query_string);     $festivalquery['tax_query'] = array(         'showposts' => 10 ,         'orderby' => 'title',         'order' => 'ASC',         'paged' => $paged,         'relation' => 'AND',         array(             'taxonomy' => 'festival_year',             'terms' => array('2010-artists'),             'field' => 'slug',         ),         array(             'taxonomy' => 'art_genre',             'terms' => array('consumable-crafts'),             'field' => 'slug',         ),     );     query_posts($festivalquery);     ?>      which gives me the query I'm looking for. However, there are 11 genres (and of course there will be multiple years). Instead of creating separate page templates, what is the best way to accomplish this? The test site: http://www.beta.cornhillartsfestival.com/artists/ Thank you so much!


Restrict file uploads by extension?

Is there a way in WordPress 3.1 to restrict allowed file uploads by extension (images only) and file size? Bonus question: Can I limit users to only be able view files they have uploaded themselves?


Limiting allowed html elements/strip harmful scripts from editor

How can I limit html elements allowed in the tinymce editor in Wordpress 3.1 and ensure harmful scripts have been removed (script/embed tags, etc)


Can you orderby slug in a taxonomy archive page using WP_Query?

In my taxonomy.php, my query is `                 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );         $wpq = array ('posts_per_page' => -1, $term->taxonomy => $term->slug, 'order' => 'ASC', 'orderby' => 'slug');       $loop = new WP_Query($wpq);`      It correctly retrieves the ~~droids~~ posts I am looking for, but does not `orderby` `slug`. I can't find `slug` as an option in the documentation any more, but I swear I have successfully used it before. How do I make it so? Edit: `'orderby' => 'name'` appears to work in 1 category but not in my other category (so far, there are only 2). I'm wondering if the category where it does work is just coincidence...


Is Auto Post recognition a WordPress feature? How to turn it off?

I noticed that if you go to lostlettermen.com/aa, it redirects to a post. Is this a feature in WordPress that can be turned off, or is this done by some type of plugin or custom code?


Issue getting gettext to work with conditional statements

I've been trying to apply a `gettext` filter to return two different results for different product categories (or read as categories for posts, non- woocommerce specific). I cant seem to get it right. This loads, but does not actually apply the conditional, it always defaults to else condition. What am I missing? This is added to my child theme's functions.php.               function my_text_strings( $translated_text, $text, $domain ) {                 switch ( $translated_text ) {                             case 'Related Products' :                                         if  (is_product_category( 'providers' ) ) {                                             $translated_text = __( 'Check out these other Providers', 'woocommerce' );                                             } else {                                             $translated_text = __( 'Check out reviews of other Providers', 'woocommerce' );                                             }                                             break;                                             }                 return $translated_text;     }     add_filter( 'gettext', 'my_text_strings', 20, 3 );


How to add coupon printer?

Im building a directory site and for each business listing I wanted to include a printable coupon. I would want users to be able to click the coupon image (or link) and a printable version of the coupon to show up. I looked around for solutions but couldn't find anything that could help. Any help would be appreciated. Thanks a lot.


Adding uploaded images to editor from metabox instead of default popup uploader

I need to find plugin or create listing of all uploaded images for some post in custom metabox. And i can click to thumbnail for add image to editor in custom format. I downloaded a lot of photos to default upload box, and each time i will do a lot of clicks for insert new image to editor. It is very uncomfortable.


Deregister custom post types

Anyone know of a way to deregister custom post types ? Is there an equivalent to register_post_type() ?


How to correctly call custom field dates into a posts_where filter using SQL statements

Currently I have the loop listing posts between two dates using the `posts_where` filter:                function filter_where( $where = '' ) {       $where .= " AND post_date >= '2000-01-01' AND post_date <= 2004-12-31' ";       return where;      }      add_filter('posts_where', 'filter_where');      query_posts($query_string);      while (have_posts()) :        the_post();        the_content();      endwhile;      In a `meta_key` called `original_date` I have stored a different date for each post that I wish to use instead of the `post_date`. How do I correctly call up this `meta_key` into the `$where` query to fulfil the same purpose as the `post_date`?               $where .= " AND [meta_key=original_date] >= '2000-01-01' AND [meta_key=original_date] <= '2004-12-31' ";      For example, the following SQL query doesn't seem to work, even though correct values (`2001-10-29`, `2004-11-03`, etc.) are present in the `original_date` `meta_key` of the posts:               global $wpdb;      $where .= " AND (SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='original_date' ) >= '2000-01-01' AND (SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='original_date' ) <= '2004-12-31' ";      whereas the following works fine on the same posts using their `post_date` as reference:               $where .= " AND post_date >= '2000-01-01' AND post_date <= 2004-12-31' ";      Perhaps the `meta_value` array needs to be stripped of some extraneous material in order to format the results into the same form as `post_date`? How can we approach this?


Wordpress as College Application System (Embark)

Anyone knows of any plugin or anyone has been using WordPress to serve as a College Application system similar to those by Embark? If not, I'm looking for idea of using current plugins to accomplish this. The system would allow students to create an account, upload their documents, check their status, invite people to submit a letter of recommendation. The admin would then be able to manage those applications, change the status, notify the applicants.


Changing directory and/or URL structure

I'm curious if its possible (and advisable) to change certain directory names and URL structure via customization by themes or plugins. For example, say I wanted the list of all a user's posts to appear at blog.com/people/username instead of at blog.com/author/username...is this possible via customization? If so, would this type of customization be very problematic when it comes to things like forward compatibility with the latest WP updates and such? Any advice anyone can offer on this would be most appreciated. Thanks. Eddie


Exclude all pages except a few?

I have a bunch of pages and I only want to include 2 or 3 pages on my main menu. How would I do that? Currently my code looks like this:               wp_page_menu('include=156,572,542&sort_column=menu_order&echo=0');      If I am going to insert `exclude=x pages`, it wouldn't make sense because there's just too many of them. Please no plugin recommendation. I've tried some but they conflict with other things I do in this regard. **UPDATE** Here's the full function:               function main_nav() {?>

"><?php _e('Skip to content', 'thematic'); ?>
                 <?php echo preg_replace('/
/', '
', wp_page_menu('include=11,13,7,9,4&sort_column=menu_order&echo=0'), 1);?>

 <?php     }          add_action('thematic_header','main_nav',9);      It's a custom version of Thematic's thematic_access() function. I don't know why it's behaving this way. I tried it on a new installation, it doesn't work still.


How do I get posts to appear at mydomain.com/blog?

I'd like to use WP to manage my whole site, not just the blog. I don't want the blog to appear on the home page, but instead at mydomain.com/blog. What I've done so far under Settings/Reading is to change the "Front page displays" from the default of "Your latest posts" to the other option, "A static page". So that allows me to have a static page for my homepage, which is what I want. Now how do I go about getting the blog portion of my site (posts) to live at mydomain.com/blog ? Any assistance would be most appreciated. Thanks. Eddie


wp_get_current_user always returns 0

I'm new to wordpress and modifying the code that's already working on a website. I want to get user's ID but I haven't figured out yet how. The following sample code works on my local environment but it only returs 0 for a user ID on the production site. Any idea would be appreciated.               <?php     $docroot = "/home/production-site/www";     require_once $docroot . '/wp-includes/pluggable.php';          testGetUserid();          function testGetUserid(){         echo 'Before wp_get_current_user
';         $user = wp_get_current_user();         echo 'After wp_get_current_user
';         echo 'ID= ' . $user->ID . '
';     }     ?>      Btw, though I don't know if this is relevant, to me it seems something strange might be occurring in `wp-includes/pluggable.php`, so I uploaded the entire php file here to allow everyone to take a look at the file. And with this file, I had to `require_once` following files on my local env.               require_once 'capabilities.php';     require_once 'functions.php';     require_once 'load.php';     require_once 'plugin.php';     require_once 'user.php';      Env production site: WordPress Ver 3.2.1, others unknown (using sakura.ne.jp hosting service) Env local: Ubuntu 11.04, Apache/2.2.17, PHP 5.3.5-1ubuntu7.2 with Suhosin- Patch (cli) (built: May 2 2011 23:00:17), WordPress Ver 3.2.1 * * * Update June 10, 2012) In addition to everyone's suggestions, @shabushabu (what a name :) I'm Japanese) pointed out the last key factor - `init` hook. Here's what worked for me:               require( dirname(__FILE__) . '/../wp-load.php' ); // Path depends on your file structure, needless to say      :     do_action( 'login_init' );      :  // Whatever you want to do


How do I get blog posts to appear within CMS?

I'm working with a WordPress CMS website that was set up without a blog. I want the site to continue to function as it has, with mostly static pages, including the home page. I want a page called "Blog" to function as a blog. Now I've been asked to add a blog, and what I expected would be extremely easy isn't turning out that way. This is what I've tried:   1. Added a page called "Blog" and published it.   2. Under Settings >> Reading, set the Posts page to Blog. (A Static Page is selected, with Front Page set to "Home".)   3. Added Blog to the main navigation in the Theme Options.   4. Created 2 posts. When I view the Blog page, two messages appear instead of the two blog posts:               Please go to Admin Panel > Settings > Reading and setup "Front page displays" option      Another detail that may be relevant is there are only 2 page templates: Default Template and Archives. If I select Archives as the template for Blog, I get an archive menu that links to the 2 posts I set up. Should I have a Blog Template as well? How can I add one? What else should I look at?


get all categories' latest post in one query

My WP blog has 12 categories, 80 subcategories. I need to fetch the latest post from each of those 12 categories. I know how to do it in 12 queries using 12 get_posts() but is there a way to get them in one query? I tried to make it work like this but it fetches more than 12 posts:               // Get array of categories (level-0 only).         $cats= array();         $categories=get_categories($args);         foreach($categories as $category) {              if ($category->parent == 0) {                 $cats[]= $category->term_id ;             }                }         $categories= implode(',',$cats);         // Fetch the latest post of each category              global $wpdb;              $querystr = "SELECT wposts.*          FROM $wpdb->posts wposts             LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)             LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)         WHERE $wpdb->term_taxonomy.taxonomy = 'category'             AND $wpdb->term_taxonomy.term_id IN($categories)         ORDER BY wposts.post_date DESC";              $pageposts = $wpdb->get_results($querystr, OBJECT);      And then the loop:               global $post;             foreach ($pageposts as $k=>$post):                 setup_postdata($post);                 // ... wp loop through your results               }


Register new widget

I have a widgetized area and I am trying to add a new widget that can be added to my widget area, I need the code below to be the widget output
     <?php     $args = array( 'taxonomy' => 'post_tag' );     $terms = get_terms('post_tag', $args);     $count = count($terms); $i=0;     if ($count > 0) {         foreach ($terms as $term) {             $i++;             $term_list .= '
slug . '" title="' . s__('View all post filed under %s', 'my_localization_domain'), name) . '">' . $term->name . '
';         }         echo $term_list;     }     ?>
      I just need a tag list (not tag cloud) to be sortable with my other widgets, I tried extending the widget class but failed, please help


Can i add custom meta box (Media Uploader) at Category Description

I have Question how can i add custom meta box (Media Uploader) at category description, i mean when i will create or edit category then i can add any media file like PDF,                <?php add_meta_box( $id, $title, $callback, $page, $context, $priority, $callback_args ); ?>       That is wordpress meta box function but i did not understand how can i use at category description, can any one help me to solve this. Thanks Umer


Is it possible to "freeze" a WordPress blog?

I'm currently running a 365 photos project and it's based on a WordPress platform. Currently this is very helpful because I can upload the photos easily and manage comments and stuff. Because we are reaching the end of the year, I would like to "freeze" the blog. I mean, remove all the WordPress engine code and leave all the pages as statics HTML. This will allow me not to have to get updates for WordPress, or worry about security. **Is there any way to "freeze" a WordPress blog?** Do I have to download the entire site with, say, HTTrack and re-upload it or is there a fancier way to do this? BTW, I have no interest of keeping the comments on or any interactivity that the blog has. I just want a static website.


Front end posting, not working wp_redirect with 'cannot modify header information' error

Im trying to make front end posting page but, sometime 'wp_redirect' is not working with 'cannot modify header information' error. adding data is working well but I don't know why is working well without error sometime, showing error sometime.. Sorry for my bad english, please help me out... and I'm not a programmer just understand some codes anyway... Many thanks!!                   if (isset ($_POST['post_title'])) {             $title =  $_POST['post_title'];         } else {             echo 'Please enter a game  title';         }         if (isset ($_POST['description'])) {             $description = $_POST['description'];         } else {             echo 'Please enter the content';         }              $new_post = array(             'post_title'    => $title,             'post_content'  => $description,             'post_status'   => 'publish',             'post_type' => 'property',               'tax_input' => array( 'property_type' => array($property_type), 'suburbs' => array($suburbs) )          );                   //save the new post and return its ID         $pid = wp_insert_post($new_post);                  //add thumbnail             if (!function_exists('wp_generate_attachment_metadata')){                     require_once(ABSPATH . "wp-admin" . '/includes/image.php');                     require_once(ABSPATH . "wp-admin" . '/includes/file.php');                     require_once(ABSPATH . "wp-admin" . '/includes/media.php');                 }                  if ($_FILES) {                     foreach ($_FILES as $file => $array) {                         if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                             return "upload error : " . $_FILES[$file]['error'];                         }                         $attach_id = media_handle_upload( $file, $pid );                     }                    }                 if ($attach_id > 0){                     //and if you want to set that image as Post  then use:                     update_post_meta($pid,'_thumbnail_id',$attach_id);                 }  //add thumbnail end              update_post_meta($new_post_id, 'tax_input', $property_type);         update_post_meta($new_post_id, 'tax_input', $suburbs);              //insert custom fields         update_post_meta($pid,'bathrooms',$_POST['bathrooms']);         update_post_meta($pid,'property_lease',$_POST['property_lease']);         update_post_meta($pid,'lost_found_date',$_POST['lost_found_date']);         update_post_meta($pid,'dog_sex',$_POST['dog_sex']);         update_post_meta($pid,'latitude',$_POST['latitude']);         update_post_meta($pid,'longitude',$_POST['longitude']);                   $url = get_permalink( $pid );         wp_redirect($url);         exit();     }           get_header();


Looping through tabular data

I am trying to create a table containing information that is a result of two different loops. The first loops through a list of custom post types to display team names. The other is to provide data concerning each of the teams and stored as metadata. So I think I need some way of constructing a double query in order to create a single loop. This is what I have so far:               $team = new WP_Query(array('post_type' => 'team_page') );           $args = array(            'post_type' => 'match_report',            'meta_query' => array(              'relation' => 'OR',               array(                  'key' => 'report_home-select',                  'value' => $team->post->ID,                  'compare' => '=',               ),               array(                  'key' => 'report_away-select',                  'value' => $team->post->ID,                  'compare' => '='               )            )                                            );              $my_query = new WP_Query($args);          $played = $my_query->post_count;          if ( $team->have_posts() ) {     while ( $team->have_posts() ) {         $team->the_post();     ?>
                                  <?php the_title(); ?>	                                  <?php echo $played;?>	                                  9	                                  0	                                  2	                                  	                                  10	                                  33	                                  27
           <?php } ?>


Search results sorted by post types

I am working on a site with several post types - 4 to be exact - and I am trying to setup the search results page to have a filter/sort the results by post types. For example, when a person searches a term they are taking to the page with the results, all posts found from all post types are shown but up top there are the different post types name links that will sort the results and show only the respective post type's post. Right now I have several loops on the search results page for each post type but when I test it, the loops are all showing the same results even though each loop has a query for a different post type. How do I fix the loop so that it only shows the search results from that post type? I dont want to have different search forms or reset the query and end up losing the search term. Here is some of the code from the page -- http://pastebin.com/L9zEw1cn The first loop is the default loop which will show all the results and the second loop is the loop I am trying to use for the rest of the post types. So is there anyway to fix the second loop so that it only shows the search results for that post type? Any help would be greatly appreciated. Thanks. Reply


Neither the_excerpt() nor the_content() works properly?

I'm wondering what should be used in index.php (post listing page): `the_excerpt()` or `the_content()`?   1. Twenty Thirteen uses `the_content()` but this prints entire content unless `<!--more-->` exists and it completely ignores Excerpt field from [Posts > Add New > Excerpt].   2. So, I used `the_excerpt()` instead but this doesn't react to `<!--more-->` tag at all and it just grabs first 55 words or uses manual Excerpt and doesn't produce "Read more..." link. What I would like to achieve is this:   * print 55 words   * but react to `<\--more-->`   * and if manual excerpt is specified, use this instead (most people don't want the beginning of their post to be their excerpt so this is of crucial importance)   * produce optional "Read more..." link This looks like the most intuitive to me for post listing pages. Does something like this exist? If not, should `the_content()` be used on post listing pages? I think that most theme users aren't familiar with `<\--more-->` tag and they rather expect that themes will create proper excerpts for post listing pages rather than displaying full post content. Reference:   * http://codex.wordpress.org/Function_Reference/the_excerpt   * http://codex.wordpress.org/Excerpt   * http://www.rarst.net/script/wordpress-excerpt-teaser/


How to remove 'Site' in the comment form?

I' would like to remove the "site"-inputfield in the comment form in Wordpress twenty eleven. Someone who knows the answer? Thanks in advance.


How to output all taxonomy links from a custom post type in a menu?

I made a custom post type called Product. And a taxonomy with the name 'product-category'. These taxonomies have pages where we show a list of the products that have that taxonomy. Now my question is how to get all the taxonomies as a menu in the header. Its an awful lot of work to add it manually in the menu editor. Also because i need sub-menu's and sub sub menu's. How do I do this?


294 Queries on Mainpage of Wordpress

I have 294 queries on my wordpress site. I checked using sql monitorand the maximum queries are to display count of a cities list custom field. Lets say there are 200 cities then 200 queries are happening in a loop to count the number of posts about a city. Is a there a way to do this more efficiently. The code I have used to get counts of countries is               <?php      global $wpdb;     $countries = tgt_get_countries();     foreach ($countries as $country) {     $testcount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_value = '$country' AND meta_key = 'tgt_job_country'");     if ($testcount !=0)     echo "
".$country."(".$testcount.")
";     }     ?>


How to count get_users query?

I have been searching high and low for a way to count the amount of results from a get_users query. Most of what I found is to count the total number of posts in a post query, but nothing for counting the total number of users in the get_users query. Can someone point it out for me? Thanks a lot.


Warning: Creating default object... when altering Customize panels

I'm trying to move my theme's [only] widget area outside of WP 4.0's nested "Widgets" panel by doing the following:               $footer_widgets_section = $wp_customize->get_section( 'sidebar-widgets-footer_widgets' );     $footer_widgets_section->panel = '';      The key is to reset the panel to empty, rather than `widgets`. However, I'm getting a PHP warning: **`Warning: Creating default object from empty value in ...`** (the second line of my above code). Does anyone know how I can fix this?


How to remove class attributes from custom menu markup?

Just playing around with adding "custom menu" support to my theme. I'm super excited about it. HOWEVER, Check this out >

           Home

      Worst case of "class-itus" I think I've ever seen. Is this something "I" did unintentionally or is this the default? How can I control or remove the class attribs on these menus?


Issue on Working with Metabox - Checkbox to enable Sale Items

Using WP 3.8.1, I have a `Custom Post Type` which is called " **Sport** " and it has a Metdabox - medata data as ![enter image description here](http://i.stack.imgur.com/5u9Uh.png) I do not need to set up online shopping but I world like to add Price of my products to any Sport CPT and enable updating the Price in the WP table by Checking the Sale on checkbox and specifying sale amount or presentage. so the out put looks like ![enter image description here](http://i.stack.imgur.com/Zufj9.png) I know some part of job can be done by JavaScript(Like adding Sale class to Price or adding sale icon to box) on checkbox but on WP side I also need to update the table to take new price also be able to list all on sale Items for each CPT. Can you please let me know how to do this? and this is the code:               <?php     /* Custom Meta Boxex */     add_action('add_meta_boxes', 'cpt_metadata_add');     add_action('save_post', 'save_options');     function cpt_metadata_add()     {         add_meta_box(             "prodInfo-meta",             "New Dress Shoe Attributes ",             "render_meta_elemnts",             "sport",             "normal",             "low"         );     }     function render_meta_elemnts()     {         global $post;         $values  = get_post_custom( $post->ID );         $price   = isset( $values['metadata_price'] ) ? esc_attr( $values['metadata_price'][0] ) : '';         $sale    = isset( $values['metadata_sale'] ) ? esc_attr( $values['metadata_sale'][0] ) : '';         $saleamount  = isset( $values['metadata_sale_amount'] ) ? esc_attr( $values['metadata_sale_amount'][0] ) : '';         $salepercentage = isset( $values['metadata_sale_percentage'] ) ? esc_attr( $values['metadata_sale_percentage'][0] ) : '';         wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );          ?>

       <?php echo 'Price : $'; ?>	       <?php echo '<input name="metadata_price" value="'. $price . '" id="metadata_price" />'; ?>	       	       <?php echo 'Sale On : <input type="checkbox" name="metadata_sale" id="metadata_sale" <?php checked( $sale, 'on' ); ?> />'; ?>	       <?php echo 'Sale Percentage : %'; ?>	       <?php echo '<input name="metadata_sale_percentage" value="'. $salepercentage . '" id="metadata_sale_percentage" />'; ?>	       	       <?php echo 'Sale Amount : $'; ?>	       <?php echo '<input name="metadata_sale_amount" value="'. $saleamount . '" id="metadata_sale_amount" />'; ?>

     <?php     }     function save_options()     {         global $post;     if (!isset($_POST['source']) || $post->post_type != 'sport'){          return $post;         }           update_post_meta($post->ID, "price", $_POST['price']);         }      Update:               <?php     $args = array( 'post_type' => 'sport');     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();     $meta = get_post_custom($post->ID);         the_title();         echo $meta['price'][0];          endwhile;     ?>      **Update 2**               <?php     $args = array( 'post_type' => 'sport');     $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post();     $meta = get_post_custom($post->ID);          if(metadata_sale = checked) {             echo $meta['metadata_price'][0] - $meta['metadata_sale_percentage'][0];         }         else{            echo $meta['metadata_price'][0];         }     endwhile;     ?>


How to place HTML below the title of the (custom) post overview

**Edit:** Yes, I know, I provided an answer to this question myself. However, I'm still interested in other solutions and/or comments on the one I found. Is this how you would do this? Are there any other ways? * * * I would like to provide some additional description and on-page help (i.e., no contextual help or help tabs) on the overview page (i.e., `edit.php`) for a custom post type. According to `edit.php` (as well as `class-wp-list-table.php` and `class-wp- posts-list-table.php`) there is no appropriate hook. So, how can I do this? A few notes:   * I came up with a solution, which I would describe _a bit hackish_ , so I'm open for a _clean_ solution (if there is one);   * I will post my solution as an answer so you can comment on that (and so the question and answer are kept separate);   * I'm aware that I can do this via JavaScript/jQuery - but that's not _clean_ (IMO) as well...


Custom Taxonomy Term Caching?

I have two Custom Post Types, "event", and "opportunity". They share a custom hierarchal taxonomy, "location". My client had added a handful of terms (United States (parent), then a few States (children)). I decided to save them time by adding the rest of the States via wp_insert_term. This worked great! Or, so it seemed. The terms showed up fine for me as an admin. When logging into a "Contributor" account, I can go and create a new "Opportunity", and all the terms show as expected. When going to create a new "Event", the only terms that show up are the ones that were created by hand. You can _add_ a new term on the spot via "Event" and it shows up just fine in the location manager. Its as if WordPress is caching the older terms. Any ideas what might be causing this or where I should look? Details: WordPress 3.0.3   Role Scoper 1.3.20


Content not shown on some older browsers and mobile devices (SGS3)

I'm fronting an issue with my newly created website. I'm using Wordpress 3.8 and a custom child theme (Twenty Fourteen). I've seen a problem, where some mobile phones (like the SGS3) and some older browsers cannot show the content of posts and pages. http://www.citizen-science.at/ Samsung Galaxy S3 was one of a few phones which could not display the page. Also some older versions of the Safari browser and some others. It seems as if updating the browser mostly fixes the issue, but I want to support older browsers as well. Here is an example of how it looks like: ![screenshot with missing content part](http://i.stack.imgur.com/HPxhw.png) Where the white part is, there should be the content of the page, which is just not shown. **EDIT:** _Known browsers which are not working:_   * Android Internet (Samsung Galaxy S3, Android 4.3)    * Android Internet (Samsung Galaxy S3 mini, Android 4.1)    * Safari (Desktop Version 5.1.7, Win 8.1) **EDIT 2:** I've seen that one subpage of my site is working: http://www.citizen-science.at/projekte/roadkill/ubersicht/ But others aren't.


How do I fix the URL used in the Wordpress admin menu for customize.php

I recently moved a Wordpress-based website to a new domain and updated all references to the old domain in the database, but the "customize.php" link in the Wordpress admin menu still references the old domain. It contains: http://www.newdomain.com/wp- admin/customize.php?url=http%3A%2F%www.olddomain.com%2F I have searched the database and all files in the Wordpress installation and cannot find any references to www.olddomain.com. I've also deactivated and re- activated each plugin, deleted transients out of the database and deleted all cookies in my browser for both old and new domains. Everything else on the site is working properly. How do I fix this?


Text Widget to Show database fields based on post

I am wondering whether this is possible:   * I would like a widget which displays fields taken from a database table I have created.  Table contains information about the location of the post. Widget to show the information about the post location based on a custom field in the post e.g Post Custom Field Location = London Widget to show text about London (stored in the database)


Implementing advanced add_* function wrappers

`add_action()` and `add_filter()` are major functions. However in some scenarios _add one more function and hook it somewhere_ approach gets bulky and inconvenient. I had determined for myself several use cases that can streamline code with wrappers on top of `add_*` functions. Things that are better handled with single-liner than extra function each and every time.   1. **Add arbitrary filter return**. There is already `__return_*` functions but they are very limited by definition. Why not just pass what you want returned in filter. Saves from myriad `function return_stuff(){return 'stuff';}`   2. **Replace X with Y in filter**. Saves from myriad `function replace_stuff(){return str_replace();}`   3. **Add action with arbitrary arguments**. Actions fire with arguments, passed in hook. But sometimes you don't care about that and just want ot run your function with your own arguments at specific hook. Saves from myriad `function echo_stuff(){echo 'stuff'};` and more. So...   * Are there any other use cases you want and/or use in practice?   * How would you implement such wrappers? There are a lot of possible approaches (closures, global variables to keep additional arguments, passing objects in callback, etc). **PS** I have couple different implementations for **(1)** and **(3)** already and (as suggested) will post bits of my code some time later so I don't spoil the fun. :) **Example** Current way:               add_filter('wp_feed_cache_transient_lifetime', 'change_transient_lifetime', 10);          function change_transient_lifetime($lifetime) {              return 3600;     }      Wrapper:               add_filter_return('wp_feed_cache_transient_lifetime', 10, 3600);


Wordpress Command Question

Ok would like to learn how to run commands through WP rather than SQL commands So I have created a text file named delete-non-authors.php to delete authors with no posts Do I need to add this to a folder before uploading? What are the permissions to execute this plugin? Thanks in advance


How to get the image-URL from Media-Upload in a post?

I generated a new MetaBox for all standard posts in WordPress 3.1. There I generate a input:text field with the ID `_meta_fotos[pic]`, which should hould the image url generated by the standard media-uploader. I want to use the standard media-uploader from the standard post window. So I generated the following JavaScript code.               jQuery(document).ready(function() {       jQuery('#_meta_fotos\\[pic\\]').focusin(function() {         formfield = jQuery('#_meta_fotos\\[pic\\]').attr('name');         tb_show('', 'media-upload.php?type=image&TB_iframe=true');         return false;       });       window.send_to_editor = function(html) {         imgURL = jQuery('img',html).attr('src');         jQuery('#_meta_fotos\\[pic\\]').val(imgURL);         tb_remove();       }     });      On the first step all works fine. But I don't get the real image URL. All I get back is a URL to the correct uploads-path with a filename `blank.gif`. I checked if the ThickBox is called by the `focusin`-function: It is alright. I think the problem ist in the `send_to_editor`-function. It returns in `html` the code from the underlaying main-Page and not from the popup-window of the media-uploader/thickbox. Can anyone help me, to find the mistake? Any help is aprreciated!


How to get full slug, including all parent pages

I am trying for hours and I managed to get full slug for parent of sub-page when I am on 3rd level sub-page I can not get slug of the top parent page. Example domain.com/top_page/sub_page/sub_sub_page I need to get full slug 'top_page/sub_page/sub_sub_page' I am doing this for language sites that are on sub-domains (individuals sites). These pages have same slug across sub-domains. So I want to link language site that when you are on some given page link to language site will take you to that page in that language (not home page of that language). example of hyperlink to English language sub-domain:               echo ''English'';      Is it possible to get slug of top parent when you are on third level page, sub-sub-page Hope somebody can help


If no posts in category display Form instead of not found

I have a couple of categories that don't contain any posts (yet). What I would like to do is have a form which takes users details for future posts. Am I right I thinking I simply edit the page which displays the current search bar.


Getting Term ID from Term Name for WordPress Query

I am trying to get term ids from term name and cannot figure out why this code is not working.               $excludes = '';         if($filtering_excludes) {               $exclude_terms = explode(", ", $filtering_excludes);             foreach ($exclude_terms as $exclude_term) {                      $term = get_term_by( 'name',  $exclude_term,  $filtering_tax  );                  $exclude_term = $term->term_id;                           }                  $excludes= implode(", ", $exclude_terms);              }      When I do a var_dump on $exclude_term is has the term id but $excludes is still returning the term name. I have similar code for getting the category id from name and it works without a problem -- this is that code.               $excludes = '';         if($filtering_excludes) {               $exclude_cats = explode(", ", $filtering_excludes);             foreach ($exclude_cats as &$exclude_cat) {                  $cat_id = get_category_by_slug($exclude_cat);                  $exclude_cat = $cat_id->term_id;                  }                  $excludes= implode(", ", $exclude_cats);         }      Can anyone see why my $exlcudes for terms is returning the name and not id?


List Parent page with sub pages

I have a page structure like this:                 Home            Projects        - Work_1        - Work_2        - Work_3        - Work_4      Home and Projects are Pages. Work_1 - Work_4 are pages with Projects as their parent. When I click the Projects page I'm using this code to get the children of Projects as a sub menu, so I get Work_1 Work_2 Work_3 Work_4 as the sub menu.                 <?php         if($post->post_parent)         $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");         else         $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");         if ($children) { ?>         <ul>         <?php echo $children; ?>         </ul>       <?php } ?>      How can I include include Projects in this sub menu so I get Projects Work_1 Work_2 Work_3 Work_4 Hope I have explained this and thanks in advance for any help.


search page different results

I have custom post types and would like to display the different results based upon a users search meta. I have three custom post types that are styled differently and want to return the search results based upon their respective styles, not the generic page link and excerpt that it currently shows. could I use is_search()?               <?php if ( is_search() ) : // Only display Excerpts for Search ?>
         <?php the_excerpt(); ?>
     <?php else : ?>
         <?php the_content( __( 'Continue reading →', 'bsq' ) ); ?>         <?php             wp_link_pages( array(                 'before' => '
' . __( 'Pages:', 'bsq' ),                 'after'  => '
',             ) );         ?>
     <?php endif; ?>


Prevent page slug from interfering with custom post type archive permalink?

In my plugin, I'm creating a custom post type that has an archive and uses the rewrite parameter to choose a slug:               $args = array (         'public' => true,         'has_archive' => true,         'rewrite' => array('slug' => 'lessons', 'with_front' => false)     );     register_post_type ('my_plugin_lesson', $args);      With this code, I get an archive of the 'my_plugin_lesson' posts at `example.com/lessons/`. However, I can also create a Page with the title "Lessons", and WordPress will assign it the slug 'lessons'. The View Page link on the admin panel for this page will be `example.com/lessons/`, but the page is inaccessible because WordPress shows the archive for my custom post type. Is there a way to prevent WordPress from choosing a slug for pages or posts that interfere with the slug of my custom post types?


How to redirect user after session timeout

How can i redirect user after session timeout in multisite to my custom Page? Normally Wordpress multisite redirects users to example.com/subdirectory/wp- login.php


Hide image gallery in Woocommerce if NO image

I have a few products with no images but they template leaves a big empty space where the image should be, I was wondering if there was a way to hide this product gallery section only IF there are NO images uploaded to that product. Thanks Badger


Are custom posts included when getting a categories' posts?

Would `WP_Query('cat=1')` display custom post types, or is that something that I have to specify? I have a custom post type, am assigning it to a category, and would like for it to be displayed when that category is visited, but that doesn't seem to be happening. Thank you for your help.


Custom post types: change "read more" text

I'm developing a website that has a blog section as well as a "free monthly download" section set up as a custom post type. On the home page I'm displaying excerpts with "read more" links for both the most recent blog post and the most recent monthly download (these are in separate loops). The read more link is generated automatically by this code in my functions.php file:               function excerpt_read_more_link($output) {     global $post;     return $output . 'ID) . '">Read more';     }     add_filter('the_excerpt', 'excerpt_read_more_link');      This is working fine, but I'd like "read more" for the custom post type excerpt to read "Get it now". Any suggestions for how to have different "read more" text for the blog post excerpts and the custom post type excerpts? Thanks in advance.


Output in XHTML or HTML 5 for plugins?

I'm currently writing a plugin that displays some images - possibly with captions. So, I was wondering whether to use XHTML (`<div>`s and `<span>`s) or HTML 5 (`<figure>` and `<figurecaption>`) for output. I image that the answer to this question depends somewhat on the theme being used. Is there a way to figure out which output format the user's theme is using? Or what's the best approach here? What's Wordpress doing to solve this issue?


page title, parent tilte and grand parent title

I am using a page hierarchy and I want to show the title of the parents and grand parents page (if there is any). The structure is something like Startpage Startpage > Second page Startpage > Second page > Third page Startpage > Second page > Third page > Fourth page The title should be something like On the Fourth page: "Fourth page - Third page - Second page - Startpage" On the Third page: "Third page - Second page - Startpage" The solution I have found isn't that good:               <title><?php          if(is_page()){          $parent = get_post($post->post_parent);     $parent_title = get_the_title($parent);     $grandparent = $parent->post_parent;     $grandparent_title = get_the_title($grandparent);         if ($parent) {             if ($grandparent) {                 echo wp_title('') . " - " . $parent_title . " - " . $grandparent_title . " - ";             }             else {                 echo wp_title('') . " - " . $parent_title . " - ";               }         }              else {             echo wp_title('') . " - ";         }     }?>  Startpage</title>      On the Second page level the title for that page gets double... "Second page - Second page - Start page" Anyone?


How do I enqueue(or delay loading of) <script> tags in individual page posts?

My customer has many pages with `<script>` elements including javascript.               <script src="myscriptforthispageonly.js"></script>      I'm trying to get all scripts to load in the footer using `wp_enqueue_script()`, but I'm not sure how to enqueue a script from within a page. Again, this is within a Wordpress **page**. Is it possible to enqueue an external script from a **page** or **post**? If that's not possible, is it possible to delay loading the script until the onload event fires?


Delete all associated media when custom post type removed

Basically I have so many images associated with custom post type that I need to be able to safely delete all related media on removal from trash. Is there a safe way of doing this?


How do I pass $in_foooter to wp_enqueue_script() without passing other params?

I have some scripts that I'm enqueueing like this:               wp_enqueue_script("jquery");     wp_enqueue_script("myscript" , get_template_directory_uri()."/js/myscript.js", Array('myscript'), " ");      I want to enqueue them in the footer, which means I should use the last parameter of `wp_enqueue_script()`, but I don't always want to pass the other params.               wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);      How do I get to `$in_footer` without messing up the default params in between it and `$handle`? Can I just put empty strings for each?


Add a menu item to Wordpress 3.5 Media Manager

How can add a new menu item underneath the "insert From URL" on the left sidebar in the new Wordpress 3.5 Media Manager? I've been looking at the backbone js and tried my hand at hooking into it with my own JS but without success. Edit 2: This seems to do the trick: http://sumtips.com/2012/12/add-remove-tab-wordpress-3-5-media-upload-page.html It should do for simple stuff, but I guess its also possible to do the same thing in Javascript. Would be nice if there was a tutorial/explanation on how the new media manager internals work.


Running WordPress on the Command Line - Turn off Delayed Output?

I'm creating a cron job that runs outside of WordPress. From a development perspective, this makes it really easy to debug and create cleanup scripts or cron jobs, by just running a command like the following on the command line:               php myfile.php      My issue is that WordPress somehow delays all output... typically when you run php files like this the output is generated on your screen in real time. Does anyone know how to prevent WP from delaying all the output until the end of the job? It's probably some simple parameter I'm missing when running the PHP file, or a constant of some kind, but I'm not sure. In the following code, you'd expect to have a 1-second delay between each output, instead, I currently get all the info printed at the end, at once:               set_time_limit( 0 );     ini_set( "memory_limit", "64M" );          ob_start();     require_once( dirname( __FILE__ ) . '/wp-load.php' ); // you need to adjust this to your path     ob_end_clean();          global $wpdb;     $q = $wpdb->prepare ("SELECT * FROM wp_posts LIMIT 5");     $results = $wpdb->get_results ($q);     echo "found " . count ($results) . "\n";          foreach ($results as $post)     {         echo $post->post_title . "\n";         sleep(1);     }          echo "\n\ndone";


Custom Taxonomy Tree view

I have been trying google for this, but not so easy to search for. I have a custom hierarchical taxonomy, something along the lines of:               Chainsaws     - Electric     - Petrol     - Other     Grasscutters     - Electric     - Petrol     - Other      What I need to do is create an index page, retaining the hierarchical structure. The closest I have come to doing it is with:               $products = get_terms('product-type');     foreach ($products as $product) {           $out .= $product->name;     }      But this just shows the ones in use, and loses it hierarchy :( Any insights are very welcome. Thanks in advance Andy


Custom Canonical URLs

I am moving my site from olddomain.com to newdomain.com. I want to keep all of the content at olddomain.com but I want the canonical version in google to be recognized as newdomain.com/whatever-post/ instead of the same thing at olddomain.com. How can I modify the rel=canonical in the section of olddomain.com to make this change?


Cache issues with images not showing up

Images are there, but they don't always show up. Could this be a cache problem? Or Timbthumb? Here is an example: http://designportugal.net/servicos/design/   And another: http://designportugal.net/portfolio/#all/3/list I sometimes also have trouble getting into WP dashboard, it gives a warning php error, but when I refresh, it goes away and I get inside fine.


Adding a Tag Parameter / Filter to My Shortcode

I have this plugin that displays category featured image thumbnails for each post via shortcodes.. like so,               [categorythumbnaillist 3] (3 being the category of course)      I would like it to only show posts with the tag "news".. only if you set the tag value to "news" via the shortcode. So if you entered in...               [categorythumbnaillist 3 tag="news"]      Then it should only show posts with the news tag in it. If no tag is entered, it should then display the posts for the respective category like the plugin already does. Here is the code I made for displaying the results.               $args=array(           'showposts'=> 5,           'category'=> $listCatId[1],           'orderby'=> $categoryThumbnailList_OrderType,           'order'=> $categoryThumbnailList_Order            );          $myposts = get_posts( $args);     $output = '<div class="categoryThumbnailList">';     foreach($myposts as $post) :      I tried to read and understand Wordpress's shortcode API, but I just couldn't seem to wrap my head around it. There are more functions from the plugin, So I have provided the full plugin code here: http://pastebin.com/QHrB8xUn Any help to getting my plugin shortcode to filter results by the tag news (if entered) would truely be appreciated. :)


Counting words in a post

How can I count words in a post? Something like the one displayed just below the post? Can someone please show me the code for getting this. I have been searching everywhere.


Is this the right way to execute some PHP in my plugin after a button click on an options page?

I have an options page for my plugin. I want the user to be able to click a button to execute a member function of my plugin's class. I found this page: http://stackoverflow.com/questions/8597846/wordpress-plugin-call-function-on- button-click-in-admin-panel But I'm not sure if I am interpreting the instructions correctly. I found that creating a form with an action="options-general.php?page=MY_OPTIONS_PAGE_SLUG" will work. Like this:                           <form method="post" action="options-general.php?page=my_options_page_slug">                     <input type="hidden" name="banana" value="yellow">                     <input type="submit" class="button-primary" value="<?php _e('Go') ?>" />                 </form>      Is this what the stackoverflow article is recommending? Is this a decent way to do this? I am not ready to step into (the WP) AJAX just yet. I'm ok with a form and a page refresh. Thanks for reading.


WordPress Network admin options page: how to store options and where will they be stored?

I'm creating an additional WordPress Network admin page, and I need to store some system-wide option. The good thing that a config file will be generated, so no access is required from the child blogs, but the question is: how to store options to Network Admin, and where will they be stored in the database? Thanks, Peter


Making next_posts_link(); return posts by month

I'm building a site for a magazine using WP and am needing to display a month of posts at a time. **How would I make the next_posts_link(); and previous_posts_link(); functions return results, shorted as one month per page?** If I can't do it via those functions, how would I make the front page display in an archive-like mode? Thanks!


Multisite ad server solution

If I am setting up a multisite WordPress installation, is there a solution that would let me manage ad inventory (multi)site wide? Can I place ads in various zones at various weights or percentages? Is there a way to auto-fill unused inventory? What are the best solutions out there?


If statement to check for post_content

I'm trying to write an if statement to check for post_content and if there is no post_content then to grab a textarea field content. Below is my code and with this, at this point it's only rendering "Array" to the page. Any help is greatly appreciated. Thank you! **CODE:**               <?php     foreach ($partners as $partner) {       $a_description = get_post_meta($partner->ID, "a_description");     ?>            <div class="partner-content">         <?php           if ($partner->post_content && !$a_description) { ?>             <?php echo $partner->post_content  ?>           <?php } else { ?>             <?php echo get_post_meta($partner->ID, $a_description, true); ?>           <?php } ?>       </div>     <?php     }     ?>


How to use a custom domain?

I recently created a ProPhotoBlog using WordPress for my photography business. I have been unable to successfully use my custom domain name with the new site. When I change both the Site URL and the WordPress URL, the entire site crashes (even after I have followed the tutorials provided by ProPhoto). My custom domain is currently pointed at the blog, and the homepage does come up, but the slideshow will not play, and when any of the pages links are clicked, I am being redirected to the temporary address provided by my host, Network Solutions. This redirection happens when navigating to any part of the site, as well as navigating back to the home page after viewing something. When being navigated back to the homepage after viewing something else, the slideshow does work, and the address is the local host address. The address I would like to use is http://www.mischaboltonphotography.com (which brings up the homepage), and the temporary address I am being redirected to is http://03525b8.netsolhost.com/WordPress/


Recent posts per category loop?

I need a loop/plugin/widget to display latest posts from the category the user is browsing and at the same time if he visits the home page, it should show posts from all categories (not a specific one) Any Ideas ???


Plugins error (Use roles and capabilities instead) on latest version, multisite

I have the latest, version 3.1.2 and have multisite installed. I have debug on true for testing purposes. I get the follow error when I install plugins. Where and how do I fix this? > Error: Notice: has_cap was called with an argument that is deprecated since > version 2.0! Usage of user levels by plugins and themes is deprecated. Use > roles and capabilities instead. in /home/mysite/public_html/wp- > includes/functions.php on line 3387 thanks in advance!


order of date column in custom post type

I have a custom post type and trying to set custom columns, the date column is there by default, and it appears right after the title. Do I have to unset the date first and then re-apply it, or is there a more elegant way of achieving this:               function custom_columns($columns) {         unset( $columns['date'] );              $columns = array_merge($columns, array(             'title'     => 'Alert Title',             'region'    => 'Region',             'date'      => 'Date',             )          );              return $columns;     }


How to add subscript and superscript in WordPress page titles

It is possible to add subscript and superscript in a WordPress page title? I need to add pages with "H2O" in the title. I have been searching, but cannot find anything with answers... only a few non-answered threads on wordpress.org forums.


Pagination for multiple queries merging into one Loop

I have an events site where I want to display upcoming events that can be booked in ascending date order and then events that are closed for registration in descending order. I'm using get_posts for each query and the I'm able to list the results:               <?php                 $posts = get_posts( array( 'post_type' => 'espresso_event',         'meta_key'  => 'event_start_date',         'orderby' => 'meta_value',         'order' => 'ASC',         'posts_per_page' => '10',          'paged' => $paged,         'meta_query' => array(             array(                 'key' => 'event_registration_end',                 'value' => date('Y-m-d'),                 'compare' => '>='             )         ) ) );      $moreposts = get_posts( array( 'post_type' => 'espresso_event',         'meta_key'  => 'event_start_date',         'orderby' => 'meta_value',         'order' => 'DESC',         'posts_per_page' => '10',          'paged' => $paged,         'meta_query' => array(             array(                 'key' => 'event_registration_end',                 'value' => date('Y-m-d'),                 'compare' => '<='             )         ) ) );     $posts = array_merge( $posts, $moreposts );     foreach( $posts as $post ) :     setup_postdata( $post );     ?>      Unfortunately I don't seem to be able to get the results to paginate.


Page Template Dropdown - Missing In WordPress MultiSite

I am using WordPress Multi-Site and on the page edit screen I am completely missing the Page Template drop down. I have tried looking in Page Options and it's missing from there as well. If I enable the same theme in standard WordPress then the page templates show up Anyone any ideas?


Custom post type, no need for single view, plus want permalink rewrites that include hash in URI

We are using CPT's to manage a frequently asked questions page on a site, where the question is the post title and the answer is the post content. There is a main page for the FAQs that shows all posts (FAQ archive page). With this structure we really have no need for the single view for any FAQ and in fact would like to omit it from the site structure. To address permalinks we'd like to set them to be something like example.com/faq/#uniqueIdentifier, thinking that we'll use the #uniqueIdentifier to match a div on the archive page containing the answer and call attention to it in some fashion. The uniqueIdentifier could be post ID, faq question title, data from a meta box, or something else. So let me recap what I need we need to accomplish: (1) rewrite the faq permalinks to be /faq/#something, and (2) make sure all /faq/ links route to archive template and not single I'm mostly a noob but pretty good at fumbling my way through things. Have never attempted any rewrites though so would appreciate some particular direction on that. Thank you.


How to sort CPT by custom meta value (date), and return posts month by month

**For future reference** :   I am using the great Meta Box Plugin to help expedite meta box creation for my custom post types. **My goal** :   To build a highly customizable events section closely resembling a traditional calendar like `get_calendar` creates, but for a specific custom post type. **The Problem:**   -- By relying solely on using Wordpresses built in time parameters, I am able to return my posts in an ASC order similar to a traditional calendar but I am limited to only showing posts up to the current day since there is no way to query and return scheduled posts - this is an issue obviously since I need to display ALL event posts for the current month, and onward...   -- Additionally, I also need to be able to page to "previous" and "upcoming" months similar to `get_calendar`.   **My Solution Thus Far** :   -- Due to the time parameter restrictions, I've opted to return my posts via `WP_Query`'s `meta_key` parameter instead and assigned it to my events "startdate" field, and then orderby - `meta_value_num`... This seems to replicate the same functionality Im after for the most part but now I'm posed with a serious issue of: > "how do i treat this meta value just like wordpresses native time parameters > so that I can store this data appropriately for each month and have the > option to page through the months similar to the get_calendar archive?" Hopefully I was definitive enough in my explanation to help anyone who reads this make sense of it all. If not, please let me know and I will happily attempt to further clarify whatever it is...and thank you for the help! * * * Pasted below is my current "Calendar/Events" template as well as a screenshot of how it will most likely look on the front end.               <?php     /*     Template Name: Calendar     */     ?>          <?php get_header(); ?>               <?php include ('featured_images.php'); ?>

<?php wp_title('', true); ?>

<?php the_time( 'F Y' ); ?>

                      <?php $current_year = date('Y'); // Get current YEAR ?>                  <?php $current_month = date('m'); // Get current MONTH ?>                 <?php $calandar_posts = new WP_Query(                     array(                         'post_type' => 'calendar',                          'year' => $current_year,                         'monthnum' => $current_month, // Show ALL posts for current Month                          'meta_key' => 'epr_startdate',                         'orderby' => 'meta_value_num',                         'order' => 'ASC',                          'posts_per_page' => -1,                          'paged' => get_query_var('paged') ? get_query_var('paged') : 1,                     ));                  ?>                 <?php if($calandar_posts->have_posts()) : while($calandar_posts->have_posts()) : $calandar_posts->the_post(); ?>
                         <a href="<?php the_permalink(); ?>" class="calendar_link" title="<?php the_title_attribute(); ?>">
                             <?php echo get_post_meta($post->ID, 'epr_startdate', TRUE); ?>

                         <?php the_post_thumbnail('calendar-teaser', array('class' => 'calendar-teaser-img', 'alt' => 'View Event')); ?>
                      <?php endwhile; else: ?>
No Events for the month of <?php the_time( 'F' ); ?>
                 <?php endif; ?>                 <?php wp_reset_query(); ?>

          <?php get_footer(); ?>      ![enter image description here](http://i.stack.imgur.com/hBDR5.png)


Testing a Form's Zipcode Field with Regular Expressions to Determine Wordpress Page Behaviour

I want to use a Regular Expression(regex) to test the value of a form's zipcode field on a WordPress page, then based upon those results either:   * Selectively assign/reveal price fields on the same page. **or**   * Selectively redirect user to a page having the result-specific pricing. Here's the regex and the js pseudo-code skeleton.               var  zip5 = event.value.toString();          var myRegExp = /^92(2|3|5)/;          if ( zip5.length === 5 && myRegExp.test(zip5))     {         // Code to assign/display price set #1 on same page...or         // Code to move to Wordpress Page with Price Set #1     }     else     {         // Code to assign/display price set #2 on same page...or         // Code to move to Wordpress Page with Price Set #2     }


Add class to Reply button in Comments area

Under each comment there is a link called 'Reply'. I want to add a class to this link. It's default class is `comment-reply-link`. How can I do so? I am creating my own theme and I don't want to manually edit files inside the wp- includes directory.


Problem with -> in pre tags

Hello I am having a problem in a `pre` tag. All of a sudden all my `'->'` appear as `'-&gt ;'` on my blog. How can I solve this? I have updated to the newest version.