Reload meta box content with AJAX

I want to build a meta box that contains multiple textfields which get filled if a submit button is pressed. The data is set by a function which should get called if the button is pressed. How can I do this with AJAX, without reloading the page? My attempt for the meta box content was the following (everything is written in a plugin **.php file /plugins/myplugin.php** ):               <?php          // register metabox     add_action( 'admin_init', 'my_admin' );          // add metabox     function my_admin() {         add_meta_box( 'movie_info_div',             'Fetched information:',             'display_info_mbox',             'my_custom_post_type',             'normal',             'high' );     }               add_action('wp_ajax_fetch_action', 'fetch_action_callback');          // function that should be called if button is pressed     function fetch_action_callback() {         $input = esc_html( $_POST['input'] );         $input .= ' + fetched data';         echo $input;         die();     }      The function to display the metabox content:               // Display metabox content     function display_info_mbox( $movie_review ) {         ?>             Start fetching             <input id="source" type="text" value="" />             <input id="content" type="text" value="" />

                               <?php } ?>      Actually I just want to build **a button that triggers a php script** which returns some fetched data to a form, depending on a text-input but with a submit-button it reloads the whole page. As I am completely new to AJAX and jQuery I'm kind of lost. I would appreciate your help.


Why was my plugin rejected from the WordPress.org repository?

I have made a WordPress plugin, and it works. But when I send it to the WordPress.org plugin team, they responded: > Calling wp-load.php directly > > Including wp-config.php, wp-blog-header.php, wp-load.php, or pretty much any > other WordPress core file that you have to call directly via an include is > not a good idea and we cannot approve a plugin that does so unless it has a > very good reason to load the file(s). It is prone to failure since not all > WordPress installs have the exact same file structure. Usually plugins will > include wp-config.php or wp-load.php in order to gain access to core > WordPress functions, but there are much better ways to do this. It's best if > you tie your processing functions (the ones that need but don't have access > to core functions) into an action hook, such as "init" or "admin_init". > > Please consult the Plugins API reference for more information: > http://codex.wordpress.org/Plugin_API If you're trying to use AJAX, please > read this: http://codex.wordpress.org/AJAX_in_Plugins I don't know what to do :( This is my plugin http://szymoon.nazwa.pl/plugins/Printer-Friendly-WP.zip Where is a good example of making the correct plugin? Or one that was accepted by the WordPress.org team.


Copy Widget Settings because of changed IDs

I want to update a customers blog to a child theme that is based on a newer version of the actual deployed theme. My problem is, the developers of the theme changed the IDs of sidebars. In the old version `register_sidebar()` was called without providing an ID, therefor WP used numeric IDs. Now developers named the IDs alphanumerical (`home-1`, `home-2`, etc). I couldn't find out how to copy the widget settings in the database from one sidebar to another. Therefor I registered the new sidebar IDs in the old theme and the old sidebars in the new theme. Than I used the Duplicate Widget Plugin to replicate the widgets in the new sidebars. When I preview the new theme, everything looks good, but upon activation my widgets are gone. Looking into the widget backend and my sidebars are mostly empty, except one or two. Reactivating the old theme and everything's fine. I also tried to export and import widget settings, but one plugin didn't install correctly and the other one exported a mostly empty `widget_settings.xml` file shown below. ` <?xml version="1.0" encoding="ISO-8859-1"?><widget_settings></widget_settings> `


How do i use the use the wooCommerce functions in a wordpress plugin?

How would i use the wooCommerce hooks in my wp plugin? Here is what i am trying to do:                   add_filter('woocommerce_edit_product_columns', 'pA_manage_posts_columns');         function pA_manage_posts_columns($columns, $post_type = 'product') {         global $woocommerce;     if ( in_array( $post_type, array( 'product') ) ) {             $columns['offering_price'] = __( 'offering price', 'your_text_domain' ); // this offering price title              $columns['offering_qty'] = __( 'Qty', 'your_text_domain' ); // add the quantity title     }         unset($columns['name']);     return $columns;      } I have included the woocommerce class:               $ds = DIRECTORY_SEPARATOR;     $base_dir = realpath(dirname(__FILE__)  . $ds . '..') . $ds;     $file = "{$base_dir}woocommerce{$ds}woocommerce.php";      include_once($file);


Featured Image not shown and getting error "Object of class WP_Error could not be converted to int"

First of all I'm using twentyeleven theme, I created a custom template page to insert posts. **It has 4 submit forms. it is working well, also setting feature image is ok for 3 forms except the first one it is not setting feature image for the post even it upload the image (using upload form and also using image from link) and attach it to the post** , what makes me crazy is that I'm using the same function to set feature image, but I don't know why it is not working with the first submit form This is my code for setting feature image:               $pid = wp_insert_post($new_post);     $upload_dir = wp_upload_dir();     $image_data = file_get_contents($image_url);     $filename = basename($image_url);     if(wp_mkdir_p($upload_dir['path'])){         $file = $upload_dir['path'] . '/' . $filename;     }else{         $file = $upload_dir['basedir'] . '/' . $filename;     }     file_put_contents($file, $image_data);          $wp_filetype = wp_check_filetype($filename, null );     $attachment = array(         'post_mime_type' => $wp_filetype['type'],         'post_title' => sanitize_file_name($filename),         'post_content' => '',         'post_status' => 'inherit'     );     $attach_id = wp_insert_attachment( $attachment, $file, $pid );     require_once(ABSPATH . 'wp-admin/includes/image.php');     $attach_data = wp_generate_attachment_metadata( $attach_id, $file );     wp_update_attachment_metadata( $attach_id, $attach_data );          set_post_thumbnail( $pid, $attach_id );      I'm getting these errors 1- In the the **home** page and **edit post** in admin area: `Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/post.php on line 4294` which leads me to `wp_attachment_is_image` function in the main post.php page               function wp_attachment_is_image( $post_id = 0 ) {         $post_id = (int) $post_id;         if ( !$post = get_post( $post_id ) )             return false;              if ( !$file = get_attached_file( $post->ID ) )             return false;              $ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false;              $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );              if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) )             return true;         return false;     }      I tested `$post_id` by is_int and fount that is is integer 2- In the home page : `Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/functions.php on line 3814` which leads me to `_get_non_cached_ids` in `functions.php` page               function _get_non_cached_ids( $object_ids, $cache_key ) {         $clean = array();         foreach ( $object_ids as $id ) {              $id = (int) $id;             if ( !wp_cache_get( $id, $cache_key ) ) {                 $clean[] = $id;             }         }              return $clean;     }      I tested `$id` by is_int() and I got that **it is not integer** How can I fix that problem, and why only this first form is not setting feature image even it is attach the image to the post


Include title and content of one page in another page

In this question contents of another page can be rendered to another page, but how do I do it for the title too? Can I just go `$content = apply_filters('the_title', $post->post_content);`? But what do I add at the second argument? From how it looks like, it's an array right? Which one stores the actual title of the page?


How to get "custom post type"-archive with working permalink to it?

First I will show my permalink structure: `/%category%/%post-name%/` Then, I created a custom post type. And now I want to create an archive for those posts related to my custom post type. So I wonder, how will I do that? Viewing it in the WordPress documentation, there is something about create a `archive-{post-type}.php` file, but I still don't understand how it works, and it says nothing about how the permalinks will look like. What should I do?


Use a language specific thousand separator

I have a views counter on each post. When it reaches for example 1000, it adds a dot as the thousand separator, the result is 1.000. This is odd in my language, I should have a space as separator or nothing. How can I change that?!


How to get current term in my custom taxonomy in WordPress?

I need to display the current term in my custom taxonomy in a single post. **example:**   * My custom taxonomy is _products_ and term of them is _product-1_ , _product-2_ and _products-3_.   * My post is assigned to _product-2_   * And I want to print the current products = _products-2_ in my post In fact, I need a function like WordPress's `the_category();` but for my taxonomy like `the_customtaxonomy();` UPDATE : in facts i know i need to get id of this becuse i need to show a icon for this in my single , for example a function like `the_category_ID();`


Parked domain redirecting to wrong error404 page

I have 3 different WordPress sites on my host provider in a linux shared hosting package. The main domain is domain-a.com. A secondary add-on domain is domain-b.com. I have a parked domain domain-c.com that redirects to domain-b.com. All are registered elsewhere and the a-record points to this host provider. Here's the problem: when a user types domain-c.com it properly redirects to domain-b.com. No problem there. The problem occurs when a user types domain-c.com/something.html (anything that is not found on the domain-b.com). It produces my error404 page for domain-a.com, not domain-b.com. I am told by the host providers (at the registrar and this host) that this is a WordPress issue because of the htaccess file and how WP resolves the domains. I have tried a plugin named Simple 301 Redirects but it has no effect here. Any suggestions? Thanks, Larry


How to force buddypress users to complete profile after registration?

Seems logical for any other network, not for buddypress though :( We all know the extended user profiles in buddypress - problem is, even though some fields are marked as required, that "required" seems to have no real significance for buddypress developers. So we have some "required" fields, which nobody EVER asks the user to fill in ... "Great" job so far ... So the question is... how can we force the newly registered user to first fill in all those required fields from the extended user profile, BEFORE he is able to use anything on the site !? Like he registers with name, prename, email and once he logs in he will be presented with a page/screen where he will have to first complete all the other missing required fileds, before he'll be able to see ANY content on the site !!? Anyone please an idea about how to achieve this? It's more than 1 year I think I search for a solution ... :-(


Memory question on Wordpress Multisite

Im currently using WP-Memory-Usage plugin on my wordpress multisite network to monitor my memory usage. The memory usage displays **39.1 MByte**. Does it mean **39.1 MByte** per blog?


Remove taxonomy slug from a custom hierarchical taxonomy permalink

I created a 'forum' taxonomy, using these rules:               register_taxonomy(       'forum',       array('topic'),       array(         'public' => true,         'name' => _a('Forums'),         'singular_name' => _a('Forum'),         'show_ui' => true,         'show_in_nav_menus' => true,         'hierarchical' => true,              'labels' => array(           'name' => _a('Forums'),           'singular_name' => _a('Forum'),           'search_items' => _a('Search Forums'),           'popular_items' => _a('Popular Forums'),           'all_items' => _a('All Forums'),           'parent_item' => _a('Parent Forum'),           'parent_item_colon' => _a('Parent Forum:'),           'edit_item' => _a('Edit Forum'),           'update_item' => _a('Update Forum'),           'add_new_item' => _a('Add New Forum'),           'new_item_name' => _a('New Forum Name'),         ),         'query_var' => true,         'rewrite' => array('slug' => 'forums', 'with_front' => false, 'hierarchical' => true),         )     );      In the front-end the URLs looks like:               forums/general-discussion/sub-forum      How can I remove the front slug ("forums")? Ie, change the URLs to:               general-discussion/sub-forum      If I pass a empty slug argument to register_taxonomy() it works, but that causes issues with the permalinks of the post type associated with this taxonomy


Shortcode content filter?

I'm looking for something, but don't exactly know what. I have a shortcode, let's call it [shortcode]. Users will input HTML tags inside, mostly images, but also links, images in links, etc., for example:               [shortcode]               (...)     [/shortcode]      The point is I want to format URLs, differently, I want every img src to start with files/myimagescript? So the code above should output:                                      (...)           So basically I need to simply change src of images. And it should work for any number of images, from 1 to unlimited. I'm thinking about foreach PHP loop, but I'm not sure how to grab each img src line from shortcode and process it before displaying?


if (has_custom_menu())?

I've taken this line from header.php of TwentyTen where its loading the custom menus...               <?php /* Our navigation menu.       If one isn't filled out, wp_nav_menu falls back to wp_page_menu.       The menu assiged to the primary position is the one used.       If none is assigned, the menu with the lowest ID is used.  */ ?>     <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>      I understand their fallback plan, but for mine, if no custom menu has been assigned to my custom menu selector, I don't want to return anything. What's the function to determine if my custom menu has an assigned menu?


Remove li from wp_nav_menu

How can I remove the li from wp_nav_menu? I know I can remove ul but is it also possible to remove the li? I would want to do this on just one menu not all the menus on my site.


Post/Page Preview Template

Is there a way to have a custom template php file that is only used for previews instead of it using the single.php file? This way the user knows they are in preview mode?


Resizing the wordpress editor

I've been looking around on how to re-size the WYSIWYS editor for wordpress and have used firebug to re-size the #post-body-content but it doesn't resize ever. It will resize in the firebug application but not when I go to put it into my style.css for my toolbox theme.               #post-body-content {         width:650px !important;     }      Is there something I have to put in the functions.php page? Site is here UPDATE I've placed the provided code into my function.php file and it worked but only half of it. I've tried to place another style for another part I see but it doesn't apply the style. Am I only allowed one style in the new function? ![enter image description here](http://i.stack.imgur.com/2NuZP.png) The line just behind the content is the newly resized editor, but the content is still spilling past it. Would it be because of the Tiny MCE toolbar?


How to looping taxonomy terms?

is there any way to loop terms in a way they display in menu? Eg: Let say I have 2 taxonomies in a post type - tax1 and tax2. They are not hierarchical to each other. If I have posts that have terms like this:   * post 1 => tax1 = p1 ,tax2 = term1   * post 2 => tax1 = p1 ,tax2 = term2   * post 3 => tax1 = p1 ,tax2 = term3   * post 4 => tax1 = p2 ,tax2 = termA   * post 4 => tax1 = p2 ,tax2 = termB   * ......etc Can I use               if(tax1=p1) echo 'term1,term2, term3... in menu/widget'     elseif if(tax1=p2) echo 'termA,termB, termC... in menu/widget'      in my template to display the tax2 terms in the sidebar menu? Somebody might wondering why I don't want to use parent-child terms. Well, this is because I expects have hundreds of term in tax2. If I use hierarchical taxonomy, that will be very long list in single taxonomy. I don't know whether WP able to process them or not.


Forcing absolute <img> src links in the RSS feed

We are using relative image URLs in the post's HTML code. Looks like relative src links break on many RSS readers. By default, Wordpress does not seem to prepare post's HTML for feed too much. Does there exist any solution for post-processing the feed URL and encoring all links and src attributes to be absolute?


Is it possible to install BuddyPress with blogs installed on several servers?

As far as I know, if you want to install BuddyPress you've got to have a WordPress MU installation (I know WordPress 3.x already is MU in itself) **with a unique database** , which has different tables for each blog. But my situation is quite different: we have a blog network, and **we would like to have a buddypress installed** for all our blogs. This way users could register once and comment on the blogs automatically, see their activity, link to other users, etc. But **the blogs are on different servers** :( Our current physical division of blogs (some of them are together in the same server, but others are in different servers, **each with its own database** ) makes me think this is quite difficult to do. I know that the Multi-DB plugin could help us with the database thing, but... what if the blogs are, as in our situation, in different servers/VPS's?


SHOPP breadcrumbs (that work!)

Anyone who has used SHOPP, the ecommerce plugin, will know that the breadcrumbs are a little crappy... I would like them to work throughout the site. I currently use Yoast Breadcrumbs plugin, but the chain for SHOPP stops after the 'store' part. For example; the url would be http://example.com/store/category/a-category/ and the breadcrumbs would only show 'home >> Store', with home being the only link... Not sure why this is, but would really like a fix for it if anyone has any experience with SHOPP! Thanks


How can I grant capabilities directly to users (not roles) in wp-admin?

I want to create dynamic capabilities using WP_Role::add_cap(), something like               $author_role = get_role('author');          foreach ($sections as $section) {         $author_role->add_cap( "edit_{$section}_pages", /* grant= */ false );     }      and then let administrators grant certain of those capabilities to certain authors only (e.g., Jane can edit_school_pages) in wp-admin ( **not** programmatically, via WP_User::add_cap()). I assume a plugin can help with this, but those I've found (e.g., Capability Manager) seem to emphasize creating new Roles or Capabilities and adding/moving Capabilities among Roles, not granting capabilities directly to users (though I could be wrong). Advice? Thanks, s


Comments Reply Form

When I click on Reply, the reply form appears at the bottom of the page (under the last comment). How can I add the Reply Form inside the comment to which I am going to add the reply?


How do I add media to a custom post type?

I want to add some custom fields to allow a user to select items from the Media library for the custom post (in the add/edit view) Is there a way to do this?


Display in category ( taxonomy) a number of post that I want

How can I display a number of 20 posts in my Page Archive (Taxonomy Archive)? For example: in wordpress settings in Reading I use: Blog pages show at most 10 posts.   This works in arhive page, but when I click on the categories (taxonomy's) it display only 10 posts. I have this function that displays the archive:               function iti_custom_posts_per_page($query)         {             switch ( $query->query_vars['post_type'] )             {                 case 'trailers':  // Post Type named 'iti_cpt_1'                     $query->query_vars['posts_per_page'] = 20;                     break;                      case 'persoane':  // Post Type named 'iti_cpt_2'                     $query->query_vars['posts_per_page'] = 6;                     break;                           case 'serial':  // Post Type named 'iti_cpt_3'                     $query->query_vars['posts_per_page'] = 6;                     break;                      default:                     break;             }             return $query;         }              if( !is_admin() )         {             add_filter( 'pre_get_posts', 'iti_custom_posts_per_page' );         }


How to let the users edit their user names?

Is there a way to let the users edit their usernames? Today, I googled for such a code for a while and had no luck finding a solution except a few plugins. I didn't find any tutorial for doing so. These are the plugins I found- Username changer and BuddyPress user name changer. The first plugin's interface is no good and I want to offer the users a native interface to edit user names. Brajesh's BuddyPress user name changer is similar to what I expected. But that works only if BuddyPress is setup. Could any suggest me a nice way to let the users edit their user names? Plugins would help me. But I can also manage to code if someone guide me through. **Update:** I am looking for a solution to edit the default **usernames** because sometimes, there would be a problem with the default user name appearing for the public. When you use Social Networks via OAuth(Twitter and Google etc.) for your member login , the user accounts will created with prefixes like _Yourfullname-Google_ or sometimes _Yourfullemailaddress-Google_. The author URLs appear like this- _site.com/author/twitter-random-name_ or _site.com/author/google-profile-address-uglyurl_. Here the user's profile URL appears ugly or lengthy and doesn't look in a normal way like-site.com/the- author-name Also I use a plugin named Quick Subscribe which helps us to get users subscribe and register account just using their email addresses creating random passwords. Here the problem is that the the user names will be created based on the email address(ex: userfullemailaddressgmail.com). The plugin is not popular as it has to be, but that helps people like me to let the users subscribe with single email address. The author URLs appear like this- _http://site.com/author/author-full-email- addressgmailcom_. The user's email address is blown out to the spammers. I can't resist using this subscribe plugin because of it's usability. In such cases I want to let users edit their user names to save themselves being their email addresses revealed to the public.


Multiple Stylesheets For Post and post type?

Hi i'm asking this question here because i don't know exactly how to put this into words on google lol. But I have a blog and i am using custom post type and each post type will have a different stylesheet. The Post types will all have the same way of displaying content but the homepage will be different. I realize that importing the header may be a problem. her are the examples. ![enter image description here](http://i.stack.imgur.com/W7Zx4.jpg) ![enter image description here](http://i.stack.imgur.com/iME0X.jpg) Notice the first photo is the index, the home page, the second photo is a custom post type page. On the home page there is no banner at the top but on the custom post type page it is. Is there an easier way for me to implement the header and different css styles so that i won't have to go in and rearrange all custom post type pages if i decide to make a change to the header of the site. Right now All i know is, taking the header and the index.php file putting them together in the custom post type template and creating it's own css template as well. Is there an easier way for me to have the "php get header" function and add the banner without having to go in each post type template to edit the header.


How should I structure my post types?

For the site I am making, I have a few post types: News, Events, Projects, Placements. Each one of these post types will need its own archive page, accessible through the navigation. I am able to create these post types using the Types plugin, but my question is how do I create a archive page for them? I can't figure out what the URL will be. `/projects` for the post type with slug `projects` gives me nothing. I think I understand how the templates for custom post types work (`archive-{post-slug}.php`), but I don't know how to make these pages accessible.


Get single image from custom fields made with WCK custom fields creator

I used WCK Custom Fields Creator to create a repeatable custom field for uploading pairs of images (one color, one black and white) to posts. So for example, one post may have three fields, with two images (one color and one bw) each making a total of six images per post. I am trying to create a page that outputs the first field of two entries for every post in that specific category. Here is the code I have now, which spits out all of the image pairs. I dont know PHP well enough to figure out how to fix this code.
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post();        $productimgs = get_post_meta( $post->ID, 'productimg', true );             if (is_array($productimgs) & $productimgs != '' ) {              foreach($productimgs as $productimg) {         $image_color = wp_get_attachment_image_src( $productimg['product-image-color'], 'grid-large' );         $image_bw = wp_get_attachment_image_src( $productimg['product-image-bw'], 'grid-large' );         echo '
';         echo '';         echo '';         echo '
';         }     }     ?>     <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>
      I did a var_dump to see what the `$productimgs` variable outputs which I copied below:                   array(3) {      [0]=> array(2) {      ["product-image-bw"]=> string(3) "211"      ["product-image-color"]=> string(3) "212" }      [1]=> array(2) {      ["product-image-bw"]=> string(3) "214"      ["product-image-color"]=> string(3) "215" }      [2]=> array(2) {      ["product-image-bw"]=> string(3) "216"      ["product-image-color"]=> string(3) "217" }     }                array(2) {      [0]=> array(2) {          ["product-image-bw"]=> string(3) "253"          ["product-image-color"]=> string(3) "254" }     [1]=> array(2) {      ["product-image-bw"]=> string(3) "255"      ["product-image-color"]=> string(3) "256" } }           array(3) {      [0]=> array(2) {          ["product-image-bw"]=> string(3) "211"          ["product-image-color"]=> string(3) "212" }     [1]=> array(2) {          ["product-image-bw"]=> string(3) "214"          ["product-image-color"]=> string(3) "215" }      [2]=> array(2) {          ["product-image-bw"]=> string(3) "216"          ["product-image-color"]=> string(3) "217" } }


Insert a div class inside wordpress menu

About Assetline
Products & Services

Commercial Credit

Portfolio Management

News & Events
      This is the menu structure what I want to integrate into wordpress . But there's an issue to add a div id ( ) inside of a menu . Any idea to achieve this ?


Wordpress show different custom post type

In wordpress I want two different types of custom post. In one section I want to post all the `latest news` and in other I want to use as `blog`. In `latest news` post type when I will make a news it should display in the news section and in blog section when I will add a blog it should show in blog section. So can someone kindly tell me how to do that? Kindly remember that I have two different types of styles in the two different custom post in fronted. So can someone kindly tell me how to do this? I am currently using wordpress twentytweleve theme. Any help and suggestions will be really appreciable.


How to create content automatically when a post is published?

**Goal:** Ability to automatically create content in WordPress posts/pages. **Goal Details:** When a post is created/published, it will automatically create or configure content based on the base data inputs of: Post Title, Category, Tag, Image File Name, Website Name, and or a "select" set of keywords or phrases and a standard set of generic content. **Image of Concpet** Automatic Post Creation Concept   **Question:**   1. Is there a plugin that will automatically create content "inside" the post editor?   2. Is there a coded solution that will automatically create content when a post is created? **Process Concept** : Below describes the steps & how I envision this process operarting:   1. An image will be added to a post via media library.   2. A title is added to post   3. A category is added to post   4. A tag is added to post.   5. Post is published.   6. **RESULT:** Automatically a set DISPLAY OF CONTENT will be displayed in the post. On the front end, the content will be displayed. Various labels will automatically display the various keywords based on the image name, post title, category, tag labels, thereby creating a unique post. The rest of the content will be standard. To help inspire thoughtful discussion & research, the ideas I came up with include the following. However, it still begs the question how in each case & what's the best method. **Possible Ideas/Solutions:**   1. Create a custom Field that automatically produces the content   2. Create a widget I can click on that will produce the content via short code. Then I I’ll be able to edit the customized set of content (Template 1 or Template 2, etc) from a different area.   3. Create ability to automatically import a bulk set of posts with content that will automatically adjust to a set of label/keyword identifiers.


Setting a default placeholder image WITHOUT link

Can anyone help? I'm trying to show a default placeholder image on my posts when the user hasn't uploaded an image. I have the below code BUT i need to rewrite it so that the link isn't applied to the placeholder image - only the uploaded image. Unfortunately my PHP isn't great at all so would appreciate some help..
<a href="<?php the_permalink(); ?>">                <?php         // Must be inside a loop.              if ( has_post_thumbnail() ) {             the_post_thumbnail('size-2');         }         else {             echo '';         }         ?>


Redirect A URL Pattern In WordPress Using .htaccess

I am new to WordPress and just converted from Blogger to WordPress. Now as you know that Blogger URLs are too different from WordPress URLs so after migrating I started receiving 404 error in Google WebMaster as its still crawling my old links because I have about 10lac backlink according to Google Webmaster. So now Someone said to me to use .htaccess to make Google crawled 404 error URL to your new WordPress URLs so I moved on but when I saw that I have 900+ articles so it mean to loose precious time. Now I am thinking to use Pattern Redirect using .htaccess so that from one .htaccess rule I can handle my all URL and can able to remove 404 error from Google WebMaster. I want to redirect the below pattern so can you help me?   1. `/search/label/website` to `/category/website`   2. `/year/month/post-title.html/?m=0` to `/year/month/post-title.html`   3. `/year/month/post-title.html/?m=1` to `/year/month/post-title.html`   4. `/year/month/post-title.html?m=0` to `/year/month/post-title.html`   5. `/year/month/post-title.html?m=1` to `/year/month/post-title.html`   6. `/search` to `/` Please keep in mind that sometime there are variable in URL so we also want to avoid that that always start from `?variable=value&variable=value`.


Get content from WordPress posts in Boostrap modal window - Javascript side?

I have a WordPress page with a grid that pull posts. Each post is in a box showing the title + thumbnail and upon clicking on it the content of the post should also appear in the modal (namely, pulling the data from the post which is clicked). I have been looking at this example: Open WordPress Posts in Bootstrap Modal and can get it working via data attributes, namely:
          <?php       $labels = new WP_Query(array(      'post_type' => 'x',       'posts_per_page' => 1000       ));        while ( $labels->have_posts() ) :        $labels->the_post();       ?>
            <?php echo '
';?>          <a href="<?php echo get_permalink(); ?>">       <?php the_post_thumbnail('');?>            **<button type="button" data-toggle="modal"        data-target="#myModal-<? the_ID(); ?>"><?php the_title();?></button>**
           <div id="myModal-<? the_ID(); ?>" class="modal hide fade"       tabindex="-1" role="dialog" aria-labelledby="myModalLabel"        aria-hidden="true">

           <?php the_title();?>

           <?php the_content();?>

         <?php the_post_thumbnail(); ?>

         <button type="button" class="close" data-dismiss="modal"         aria-hidden="true">×</button>

                <?php endwhile; ?>      <?php wp_reset_query(); ?>
      But unfortunately I just cannot get it working via Javascript. Would be great if anyone can help me with the code and how I can implement the dynamic feature in it? The following just doesnt work, if I have instead of the button:               <a href="#myModal-<? the_ID(); ?>" data-toggle="modal" id="clickme">       <?php the_title();?>           and then in the js file the following:                 **$(document).ready(function(){          $("#clickme").on        ("click", function(){ $("myModal-<?the_ID();>").modal();});        });**      Thank you SO much!


Output HTML only on individual post view

I am looking for a way to output some html (javascript actually) on a post view only and not on a main page, tag, category view (where WP outputs several posts). E.g it would be output on this page blog.yourdomain.com/2012/05/some-post/ But not on blog.yourdomain.com/ blog.yourdomain.com/category/xxx/ blog.yourdomain.com/tag/yyy/ etc. **The HTML to be output is different for each post**


Woocommerce - Add a product to cart programmatically via JS or PHP

I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to it's cart via some call or function rather than using it's own 'add-to-cart' buttons. By this I basically mean send Woocommerce a SKU and quantity for example and have the cart update.               sendToCart('123456', 55);      etc I've looked through the documentation and can't seem to find a reference to this sort of thing. Can anyone suggest how I might achieve this?


How to place HTML tags in content from the_content()?

Firstly, I am new to Wordpress so thank you for your patience. I have a list of posts (with excerpts) being displayed in the page using Short Tags. The output is fine , However, I wish to add and change some tags which is coming as a content from the_content as I see under page.php file of my theme files. Any direction / guidance is greatly appreciated. Many thanks.


Custom Post Type, WP_Query and 'orderby'

I do have a custom post type with the following setup:               $supports = array(         'title'         , 'editor'         , 'thumbnail'         , 'revisions'         , 'page-attributes'     );          $args = array(       'hierarchical' => true       , 'supports' => $supports       [...]     );          register_post_type('myType', $args);      I would like to show all posts and have them sorted like in the wp-admin area (indention is for readability):               1,      2,      3,         1, (parent 3)        2, (parent 3)     4      Therefore I tried the following query with the order-type set to 'menu_order':               $loop = new WP_Query( array(            'post_type' => 'myType'          , 'posts_per_page' => 50          , 'orderby' => 'menu_order'          , 'order' => 'ASC'     ));      Unfortunately all post are sorted by `menu_order`, but by `menu_order` exclusively, ignoring the parent relationship (`post_parent` attribute). So I get something like this               1,     1, (parent 3)     2,      2, (parent 3)     3,     4      Changing the query to `'orderby' => 'parent menu_order'` leads to the following               1,     2,      3,     4     1, (parent 3)     2, (parent 3)      So all in all it looks to me, as everything works as designed and the orderby- value is directly translated to the corresponding SQL 'Order By'. ### Question What is the easiest way to get the desired order? ### SQL I assume this is the main sql-query wordpress creates:               SELECT SQL_CALC_FOUND_ROWS wp_2_posts.ID      FROM wp_2_posts      WHERE 1=1 AND wp_2_posts.post_type = 'inhalt' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private')      ORDER BY wp_2_posts.post_parent, wp_2_posts.menu_order ASC LIMIT 0, 50      which is then followed up with:               SELECT wp_2_posts.*      FROM wp_2_posts      WHERE ID IN (40,42,44,46,48,50,52,54,56,58,60,76,62,65,69,71,74)          SELECT post_id, meta_key, meta_value      FROM wp_2_postmeta      WHERE post_id IN (40,42,44,46,48,50,52,54,56,58,60,62,65,74,69,71,76)      ### Workaround A known workaround, but not an answer is to give all posts higher and more "spaced" order values, like               100,     200,      300,        310,        320,     400


SQL update post category by post starting letter

I need to update post category based on post first letter.   E.g. all post starting with "A" should go into "A" category. so far i can only select posts starting with "A".               SELECT * FROM wp_posts     LEFT JOIN wp_term_relationships ON     (wp_posts.ID = wp_term_relationships.object_id)     LEFT JOIN wp_term_taxonomy ON     (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)     WHERE wp_posts.post_status = 'publish'      AND wp_posts.post_title  LIKE 'A%'     AND wp_term_taxonomy.taxonomy = 'category'     AND wp_term_taxonomy.term_id = 1     ORDER BY post_date DESC        Any ideas?


Update Post Taxonomy Automatically Based On Date

I am using the below function to set a custom post type taxonomy to a certain term based on the current date. This is for an event that lists upcoming, ongoing, and future events at a venue. I need the taxonomy term to automatically update based on the current date. Right now, this function only works if I go into the post and click update so that the function runs on save_post. Someone else mentioned I need to use javascript for this, but I'm dumb when it comes to js. Here is the function:               //Set post_status based on the current date     function set_event_status($post_ID) {         $start = strtotime(get_field('start_date'));          $end = strtotime(get_field('end_date'));         $now = strtotime('now - 7 hours');         if ($start && $end) {             if (($start <= $now) && ($end >= $now)) {                 $status = 'playing_now';             } elseif ($start >= $now) {                  $status = 'opening_soon';             } elseif ($end < $now) {                 $status = 'closed';             }         } elseif ($start) {             if ($start <= $now) {                 $status = 'closed';             } elseif ($start >= $now) {                 $status = 'opening_soon';             } elseif ($start == $now) {                 $status = 'playing_now';             }         } else {             $status = 'closed';         }         wp_set_post_terms( $post_ID, $status, 'event_status' );         return $post_ID;     }     add_action( 'save_post', 'set_event_status' );


background images WP Supersized on homepage

I'm using the WP Supersized plugin to load background images on posts and works fine. The problem I have at this point is I want to show the latest post in cat 17, with custom field key FeaturedOnHomepage, with value yes on my homepage and display the background images from that post. Below the query I use:                       <?php query_posts('cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes'); ?>             <?php if (have_posts()) : ?>             <?php while (have_posts()) : the_post(); ?>                 <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?>                <?php endwhile; ?>                 <?php else : ?>                 <?php endif; ?>      Somehow WP Supersized is getting confused and is showing the default image folder (like all images in the Media Library. Do I need to include code to make this work?


Unique Post Meta Values

I want to use Unique IDs like YouTube video IDs and WordPress post IDs in a custom field 'youtube_id'. I just created a front-end add post page and want to check if 'youtube_id' used or not used in a older post.                   $title = 'blah blah blah';         $different=mysql_query("SELECT post_title FROM wp_posts WHERE post_title='$title'");         if(mysql_num_rows($different)>0) {         echo 'Dude, we already have this post.';         }      this code looks for post title is unique or not. I need something similar with this. But I need to use postmeta, not post_title. Any idea to check it with WordPress functions or mysql? PS: Sorry for my poor English.


How does WordPress know if a URL doesn't exist?

The WordPress theme I am using didn't come with a proper Error 404 handler and I'd like to add one to the code. I am having a hard time how WordPress determines if a URL does exist as a post, is a search query, or doesn't exist. I'd like to know where the code WordPress uses is located, or how WordPress determines this as I need to implicate it in the theme files.


Pagination for custom post types

Hi I have a custom post type and its posts are called via a shortcode on any other post or page. I'd like to paginate this post type, say display 10 items. So the page in the URL remains the same, but the content inside (via shortcode) changes when I go to the 2nd page from the pagination buttons. How do I do this?


Creating Tables in WordPress Database

I'm planning to make a database for my wordpress website. It is to store (and retrieve) information about the products the members want to sell. As far as i understand, i have to make the tables in wp database self. ( I'd used this source ) But i'm new in php and wp and i don't know how i can create tables in wp_database. Thanks a lot!


Upgrade wordpress core programmatically with PHP

**What I want to do** I want to upgrade Wordpress programmatically to a later version. That I want to do with PHP, lets say from http://www.example.com/?upgrade_wp=true I already know how to get the URL of the latest version so I don't having any problem with checking for versions or finding the right URL. **Answers I want**   * A link to a tutorial of how this is done.   * A plugin that does this and not so much more.   * A hint to the functions that I need to use. **Answers I don't want**   * The way to do it with SVN or subversion.   * Answers containing Wordpress MU.   * How to manually doing this.   * How to do this with other code than PHP.


Allow Google crawler to crawl specific Author pages

I have a WordPress website with thousands of registered users. For each user a profile page is created. Most of these pages are low quality because most users do not fill their profile with information, therefore, I don't want search engines indexing these pages. However, some Author pages are high quality. At the moment I'm using WordPress SEO plugin to add a noindex metatag in Author pages, I know I could also block the `/Author/` directory in robots.txt. But the thing is, I want to allow crawlers to crawl those specific high quality Author pages. Any ideas?


How to reset a custom theme

After making a lot of little changes to the current custom theme [zeeBizzCard] I'm using, I want to reset it back to it's original style. Being new to WP, I didn't make a backup of the default theme and can not find a quick and easy method of reseting the theme. Have I missed something, or is there no "reset" options for downloaded themes? Thanks


Help sorting by Meta Key value

using this https://github.com/growthspark/wp-advanced-search I am not sure how to sort by meta_key value. I currently have a meta key called "Due Date" with the date entered like 06/06/2012 (M/D/Y). The search framework is nothing special, as it is simply php and wordpress codex standards so I hope someone can help. I have something like this                              $args['fields'][] = array('type' => 'meta_key',                                             label' => 'Test',                                             'meta_key' => '',                                             'format' => 'select',                                             'values' => array());      but it is not right. Any ideas?


setting comments off as default for pages and custom post types?

I want to turn the comments off by default with pages and custom post-types Initially I simply used conditionals in the comments display function to avoid displaying the block on these pages, but I need the user to be able to turn the comments back on as required.


How to make get_template_part always check child theme first?

How can I force WP to always check the child theme folder first when running `get_template_part`? Example: child theme loads `get_template_part('content', 'inventory')` in `single.php`. Because all child themes (and there are a lot) share the same common inventory template base, the file `content-inventory.php` is in the parent theme. So far so good. I would like to add a small section to said inventory template that will be unique to each child theme. Adding `get_template_part('content', 'inventory- special')` into `content-inventory.php` will not check the child theme directory first.


Function to check whether the user is at the top level of the network?

I need a conditional to check to whether or not to execute code at the top level of network admin pages: `/wp-admin/network`


Switch Categories on a Specific Date?

I usually like to provide a code I've started with and have others help me out with it - but this is one where I don't even know where to begin. I would like to be able to set a date on posts in which the selected post will automatically be moved to another category. Has anybody attempted this?


For loop logic for combinations

I have WP E-Commerce installed and I'm moving whole it's dashboard to frontend. I have everything ready and am on the last part. In fact I thought this part was ready, until I added two variations, where I understood that it works a little bit different. Let me show you what I'm talking about. ![variations1](http://i.stack.imgur.com/nEh2j.png) And this are product variations ![variations2](http://i.stack.imgur.com/rNrcf.png) here every variation from second category is assigned to first like (1,a;1,b;1,c);(2,a;2,b;2,c);(3,a;3,b;3,c); Here is my codebin So how to remake my for loop with some nested for loop ( I guess ) to work like combinations. At this moment it just creates separate variations without nesting them.               $parent = $_POST['variationParent'];     $children = $_POST['variationChild'];     if(!empty($parent)) {         $affparent = wp_set_post_terms( $post_id, $parent, 'wpsc-variation', true );         $affchildren = wp_set_post_terms( $post_id, $children, 'wpsc-variation', true );         $N = count($children);         for($i=0; $i < $N; $i++) {             $cat_id = (int) $children[$i];             if(!in_array($cat_id,$varArray)){                 $cat = get_term( $cat_id, 'wpsc-variation' );                 $new_entr = array();                 $new_entr['post_title'] = esc_attr(strip_tags($_POST['postTitle'])) . " (" . $cat->name . ")";                             $new_entr['post_content'] = esc_attr(strip_tags($_POST['postContent']));                                 $new_entr['post_status'] = 'inherit';                                 $new_entr['post_category']  = $cat->term_id;                                 $new_entr['post_type'] = 'wpsc-product';                                 $new_entr['post_parent'] = $post_id;                                 $new_entr['post_author'] = $user_id;                                 $var_id = wp_insert_post($new_entr);                                 wp_set_post_terms( $var_id, $cat->term_id, 'wpsc-variation' );                                 update_post_meta($var_id, '_wpsc_price', $price);                                 update_post_meta($var_id, '_wpsc_special_price', $special_price);                                 update_post_meta($var_id, '_wpsc_sku', $sku);                                 update_post_meta($var_id, '_wpsc_stock', $stock);                             }                         }                     }       I think at first I need to remake my FORM to chain parents with their parent.               <fieldset>

             <?php                 $parentArray = array();                 foreach ($parentVariations as $variation) {                     $parentArray[] = $variation->term_id;                 }                 foreach($variationCategories as $category) {                     //var_dump($category);                     //echo ;                     // check if this variation is already checked                     if (in_array($category->term_id, $parentArray)) {                         if ($category->parent == 0) {                             echo "

<input type='checkbox' checked name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";                         } else {                             echo "

<input type='checkbox' checked name='variationChild[". $category->parent ."][]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "

";                         }                     } else {                         if ($category->parent == 0) {                             echo "

<input type='checkbox' name='variationParent[]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "";                         } else {                             echo "

<input type='checkbox' name='variationChild[". $category->parent ."][]' autocomplete='off' value='". $category->term_id ."'>" . $category->name . "

";                         }                     }                 }             ?>
     </fieldset>      That's the output of this form. first value in array is parent termID and second is ChildID.               array(2) {           [3]=> array(3) {               [0]=> string(1) "4"               [1]=> string(1) "5"               [2]=> string(1) "6"         }          [7]=> array(3) {               [0]=> string(1) "8"               [1]=> string(1) "9"               [2]=> string(2) "10"         }     }      So my code should assign all values from parent[7] to parent 3. meaning in the end of the loop, there will be 9 variations. Question is, how to solve this nested loop. count parents first and and nest that many loops (or foreach) ? (also might be interesting how wpsc deals with that, which I don't understand at all wpsc class


How we display Archives for specific categories

I just want to show `Archives` for special categories. For example i have `categories` `abc`,`xyz`. I just want to show `Archives` for `xyz` not for abc. Currently i am using code to display Archives is

<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'li', 'show_post_count' => 1, 'include'=>1 ) ); ?>

      so how can i show `Archives` for `xyz` `category` only. Thanks


How can I use wp_save_image_editor_file filter?

I would like to use `wp_save_image_editor_file` filter, but there is no documentation on the internet. Also, it seems that no matter how many arguments I pass to the handler, all are null.


How to make wp cron job not fire immediately?

I'm scheduling a job in wp cron:               add_action('my_cron_hook', 'my_cron_action');     wp_schedule_event( time(), 'interval1', 'my_cron_hook' );           function my_cron_action(){         //do something     }      The variable interval1 is set by the admin in another part of the code.   Also, there is a switch that lets the admin _enable_ or _disable_ the wp crop job. **My problem is this:**   my_cron_action is executed as soon as it is scheduled   (this means, as soon as the admin enables the cron job from the backend). **What i want to do is this:**   if we suppose that the time that the admin enabled the job is **T** ,   i want the job to be run at **T+interval1** for the first time, and _not at T_. The next thing i want after this is done, is to create a button "Execute job now" that will run the job as soon as it's clicked.


Load more posts (Ajax) in tabbed sidebar on single.php

I'm trying to use this approach http://wordpress.stackexchange.com/a/56349/18144 to create a 'load more' button in the sidebar on single.php. I would like to able to load more posts in a sidebar tab after clicking the load more button. I'm missing something, since it doesn't work. But there are no errors in the console, so I don't really know where to start. The sidebar on single.php has the following (simplified)structure:
....

...

...

Up | My Fav's |Load More

           What I've got so far: In functions.php I've added:               add_action( 'wp_enqueue_scripts', 'wpa56343_scripts', 100 );          function wpa56343_scripts() {     wp_enqueue_script(         'wpa56343_script',         get_template_directory_uri() . '/js/ajaxscripts.js?ver=1.0',         array( 'jquery' ),         null,         false     );     wp_localize_script(         'wpa56343_script',         'WPaAjax',         array(             'ajaxurl' => admin_url( 'admin-ajax.php' )         )     );     }          add_action('wp_ajax_wpa56343_more', 'wpa56343_more');     add_action('wp_ajax_nopriv_wpa56343_more', 'wpa56343_more');          function wpa56343_more(){     global $wp_query;          $offset = $_POST['postoffset'];     $args = array(         'offset' => $offset,         'posts_per_page' => 10     );     $wp_query = new WP_Query( $args );          get_template_part( 'includes/ajaxsidebar');     exit;     }      ajaxscripts.js contains:               jQuery(document).ready(function($){          $('#blog-more').click(function(e){ // <- added         e.preventDefault(); // <- added to prevent normal form submission         var postoffset = 5;         $.get(             WPaAjax.ajaxurl,             {                 action : 'wpa56343_more',                 postoffset : postoffset             },             function( response ) {                 $('#new').append( response );             }         );     });          });      template part ajaxsidebar contains:               <?php if (have_posts()) : ?>                <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail() ?><?php the_title(); ?>
                <?php endwhile; ?>      <?php endif; ?>


Update widget form after drag-and-drop "only specific plugin"

This solution, Update widget form after drag-and-drop, works correctly but I want to adapt this function to affect only a **specific plugin and not every plugin**. How could I do it?


Get data from Theme Options and use them into meta options field in custom post type

I want to grab data from my theme options and have to use them in meta option fields in custom post types. I know how to grab theme option data and show them on front pages but don't know how to grab it for backend usage. I want to use data from one of my theme options text field and put it into my metabox text field. Actually I have two check boxes on my metabox text field and also two metabox text fields above that text field. Also two text fields in my theme options in which I have to put some html and javascript code. So here is my code: Metabox text fields and checkboxes:               <input type="textarea" id="c" value="Your Name" />     <input type="textarea" id="d" value="My Name" />     <input type="checkbox" id="a" />     <input type="checkbox" id="b" />     <input type="textarea" id="e" />      Theme Option Text fields:               <input type="textarea" id="f"  />     <input type="textarea" id="g"  />      I have to put javascript in theme option text fields somewhat like this:               <div>     <script type=text/javascript> name: 'My Name is/', name2: 'Your name is/', </script>      </div>      Now comes the real worry. I want that when I click check box with the id 'a', the code from the theme options text field with the id 'f' will be put into the metabox text field with the id 'e' but with little modification. The modification i need is that the data from metabox text fields with the id 'c' and 'd' will first be added to the code that has been grabbed from the theme option text field with the id 'f' in such a way that value of metabox text field with the id 'c' is added to the "name: My Name is/(Here will be the value of text field with the id 'c')" and value of metabox text field with the id 'd' is added to the "name2: Your Name is/(Here will be the value of text field with the id 'd')". I am also using jquery code for these checkboxes behaviour. Here is my jQuery code.               $(function () {     $('#a, #b').change(function () {         var $a = $('#a'), $b = $('#b'), $c = $('#c');         if (this.id == 'a' && this.checked) {            $c.val('Hello World!');            $b.prop('checked', false);         } else if (this.id == 'b' && this.checked) {            $c.val('Not hello World!');             $a.prop('checked', false);         } else {            $c.val('');         }     });     });       Obviously there is flaw in this jQuery code as I don't want these values such as Hello world or Not Hello World of my metabox text field with the id 'c'. I want the value of that field as I explained earlier. Please help me in this regard. I am very much frustrated.


Exclude Author by ID

How can I exclude authors by ID from this:               <?php     //displays all users with their avatar and their posts (titles)     $blogusers = get_users_of_blog();     if ($blogusers) {       foreach ($blogusers as $bloguser) {         echo '
';         $user = get_userdata($bloguser->user_id);         echo '
' . get_avatar( $user->ID, 128 ) . '
';         $args=array(           'author' => $user->ID,           'post_type' => 'post',           'post_status' => 'publish',           'posts_per_page' => 1,           'caller_get_posts'=> 1         );         $my_query = null;         $my_query = new WP_Query($args);         if( $my_query->have_posts() ) {           //echo 'List of Posts for ' . user->user_firstname . ' ' . $user->user_lastname;           while ($my_query->have_posts()) : $my_query->the_post(); ?>


Add a custom stylesheet for BlackBerry

I want a little help loading a custom stylesheet in wordpress. I'm using PHP to check if the user agent is BlackBerry. If yes, I want to load blackberry.css, if no, regular wordpress style.css. Here's what I have so far:               $ua = strtolower($_SERVER['HTTP_USER_AGENT']);        $pos_blackberry = strrpos($ua, "blackberry");        $pos_webkit = strrpos($ua, "webkit");             if (!($pos_blackberry === false)) {           if (!($pos_webkit === false)) {                   **//load blackberry.css**                }        } else {          wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );        }      **Question:** what is the "grammatically correct" WordPress syntax for loading blackberry.css stylesheet?


How I can change PayPal IPN 'custom' field in woocommerce?

I use Woocommerce plugin. All works great, but I need add to PayPal IPN 'custom' field only 1 word instead "order_id" that writes at 'custom' field now. I trying edit this file: ...woocommerce/classes/gateways/paypal/class-wc- gateway-paypal.php here you can see code here screenshot of code that maybe needs to change Need to change script that send "order_id" to PayPal on script that send my word to PayPal. That's all. I believe it's easy to do. Please help. Appreciate any answers. Thanks.!


JS plugin script loading but not working

I am trying to create a theme using curtains.js but am having a few problems. I have both registered and enqueued the script and the part that would go in the footer like so:               add_action('wp_enqueue_scripts', 'tf_load_custom_scripts');          function tf_load_custom_scripts() {         wp_register_script('curtain', get_template_directory_uri().'/js/curtain.js', array('jquery'), 2.0 );          wp_register_script('curtain-instance', get_template_directory_uri().'/js/curtain-instance.js', array('curtain','jquery'), true );               if( is_front_page() ) {             wp_enqueue_script('curtain');             wp_enqueue_script('curtain-instance');         }              wp_enqueue_script('custom_script', get_template_directory_uri().'/js/script.js', array('jquery'), 1.0, true );          }      I've also changed all the `$` to `jQuery` to comply with no-conflict rules. My scripts all seem to be loading fine but not running. I'm probably missing something very obvious. Thanks in advance for any insight.


Order by meta values

I have 3 meta fields related to dates:   * `year = 2012`   * `release_date = 14 November 2012`   * `release_date_db = 20121114` I need to show the posts from year 2012 sorted by release_date. I made this:               query_posts('meta_key=year&meta_value=2012&order=ASC&posts_per_page=7');      How can I order posts by `release_date` or `release_date_db`?


Why does WordPress reverse conditional statements?

In WordPress' core code, you often see this:               if (1 == $someVar)      as opposed to this:               if ($someVar == 1)      I don't know if the first way is a WordPress-centric style of coding, but I've only noticed it in WP code (either core or 3rd-party code).


Alter image output in content

I'm trying to implement the JAIL javascript into my WordPress install. The javascript requires me to add a data-attribute and change the output html of images. I have been looking through the codex for filters or hooks that can help me, but i can't find anything. Anyone have a solution?


inner jQuery won't work

i'm enqueuing jQuery with `wp_enqueue_script( 'jquery' );` (i see               <script type='text/javascript' src='http://localhost/wp/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>     <script type='text/javascript' src='http://localhost/wp/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>      in the resulting html page) now, i'm tryin to use:               $(document).ready(function() {         $('#showmenu').click(function() {                 $('.menu').slideToggle("fast");         });     });      and it only works if i add a jQuery reference manually (`<script src="//code.jquery.com/jquery-1.10.2.js"></script>`) do i miss something?


FTP credentials on localhost

> **Possible Duplicate:**   >  wordpress on localhost lamp doesn't let me install plugins I just started working locally with Wordpress. Trying to update theme/plugins I get asked for my FTP credentials and I get really confused...what the heck is my FTP credentials when working locally?


wordpress on localhost lamp doesn't let me install plugins

i've installed a LAMP server on my ubunutu 11.04. i've installed wordpress and hooked it right with the MySQL db. i've changed the permissions of the www- data group to read and write files. every thing is seems to work and i can manage the site through the admin panel, but i can't install plugins cause the system is asking me the FTP details, and i can't seem to go through it. can any body help? please...


Trying to display stick or featured post on homepage

Im trying to add the last sticky post to a section on my homepage as a Featured article. I have created this so far and it displays posts but not the sticky ones:               <?php query_posts(array('post__in'=>get_option('sticky_posts'),'showposts' => 1 )); ?>     <?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
         <?php the_content(''); ?>     <?php endwhile; ?>     <?php wp_reset_query(); ?>      I have tried to change the query_posts to get_post. The problem then is that it displays the other 3 'latest news' posts from the other loop at the top of the page. Any help would be really really appreciated


get_terms - only top level

I am trying to get only top level term:               $cat_args = array(         'parent '       => 0,         'number'        => 10,         'hide_empty'    => false,                );          $categories = get_terms( 'question_category' , $cat_args);       But this query return all childterms too, I tried everything but it always get child terms too. I am trying since last 5 hours and can't find whats wrong in my code, is this a WP bug or there is something wrong in my code ? Thanks for helping.


How to hold all comments for moderation, including author's comments on own post

I want all comments no matter what, to be held for moderation and not appear till approved by an admin. Wordpress allows author comments on own posts to show up without holding for moderation. Any way around that please?


Taxonomies not appearing in columns on dashboard

I'm having some issues trying to get taxonomies to appear in the post columns on my dashboard, the custom functions appear correctly, just not the taxonomies, anyone see where I'm going wrong? Here is a screenshot showing the issue: http://i.imgur.com/GiMSfhF.png               // Add filters for the Games Database in the control panel     add_filter( 'manage_edit-games_database_columns', 'my_columns' );     function my_columns( $columns ) {     $columns['games_database_platform'] = 'Platform'; // Taxonomy     $columns['games_database_genre'] = 'Genre'; // Taxonomy     $columns['games_database_publisher'] = 'Publisher'; // Custom Function     $columns['games_database_developer'] = 'Developer'; // Custom Function     $columns['games_database_rating'] = 'Review Score'; // Custom Function     unset( $columns['comments'] );     return $columns;     }     add_action( 'manage_posts_custom_column', 'populate_columns' );     function populate_columns( $column ) {     if ( 'games_database_publisher' == $column ) {         $game_publisher = esc_html( get_post_meta( get_the_ID(), 'game_publisher', true )     );         echo $game_publisher;     }     elseif ( 'games_database_developer' == $column ) {         $game_developer = get_post_meta( get_the_ID(), 'game_developer', true );         echo $game_developer;     }     elseif ( 'games_database_rating' == $column ) {         $game_rating = get_post_meta( get_the_ID(), 'game_rating', true );         echo $game_rating . '%';     }     elseif ( 'games_database_platform' == $column ) {         $game_platform = get_post_meta( get_the_ID(), 'games_database_game_platform', true );         echo $game_platform;     }     elseif ( 'games_database_rating' == $column ) {         $game_rating = get_post_meta( get_the_ID(), 'game_rating', true );         echo $game_rating . '%';     }     }


Make Textarea a TinyMCE (editor box)

Ive picked up an old plugin and am needing to enhance it for my clients specific needs. In the admin section there is a text area used to add info about a download (essentially a custom post type). However the description field is a simple text area, and so only text is stored. The client need to be able to use this in a similar fashion to the post or blog editor elsewhere in WP. Primarily it needs to add new lines and formatting without the need to manually add html. So, from my limited knowledge of WP I'm assuming that the way forward is to some how tell WP to make this utilise the TinyMCE... Here is the function used to create the in the relevant admin page;                   public function display_sdm_description_meta_box($post) {  // Description metabox         _e('Add a description for this download item.', 'sdm_lang');         echo '

';              $old_description = get_post_meta($post->ID, 'sdm_description', true);         ?>         <textarea id="sdm_description" name="sdm_description" style="width:60%;height:100px;"><?php echo $old_description; ?></textarea>         <?php         wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');     }      If someone could show me how to adapt this code to get the required result, I'd be really grateful. Thanks in advance!


Mandatory excerpt for custom post type

This is proving to be a challenge. I'm trying to make the excerpt a required field, but only when editing/saving a post in a custom post type. The following code makes the excerpt a required field for all posts, but doesn't take into account for narrowing its affect to a single custom post type.               function mandatory_excerpt($data) {       $excerpt = $data['post_excerpt'];            if (empty($excerpt)) {         if ($data['post_status'] === 'publish') {           add_filter('redirect_post_location', 'excerpt_error_message_redirect', '99');         }              $data['post_status'] = 'draft';       }            return $data;     }          add_filter('wp_insert_post_data', 'mandatory_excerpt');          function excerpt_error_message_redirect($location) {       remove_filter('redirect_post_location', __FILTER__, '99');       return add_query_arg('excerpt_required', 1, $location);     }          function excerpt_admin_notice() {       if (!isset($_GET['excerpt_required'])) return;            switch (absint($_GET['excerpt_required'])) {         case 1:           $message = 'Excerpt is required to publish a post.';           break;         default:           $message = 'Unexpected error';       }            echo '

' . $message . '

';     }          add_action('admin_notices', 'excerpt_admin_notice');


How to add a class to Buddypress avatars in the Activity stream?

I'm in the process of trying to integrate bootstrap with Buddypress and am trying to add a class of "media-object" to Buddypress avatars. I could do this by mimicking the Bootstrap CSS, but in the interest of learning new things is there a way to add a class, perhaps by using a filter? The bp_loggedin_user_avatar is where the image is created. How can I hook into it and add a class?
             <a class="pull-left" href="<?php echo bp_loggedin_user_domain(); ?>">                 <?php bp_loggedin_user_avatar( 'width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height() ); ?>


Custom Post Type Capabilities

I have a custom post type which I want authors to be able to edit others posts but no able to delete others posts. My code as follows:               $labels = array(         'name'          => __( 'Book', 'textdomain' ),         'singular_name' => __( 'Book', 'textdomain' ),         'menu_name'     => __( 'Books', 'textdomain' ),         'add_new'       => __( 'New book', 'textdomain' ),         'add_new_item'  => __( 'New book', 'textdomain' ),         'edit_item'     => __( 'Edit book', 'textdomain' ),     );     $args = array(         'labels'        => $labels,         'public'        => true,         'menu_position' => 6,         'menu_icon'     => 'dashicons-book',         'has_archive'   => true,         'supports'      => array( 'title', 'author' ),         'capabilities'  => array(             'edit_post'             => 'edit_posts',             'read_post'             => 'edit_posts',             'delete_post'           => 'edit_posts',             'edit_posts'            => 'edit_posts',             'edit_others_posts'     => 'edit_posts',             'publish_posts'         => 'edit_posts',             'read_private_posts'    => 'edit_others_posts',             'delete_others_posts'   => 'edit_others_posts',         ),     );     register_post_type( 'book', $args );      What I am experiencing with the above code is:   1. When `'edit_others_posts' => 'edit_posts'`, "mine" tab in admin post editor list doesn't show, and I want it to be always shown. Is it possible to force it back?   2. Even if `'delete_others_posts' => 'edit_others_posts'` (author users don't have the capability to 'edit_others_posts'), authors can delete others posts.   3. If I modify the code above with `'edit_others_posts' => 'edit_others_posts'`, "mine" tab shows up but author users still can edit others posts, which confuse me. I'm really not sure if I am using capabilities the right way or if what I intent to do is possible. Thanks in advance.


Global change of permalink structure across multisite

Is there a way to update the permalinks across an entire multisite without having to update them one by one?


Wp Pagenavi how to display all results

I'm using Wp Pagenavi Plugin. I'm trying to display all results from a button. I'm using this:               $out .= '<form action="" id="showall" method="POST" name="results">     <input type="hidden" name="woocommerce-sort-by-columns" id="woocommerce-sort-by-columns" class="sortby" value="100"><input type="submit" name="submit" value="All">     </form>';      It's working if I'm on the first page, but if I'm on another page (second one / third one..), it gives me the 404 Error message. How can I fix this problem? Thanks.


how to change permalinks from id to name of a particular location

I am working on WordPress permalinks. I wanted to change the permalink URL from `xyz.com/abc/locations/18` (which is location id) to `xyz.com/abc/locations/locationname` With locationid the page is loading perfectly but when I change to locationname the page is giving a 404 error.


Wordpress multisite,several different languages,page redirect?

I have something like this http://example.com/en , http://example.com/fr and http://example.com/es for example I would like if I'm on this page http://example.com/en/about-us/ when I click on other language link,just to redirect to that language,but to stay on same page,for example if I click on link that will go to french site,and I'm currently on http://example.com/en/about-us/, I would like to go to this link http://example.com/fr/about-us/ if that page doesn't exists I would like to be redirect to homepage,is this possible.Hope you understand me,thank you in advance.


How to redirect wp-admin/index.php to a custom post type?

I want to redirect my index.php on the admin side to a custom post type. When I go to mysite.com/wp-admin, it must show a custom post type and not the dashboard. How can I do this?


Send a Notification to a Wordpress Theme

I'm basically looking for something or at least a base line to create a piece of code that allow me to send notifications to my clients via the Wordpress CMS. The Study case is basically like, I'm creating some themes and clients can select between different "modules" to buy, so I'm looking for a way to notify when new modules are available, or when I update some of them. I've been looking for a solution around and I cannot find anything good enough, would be great. Thanks in Advanced.


WP url to get rss with full text of post

I need to curl a wordpress site and fetch in rss format:   1. all categories   2. for a category, all posts. They need to contain title and full body (not description). given my site is somewpsite.com, how do I write the 2 URLs for above needs? thank you.


Display custom content using page.php from theme

I am developing a plugin and need to generate a blank page (load the `page.php` from the current theme) and print custom content such as an HTML form or a message. It should have a URL like `http://example.com/?wpex_page=confirm` How can I display a page with the current theme's page.php and custom content in it? **EDIT (18 Jan 2012):** Found a better and simpler working solution: **Generate a custom/fake/virtual Wordpress page on the fly**


How to prevent parent being choosen in wp_dropdown_categories

I have a grand-parent-category with several parent-category. Each groundchild means a specific method to process later. Parents should not be selected, it merely means to group the children together. I use `wp_dropdown_categories` with `child_of` to show the dropdown form. The parents shows up as a choice which can course confusing for users.               wp_dropdown_categories('child_of'=>$ground_parent_id);      If I add `exclude = $parent_ids`, the whole dropdown list gone.               wp_dropdown_categories('child_of'=>$groun_parent_id,'exclude'=>$parent_ids );      I can throw error message or process to a default value if a user choosed a parent, but this is a way to frustrat my users. Is there any other way to make a dropdown without parent?


Twenty Eleven theme-options error

I was trying to add Google Analytics and added it to the theme-option page by accident when I went to remove the added info I received the following error. Parse error: syntax error, unexpected '<' in /home/content/07/9999407/html/wp- content/themes/twentyeleven/inc/theme-options.php on line 416 Is there a way to restore the twenty eleven theme-option? Self taught and not doing well apparently


How to let user know his session has expired and show him a popup?

Can anyone knows how to show a popup once user session has expired? This is what i want to achive When User has been automatically logged out due to inactivity or session expiration I need to show them a pop-up warning: "Due to inactivity, you have been automatically logged out for security reasons. Please log in again." I have researched a lot but not able to figure out how to handle this?


Multisite - create new site with precreated pages, menu etc

I'm developing a site, where users will be creating their own sub-sites. On new site creation, I would need to prefill it with some Pages, Menu settings etc. Is there an easy way to do this, any hook to use?


Infinite Scroll plugin works but no [shortcode]

On my blog I use the Infinite-Scroll plugin. Works properly, but in the new post loaded I didn't see shortcodes (ex. [jwplayer ..]), or the galleries created by the editor (appears "This slideshow requires JavaScript.") Where is the problem?


Should I use transients for these API call results?

I am consuming an API that gives me a list of people and their profiles. My initial idea was working perfectly fine when it's just the list of people because I was just saving the ids and names using transients and then displaying them on a page. However, I now need to display each person's profile on a page so I reconstructed my idea. My flow is now like this: Hit API Store in cache (transient) Insert in post (custom post type) - my reason for inserting to the DB is because I need to have a format like /people/person_id. /people has the list of people /people/person_id has a person's profile. The API consumer just runs once a day. Is this a good process?


Determine mime type, wordpress mechanism

I need to tell file mime type. I'm really don't want to deal with PECL finfo extension. I don't know what php version client server has. Since I'm using wordpress, and it does have file upload feature, I thought wp should have some mechanism for saving mime types to DB along with attachment. There is mime_type column in db for attachements. Inside include.php I found:               wp_check_filetype_and_ext();      But it returns false all the time.               $appointment_id = $wpdb->insert_id;             $files = $_FILES['files']['tmp_name'];             foreach ($files as $f) {                 $mime = wp_check_filetype_and_ext($f,$f);                 $resp2 = $wpdb->query(                     $wpdb->prepare(                         "INSERT INTO wp_appointments_attch                                      (appointment_id, attachement, attach_type, mime)                               VALUES (%d, %s, %s, %s)",                         array(                             $appointment_id,                             file_get_contents($f),                             $_POST['requireddocs'],                             json_encode($mime)                         )                     )                 );             }             echo $resp2;      This is how my code looks. Is there a better function? I think the fact that wp upload happens by admin from backend, there was no need for more thorough function? I need to see if uploaded binary data is PDF or img.


Filter set-screen-option value not saving in 3.9

This code works fine in 3.7, but not in 3.9 and I have no idea why not. The value 'stores_per_page' is created in the db, but the value is never saved in 3.9. I tried 'init', 'admin_init' and 'plugins_loaded' with this line of code, but it makes no difference.               add_action( 'plugins_loaded', array( $this, 'screen_options' ) );      Also tried to place the set-screen-option add_filter line at the bottom of the create_admin_menu function, but it makes not difference. It never saves the value.               class Screen_Option_Test {          function __construct() {         add_action( 'admin_menu', array( $this, 'create_admin_menu' ) );          add_action( 'plugins_loaded', array( $this, 'screen_options' ) );     }          function create_admin_menu() {         $hook = add_menu_page( 'Screen Test', 'Screen Test', 'manage_options', 'screen_test_menu', array( $this, 'screen_test' ) );         add_action( "load-$hook", array( $this, 'add_screen_options' ) );     }          function screen_options() {         add_filter( 'set-screen-option', array( $this, 'set_screen_options', 10, 3 ) );     }          function screen_test() {         echo 'screen test';     }          function add_screen_options() {         $option = 'per_page';         $args = array(             'label'   => 'Stores',             'default' => 10,             'option'  => 'stores_per_page'         );              add_screen_option( $option, $args );     }          function set_screen_options( $status, $option, $value ) {              if ( 'stores_per_page' == $option ) return $value;              return $status;     }           }          new Screen_Option_Test();      Does anyone see what I'm doing wrong here, and what I would need to change to make it save the screen option value in 3.9?


Sanitize Term Custom Field - apostrophe problem

Alright guys, before posting I've searched the similar questions but I couldn't find the answer. **Problem** : I've added custom fields to a custom taxonomy, when I'm saving the options using (update_options) the single quotes get slashes in front. Text area value: `l'a` Once saved, I get: `l\'a` **What do I use?** I use `sanitize_text_field()` before the update_option, when I get the value from the `$_POST` And then I use `esc_attr()` when printing the value in the textarea. I've reviwed the codex: http://codex.wordpress.org/Data_Validation but I don't seem to find the right combination. **Any ideas?**


Why isn't admin_notices displaying my text? [Simple Plugin, Beginner]

Here is some code that is the result of four days of studying Wordpress and PHP. Unfortunately, it's not working the way it's supposed to. Nothing displays at the admin_notices bar. Originally, I thought it was the **$filename = is_plugin_active($filename) ? "$filename: Active" : "$filename: Disabled";** line, but that was not the problem. What say you?               function show_names()     {                         $paths = array();            foreach (glob("*/plugins/*") as $filename) {                                                                                $filename = is_plugin_active($filename) ? "$filename: Active" : "$filename: Disabled";         $filename = str_replace('wp-content/plugins/', '', $filename);         $paths[] = $filename;            }            $paths = implode("---", $paths);       echo $paths;     }          add_action("admin_notices", "show_names");


How to filter posts by categories?

I have a custom post type and now I need to filter the projects according to their categories and without being directed to another page. Also I need to have `all` category which would show all the projects. Link to the test site. I would appreciate any help. portfolio-type.php:                <?php           if ( function_exists( 'add_theme_support' ) ) {          add_theme_support( 'post-thumbnails' );         set_post_thumbnail_size( 270, 170, true ); // Normal post thumbnails         add_image_size( 'screen-shot', 720, 540 ); // Full size screen      }           add_action('init', 'portfolio_register');             function portfolio_register() {      $labels = array(         'name' => _x('Portfolio', 'post type general name'),         'singular_name' => _x('Portfolio Item', 'post type singular name'),         'add_new' => _x('Add New', 'portfolio item'),         'add_new_item' => __('Add New Portfolio Item'),         'edit_item' => __('Edit Portfolio Item'),         'new_item' => __('New Portfolio Item'),         'view_item' => __('View Portfolio Item'),         'search_items' => __('Search Portfolio Items'),         'not_found' =>  __('Nothing found'),         'not_found_in_trash' => __('Nothing found in Trash'),         'parent_item_colon' => ''     );     $args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => 5,         'supports' => array('title','editor','thumbnail')     );      register_post_type( 'portfolio' , $args );     }          function create_portfolio_taxonomies() {     $labels = array(         'name'              => _x( 'Categories', 'taxonomy general name' ),         'singular_name'     => _x( 'Category', 'taxonomy singular name' ),         'search_items'      => __( 'Search Categories' ),         'all_items'         => __( 'All Categories' ),         'parent_item'       => __( 'Parent Category' ),         'parent_item_colon' => __( 'Parent Category:' ),         'edit_item'         => __( 'Edit Category' ),         'update_item'       => __( 'Update Category' ),         'add_new_item'      => __( 'Add New Category' ),         'new_item_name'     => __( 'New Category Name' ),         'menu_name'         => __( 'Categories' ),     );          $args = array(         'hierarchical'      => true, // Set this to 'false' for non-hierarchical taxonomy (like tags)         'labels'            => $labels,         'show_ui'           => true,         'show_admin_column' => true,         'query_var'         => true,         'rewrite'           => array( 'slug' => 'categories' ),     );          register_taxonomy( 'portfolio_categories', array( 'portfolio' ), $args );     }      add_action( 'init', 'create_portfolio_taxonomies', 0 );          ?>      index.php:

Portfoolio

Tööd:
                                                                      <?php                                $taxonomy = 'portfolio_categories';                           $terms = get_terms($taxonomy); // Get all terms of a taxonomy                                if ( $terms && !is_wp_error( $terms ) ) :                           ?>

A
                                   <?php foreach ( $terms as $term ) { ?>
<a href="<?php echo get_term_link($term->slug, $taxonomy); ?>" ><?php echo $term->name; ?>
                                   <?php } ?>
                           <?php endif;?>
                                     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                                      <?php                                     $title= str_ireplace('"', '', trim(get_the_title()));                                     $desc= str_ireplace('"', '', trim(get_the_content()));                                 ?>
                                      <a class="project-wrp fancybox" title="<?=$title?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>">

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

<?php echo $title; ?>

<?php echo $desc; ?>

                             <?php endwhile; endif; ?>


Multiples Realtions with meta keys

I need multiple relations with meta keys. Bu the follow loop doesn't work.               $args = array(                   'post_type' => 'any',                   'posts_per_page' => 5,                   'meta_query' => array(                            'relation' => 'OR',                        array('key' => 'iframe'),                        array('key' => 'video'),                                'relation' => 'AND',                        array('key' => 'videoflv')                   )                 );


Query Posts with Custom Taxonomy from a Custom Post Type

I've been bashing my head against my desk over this for the past day or so...I have created a custom post type called 'advertisement' and a custom taxonomy within that post type called 'group'. I've created a bunch of different posts and assigned them to the various groups that I have created, but the problem is when I try to query the posts for my custom taxonomy, it comes up empty. When I try to query a regular post with the default category it works fine, so I'm beginning to think it has something to do with the way I have setup my taxonomies. I've already tried resetting permalinks, but to no luck. Here is what I have so far: If anyone could shed some light on where I might have gone wrong, that would be wonderful. Thanks!               /*-----------------------------------------------------------------------------------*/     /*  Initialize the post type     /*-----------------------------------------------------------------------------------*/          /**      * Custom Post Type: Advertisements      *      * @package WordPress      * @subpackage ExportWise      */               /* Register custom taxonomies on the 'init' hook. */     add_action( 'init', 'register_taxonomy_groups' );          function register_taxonomy_groups() {              $labels = array(              'name'                          => __( 'Groups',                            'bd' ),             'singular_name'                 => __( 'Group',                             'bd' ),             'search_items'                  => __( 'Search Groups',                     'bd' ),             'popular_items'                 => __( 'Popular Groups',                    'bd' ),             'all_items'                     => __( 'All Groups',                        'bd' ),             'parent_item'                   => __( 'Parent Group',                      'bd' ),             'parent_item_colon'             => __( 'Parent Group:',                     'bd' ),             'edit_item'                     => __( 'Edit Group',                        'bd' ),             'update_item'                   => __( 'Update Group',                      'bd' ),             'add_new_item'                  => __( 'Add New Group',                     'bd' ),             'new_item_name'                 => __( 'New Group',                         'bd' ),             'separate_items_with_commas'    => __( 'Separate groups with commas',       'bd' ),             'add_or_remove_items'           => __( 'Add or remove groups',              'bd' ),             'choose_from_most_used'         => __( 'Choose from the most used groups',  'bd' ),             'menu_name'                     => __( 'Groups',                            'bd' ),         );              $args = array(              'labels'                        => $labels,             'public'                        => true,             'show_in_nav_menus'             => false,             'show_ui'                       => true,             'show_tagcloud'                 => false,             'show_admin_column'             => true,             'hierarchical'                  => true,                  'rewrite'                       => true,             'query_var'                     => true         );              register_taxonomy( 'group', array('advertisement'), $args );     }               /* Register custom post types on the 'init' hook. */     add_action( 'init', 'my_register_post_types', 20 );          /**      * Registers post types.      *      * @since  0.1.0      * @access public      * @return void      */     function my_register_post_types() {              /* Set up the arguments for the post type. */         $args = array(                  'public'              => true,             'publicly_queryable'  => true,             'exclude_from_search' => true,             'show_in_nav_menus'   => false,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_admin_bar'   => true,             'menu_position'       => 20,             'menu_icon'           => 'dashicons-chart-line',             'can_export'          => true,             'delete_with_user'    => false,             'hierarchical'        => true,             'has_archive'         => false,             'query_var'           => true,             'rewrite' => array(                 'with_front' => false,                 'pages'      => true,                 'feeds'      => true,             ),                  'supports' => array( 'title' ),             'taxonomies' => array( 'group' ),                  'labels' => array(                 'name'               => __( 'Advertisements',                   'bd' ),                 'singular_name'      => __( 'Advertisement',                    'bd' ),                 'menu_name'          => __( 'Advertisements',                   'bd' ),                 'name_admin_bar'     => __( 'Advertisements',                   'bd' ),                 'add_new'            => __( 'Add New',                          'bd' ),                 'add_new_item'       => __( 'Add New Advertisement',            'bd' ),                 'edit_item'          => __( 'Edit Advertisement',               'bd' ),                 'new_item'           => __( 'New Advertisement',                'bd' ),                 'view_item'          => __( 'View Advertisement',               'bd' ),                 'search_items'       => __( 'Search Advertisements',            'bd' ),                 'not_found'          => __( 'No advertisements found',          'bd' ),                 'not_found_in_trash' => __( 'No advertisements found in trash', 'bd' ),                 'all_items'          => __( 'All Advertisements',               'bd' ),                      'parent_item'        => __( 'Parent Advertisement',             'bd' ),                 'parent_item_colon'  => __( 'Parent Advertisement:',            'bd' ),             )         );              /* Register the post type. */         register_post_type(             'advertisement',             $args         );     }               /*-----------------------------------------------------------------------------------*/     /*  Add custom taxonomies to the post type     /*-----------------------------------------------------------------------------------*/          function create_my_taxonomies() {         register_taxonomy(             'group',             'advertisement',             array(                 'labels' => array(                 'name' => 'Groups',                 'add_new_item' => 'Add New Group',                 'new_item_name' => "New Group"             ),             'show_ui' => true,             'show_tagcloud' => false,             'hierarchical' => true,             'public' => true             )         );     }     add_action( 'init', 'create_my_taxonomies', 0 );          /*-----------------------------------------------------------------------------------*/     /*  Query the CPT for Posts from a specific custom taxonomy     /*-----------------------------------------------------------------------------------*/              // If on an Article, display random advertisements         if ( is_single() ) {             $posts_per_page = 1;             $orderby = 'rand';              // Otherwise display the latest advertisement         } else {             $posts_per_page = 1;             $orderby = 'date';           }              $args = array(             'post_type' => 'advertisement',             'tax_query' => array(                 array(                     'taxonomy' => 'group',                      'terms' => array( 'homepage' ),                     'field' => 'slug',                 ),             ),             'posts_per_page'    => $posts_per_page,             'orderby'           => $orderby,          );              $query_advertisements = new WP_Query( $args );              //echo $query_advertisements->request; ?>              <?php if ( $query_advertisements->have_posts() ) : ?>

                         <?php                              while ( $query_advertisements->have_posts() ) : $query_advertisements->the_post();                                 $adv_image = getUploadedImageSrc();                                 $adv_url = get_post_meta( get_the_ID(), 'adv_url', true );                                  echo '';                             endwhile;                              wp_reset_postdata();                         ?>

         <?php else : ?>
Error retrieving advertisements! Please try again later.

         <?php endif; ?>


Disable edit media attachments?

Looking for a way to disable the "Edit Image" option. I would still like to be able to edit the description, alt, etc. But remove the Edit image button or disable that image editor. Thanks,


How to create tabled index of posts in a certain category

I have a tech blog, what I want to do is to create an index page for articles in a certain category. For example, I want all the articles under the category "WordPress BasiX" to be arranged in an index (tabled preferably) at one page. Is there a way to do it in wordpress? Help please. My wordpress version is 3.4.2