How to parse nested shortcodes?

The nested shortcodes won't parse correctly:               [row]         [col size="6"]...[/col]         [col size="6"]             [row]                 [col size="6"]...[/col]                 [col size="6"]...[/col]             [/row]         [/col]     [/row]      From the WordPress documentation, I understand that it is a WordPress shortcodes limitation. Is it still possible to get it work? **Edit:** Here's my shortcodes code, it works fine if its not nested (ie., row shortcode is not used inside the col shortcode).               add_shortcode( 'row', 'row_cb' );     function row_cb( $atts, $content = null ) {                          $output = '';             $output .= '
';             $output .= do_shortcode( $content );                     $output .= '
';                  return $output;      }          add_shortcode( 'col', 'col_cb' );     function col_cb( $atts, $content = null ) {              extract( shortcode_atts( array(                 'size'  => '',             ), $atts ) );                   $output = '';         $output .= '
';         $output .= do_shortcode( $content );                 $output .= '
';              return $output;      }


Register frontend page without access in backend

I'm looking to register a page that can be accessed from the frontend, while not actually having it show up as a "page" in the admin. I had thought about creating the page programatically and then setting an access level to hide it from users, but since I'm dealing with a multi-network site, I'd like to be able to configure a URI and then filter to that and show data as needed (and also change if needed as well). One plugin that seems to be doing this would be Events Calendar (Tribe). You set a slug for your events page and it "saves" that as a URI that they can interact with. I had thought that a possible solution would http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint but I haven't had any luck as of yet. An example would be to register `special-page` and interact with that slug, but if someone were to try to create an admin page called `Special Page`, it would notice `special-page` exists and send the slug to something like `special-page-2`. Thanks for any help/suggestions!


Facebook doesn't display the related thumbail for some posts

When I share some of my blog posts, Facebook doesn't display their right thumbail or anyn related image to the posts ... It just gives 3 unrelated thumbails to choose ... For example , FB shows the right thumbail with this post : http://www.moroccoenglish.com/?p=480 while it doesn't with this post : http://www.moroccoenglish.com/?p=578 **How can I set FB to display me the related thunmbails of the shared post ?** thanks for helping me ...


finding out the top 5 source ( source is a custom taxonomy ), in a given category

The client I'm working with have thousands of articles and media ( audio/video ) files. To WordPress, all are posted by Author ID 1, which we named as STAFF. All the content though in reality has been created by various people and sources, certainly not by the STAFF. To keep that info ( who created the content or where the source is ), I used a non-hierarchical custom taxonomy called "source". if the source happens to be an institution name I tagged the content by the institution name as follows. Example: source: CNN source: Washington Post And if the source happens to be a person, I used a prefix "by " in front of the name. Example: source: by anderson cooper source: by jon stewart Of course, the content has been tagged and categorized, accordingly. Now, the question is how to effectively find out things like who's the top 5 source's in category XYZ? I don't think this can be pulled by using the wp_query args - by tapping into the advanced tax query's section, cause wp_query args eventually returns posts only. Here we are asking terms in return. One possible way for this is the following take the XYX category go thru all the XYX categorized posts - one by one - particularly paying attention to the source data in those posts and while going thru them, dump each source term id encountered in those posts into a temporary table. ( for this you will use wp_terms, wp_term_relations and wp_term_taxonomy and that your creation mySQL table) when done with going thru all the posts in that category, you finally switch your attention to the temporary table and get a summary on that table, by getting ( source ) term counts after a group by and finally get the top 5. but getting all that in a single statement? that ain't my cup of tea yet.


$TBA Getting Translated to $0 (Custom Fields)

I'm working on a products showcase website, and in my index I have this snippet of code for my two variables ($price for the price, $buynow for the URL)
     <?php global $post; $price = get_post_meta($post->ID, 'price', true);     $buylink = get_post_meta($post->ID, 'buynow', true);     if ( $price ) { ?>$<?php echo ( number_format($price, 2, ".", "") * 100 / 100 );      Echo "(Buy)" ?>     <?php } else {} ?>
      This works perfectly. For a non-product post, when no price is filled, nothing is displayed. **However,** there are products that the price of is TBA (To Be Announced). **I suspect because I'm using`number_format` when I enter TBA as the value of `price` it automatically outputs $0.** How can this be fixed while taking into account that I do need to use `number_format` so I can sort products by price later on. Please note that I'm just starting to get my hands dirty with code so any further elaboration will be much appreciated!


Giving WordPress Its Own Directory together with index.html

I want to power my website from `http://www.example.com` and not from `http://www.example.com/foldername` I've completed this task and this is working but before people actually get to the WordPress website they must pass another website-page. See the scheme below. `www.example.com`: shows a page with some information and a link to navigate to the wp site. My problem now is that when I follow the steps on http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory, my index file is fighting with the one from WordPress. I hope people understand the problem. **EDIT** Changing `.htaccess` to:               DirectoryIndex home.htm index3.php index.htm index.html default.htm      This is working to change the homepage, but as soon you are on the WordPress website and you click on home in the menu, you get back to the homepage set in the `.htaccess` file.


Stop wordpress from hardcoding img width and height attributes

I'm wondering if there's a simple way top stop WordPress automatically hardcoding featured image height and width attributes, other than using regex... As I'm using a flexible grid for my project (who isn't!) this is causing some funky image issues.


Open div inside a custom post-type with Fancybox

I did have a similar problem with this but never managed to find a solution... I have a custom post-type with a number of pages, but what I want to do is grab a particular div from the pages and display them in a Fancybox when I link to them. Here is the HTML: **about.php** \- this page has the fancybox links, so I want the links on this page to grab the div from another page called **single-team.php** :
             <?php $teamFeed = new WP_Query(array('post_type' => 'team', 'orderby' => 'name')); ?>             <?php while ($teamFeed->have_posts() ) : $teamFeed->the_post(); ?>
                 <?php if (has_post_thumbnail( $post->ID )): ?>                     <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>                     <a href="<?php the_permalink() ?>" rel="bookmark" class="teamThumb" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=71&h=71&zc=1" alt="<?php the_title(); ?>" />                 <?php endif; ?>                 <a href="<?php the_permalink() ?>">
<?php echo substr($post->post_title,0,50); // short title ?>...

             <?php endwhile;?>
      **single-team.php** \- This is the content I want to display in the Fancybox div on **about.php**. **single-team.php** has other elements within it, but I've just pasted the code I was to grab here...

<?php the_title(); ?>
             <?php if (has_post_thumbnail( $post->ID )): ?>                 <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>                 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=640&h=157&zc=1" alt="<?php the_title(); ?>" />             <?php endif; ?>             <?php while (have_posts()): the_post(); ?>                 <?php the_content(); ?>             <?php endwhile; ?>

      And of course, the jquery:               $(document).ready(function() {         $('a.teamThumb').live('click', function(e){             e.preventDefault();             var url = $(this).attr('href');             url = url + ' #productMainPanel';             $('#productMainPanel').load(url, function(data, stat, req){                 $(this).fancybox();             });         })               });      Does anyone know how I can get this to work? Because so far, it's either just linked straight to the page or it's opened up the Fancybox but displayed the entire **single-team.php** page. Thanks


Admin Dashboard - Recent Comments source

I need to see the source file for the admin dashboard widget that shows recent comments, can anyone point me to the exact php file that does this? I can't find it anywhere on the codex or in google searches. Thanks


Custom Permalinks for CPT causing 404 errors for 'normal' single post pages

I'm having a problem with the permalink structure of a Custom Post Type which is conflicting against the normal single posts (in the 'posts' post type which comes as standard with WordPress). Heres the code:               <?php          // Properties     // -------------------------------------------------------------     function _init_properties_post_type() {            // Property types         //---------------------------       register_taxonomy(           'property_type',           array( ),           array(             'labels' => array(               'name' => __( 'Property types' ),               'singular_name' => __( 'Property type' ),               'search_items' => __( 'Search Property types' ),               'popular_items' => __( 'Popular Property types' ),               'all_items' => __( 'All Property types' ),               'parent_item' => __( 'Parent Property types' ),               'parent_item_colon' => __( 'Parent Property type:' ),               'edit_item' => __( 'Edit Property type' ),               'update_item' => __( 'Update Property type' ),               'add_new_item' => __( 'Add New Property type' ),               'new_item_name' => __( 'New Property type' ),             ),             'public' => true,             'show_in_nav_menus' => true,             'show_ui' => true,             'publicly_queryable' => true,             'exclude_from_search' => false,             'hierarchical' => true,             'query_var' => true,             'rewrite' => array( 'slug' => '', 'with_front' => false ),           )       );            // Create post type       //---------------------------       register_post_type( 'property',         array(           'public' => true,           'show_ui' => true,           'capability_type' => 'page',           'hierarchical' => true,           'publicly_queryable' => true,           'exclude_from_search' => false,           'menu_position' => 21,           'menu_icon' => 'dashicons-admin-home',           'query_var' => true,           'taxonomies' => array( 'property_type' ),           'rewrite' => array(             'slug' => '%property_type%',             'with_front' => false           ),           'supports' => array( 'title', 'excerpt', 'thumbnail', 'page-attributes'),           'labels' => array(             'name' => __( 'Properties' ),             'singular_name' => __( 'Property' ),             'add_new' => __( 'Add New' ),             'add_new_item' => __( 'Add New Property' ),             'edit' => __( 'Edit' ),             'edit_item' => __( 'Edit Property' ),             'new_item' => __( 'New Property' ),             'view' => __( 'View Properties' ),             'view_item' => __( 'View Property' ),             'search_items' => __( 'Search Properties' ),             'not_found' => __( 'No Properties found' ),             'not_found_in_trash' => __( 'No Properties found in Trash' ),           )         )       );            add_filter('post_type_link', 'properties_permalink_rewrite', 1, 3);       function properties_permalink_rewrite( $post_link, $id = 0, $leavename = FALSE ) {           if ( strpos('%property_type%', $post_link) === 'FALSE' ) {             return $post_link;           }           $post = get_post($id);           if ( !is_object($post) || $post->post_type != 'property' ) {             return $post_link;           }           $terms = wp_get_object_terms($post->ID, 'property_type');           if ( !$terms ) {             return str_replace('%property_type%/', '', $post_link);           }           return str_replace('%property_type%', $terms[0]->slug, $post_link);       }            // Fix permalinks       //---------------------------       flush_rewrite_rules();          }          add_action('init', '_init_properties_post_type');                    add_action( 'init', 'wpse16902_init' );     function wpse16902_init() {         $GLOBALS['wp_rewrite']->use_verbose_page_rules = true;     }          add_filter( 'page_rewrite_rules', 'wpse16902_collect_page_rewrite_rules' );     function wpse16902_collect_page_rewrite_rules( $page_rewrite_rules )     {         $GLOBALS['wpse16902_page_rewrite_rules'] = $page_rewrite_rules;         return array();     }          add_filter( 'rewrite_rules_array', 'wspe16902_prepend_page_rewrite_rules' );     function wspe16902_prepend_page_rewrite_rules( $rewrite_rules )     {         return $GLOBALS['wpse16902_page_rewrite_rules'] + $rewrite_rules;     }      The actual Custom Post Type itself is working perfectly and I've got the correct permalink structure I want for those but for some reason I can't get the normal post single pages to work. The categories for it do work however. Heres the permalink structure for normal posts within the admin area:               /blog/%postname%/      I've also found that if I delete the Custom Taxonomy ( _property_type_ ) then this will allow the posts to work. Also, deleting the _rewrite_ rules on both the Taxonomy & Post Type; as well as removing the _properties_permalink_rewrite_ function makes the posts work. Any help would be awesome.


add action wp_head not working

I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making. The plugin has an interface where the user enters some details which are then added to the options table. This is all working perfectly fine so far. But then I want to write a conditional statement if there is an open then add to head. Basically I have this all in the main plugin file and it looks like this;               if(get_option( 'MyOptionName' )){         function testingone(){ ?>             <script>var Script = GoesHere; </script>         <?php ;}         add_action('wp_head','testingone');     }      I have tried placing this inside the actual block that pulls the data and then adds to options, but that didn't work, then I decided to do it this way, where it looks to see if there is an option in the table but this also doesnt inject anything to the head. Some places I have seen people put the add_action above the function, but in the codex it shows an example of it below. but either way I have tried and failed. Can anyone see where this is going wrong? Cheers


Pretty product permalinks with Woocommerce shop/category/subcategory/product-name

I'm having a tough time figuring out how to do pretty permalinks for Woocommerce with this kind of structure "www.page.com/shop/category/subcategory/product-name" The best I could come up with was "www.page.com/somename/cateogry or subcategory/product-name" Which in my opinion isn't SEO friendly. When I set woocommerce product custom base name the same as shop page name, it gives 404 error, and it seems there is no option for having both category and subcategory in the product permalinks, it's either one or another. Thanks in advance!


Admin post comments not returning in get_comment function

I don't get the comments of the post submitted by admin in user side. From the users side, I want to show the admin post and each posts comments. I am writing the following code,               $args = array(                     'post_id' => $post->ID                 );     $comments = get_comments($args);     foreach ($comments as $comment) :     // show comments here;     endforeach;      Do you have any idea ? I am using wordpress 3.6


Problem with drop down with custom categories

I am having an issue with using a custom category. The category is called counties and includes the following entries: Warwickshire, West Lothian, Westmorland, Wiltshire, Worcestershire and Yorkshire I can make these counties appear and list out by doing:               <?php wp_dropdown_categories( 'taxonomy=counties' ); ?>     <input type="submit" name="submit" value="view counties" />      But whenever I select one and click the submit button it simply takes me to a 404 page. I have tried creating a category-counties.php file but this doesn't work either. Any help appreciated. Thanks


query_post order desc

According to:http://codex.wordpress.org/Function_Reference/query_posts To show all posts in a category:               query_posts( array ( 'category_name' => 'The Category Name', 'posts_per_page' => -1 ) );      Works great, but if I want to show the posts > ORDER BY ID DESC Anyone have any idea how to do that?


What is the best way to include a widget in a Page?

I am setting up a new WordPress blog and would like to include a widget in the content of a Page. I found some forums describing PHP hacks which appeared to apply to older versions. With WordPress 3.0.1 what is the best way to include a widget in a page?


How To Retrieve An Image Attachment's Alt Text?

I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt text isn't included when when wp_get_attachment_image_src() is used. I don't think WP has a function to retrieve it, so I need my own. To write that function I need to know...Where is the alt text for an image stored? My attachment page uses `wp_get_attachment_image_src()`, which doesn't include the alt text.
     <?php      if ( wp_attachment_is_image( $post->id ) ) :          $att_image = wp_get_attachment_image_src( $post->id, "large");?>              <a href="<?php echo wp_get_attachment_url($post->id); ?>"              title="<?php the_title(); ?>"              rel="attachment">         <img class="attached_img"              src="<?php echo $att_image[0];?>"              width="<?php echo $att_image[1];?>"              height="<?php echo $att_image[2];?>"               class="attachment-medium"              alt="<?php $post->post_excerpt; ?>" />               } <?php endif;?>
      This shows:

        I'm aware that the `$post->post_excerpt` is being called in the above code, but I am not sure what to replace it with to get the image's alt attribute.


Offering Ads Dependent on Visitor Type?

I wish to be able to give different ads to visitors of different "types". For example:   1. People from country X will get one ad, while people from country Y will get no ads.   2. First time visitors will get an ad. Returning visitors won't. The ad can be either google ads or something else. Any plugin or hack to do it?


Tracking RSS subscribers in Google Analytics

I wish to tag visitors who came to my site and clicked the RSS button. My goal is to "Segment" this visitors in Google Analytics, so I'll be able to see where my "new readers" are coming from. How can it be done in WordPress?


Need a WordPress Plugin for Google Analytics, Favicon, Meta Keywords & Description?

I am using WordPress for my site and need to add Google Analytics, a favicon, meta keywords, meta descriptions. I searched for plugin that would do this and found different plugins for each. Can anyone suggest me a plugin which can add Google Analytis, a favicon, meta keywords and meta description? Any help will be appreciated. Thanks in advance


Loading External Scripts in Admin but ONLY for a Specific Post Type?

So I continue to run into this issue and I just looking for the best and simplest solution to solve this problem. I have come to make use of custom post types in many different projects and have extended these with custom metaboxes which I have then further extended by adding custom scripts such as jQuery event calendar selectors... All of this works great except for one key issue... I don't want these custom jQuery scripts to load on every page in the admin. I am essentially just looking for a way to just have these custom jquery fields loaded when I am on the "edit post" page for a SPECIFIC post type. What's the best solution here? * * * ## UPDATE 1 First of all, thank you very much. I am actually shocked that plugin developers dont make sure of things like this because as I am finding out this is one of the key reasons that problems exist with different plugins. I am having some further issues though with this. For example... I have modified the script to call the if statement like this: > `if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php' && > $typenow=='events')` As you can see I am trying to set things up so that my scripts ONLY get called when I am adding or editing a post within the post type of "events". I don't want the script to load on any other page and also don't want it to run on the list of page within the post type of "events" so I would think the if statement is correct. The problem however seems to be that the script only gets loaded when I create a new post within this post type but it does not seem to work when I am editing an existing post. Could you test this out and maybe let me know what I could be doing wrong? Here is the exact code which I am using... maybe there is a better or simple way of doing this?               <?php     // INCLUDE METABOX CUSTOM JQUERY DATEPICKER 2     add_action('admin_init','load_admin_datapicker_script');     function load_admin_datapicker_script() {       global $pagenow, $typenow;       if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php' && $typenow=='events') {         $ss_url = get_bloginfo('stylesheet_directory');         wp_enqueue_script('jquery');         wp_enqueue_script('custom_js_jquery_ui',"{$ss_url}/admin-metabox/js/jquery-ui-1.7.1.custom.min.js",array('jquery'));         wp_enqueue_script('custom_js_daterangepicker',"{$ss_url}/admin-metabox/js/daterangepicker.jQuery.js",array('jquery'));         wp_enqueue_script('custom_js_custom',"{$ss_url}/admin-metabox/js/custom.js",array('jquery'),NULL,TRUE);         wp_enqueue_style('custom_css_daterangepicker',"{$ss_url}/admin-metabox/css/ui.daterangepicker.css");         wp_enqueue_style('custom_css_jquery_ui',"{$ss_url}/admin-metabox/css/redmond/jquery-ui-1.7.1.custom.css");       }     }      Also... if I wanted to add three post types and load different JS scripts for each post types then would I just duplicate the code above three separate times or is this not a good way of doing this? For example... would it be better to just call: global $pagenow, $typenow; At the top of my functions file or does it matter or complicate things when I duplicate it more than once? On a different problem related to the same... I for example am utilizing the "gravity forms" plugin but I have noticed their scripts run on every page on the admin which is causing issues with other plugins. How would i go about modifying their script to ensure the scripts only get loaded when I need them. * * * ## UPDATE 2 I have modified my functions.php file with the code provided by Mike (below) however it seems that the applicable javascript is still being included when you create a NEW Post or Page. This means that when you attempt to create a NEW Post or Page either by creating a new default wordpress post/page or when you create a NEW post/page based off one of your custom post types. The code proposed by Mike IS working on all other admin pages and it DOES work when you "EDIT" an existing post/page or custom post type. Any suggested modifications to make this work correct? Here is my current code:               <?php        add_action('admin_init','load_admin_datapicker_script');        function load_admin_datapicker_script() {         global $pagenow, $typenow;         if (empty($typenow) && !empty($_GET['post'])) {             $post = get_post($_GET['post']);             $typenow = $post->post_type;         }         if (is_admin() && $pagenow=='post-new.php' OR $pagenow=='post.php' && $typenow=='events') {             $ss_url = get_bloginfo('stylesheet_directory');             wp_enqueue_script('jquery');             wp_enqueue_script('custom_js_jquery_ui',"{$ss_url}/admin-metabox/js/jquery-ui-1.7.1.custom.min.js",array('jquery'));             wp_enqueue_script('custom_js_daterangepicker',"{$ss_url}/admin-metabox/js/daterangepicker.jQuery.js",array('jquery'));             wp_enqueue_script('custom_js_custom',"{$ss_url}/admin-metabox/js/custom.js",array('jquery'),NULL,TRUE);             wp_enqueue_style('custom_css_daterangepicker',"{$ss_url}/admin-metabox/css/ui.daterangepicker.css");             wp_enqueue_style('custom_css_jquery_ui',"{$ss_url}/admin-metabox/css/redmond/jquery-ui-1.7.1.custom.css");         }        }     ?>


Comment filtering (search)

Basically I want to develop the ability to search comments on my site. A form with input field where the visitor can enter a search string, which tells WP to display only comments that contain that search phrase. I think the best way to do this is by making a custom comments_template() function, then filtering out comments that don't contain `$_GET['search_phrase']`. Any pointers/suggestions, especially on the SQL part are welcome :)


Need advice on which plugins to use - eCommerce

I need a solutions that allows for custom pricing based on roles that WILL display product page. I have found some plugins that allow custom pricing, but only display at the cart. Has anyone done this before? I have included background for the site below as a reference. * * * DETAILS: System Requirements:   * WordPress   * WooCommerce Allowed solutions should include:   * Plugins (possibly WooCommerce Dynamic Pricing, WooCommerce Conditional Content, but others are totally fine)   * Minimal system file edits (Zero if possible) Required Functionality:   * eCommerce system for creating Purchase Orders (orders without payment) Future implementation of online purchasing   * Products must have variations eg. Selling wood blocks Wood blocks (listed items) listed by shape (Each shape has variations) \- Type of wood \- Color of wood stain \- Number of holes in block   * All variations must be able to be individually price based on user role (and preferably per user). (optimally would default to a base price unless specified)   * User need to be able to self register, but have NO access to any pricing until approved (no ability to see any products is an acceptable solution, if no other option)


WP_Editor Shortcode Issue

I have created a front-end editor using wp_editor that functions as it should. Upon testing I have noticed that it is stripping out any shortcodes that have been inserted in the content. I have looked into this issue and found that it's the 'ob_' (output buffering) that is removing them. If I remove this output buffering then the shortcodes display fine, but it breaks the functionality I have created for the editor. How would I keep the code I am using below, but amend it to make sure that all shortcodes are being displayed? Any help/ideas greatly appreciated, S.               if(!is_feed() && current_user_can( 'manage_network' ) ) :          function ps_add_post_editor($content) {     global $post;     $settings = array(         'wpautop' => true,         'media_buttons' => false     );         $content .= '
<form action="" id="page-content-editor-panel" method="post">' . wp_create_nonce( 'ajax_my_post_edit_nonce' ) . '' . ps_get_wp_editor($post->post_content, 'textarea-' . $post->ID , $settings) . '<input type="submit" id="feesavebtn" value="Save" /></form>Cancel

 saving...
                            ';          return $content;     }          function ps_get_wp_editor($content,$textarea,$settings) {     ob_start();     wp_editor($content, $textarea, $settings);     $edior_html_code = ob_get_contents();     ob_end_clean();     return $edior_html_code;     }      add_filter('the_content', 'ps_add_post_editor');          add_action('wp_ajax_add_foobar', 'prefix_ajax_add_foobar');     add_action('wp_ajax_nopriv_add_foobar', 'prefix_ajax_add_foobar');          function prefix_ajax_add_foobar() {     if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax_my_post_edit_nonce' ) )           {               $myfee_post = array();         $myfee_post['ID'] = $_POST['post_id'];         $myfee_post['post_content'] = $_POST['post_data'];         wp_update_post( $myfee_post );               die("This page has now been updated.");      } else {                 die("Unable to process your request at this time.");     }     }          endif;


Can you have a blog in a subdirectory hosted on a different server?

I am interested in having a blog on my site which will be in a subdirectory of the main wordpress homepage e.g. website.com/blog however, I am interested to know if there is a way to host the blog on a separate server - primarily because I don't want to overload the server for the rest of the site if there is a lot of traffic going to the blog. I am keen on the idea of it being a subdirectory though. Anyway - just thought there would be someone smarter than me who might have a bright idea :)


Querying custom posts and regular posts

I want to populate the "Greenway News" box on this page with the three latest headlines from the site's Press section AND blog. The blog is a regular WP blog and I am currently using this code to get my results: `<?php query_posts('cat=3&posts_per_page=3'); ?>` The Press page is a custom post type. I can get the following code to work as well: `<?php query_posts( array( 'post_type' => 'portfolio', 'toolkit' => '2011' ) ); //the loop start here if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> ` However, I am a PHP nitwit and have failed to combine the two calls in to one. Is this not feasible? Thank you for any help.


Check if a script/style was enqueued/registered

Is it possible to test whether a script or a style was registered using `wp_register_script/_style` or `wp_enqueue_script/_style`? All functions doesn't return a value and I'm completely clueless. I need it to switch between different functions depending on stylesheet- libraries and scripts I offer. Thank you!


Query Posts or Get Posts by custom fields, possible?

If I were to take a standard query post.               <?php query_posts('post_type=payment'); while (have_posts()) : the_post();?>      Only this time I would like to query the post by 2 custom fields that it may contain.               <?php query_posts('post_type=payment'.get_post_meta($post->ID,'bookingref', true).get_post_meta($post->ID,'customerref', true) ); while (have_posts()) : the_post(); ?>      That doesn't work. Is something like this possible and how is it done? Any ideas? Marvellous


Any plans for a non backwords compatible WP release?

Imagine all the old_functions_that_do_the_same_thing_as_new_functions() being ripped out. Think of the consistency and improved work flow while working with different themes and plugins. Is there already a branch like this or is there something in the pipeline?


getting "Object of class WP_Post could not be converted to string" - when it is a string

I have the following code in my functions.php, which executes a script upon publish:               function save_new_post($post_ID)     {              $site_root = '/home/forexmag/public_html/directory2';         $post = get_post($post_ID);         $title = $post->post_title;         $breaking_news = false;              $categories = get_the_category($post_ID);         if (is_array($categories) && !empty($categories))         {             foreach ($categories as $cat_det)             {                 //this is the id for the breaking (bad) news                 if (5668 == $cat_det->cat_ID)                 {                     $breaking_news = true;                     break;                 }             }         }              $exec_code = "/usr/local/bin/php                  $site_root                  /crons/cron_notify.php '$title' $post_ID 2 " . intval($breaking_news);         exec(             $exec_code         );          }     add_action('publish_page', 'save_new_post', 10, 1);      When I publish a new post I keep getting the following error:               Catchable fatal error: Object of class WP_Post could not be converted to string in /home/forexmag/public_html/wp-content/themes/forex_magnates/functions.php on line 712      This line is where I set the `$exec_code` var. However, as you can see, and as I confirmed via var_dump, the $title variable **is** a string. What am I missing?


How to attach image to custom post type

I am using this answer to upload files in my custom post type meta box. How do I attach the actual attachment post to parent post(custom-post-type), so that in wordpress admin, I know that the image is attached to the post. I could do this manually, but thats not why I am here. Here is a screenshot of the portion of WordPress where the images can be attached manually ![enter image description here](http://i.stack.imgur.com/00Qn0.png)


Editing Featured Image Display When Creating Post

I am trying to find out a way to edit the width of the thumbnail that displays for the featured image on the "Edit Post" page (note: not the front end of the site, I'm talking about when making or editing a post and you set the featured image on Wordpress's backend). I would like it so that when I've set a featured image on Wordpress's backend, it displays to me at, say, 50px wide (and the height of course adjusts automatically). The reason I need to do this is because I've setup my theme where I can "crop" the featured image on the front page to move up or down based on margin and padding in a custom field I've setup. That way I can "crop" the thumbnails exactly how I want. So I want the thumbnails on the Wordpress edit page to be the same height as the front end of the site so I can eyeball how much pixels to move the images up and down before posting the news story. This way, I'll be able to better center the image on the back end rather than having to publish the story then run to the front page to see how much I need to move it up or down (since the image has been sized correctly). It would also be nice if someone could tell me how to apply a CSS class to the featured image on the backend as well. That way, I can overlay in a little ruler that can assist me in determining how much I should move the image up or down. Thank you!


Using Dynamic Data Pulled from a MySQL Table in a WordPress Page

I'd like to pull data from a mySQL database and put it in some tables in a WP page. I'm using WP 3.1.1. Imagine that I've got a table of sales figures that I want to pull from a mySQL database and then display them in a table on a WordPress page. I know just enough php to make a db connection, pull the data, and echo it out. But, I'm not sure what is the best way to do this in conjunction with WordPress. a) Is it okay if I put my tables in the WordPress database? (This way I could use the WP's database connection). Would they cause some sort of conflict? Would they be over-written when I upgrade WP? b) Where should I put my php code? Can I just plop the php in the WP's HTML editor when I create a new page? If not, should I just make a php file and include it somewhere? If so, where would I put the include line? c) Is there a plugin that allows you to pull data from a database? I've seen some table plugins, but the data had to be input by hand or pulled from XML. Unfortunately, I've got too many tables to input the data by hand. Any suggestions? Thank you! -Laxmidi


How to make ajax call in wordpress in right way?

I am trying to using jquery ui tabs with ajax calls to run a function. Here is the code i am using:               function ajax_load_user_feed(){         if(isset($_GET['type'])) $type = $_GET['type'];         if(isset($_GET['userid'])) $userid = $_GET['userid'];              if(!$type && !$userid){             $type = 'error';             show_feed($type);             die();         } else {             $user_info = get_userdata($userid);             show_feed($type, $user_info);             die();         }     }     add_action('wp_ajax_load_user_feed', 'ajax_load_user_feed');               function show_feed($type, $user){         if($type == 'rss'){           echo '
Show rss Feed
';              } elseif($type == 'twitter'){             echo '
Show twitter Feed
';              } elseif($type == 'facebook'){             echo '
Show Facebook Feed
';         } elseif($type == 'error'){             echo '
Something is wrong with the request!
';         }     }      **The html for jqurey ui tabs:**

                                 <?php  if($author->feeds): ?>
<a title="activity_feed" href="<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=load_user_feed&type=rss&userid=<?php echo $author->ID; ?>">Blogs
                                     <?php endif; if($author->twitter): ?>
<a title="activity_feed" href="<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=load_user_feed&type=twitter&userid=<?php echo $author->ID; ?>">Twitter
                                     <?php endif; if($author->facebook): ?>
<a title="activity_feed" href="<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=load_user_feed&type=facebook&userid=<?php echo $author->ID; ?>">Facebook
                                     <?php endif; ?>

Activity Feed

      What i am trying to do here is calling admin-ajax.php file to call the function `load_user_feed();` function. Now the code is works for logged in users only. I mean when users logged in the see the feeds but logged out users are seeing only `-1` in output. Here is the page: http://citystir.com/author/designdons/ There must be some good way to call ajax with jquery ui tabs. Waiting for your help. Thanks!


Easy-Post-Type is visible in search, but 404 when clicked

* I've installed Easy Post Types   * created a custom post type: Attractions   * created an Attraction: (joes-cafe)   * created a category set: attraction-type (cafe)   * copied single.php to single-attractions.php   * added the category: cafe to wp-navigation-menu But when I visit the menu item, I get a 404, when i search for the cafe by name, i see an excerpt, but clicking its title gives me a 404! Any Clues? What am i doing wrong? I am using a Thematic child theme, and i duplicated single-attractions.php as single-attraction.php just in case, because i found the distinction confusing... Thanks, Tim


how much php coding do i need to know in order to create web blog using wordpress.org

I want to create web blog using WordPress so in order for me to create that blog, what level of php coding do I need to know. At the moment, I'm just learning the basis of php I kind of started designing the blog but just could not get around the PHP coding bit so just wondered weather I need or not Can I create the blog without using PHP coding so please I need some advice on weather I must use PHP to create the blog or does not matter if I use or not.


How to change permalinks to show categoryname/post-name?

I've placed the string below into my custom permalinks input but it does not appear to have any effect... > /%category%/%postname%/ I'm trying to insure that my post links are in the form of /category- name/post-name


Create slugs programmatically

I'm updating programmatically posts in a WP 3.01 install, using custom made tools. Sometimes I do change programmatically `post_status` from DRAFT to PUBLISHED using custom `SELECT` queries, however this seems spoiling posts permalinks. When in a DRAFT state, posts have the following link structure               http://myblog.com/?p=73006      Could there be some "trick" to force a change in the link structure, generating the proper permalink?


How to store a medium amount of options?

I develop a plugin that has a not too small number of settings. So far, there has been a fixed number of them, so I store them in a Wordpress option. Now I consider letting users define (an arbitrary number of) styles, that is sets of options. Since these will still be rather general options, none of the categories listed in the Codex really fits. Storing all that stuff in one option is clearly not a good idea, but creating a whole database tables does not feel right, either. What are your recommendations? Note that I post one idea I have as an answer in order to separate it from the question. Would mark the question CW, but that seems to be disabled here?


How to show parent pages on a specific page if user is logged in?

I have tried with the code bellow, but it's not working. 43 is the ID of the forum page. Also I'm trying to use `is_user_logged_in()`:               function forumpage()     {     global $post;     global $wp_query;          if ($post->post_parent != 43)     {         $thePostID = $post->post_parent;         // echo 'You are not on the forum page';     }     else     {         $thePostID = $wp_query->post->ID;         // echo 'You are at the forum page';     }     }     add_action( 'init' , 'forumpage' );


Does settings API create settings on run time?

I'm tweaking a plugin and I'd like to have an option value different for each backoffice user. Currently the options are defined using the `add_settings_field` method that is performed in the `admin_init` hookup. My question is, could I register a new set of settings by prefixing my settings using the current user ID? Such a way, if valid, could help to solve other problems, such:   * How to Set an Individual Homepage for Each User?   * Settings- API: Creating setting fields on-the-fly


Unable to change the "Read more" text inside the_excerpt

I am unable to change the "Read more" text while using the excerpt. I've tried the following code:                function new_excerpt_more( $more ) {      return '       Custom text';      }           add_filter( 'excerpt_more', 'new_excerpt_more' );      And this is how I am printing the excerpt:                <?php the_excerpt(); ?>      But it doesn't seem to work. Any ideas?


Print Archive post

this code               <?php wp_get_archives( array( 'type' => 'yearly', 'limit' => 12 ) ); ?>      print me only year 2013. And this code print me all post:               <?php wp_get_archives( array( 'type' => 'postbypost', 'limit' => 20, 'format' => 'html' ) ); ?>      But i whont list: year2013   * post2013   * post2013   * post2013   * post2013 year2012   * post2012   * post2012   * post2012   * post2012


Query Posts by date range with fixed beginning and end

I need to get posts from a certain timeframe. I am using the `posts_where` filter. I want to specify a beginning date and an end date. This is the function I use:               function filter_where( $where = '' ) {         $where .= " AND post_date >= '2012-03-01' AND post_date =< '2014-03-01'";         return $where;     }      This Filter returns nothing. The error ust be located anywhere around the second `AND`. This is my function:               number_sold_mottos( $from, $till );          function number_sold_mottos( $from, $till ){         add_filter( 'posts_where', 'filter_where' );         $args = array( 'posts_per_page' => -1, 'post_type' => 'shop_order'  );         $post_ids   = array();         $the_query = new WP_Query( $args );         $last_order_ids = array();         if ( $the_query -> have_posts() ):             while ( $the_query -> have_posts()) :                 $the_query -> the_post();                 the_title();             endwhile;         endif;         wp_reset_query();         remove_filter( 'posts_where', 'filter_where' );      }               function filter_where( $where ) {         $where .= " AND post_date >= '2012-03-01' AND post_date =< '2014-03-01'";         return $where;     }      Any help is welcome.


Remove author bio from posts of a specific author

I am trying to find how all posts of a specific author will appear without the author box, while all the others authors posts will have their author boxes. Can somebody help me with this?


How Do I Load My Action Earlier Enough?

With add_action, I want to intercept as early as I can in my plugin and send a 304 Not Modified header per some rules. **Does anyone know what the order is of events?** When I view this page, it seems to hint that the best place for this would be plugins_loaded, and that it comes before the init event. Is that correct? The page in that link doesn't describe what the event order is, but seems to imply it.


Front end update_post_meta Help

I followed the help provided in this question but cannot get the form save the data. I tried using 'save_post' action hook to try and save the post like we do for admin side. Any help would be highly appreciated. My code is as below: /* This is above the get_header() of the template */               if ( isset( $_POST['grn_data'] ) && wp_verify_nonce($_POST['grn_data'],'update_grn_postmeta') )     { //if nonce check succeeds.         global $post;         $postid = $post->ID;         $data = $_POST['grn'];         update_post_meta($postid,'grn',$data);     }      And the form is in a seperate file and i am calling it whenever it is necessary.               <?php     /* This file is to provide input fields to record data from Front End */     function grn_data($c) {             global $post;             $grn = array();     ?>
             GRN

             <?php             $curgrn = 'grn';             $grnval = get_post_meta($post->ID, $curgrn, true); ?>             <form method="post" action="">             <?php wp_nonce_field('update_grn_data','grn_data'); ?>             <input type="text" size="30" maxlength="30" name="<?php echo $curgrn; ?>" value="<?php echo $grnval; ?>" />             <input type="submit" value="Save" />             <?php var_dump($grnval); ?>             <?php var_dump($curgrn); ?>             </form>

     <?php }          ?>      Please can someone advise on this? I have been stuck like this for days now.


registration plugin

I am working on a website and need the fallowing functionality: **From the admin area, I need to be able to add/remove/edit codes/tokens that I will later send out to people so they can come to my site and use them to register a user.** I just do not want people to be able to register to my site without a code that I will give to them before hand. Does that make sense? I do not want people that I do not know to be able to register(people that does not have one of the preset codes), but at the same time I would like to automate it so they do not have to wait on me to create a user name for them. EDIT: I hope that this improved my question. For example:   I go to my admin page and add a new code "meeting20120505". After I have this code already in the database I can go to a meeting and if I meet someone there that he is interested in my website and would like to register I will give him this new code I just made(meeting20120505) and with it the person could go to my website and register. The registration could go in two ways:   1\. I will give him a link to a for that has one field that he will enter the code and if the code he matches the codes in my database he will be redirected to a registration page.   2\. On my registration page I have a field that is required and will be validated and id there is no match he will not be able to register. **Please if you are going to mark me down at least share with me why!   Thanks.**


Multiple next / previous

One of my custom post types requieres multiple next/precious post titles buttons for usability issues. Does anyone know how to get this working? Example: **LATEST POST (Today)** [previous post title] - [previous post title] - [previous post title] **YESTERDAY POST** [next post title] - [previous post title] - [previous post title] **LAST POST** [next post title] - [next post title] - [next post title] Thanks in advance.


Page for custom post type

I'm a newbie in WordPress and I've just created a new custom-post type called arts. Is there a way I can create a custom page to display the 'art's custom type? The custom-post type has thumbnails which I'll be displaying on the post and 'arts'are a bit more different form other posts. Any help offered will be highly regarded.


How to create additional thumbnails of custome size in nextgen gallery while uploading images?

Is there any way out to create additional thumbnails of custome size in nextgen gallery while uploading images? For example I would like to create 3 thumbnails of size 25*30, 100*50, and 400*350 to display them in certain custom pages.Or can i add custom code to resize when image upload is triggered and if so where?


WordPress 4.0 Cookie Authentication to avoid nonce error when publishing a post and page

Cookies are now tied to internal sessions in WordPress 4.0. This means plugins using basic cookie authentication will have trouble because a token is required for publishing a post or page (as well as update a plugin or core). I've seen this reported for three different bridge plugins. The old method (used in numerous plugins) was to use `wp_set_auth_cookie($user_id,0,0)` but this will no longer work. The user is logged into the site but the user with the correct roles cannot publish a post or page. Instead an nonce error is returned ("Are you sure you want to do this?) This is the new code (among many other attempts) I've tried but still get the same nonce error.               wp_set_auth_cookie( $user_id, 0, 0 );     $manager = WP_Session_Tokens::get_instance( $user_id );     $token = $manager->create( $expiration );      To overcome this issue, and temporarily, the wp_verify_nonce is set to always return 1. However, I'd like to know how to create the token upon the set of the cookie. Has anyone overcome this issue yet? Since this is all new code for WP, does anyone have any suggestions?


Duplicating custom post type and its posts

I have a custom post type with over 100 posts. I want to create another custom post type and have the same posts with the same post titles. Is there a simple DB query that will allow me to do this, or am i stuck with having to re-create each post?


Showing a different gallery in a seperate post

i am using the `[multigallery]` function and I was wondering if there is a way to use the function to call attachments from another post. For example if i was writing a post about taylor swift and I wanted to include attachments from another taylor swift post using the multigallery shortcode how would I do so. Like by adding `id=` to the shortcode `[multigallery id=???]` where the id would be the post number and it will grab attachments from that post. here is the code that i am currently using in my function.php file               function multi_gallery_shortcode(){     global $post;     $before     = sprintf('
%s
',$post->post_title);      $gallery_sc = sprintf('
[gallery columns="6" order="ASC" orderby="menu_order" include="%s" link="gallery"]
',get_random_gallery_images($post->ID));     $after      = sprintf('
%d Photos

', get_total_attachments($post->ID));     return $before . do_shortcode($gallery_sc) . $after;     }          function get_random_gallery_images($post_id){      global $wpdb;      $ids = "";      $args = array(          'post_type'      => 'attachment',          'post_mime_type' => 'image',          'posts_per_page' => 6,          'post_status'    => 'any',          'orderby'        => 'rand',          'post_parent'    => $post_id,      );      $attachments = get_posts($args);      if ($attachments) {          $tmp=array();         foreach ($attachments as $attachment) {                 $tmp[] = $attachment->ID;          }           $ids=implode(",",$tmp);     }      return $ids;      }          function get_total_attachments($post_id){     $args=array(         'post_parent'     => $post_id,          'post_mime_type'  => 'image',          'post_type'       => 'attachment',     );      return count(get_children( $args ));     }          add_shortcode('multigallery', 'multi_gallery_shortcode');


How do I troubleshoot translation issues?

I am building a WP site using the Panoramica theme by CPOThemes, and so far most of it is working really well. However, not all translations work as they should (or at least not as I expect them to). Specifically, I can't figure out why the header "Archives" on the main page isn't translated. The site can be found here for you to look at - "Archives" is on the lower right. This is what I have, that I thought would work:   * a file named `/wp-content/languages/sv_SE.po` (and .mo) that I have not changed, but I downloaded it and opened in poedit and the key "Archives" exists and is translated correctly.   * The code line that outputs the Archives header in the theme (specifically in `sidebar-home.php`) looks like this:
<?php _e('Archives', 'cpotheme'); ?>
        * At the top of my `functions.php`, I have the following line:              <?php load_theme_textdomain('cpotheme'); ?>        * Somewhere in `wp-config.php`, I have               define('WPLANG', 'sv_SE');      Why doesn't this translate correctly?


Wordpress choose wrong database

I have 2 databases. When I include the database connection (`with a include('filename.php');`) wordpress acts really strange. I can't login, the wordpress username and password is right but it tries to connect to the other database (which I can see when I turn debug on).               WordPress database error: [Table 'api.apiwp_options' doesn't exist]     SELECT option_value FROM apiwp_options WHERE option_name = 'widget_pages' LIMIT 1     WordPress database error: [Table 'api.apiwp_options' doesn't exist]     SELECT option_value FROM apiwp_options WHERE option_name = 'widget_calendar' LIMIT 1     WordPress database error: [Table 'api.apiwp_options' doesn't exist]     SELECT option_value FROM apiwp_options WHERE option_name = 'widget_links' LIMIT 1     WordPress database error: [Table 'api.apiwp_options' doesn't exist]     SELECT option_value FROM apiwp_options WHERE option_name = 'widget_tag_cloud' LIMIT 1     WordPress database error: [Table 'api.apiwp_options' doesn't exist]     SELECT option_value FROM apiwp_options WHERE option_name = 'widget_nav_menu' LIMIT 1      It's like they can not separate the connections. Anything that can help me in the right direction? The content also stops working. **Edit: Clearifying** My Database connection:               function ir_mysql() {         global $dbm;              if(empty($dbm)){             $dbm = new Mysql(DBHOST, DBUSER, DBPASS, DBNAME);         }         return $dbm;     }      mysql.class.php               class Mysql {              // Variabler          // -----------------------------         private $db;         private $user;         private $password;         private $host;         private $linkid;         private $result;          function __construct($host, $user, $password, $db) {             try {                 $this->db = $db;                 $this->user = $user;                 $this->password = $password;                 $this->host = $host;                      $this->connect();                 $this->select();                 mysql_set_charset('utf8', $this->linkid);             } catch (exception $e) {                 die($e->getMessage());             }         }                   function Connect() {             try {                 $this->linkid = mysql_connect($this->host, $this->user, $this->password);                 if (!$this->linkid) {                     throw new Exception(mysql_error());                 }             } catch (Exception $e) {                 die($e->getMessage());             }         }                   function Select() {             try {                 if (!mysql_select_db($this->db, $this->linkid)) {                     throw new Exception("Cannot access the selected database");                 }             } catch (Exception $e) {                 die($e->getMessage());             }         }                   function Query($sql) {             try {                 $this->result = @mysql_query($sql, $this->linkid);                      if (!$this->result) {                          throw new Exception("Mysql query error: \n
" . mysql_error() . "
" . mysql_errno());                 }             } catch (Exception $e) {                 if (ir_admin()) {                     die($e->getMessage());                 }             }                  return $this->result;         }          function Close() {             mysql_close($this->linkid);     }          }      So if I'm querying something new I do like this: `ir_mysql()->query("SELECT....");` My method and wordpress method are not playing well.


jquery stopped working after deregistering wordpress stock version

I had two instances of jquery in my code and everything used to work. I decided to get rid of wordpress stock jquery by deregistering it through functions.php file. But now not a single jquery animation/script I've works! I've jquery hardcoded in my header though:               <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>      You can check my problem here: http://dev.holiday.ge/ what is going on? please help me :)


How to get meta box data to display on a page

I am trying to piece together a Metabox with 3 text editor fields for a custom post type. The box is showing up and appears to be saving on the custom post type entries but I can't get the data to display on the single-[custom-post-type].php page. Most recently I have tried the following to get the meta box data to display on the page:               global $post;     $meta = get_post_meta($post->ID, 'my-info', true );      if($meta != '') {     echo $meta     }else {      echo "Can't Display The Content";     }      I'm not sure if it's a problem with my Metabox creation/save that I can't get it to display. If anyone can point me in the right direction I'd appreciate it. Here is a link to the code that I'm using for my Metabox if it helps: Metabox Code


Latin character conversion

I'm managing a wordpress blog in Spanish for the first time and I'm currently migrating servers (e.g server A and B). The problem is that even though the file names are correctly sanitized or escaped in server A, the file names are converted; for instance NIÑOS -> NIÃOS. As a result, links in server B are broken. So, I'd like to know, is there a way to fix this? Thanks.


the_content not working

it doesn't display the content in editor i.e i have an image that i uploaded by using add media in the editor part which is not getting displayed plz help..it displays the thumbnail but not the content i have the the code as follows :                <?php if ( get_post_type() == bags ) { ?>                     <?php the_post_thumbnail(); ?>                    <?php } ?>         <?php } ?>             <?php if ( get_post_type() == books ) { ?>                     <?php the_content('editor'); ?>                    <?php the_post_thumbnail(); ?>                         <?} ?>         <?php } ?>      i m using it for posttypes where books is a postname


Title outside of the loop in page template

I have a page template, with a very simple default query. The problem is that the title is outside of the loop, because of the layout. What do you think, is it problem? Or do you know an other way?               <?php get_header(); ?>

<?php the_title(); ?>

Secondary line
             <?php                 if ( has_post_thumbnail() ) {                   the_post_thumbnail();                 } else {                     echo'';                 }             ?>

                 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                     <?php the_content(); ?>                 <?php endwhile; else: ?>
<?php _e('No posts were found. Sorry!'); ?>
                 <?php endif; ?>

          <?php get_footer(); ?>


Pagination link problem when reaching the second page

I've an issue with the pagination function in WordPress. Although the anchor text is correct, when I hit the URL for some reasons WP changes it from `www.site.com/page?page=2` to `www.site.com/page/2` thus generating a 404 error. My pagination call is like the following:                $paginate_links = paginate_links( array(                         'base' => preg_replace('/\?.*/', '/', get_pagenum_link()) . '%_%',                         'prev_text' => __('«'),                         'next_text' => __('»'),                         'mid_size'  => 5,                         'current'   => $current,                         'total'     => $totalpages                     ));      The strange thing is that using the same function in an archive page I get this working properly. Any idea on what is wrong?


Page Template Won't Load Correct CSS File

I can't get the correct css file to load for my page template. The page is correctly loading the template but still using the default css file. This is the code I'm using to load the page template's css file:               if (is_page_template('page-templates/page-nosidebar.php')) {             wp_enqueue_style('authorLuncheon-layout-style', get_template_directory_uri() . '/layouts/no-sidebar.css');         } else {             wp_enqueue_style('authorLuncheon-layout-style', get_template_directory_uri() . '/layouts/content-sidebar.css');         }      This is the whole function that contains the code above:               function authorluncheon_scripts() {     wp_enqueue_style( 'authorluncheon-style', get_stylesheet_uri() );              if (is_page_template('page-templates/page-nosidebar.php')) {             wp_enqueue_style('authorLuncheon-layout-style', get_template_directory_uri() . '/layouts/no-sidebar.css');         } else {             wp_enqueue_style('authorLuncheon-layout-style', get_template_directory_uri() . '/layouts/content-sidebar.css');         }          wp_enqueue_script( 'authorluncheon-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );          wp_enqueue_script( 'authorluncheon-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );          if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {         wp_enqueue_script( 'comment-reply' );     }     }      Thanks for any help!


get post excerpt by query

I'm trying to get post excerpt by query my code is below               global $wpdb;     $posts = $wpdb->get_results ("SELECT post_title, post_excerpt      FROM $wpdb->posts WHERE post_status = 'publish' AND (post_type = 'post')      AND post_content LIKE '%My Text%' ORDER BY post_date DESC");      but it show only title of post and wrong excerpt... any help


Custom Sortable Meta Boxes

I've looked all over and can't seem to find what I'm looking for (probably because I don't even know the terminology for what I need to do). I need to make some custom meta boxes that are similar to how you construct menus; as in, they're draggable, re-orderable, and you can add and delete them. I want to do the same, but for the sake of simplicity, let's just say for displaying custom text, and then drag and drop ordering it to be displayed on a page.


flush_rewrite_rules vs $wp_rewrite->flush_rules

I have been trying to flush the rewrite rules whenever admin chooses to change some value which needs rewriting. I first tried `flush_rewrite_rules(true)`(hard flush) which didn't work. Then I tried `flush_rules(false)`(soft flush). It worked. It got me thinking why a soft false would work when even the hard flush with `flush_rewrite_rules()` didn't work. I checked my past work where I used `flush_rewrite_rules()`. The codex doesn't provide enough information regarding this issue. I think `flush_rewrite_rules()` only work after adding some rewrite rules. So, it only update the rules it has encountered. It won't bother generating all the rules again. But `flush_rules()` will generate all the rules again and update it. Am I wrong with my guess? I tried searching but no good results. If someone can give an answer with what's actually happening, that would be great.


get post (method) in a fucntion

I have a step processing form. step1, step2, step3, step4 after Step2, it goes a fucntion and save values. then it goes to "step3". all of steps are move as post method like this.                   <form name="step1" method="post" action="" />         ...         ...         <input type="submit" name="step2" id="step2" class="btn_orange" value="<?php _e( 'Step2 ››', APP_TD ); ?>" />              <input type="hidden" name="post_type" id="post_type" value="us_visa" />         <input type="hidden" name="action" value="post" />         <input type="hidden" name="pagelocation" value="front" />         <input type="hidden" name="price" value="45000" />              </form>      After step2, it goes to a function and save data. then it has to be on Step3.                   session_cache_expire(30);         session_start();              // oid //         $oid=$_POST['passport'];         $phone=$_POST['phone'];              $_SESSION['tmp_price'] = $_POST['price'];                    $_SESSION['tmp_email'] = $_POST['email'];         $_SESSION['tmp_oid'] = $oid;                    //if ( $post_id ) {         $variable_to_send = '1';         wp_redirect( 'http://domain.com/visa-form/?step2='.$variable_to_send );         exit;      I don't know how to use method as "post" on function. therefore I used session. then it control include file like this.                   $pay=$_GET['pay'];         if ($pay==1) {include_once( get_template_directory() . '/pay/INIsecurestart.php' );                         }else{                                  // check and make sure the form was submitted from step1 and the session value exists                             if( isset($_POST['step2']) ) {                                      include_once( get_template_directory() . '/includes/visa-form2.php' );                                       } elseif( isset($_POST['step3']) ) {                                      include_once( get_template_directory() . '/includes/visa-form3.php' );                                  } elseif( isset($_POST['step4']) ) {                                      include_once( get_template_directory() . '/pay/INIsecurestart.php' );                                  } else {                                      include_once( get_template_directory() . '/includes/visa-form1.php' );                                  }                                   }      These are the processing. As you see I used "session" but I need to use "post" on function. (Function.php) How can I use "post" and "hidden" method in function or any other way to move step3 with values?


Help with changing style of the extended menu drop down

I am trying to change the style of the extended menu drop down from being on the right side to the left side. As you can see by the picture provided, the menu item named "Catholic Women's league of Canada" comes down on the right side. The reason why I want to change it to the left side is because under my "Contact" menu item there are two sub items similar to the "Parish Committees" menu item and the menu travels off of the screen. Any ideas of where I can look in the style.css file to find where I can change the way these menu items drop down? ![Menu item display](http://i.stack.imgur.com/B5tJR.png) Thank you!


Too Many Parent Posts to Select from in the Tiny Little Drop Down Menu

I'm working on coding a plugin for programs, courses, levels and lessons. The structure is created using a custom post type that is hierarchical.                            Program                     |                    / \                   /   \              Course1 Course2                 /\     /\                /  \   /  \              Lv1 Lv2 Lv1 Lv2             /\   /\   /\   /\           Lessons Lessons Lessons      I think there might be one issue with this way of doing things however and that is when I load this up with hundreds of lessons (potentially thousands) and have to select a parent for a lesson, level or course there are going to be a lot posts to choose from in that tiny little drop down. I did a fair bit of searching and could not find a solution. Anyone have any ideas? There must be a way to do this that I'm missing. Thanks!


Want wp_get_post_terms return in arbitrarily order, how to do?

Function below returns in alphabetical order and not, as wished, in arbitrarily order.   Is it possible to -not- return in alphabetical but in exact order as given in the array?               add_filter('the_content', 'my_function');     function my_function($content) {     if ( is_single() && in_category( '5' ) ) {     the_post_thumbnail('thumbnail', array('class' => 'top-post-img' ));              global $post;     $term_list=wp_get_post_terms($post->ID,array('school','article','teacher'),array( "fields" => "names"));     ?>
         School: <?php print_r($term_list[0]); ?>
         Article: <?php print_r($term_list[1]); ?>
         Teacher: <?php print_r($term_list[2]); ?>
     <?php            return $content;     } else {      return $content;     }     }      I tried by adding:               array ('orderby' => 'post__in'),  array ('post__in' => '24', '10', '3', '46' )      Numbers are the Taxonomy ID's but it is not changing any, neither does it throw an error. To find the Taxonomy ID's I used following code, or is that the wrong code?               $terms = get_the_terms( $post->ID , 'taxonomy-name' );     if($terms) {     foreach( $terms as $term ) {         echo $term->term_id.'
';     }     }      Should I use `list_filter` somewhere, or some below in the code after the `print_r` ? Added                var_dump($term_list);      to see if output would show some else, but no it was the same..alphabetical order.   I am pretty sure forgetting some but what, and where. Or is my approach totally wrong?   Would love to find a solution.   Thanks in advance for all time and effort.


Can only get one of two custom menus to display

I'm a wordpress beginner and at the moment struggling to get to grips with custom menus. I have created two menus. Wordpress tells me the theme supports two menus. I have               <?php wp_nav_menu('menu=services_menu'); ?>      Where I want one menu to appear. I have               <?php wp_nav_menu('menu=left_navigation'); ?>      Where I want the other menu to appear. I have               <?php     if ( function_exists( 'register_nav_menus' ) ) {         register_nav_menus(             array(               'services_menu' => 'Services menu',               'left_navigation' => 'Left vertical navigation Menu'             )         );     }     ?>      In functions.php. Both menus appear under "Appearance -> menus ->Theme locations" and are associated correctly. But only the services menu ever appears, in both locations. I've read a welter of different solutions to doing this, none of which seem to have any result other than the one described above. Where am I going wrong?


confirm my booking with phone number

I have created a booking form on front-end, and there is also "confirm my booking" page. once you submit your booking form. and it stored on "booking" custom post and saved post meta (such as phone number, time.. etc) But I can't figure out how to get the result when people do "confirm my booking". When users put their's "name, phone number" on confirm page, I have to show other information. I can't get the query or wordpress functions... this might be the same sql query. "select name, phone, time, day, howmany from booking_table where phone=$strPhone and name=$strName" This is what I need on confirm result page. Thanks for your time.


search.php is not generating the right results

I have a situation that didn't happen before. My search.php file didn't generate results, it just loop through all posts although the url is correct Domain_name/?s=key Here is the searchform.php code:               <form action="<?php bloginfo('url'); ?>" id="search-form" method="get">
             <input type="text" name="s" id="search-control" class="form-control" placeholder="ادخل كلمات البحث هنا">

             <input type="submit" class="btn btn-default" value="ابدأ البحث">
     </form>      Here is the search.php code:               <?php get_header(); ?>

                 <?php get_sidebar(); ?>

                     <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>                     <?php if ( have_posts() ): ?>
نتــائج البحث '<?php echo get_search_query(); /*global $wp_query; $wp_query->set('s',$_GET['s']); print_r($wp_query);*/ ?>'

                     <?php  while(have_posts()): the_post(); ?>

<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?>

<?php the_author_posts_link(); ?>

<?php the_excerpt(); ?>

                                 <?php                                 if(has_post_thumbnail()){                                     the_post_thumbnail('cat');                                 }else{                                     ?>                                     <img src="<?php echo IMAGES ?>logo_sm.png" />                                 <?php                                 }                                 ?>
                                      <?php comments_number(); ?>                                                                            <?php the_time('j') ?>                                      <?php echo the_time('M') ?>                                     <?php the_time('Y') ?>

                     <?php endwhile; ?>
                             <?php my_pagination(); ?>
                     <?php else: ?>
لا يوجد ما يطابق بحثك
                     <?php endif;wp_reset_query(); ?>

     <?php get_footer(); ?>      Note: If it changes anything, the website is in arabic.


Add values of post meta fields?

How do I add the values of meta fields in the loop? Say each post has a custom field called "rating" (or whatever) and its got a value of 1 to 5 and its kept in a custom post meta. In the loops when Im going through all the post, how would I add up all the post metas together to get a total "rating" value?


Problem with JWplayer. Video is missing?

Firstly, I am new at using video with wordpress. I have installed the jwplayer plugin and using this bit of code to show the video player on the page.               $video_array = explode("\r\n", stripslashes(extra_option('video_links')) );                      foreach($video_array as $vid){                     if (!empty($vid))                     echo jwplayer_tag_callback("[jwplayer config=\"Homepage Player\" file=\"$vid\"]");                  }      **Note:** "Homepage Player" is a custom config i made form the jwplayer plugin option page. **Problem:** You can see the site here http://photographersinsiouxfallssd.com/ There are four video to show. For the first three the player isn't showing and the last one player is showing but you can only hear sound but no video :(


How can I get list of emails of users who commented on a post?

What I want here is simple, but I'm not really sure how to approach it. I have a tournament website based on WordPress, where users sign up for a tournament by commenting on a post. The problem is, that then I need to send all those guys an email, which means I have to look up 50+ emails for users every single time. I'm thinking of doing some kind of JOIN on the comments and users tables, but I don't really know how to put this in WordPress. I read somewhere, that if I want to add stuff for users, it should be in a theme, and if I want to add it for administrators, it should be as a plugin, but this looks like it could be a simple script put somewhere. How would you solve this?


Filter for replacing the WP_query object for a given category

I'm looking for a action/filter to replace replace a category archive page with the contents of a page. I'm thinking of testing the category ID, and replacing the WP_Query object with a new one tailored for the page I want to grab, thus avoiding to have to modify the template. Which filter/action could I use, and is there perhaps a better solution?


Plug-in that shows x number thumbnails from another post

I am building a blog where the posts of a certain category make up image galleries (using the standard WP functionality and a modified single.php to display the gallery.) Now, I would like to add links to some of those galleries inside other blog posts. The ideal way would be a shortcode like               [thumbnails galleryid=209]      (or whatever) that displays a definable number of thumbnails from post no. 209, and links there. Does anybody know of a ready-made plugin that does this?


Limiting Amount of Posts in a Custom Post Type again

I've been trying to limit the amount of posts a user can create in a specific custom post type, and I had some help from Bainternet by checking out his plugin. I read over that and then came up with my own, but it doesn't seem to be working. I want to make my code much more lightweight than an entire new plugin so I am just adding it to mine, but what am I doing wrong here? The name of my custom post type will be lets say.. `newpages`. And we'll pretend `$custom = 'Developer';` has been placed before the function.               function efpd_limit_posts(){         global $pagenow,$custom;         if (is_admin() && $pagenow=='post-new.php?post_type=newpages'){             $theposts = get_posts(array('post_type'=>'newpages'));             if (count($theposts) >= '1'){                 wp_die('You have reached the maximum amount of 'newpages' you can create.');     }   }   }        add_action('admin_head','efpd_limit_posts');


Same template for all the terms of a taxonomy

My problem is the following. I have a custom post type called "photography" which contains a taxonomy called "photographyCategories", which contains several terms : "outside", "inside", "portrait"... All these terms content is based on the same outline (a list of pictures and a slider). I know that if I want to display the archive page of one of these terms I have to create, for example, the file taxonomy-photographyCategories-outside.php. I've done it and it works. But what I want is ONE template for all these terms. I don't wanna have an "outside" template, an "inside" template and a "portrait" template because they're all the same... They display the same type of content, except the photographies that are different. I can't find a way to do this... Is there a solution ?


Which hook should be used to add an action containing a redirect?

I want to build a plugin that grabs certain url params from the query string to build a new query string for the same page. I'm following the excellent the Professional WordPress Plugin Development book, but I'm not sure which hook to use for this action. Here is my action function:               add_action( 'init', 'tccl_redirect' );     function tccl_redirect() {         header ( "Location: http://www.mysite.com/$mypage?$newparam=$newvalue" );     ?>      Which hooks are suitable for header redirects?


Facebook sharing link is not showing a thumbnail of the images within the post?

Usually facebook share gets an image from the site to post and shows it as thumbnails. If you press the share this on facebook link in my test page it doesn't. This is my test site: http://alexchen.info/taiwantalk/ This is the code:               <?php     /**      * Template Name: Front Page      * @package WordPress      * @subpackage Prominent      * @since Prominent 1.0      */     get_header(); ?>

                 <?php while ( have_posts() ) : the_post(); ?>
                         <?php the_content(); ?>
                     <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="blank">Share on Facebook                 <?php endwhile; ?>                 <?php /* Display navigation to next/previous pages when applicable */ ?>                 <?php if (  $wp_query->max_num_pages > 1 ) : ?>                     <?php next_posts_link( __( '← Older posts', 'twentyten' ) ); ?>                     <?php previous_posts_link( __( 'Newer posts →', 'twentyten' ) ); ?>                 <?php endif; ?>

     <?php get_footer(); ?>      **EDIT:** I added all necessary meta tags and links:               <meta charset="<?php bloginfo( 'charset' ); ?>" />     <meta name="title" content="Article headline here" />     <meta name="description" content="Article summary here" />     <title><?php         /*          * Print the <title> tag based on what is being viewed.          * We filter the output of wp_title() a bit -- see          * twentyten_filter_wp_title() in functions.php.          */         wp_title( '|', true, 'right' );     ?></title>     <link rel="profile" href="http://gmpg.org/xfn/11" />     <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />     <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />     <link rel="image_src" href="http://alexchen.info/taiwantalk/wp-content/uploads/2011/03/cheating.png" />      But this is the only thing that is shown: > asdasd | Taiwan Talk http://alexchen.info/taiwantalk/2011/03/... > > You may use these HTML tags and attributes: any suggestions?


Wordpress Bug on IIS ? Problem when uploading image on IIS 7

When I upload image, I can preview it, but once it's uploaded, It's broken in post, I'm obliged to go to the directory and go to security to add NETWORK SERVICES the right to access the picture. How to fix this ? Is this a bug ?


Trouble with wp_nav_menu, conditional tags and fallback_cb

I created some menus, and now I'm trying to set up a conditional construction with wp_nav_menu in header.php, but the behavior is not really as expected. I'm doing something like               <?php      if ( is_front_page() )       {          wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => '68' ));     }      elseif ( is_single() )       {          wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => '69' ) );     }      else      {          wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => '33' ));     }      ?>      the last "else" catches 404s and pages, but with archives (categories, tags, search, author, ...) the menu falls back to the default fallback (wp_list_pages) instead of menu 33. Any ideas why this is happening? Note: I'm modifying the TwentyTen theme.


How to add a button to First and Last Page using posts_nav_link?

I'm using "posts_nav_link" to make the pagination of my wordpress site because this was the only way I found to include the current page / number of pages between the prev and next buttons. However now I need to add buttons to the first and last page too. Is there any way I can do this? Thanks in advance! My code:               function wp_pagenavi() {       global $wp_query, $wp_rewrite;       $pages = '';       $max = $wp_query->max_num_pages;       if (!$current = get_query_var('paged')) $current = 1;       $args['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));       $args['total'] = $max;       $args['current'] = $current;            $total = 1;       $args['mid_size'] = 0;       $args['end_size'] = 0;       $args['prev_text'] = '«';       $args['next_text'] = '»';            if ($max > 1) echo '
';      if ($total == 1 && $max > 1) $pages = '' . $current . '' . ' / ' . $max;      echo posts_nav_link($pages, '<', '>');      if ($max > 1) echo '
';     }


first_post_link and last_post_link?

> **Possible Duplicate:**   >  Is it possible to add a first and latest posts link? I'm working on an image gallery website. Here is the navigation code that appears at the bottom of each "view image" page:               <div class="previous <?php if(!get_previous_post()){ echo 'inactive'; }?>">         <?php previous_post_link('%link'); ?>
     <div class="next <?php if(!get_next_post()){ echo 'inactive'; }?>">         <?php next_post_link('%link'); ?>
      Currently, when the user is at the first post, the previous post link is inactive. I'd like to make it so that clicking the previous post link will take them to the last image. Is this possible?


How can i link a custom post type thumbnail to intermediate size

I'm trying to build a picture gallery with custom post type in my theme and I think i figure it out almost everything but the call in the template, I already have the custom post type in the functions.php, I have a Page with a custom call to the post type and it’s working (the post are showing in the page with the template) what I cannot figure it out it’s the call for the href that should go to open the image bigger probably with some modal like lightbox or something like that. I have to mention that I’m trying to use feature image and already have created some image sizes for it in the functions.php, I’m going to paste the code for you to understand… Thank you in advance Custom post type template               <?php     /*               Template Name: test Post Type Gallery        */     get_header();      ?>

                  <?php $loop = new WP_Query( array( 'post_type' => 'bird', 'posts_per_page' => 10 ) ); ?>             <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<?php the_title( '
', '
' ); ?>                  <?php the_post_thumbnail(array(200,200)); ?>

                  <?php endwhile; ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>      **Functions.php**   This is for the Size of the Images               if ( function_exists( 'add_theme_support' ) ) {          add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 250, 250, true ); // Normal post thumbnails         add_image_size( 'medium-picture-thumbnail', 400, 400 ); // Medium thumbnail size         add_image_size( 'big-picture-thumbnail', 700, 700 ); // Big thumbnail size     }


How can I hide custom field from users used for caching response from external api?

I have a custom meta box created using Rilwis meta box script(http://www.deluxeblogtips.com/meta-box/) inside my theme functions.php. It has 2 text fields, one field is required to fetch results from api, so, it needs to be visible on the custom meta box. But, the other field stores a serialized array which is the response fetched from external api. So, I want to make this field hidden. Please tell me how can I hide the other field. Here is the code which defines the two text fields:               if (!class_exists('F8_Stores')) {         class F8_Stores {                  private $fields = array();             private $validation = array();             private $prefix = 'f8_';                  public function __construct() {                      add_action('admin_init', array($this, 'register_store_meta_box'));             }                  public function register_store_meta_box() {                 $this -> fields = $this -> add_custom_fields();                 $this -> validation = $this -> add_validation_rules();                      $meta_box = array('id' => 'f8_stores', 'title' => 'Online Retail Stores', 'pages' => array('post', 'page'), 'context' => 'normal', 'priority' => 'high', 'fields' => $this -> fields, 'validation' => $this -> validation);                 new RW_Meta_Box($meta_box);                  }                  private function add_custom_fields() {                 $fields = array( array('name' => 'Amazon US Product ASIN', 'desc' => 'Please enter product ASIN', 'id' => $this -> prefix . 'amazon_us_asin', 'type' => 'text', 'std' => false, 'clone' => false, ),                  array('name' => 'Amazon US Store Cache', 'desc' => 'Users should not see this', 'id' => '_' . $this -> prefix . 'amazon_us_store_cache', 'type' => 'text', 'clone' => false, ), );                 echo $fields[1]['id'];                 return $fields;             }                  private function add_validation_rules() {                 $validation = array();                       return $validation;             }              }          }     $F8_Stores = new F8_Stores();      I am using this inside a class, and despite adding '_'in front of 'id' of text field 2, the field is still visible inside metabox. Don't know what I am missing? Any help is appreciated...thanks! P.S. I am using Rilwis Meta Box 4.2.3 and Wordpress 3.5 running on xampp. **Update:** I have now posted my actual class responsible for generating metabox. **Update:** Thanks everyone for response, the problem is now fixed.


how to use joomla password format in wordpress?

I need to import more than 1000 users from joomla to wordpress. I can do that with csv. My main concern are passwords. I did some googling and found out that it is possible to change wordpress password formats. Can anyone show me some code examples how to do that?


Where can I find a schema of wordpress plugin core architecture?

There are plenty of articles which explain how to create a wordpress plugin. I'm not looking for that, I'm looking for a schema of the core architecture of a wordpress plugin (an UML class diagram and sequence for example). Has somebody seen anything like that somewhere ? Update: I know plugin can be as simple as a function. It's not my question. My question is about the architecture of the CALLER that calls the plugin, that is the architecture of the SYSTEM pertaining to the call of the plugin. At least in which PHP module(s) is it implemented by the Wordpress Core System files ?


insert query on a custom table using ajax with jQuery plugin Jeditable

I've read tons of post already but found no solution... I'm tryin to implement Jeditable functionality in a plugin with this code:               jQuery(document).ready(function() {         jQuery('.edit').editable('http://localhost/www/wp-content/plugins/my_plugin/save.php'     });      If in `save.php` I simply echo something, it will be returned to the textfield I was updating without problem. Problem is on how to insert it into the db... If I use this:               if (isset($_POST['id'])) {         global $wpdb;         $query = "INSERT INTO table (col1, col2, col3) VALUES ('%d', '%s', '%d')";         $wpdb->query($wpdb->prepare($query, '10', $_post['value'], '0'));         echo $_POST['value'];     }      I get the following error: > "FATAL ERROR: CALL TO A MEMBER FUNCTION QUERY() ON A NON-OBJECT IN [...] ON > LINE 6" (line 6 is `$wpdb->query([...]);`). Now, what I understend from other posts is that I can't call `save.php` directly from AJAX. What I didn't get is how else should I do it. I tried all the solutions of those posts and read the official Codex page without success.


Show posts without term

I am working on a product page where I show reviews from my post type 'reviews', if the product page title matches with my term from the taxonomy 'review-product'. **Example.** Product page title: **Refrigerator** Show (reviews) posts with:   * Post type: 'reviews'   * Taxonomy: 'review-product'   * Term: **Refrigerator** This works totally fine. But sometimes I have no reviews for a product (because there is no match between product title and term) and then I want to show 'General' reviews. In my website these are posts with:   * Post type: 'reviews'   * Taxonomy: 'review-product'   * Term: **No term (!!!)** This posts don't have a term from the taxonomy 'review-product'. **My Question:** How can I show reviews posts without a term, if there are no reviews posts matching the product title. **This is what I have now:**               function gtp_show_reviews( $number = 100, $term = null ) {         $reviews = new WP_Query( array(              'post_type'         => 'reviews',             'review-product'    => $term, // Fill this with product page slug (refrigerator)         ));         if( $reviews->have_posts() ) {              while( $reviews->have_posts() ) {                 $reviews->the_post();                 // The review             }         }          else {             // Here I try to unset the 'review-product' term             unset($reviews->query_vars['review-product']);             unset($reviews->query_vars['term']);                  while( $reviews->have_posts() ) {                 $reviews->the_post();                 // Check if review has no term                 if( $reviews->has_term() == false ) {                    // The review                 }             }            }              wp_reset_postdata();     }


CSS Styling for a Page/ Site made with Pagelines

I know how to change the HTML of page inside wordpress but for some reason I can't find the CSS for the page I'm looking for. I can find a huge amount of code made by Pagelines(Is it in there?). The website I'm working on has been used by another author who did basic coding for the site and styling. All I want to do is make some small changes in the CSS for the page. Where do I find that code?


Update post meta on bulk edit / update

I have a small problem with a code that works most of the time. I just discovered it cannot be used when I bulk edit custom post type. If I'm on individual post page and hit publish, the custom post type gets published and the user meta gets updated. If I use the bulk edit to publish many posts at once, the user meta is not updated.                   function sa_ads_count() {             global $wpdb, $post;             $authordata = get_userdata($post->post_author);             $author = $authordata->ID;             // get initial count             $single = true;             $ads_count = get_user_meta( $author, 'ads_count', $single );             if ( strlen( $ads_count ) > 0 ) {                 $ads_count = intval( $ads_count ); // make sure it's a number                 $ads_count++; // increment by one             } else {                 // meta isn't set, so we'll create it                 $rows = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT(ID) as count FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post_type' GROUP BY post_status", $author ) );          $stats = array();     foreach ( $rows as $row )         $stats[ $row->post_status ] = $row->count;                 $ads_count = isset($stats['publish']) ? $stats['publish'] : 0;             }                  update_user_meta( $author, 'ads_count', $ads_count );         }          add_action( 'pending_to_publish', 'sa_ads_count' );      Any idea what is wrong here? Is it a WordPress limitation or this can be solved? The thing is, I need this hook as I only want to count and store for every user, the number of posts that I approve and publish. Later on, I want to change new post status directly to publish based on the number of posts the user has approved. This I already achieved.


Can I set a CPT title field to a dropdown with preset options if user is of a given type?

I am using the WP Property plugin so I have a Property CPT. I also have building managers who will be creating these new CPT posts. Is it possible to set the post title field to be a dropdown field with a set of preset options for a certain user type. Something like:               if (user->role == agent) {       // title field is dropdown     }