A field with dashes in the slug

How do I reach a specific userdata in the database, when that field has a dash (hyphen) `-` in the slug? I use the plugin WP-Members. I have created a new userdata field with the plugin with the name `date-of- birth` - by mistake I used these dashes `-` instead of underscores `_`. In the database (the `usermeta` table) it now looks like: ![Database screenshot](http://i.stack.imgur.com/3Nu53.png) I get the userdata with these two lines:               $user_data = get_userdata( $user_id );     $user_data->user_email;      which works for all fields - exept those with dashes in them! I have tried this:               $user_data = get_userdata( $user_id );     $user_data->date-of-birth;      which just returns `0`. And this:               $user_data = get_userdata( $user_id );     $user_data->date_of_birth;      which of course doesn't work (it gives `null`), since that is not the correct name. Is there a method to reach this field with dashes in the slug? **Note** I can't change the slug. That is not allowed by this plugin after the field is created.


Remove the <ul> Tag from wp_nav_menu

I want to remove the `<ul>` tags from the `wp_nav_menu`. I already found different posts about it here but they don´t seem to work for me. Here is what I did: First I registered the menu in functions.php:               add_action('init', 'register_custom_menu');          function register_custom_menu() {         register_nav_menu('main-navi', __('Main-Navi'));     }      Then I created the menu in the Wordpress backend. After that I put following code into my `header.php` :               <?php $args = array(         'menu' => 'main-navi',         'items_wrap' => '%3$s',         'container' => false );     ?>     <?php wp_nav_menu($args); ?>      But the output is still the following:

            Blog

            Leistungen


$post in wp_query?

How do I get the $post Variable in a WP_Query started loop? I have to get the excerpt, raw $post->post_content and further things. This is why I have to get Access to the Variable itself. How am I able to do this? Thank you in advance!


Completely remove WP_Admin_Bar for specific user roles

How do I hide/remove the admin bar that is displayed when a user with specific role is logged in? I figured I have to do something with `remove_menu()`, but not exactly what and how. Codex


User ability to favorite or 'like' content

I have a few different custom content types and would like to give my users the ability to favorite or 'like' (like Facebook, but not for Facebook) pieces of content so that they can later view a list of their favorited content. I've searched everywhere but haven't come up with a clean solution. I'm pretty comfortable with SQL and PHP but want to make sure I'm doing this in the most efficient, clean way possible. Any ideas?


Are seven additional image sizes are too many?

I am developing a theme which uses different image sizes. So I will be adding 7 image sizes, are they too many? Could that break anything like the image size selector, other parts of the interface or upload performance? Also, is it a bad practice to remove the default image sizes from the theme for example adding following to the theme?               unset( $sizes['thumbnail']);     unset( $sizes['medium']);


Speed up Wordpress

I don't have the feeling that my blog is particularly slow, but that's because I haven't really started out yet. I'm very worried that it will get slow soon, especially because I will have blog posts with (optimized/compressed) 40-50 photos. This can't be changed, but other things can. I already read a lot about it, went through various tutorials, but yet I feel there's some more I could do. First of all, my blog seems to be doing well at the moment. At least according to Webpagetest.org. Here's my blog, so you can try yourself. I'm trying to figure out what all the results REALLY mean, but I don't get all of them. **Images:** I already compressed most of my images. CSS sprites take a loooooooooot of time and so I'll skip this for now and work on that much later when I actually get a bit higher traffic. To compress my images I use Photoshop (save for web) and Yahoo's SmushIt. **Javascript:** The scripts I'm using seem to cause some problems in terms of speed as I get the following suggestions from the Webpagetest.org site: > "380.5KiB of JavaScript is parsed during initial page load. Defer parsing > JavaScript to reduce blocking of page rendering." I have absolutely no clue what that means. Could anybody tell me more about that? (I know that this is not particularly related to Wordpress, but it's part of speeding it up anyways, so I hope you're willing to help me out here) Another warning concerning Javascript: > >     The following external resources have small response bodies. Inlining > the response in HTML can reduce blocking of page rendering. >     http://zoomingjapan.com/travel/mount-koya-travel-report/ should inline > the following small resources: >         http://zoomingjapan.com/wp-content/plugins/gravatar- > box/gravbox.js?ver=1.0 >         http://zoomingjapan.com/wp- > content/plugins/jetpack/modules/wpgroho.js?ver=3.2.1 >         http://zoomingjapan.com/wp-content/themes/alltuts/js/contact- > form.js?ver=3.2.1 >         http://zoomingjapan.com/wp-content/themes/alltuts/js/my- > slider.js?ver=3.2.1 >         http://zoomingjapan.com/wp- > content/themes/alltuts/js/scrollable.js?ver=3.2.1 >         http://zoomingjapan.com/wp- > content/themes/alltuts/js/sliding_tabs.js?ver=3.2.1 >         http://zoomingjapan.com/wp- > content/themes/alltuts/js/sprinkle.js?ver=3.2.1 >         http://zoomingjapan.com/wp-content/themes/alltuts/js/tab- > renamer.js?ver=3.2.1 >         http://zoomingjapan.com/wp- > content/themes/alltuts/js/welcome_back.js?ver=3.2.1 >         http://zoomingjapan.com/wp-includes/js/l10n.js?ver=20101110 >   So, it was recommended not to have any script calls in your template files, I put ALL of it in a js folder in my theme instead and that's what you get. Thousands of tiny scripts. Of course I'm using `wp_enqueue_script`! Does that mean it's better to put it back into my header.php? Or create a custom.js and throw in all the code that possibly can work together well?! Or put all the Javascript in the footer.php?! I just don't understand what would be the best environment for WP here! **Redirects:** > Remove the following redirect chain if possible: >   >   >     http://0.gravatar.com/avatar/2b7d7f6b4622da443cc8081ca78db661... >     http://zoomingjapan.com/wp- > content/themes/alltuts/images/usericon.png?s=30 >   > > Remove the following redirect chain if possible: >   >   >     http://1.gravatar.com/avatar/35991606c4e61d2d3a4ba61a9e03ab79... >     http://zoomingjapan.com/wp- > content/themes/alltuts/images/usericon.png?s=30 >   > > Remove the following redirect chain if possible: >   >   >     http://www.zoomingjapan.com/wp-content/themes/proton- > child/images/toplight.png >     http://zoomingjapan.com/wp-content/themes/proton- > child/images/toplight.png >   This is coming from the following code in my function.php:               add_filter( 'avatar_defaults', 'newgravatar' );          function newgravatar ($avatar_defaults) {     $myavatar = get_bloginfo('template_directory') . '/images/usericon.png';     $avatar_defaults[$myavatar] = "ZoomingJapan";     return $avatar_defaults;     }      Can I get rid of the redirect, but keeping the function alive? **Other steps:**   * Disable revisions (done)   * Empty trash every 2 days (done)   * Optimize dabatase once a week (not yet)   * Use a cache plugin (done: W3 Total Cache)   * Flush early (not yet: `<?php flush(); ?>` not sure if that's a good   idea to use??!)   * Use CloudFlare as CDN (not yet: what do you think about that? does it work well with WP?) Do you have any other suggestions that are relatively easy to implement? I know, quite a lot of questions, but if you can give me just a little suggestion for any of the points, I'd be really grateful. Thanks a lot in advance.


How to create subdomain for custom post type and associated custom taxonomies

I creating shopping cart, based on **custom post types**. And for this cart I have two related custom taxonomies.   * I need to create **shop.mysite.com** instead of **mysyte.com/shop** only for **this one** custom post type.    * I **dont need multisite** solution.    * All **posts** of current post types will be opened as shop.mysite.com/some-post/.   * Related custom **taxonomies** will be opened as shop.mysite.com/customtax/some-tax-value/.   * Additionally also would like to redirect a **few pages** related to shop as shop.mysite.com/some-static-page/ Thank You for help!


Rewrite rules for custom posts types

So I created a new post type 'quote'.   Basically I want to change all quotes URLs to domain.com/quotes/ID since as it as right now (`/?quote={xxx}`) could get pretty long, and since this post type is user-input-based, I don't want to take any risks. So I tried looking for answers... I found a really good tutorial that seemed to partially work. The urls did change, but I ever since I get a `404 page not found` error.   Then, I tried looking for solutions. I tried some like adding `flush_rewrite_rules()`, opening the permalinks page in wordpress admin and press "save", changed my code and changed the slug in the `rewrite` attribute of the post type. As you can guess, nothing worked.               function my_custom_post_type() {         $labels = array(                   // too long         );         $args = array(             'labels'        => $labels,             'description'   => 'Holds our quotes and quotes specific data',             'public'        => true,             'menu_position' => 5,             'capability_type' => 'post',             'publicly_queryable' => true,             'supports'      => array( 'editor', 'comments' ),             'has_archive'   => true,             'rewrite'   => false,             'query_var'     => true,         );              register_post_type( 'quote', $args );         flush_rewrite_rules();  //one of the solutions I found              global $wp_rewrite;         $projects_structure = '/quotes/%post_id%';         $wp_rewrite->add_rewrite_tag("%quote%", '([^/]+)', "quote=");         $wp_rewrite->add_permastruct('quote', $projects_structure, false);              add_filter('post_type_link', 'quote_permalink', 10, 3); //translate the structure variables.     }          add_action( 'init', 'my_custom_post_type' );      In short, I do get forwarded to `/quotes/ID/`, but the page results in a 404 error.   I did try to look up answers but nothing really worked for me.   Hopefully someone could pinpoint the problem.


wp_nav_menu does not take arguments?

I am sorry for this nooby question, but I just don't get it : I was working with the function reference for wp_nav_menu and this is my line of code:               <?php wp_nav_menu( array('theme_location' => 'header-menu','items_wrap' => '%3$s') ); ?>      But the menu is displayed in `<ul><li>` anyway. (I want to remove that and make the menu horizontal). I can put anything in the `items_wrap`, it will always be the default `<ul>` The theme_location is maybe not working too, but since I have only one menu yet, it displays the right one. I want to say sorry again if this is very stupid, which I guess it is, but I ask for your patience and help, just a beginner here. Full index.php:               <?php get_header(); ?>     <?php if(isset($_GET['nav'])) {     $nav = $_GET['nav']; } ?>

             <a href="<?php echo home_url(); ?>"><img id="logo" src="<?php bloginfo('template_directory'); ?>/img/logo.png" />
     <?php     remove_all_actions( 'wp_nav_menu_args' );     remove_all_actions( 'wp_nav_menu' );          echo "\n\n\n";     wp_nav_menu( array( 'theme_location' => 'header-menu', 'items_wrap' => 'j' ) );     echo "\n\n\n";     ?>

<img id="shade" src="<?php bloginfo('template_directory'); ?>/img/shade.png" />

                  <img id="fbbutton" src="    <?php bloginfo('template_directory'); ?>/img/buttons/fb.gif" />             <img id="twitbutton" src="<?php bloginfo('template_directory'); ?>/img/buttons/twitter.gif" />
                 <?php if (!( isset($nav) ) ) { include('startpage.php');} else { include($nav+'.php');} ?>

     <?php get_footer(); ?>      functions.php:               <?php add_action( 'init', 'register_my_menu' );          function register_my_menu() {         register_nav_menu( 'header-menu', __( 'Header Menu' ) );     }          ?>      Ok, please try to get over unstandardized naming and strange ways of achieving stuff, this is one-third learning, one-third testing and one-third development..


How to display number of page views on a post?

Is there any currently supported plugin to display the number of page views on a post? wp-postviews seems to be the most commonly used, but it requires modifying the theme (which would require creating a child theme to avoid being overwritten by theme updates), and does not seem to work with caching plug- ins. It seems like this should be straight-forward to extend the wp-statistics / jetpack API to display this information, but I haven't found a plugin that will do so. Seems like a common feature, surely this has been done somewhere?


How to extend media gallery WP 3.5

I'm trying to extent in a theme the media gallery. basically what I'd like to do is to have another button next to 'Insert gallery' that will say something like 'use this images'. And when clicking on that button, the attachent IDs will go in a custom box. Bellow some screenshots. The custom button: http://i.imgur.com/h0l441z.png The field where the IDs are inserted: http://i.imgur.com/Knzamz1.png Any hints how to achieve this will be appreciated.


Sort taxonomies in select dropdown with topmost parents as optgroups

I have an array of objects with custom taxonomy terms. This taxonomy represents a list of countries/states/cities which are being used by a certain post type and other parameters (I'm not using a standard wp function to retrieve these). The terms are already ordered alphabetically by term name key using `usort`. I'm printing each term as an `option` within a `select` dropdown. What I'd like to do is to further organise the list by printing topmost terms as well as `optgroup` and put all child taxonomies inside as optgroup elements. **The parent itself should be listed as a selectable option too**. Only topmost parents should wrap children as options within optgroups. Currently I'm just looping the terms as options without optgroups:               $locations = my_function(); // returns an array of alphabetically sorted wp term objects     echo '<select /*...mystuff...*/>';          foreach ( $locations as $location ) :         echo '<option value="' . $location->slug . '">' . $location->name .  '</option>';     endforeach;          echo '</select>';


Select page/template from the permalink url

I use permalinks like `example.com/projects/project1` for my project pages. They use all the same template. I want to access another template with more details on the project by adding `/details` to the URL. I don't want to nest/create more pages though. I want to keep my single project page in the admin area to maintain all the info. Is this possible? Maybe with `.htaccess` or something in the `functions.php`?


Changing Multisite themes on mass

I want to start a new theme for my Multsite install instead of simply modifying the current theme. The problem is I have a lot of sites running on Multsite so it would be a little painful to change all my sites to the new theme one by one. Is there a way to change the theme of sites by more then one at a time? In sites in network admin I can see a bulk actions option but when I select my sites and click apply, it does nothing (should it!?)


Can I use WP to create a multisite importing the posts of 3 old WP website?

I am pretty new in WP and I have the following doubts about work that I have to do. I have to create a multisite (3 sites related together) starting from 3 separated old WP websites. I know that some years ago there was WordPress MU that performed this task but reading the online documentation it seems to me that now WordPress MU is a closed project and that the multisite functions is natively implemented by the standard WordPress version, is it true? So, if the previous assertion is true, can I do the following?   1. Use WP to create a multisite that implement 3 different sites (each one with a unique theme, widgets and configuration)   2. Take the posts of the previous old WP website and import it in the related new single site of my new multisite. Can I do this things?


get_post_types is not showing all registered posts

When I call get_post_types() in a plugin the output is registering only the basic set of post types. Here is the output:               array(5) { ["post"]=> string(4) "post" ["page"]=> string(4) "page" ["attachment"]=> string(10) "attachment" ["revision"]=> string(8) "revision" ["nav_menu_item"]=> string(13) "nav_menu_item" }      In this wordpress theme, however, I have registered a custom post type called 'artist', but it is not showing up. If, however, I call get_post_types() in the index.php file it does how the registered posts:               array(8) { ["post"]=> string(4) "post" ["page"]=> string(4) "page" ["attachment"]=> string(10) "attachment" ["revision"]=> string(8) "revision" ["nav_menu_item"]=> string(13) "nav_menu_item" ["acf"]=> string(3) "acf" ["artist"]=> string(6) "artist" ["release"]=> string(7) "release" }      Does anyone know why this is happening and how to get around the problem?


What does Wordpress mean by they have full rights to content

I am pondering publishing my blog. I'm leaning more towards WordPress however, I don't want to worry about WordPress doing whatever they want whenever they want withmy blog because I have signed up for the basic plan (I'm new to blogging so I'm assuming I should start with the basics) depending on how well my blog does I intend to upgrade to one of the more advanced accounts. In the meantime I read in this forum that Wordpress has full rights to content..how so? Full rights meaning no legal action can be taken against them for the reproduction or even stealing of blog posts, pictures, etc? Can they just use content as they wish? How does this work? If I have posted this in the wrong section or if this question has been asked before please don't get upset like I stated I am new to blogging and I'm trying to gain insight on the best route I should take. Thank you all in advance


How to get override the WP Admin Syndication feed limit for a custom feed?

I need to override the setting in the WP Admin for the number of recent posts in the Syndication settings under General -> Admin. I'm using the following code, which gets all posts, but I don't need that many. Can someone tell me how to retrieve 50 posts?               function no_limits_for_feed( $limits ) {         return '';     }          add_filter( 'post_limits', 'no_limits_for_feed' );


How to use Wordpress Conditional Tags in get_posts foreach loop

I have a page which has a jquery tab function to output the list of pages that are the children of this page (Bio, Archives, Contact). However I am trying to make a conditional in the foreach loop to no avail.               <?php // get_posts function: http://codex.wordpress.org/Template_Tags/get_posts#Examples     $args = array(          'paged' => $paged,         'post_type' => 'page',         'post__in' => array( 3, 4, 5, 6 ), /* Bio, Client, Archives, Contact */         'order' => 'ASC'     );     $myposts = get_posts( $args ); ?>
              <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>                 <li id="page-<?php global $post; echo $post->post_name; ?>">                     <a href="#<?php global $post; echo $post->post_name; ?>"><?php the_title(); ?>
              <?php endforeach;  ?>
              <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>             <div class="tabcontents" id="<?php global $post; echo $post_slug=$post->post_name; ?>">                 <?php the_content(); ?>                                  <?php edit_post_link("Edit"); ?>
         <?php endforeach;  ?>          <?php wp_reset_postdata();?>      Basically, I would like to output the featured image of the children pages under Archives for when user views the Archives tab. I tried using this inside the foreach loop but it didn't work:               <?php if ( is_page( 5 ) || is_page('Archives') ) {         echo 'Show me!';     } ?>      Can anyone help?


Wordpress : To load all asset files coming from HTTP to HTTPS?

_(I'm using`Wordpress HTTPS` plugin to force `Admin` mode to run under `HTTPS`.   Its fine for Admin Panel.)_ But still, once i'm under `HTTPS` mode, every front pages are broken because of, it is saying some front-pages `Asset Files` **are coming as normal`HTTP`** (without 'S') which are then getting blocked to load onto page. Than resulted in rendering the page looking messy. So to be more clear again,   * When i call the site in `HTTPS / SSL` mode .. some asset files, like:      * `http://www.my-another-site.com/something.js`     * `http://www.my-another-site.com/something.css`     * `http://www.my-another-site.com/something.jpg`     * ... etc .. are BROKEN. **_(Because i'm in`https` mode and those above files are coming as `http`)_** So how to make Wordpress to FORCE LOAD those whatever files?    _(I DON'T CARE WHETHER IT IS SECURE OR NOT. Just want the site under`https://...` to be rendering properly.)_


Get post ID's from one query and exclude from another

I have 2 instances of `wp_query`, one showing 4 "Featured" posts and another showing "basic" posts. What I want to do is exclude those 4 latest "Featured" posts from the basic query. I assume it's just a case of adding a `post__not_in` variable but how can I get the ID's from the first query and exclude them from the second?


Opinions and recommendations on the best barebones base theme

**Preamble** I'm finding myself building more and more WP sites "from scratch" as it were (ie: ignoring any theme designs out there and just creating a design wireframe purely on the needs of the client. Then I go out and either shop around a theme that has the right basic structure, or I start with TwentyTen and fork a child theme from there. Recently I've been getting the advice that maybe TwentyTen is not the best place to start as a base / parent theme because it's been stuffed with every technique possible in order to be a good learning platform. But maybe it's not the easiest or most efficient to customize (it has individual template.php pages for almost every part of the template hierarchy AND it has every template-part.php imaginable. And using existing themes (whether free themes, or themes from services like ThemeForest) is a bit of a crap-shoot - in terms of coding standards, usage of templates, template-parts or hooks, incompatibilities, etc etc. So that's not ideal either. Ideally, I'd like to whittle my starting choices to a small handful of really well-built, highly versatile, extremely barebones (light on design) themes that I could fork child themes from and adapt to my wireframe and design specs. **Getting to the question** What are your favourite **barebones themes** for forking off child themes? Why do you like them? thanks so much for your advice!


Are there action hooks for comments?

This is for a personal-use plugin I'm trying to make. I want to submit a comment from site A to my blog (sort of like sending trackbacks/pingbacks but a full comment). For instance, on site A I have a form with a name, url, and comment field. The data I enter in site A, I want to submit to site B (my blog) via URL parameters or the POST method. I assume that I'll need an action hook on my blog to retrieve data sent from site A and insert it in the wp comment table. Is this possible?


Contact Form 7 Failed on WordPress Amazon EC2 Instance

I installed WordPress 3.5.2 on an Amazon EC2 micro instance. After installing and activating the Contact Form 7 plugin, I configured this plugin by putting my gmail address in the `Mail To` settings of the plugin, then tested the form by pasting `[contact-form-7 id="17" title="Contact form 1"]` in my page and submitting my comment, but I got the following error: > Failed to send your message. Please try later or contact the administrator > by another method. Is this error caused by my EC2 security group? (please see below)               Ports           Protocol    Source     20-21           tcp         0.0.0.0/0        22              tcp         0.0.0.0/0        80              tcp         0.0.0.0/0        13000-13050     tcp         0.0.0.0/0      Or is this error related to this default restriction on sending email from an instance? I read that one possible solution is to install WP-Mail-SMTP. I was looking at the WP-Mail-SMTP plugin screenshot and it appears to require a port number. I did not initially configure a port for this during the setup of my EC2 instance and I'm thinking this plugin would not work unless I create another instance with a new security policy (since I cannot edit my current security policy). My Akismet is disabled. Any assistance with helping me understand the cause of this error will be greatly appreciated. Thanks in advance.


Using wordpress template tags within an array

A bit of a noob PHP question coming up. I am trying to create a generic archive style view for my custom post types. Ideally I want to create one generic template that can be used for all post- types. Currently I use this as my have_posts query to bring in all posts of 'custom- post-type'               <?php      $args=array(        'post_type' => 'custom-post-type.',        '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() ) {      while ($my_query->have_posts()) : $my_query->the_post();      ?>      What I want to do is swap out custom-post-type with the slug of the page so that whenever this template is assigned to a page, it will look for a custom- post-type of that name & list them. Alternatively if you know of a better way of doing it - great! Cheers, George


How do I set up a custom URL shortener for my posts?

I have several different sites running off WordPress, and the URLs tend to get fairly long and cumbersome (particularly when I try to publish them via Twitter). I recently purchased a very short domain name, and I'd like to use it as the root of a personal URL shortening service. So ...   * `http://www.eamann.com/portfolio` would become `http://eam.me/portfolio`   * `http://www.mindsharestrategy.com/wp-xmlrpc-movabletype/` would become `http://eam.me/df3DF`   * `http://www.prosepainting.com/coffee-shop-part-1/` would become `http://eam.me/csp1`   * And custom things like `http://wordpress.stackexchange.com/questions/3076/feature-survey-what-would-you-want-in-a-resume-theme` would become `http://eam.me/wpa3076` Basically, I want to set up and manage my own TinyURL-like server ... but with some specific requirements:   1. It should integrate fully with WordPress so I can dynamically create new short URLs whenever I create a page or a post (every piece of content I create on each site should have its own short URL).   2. I can specify if I want the URL to be random (like `/df3Df`) or I can choose a unique string instead (like `/wpa3076`) at the time of URL creation   3. I should be able to view/edit/manage the URLs I have in the database from within WordPress At the moment, I'm leaning towards a standalone system like YOURLS that lives in its own database. The problem I'm facing (and I'll confess now that I haven't attempted it yet) is integrating the system fully with WordPress. I want each post to automatically suggest a short URL before I hit "publish" and then automatically create the URL when I finally do "publish" the post. I'd also like to administer _all_ of my links from within _each_ of the sites using the service. Is this even possible? Is there already a solution around to do this? If not, where do I start? _(Cross-posted toStackOverflow)_


How can I add a URL field to the attachments window?

For example...               add_action('init', 'reg_tax');     function reg_tax() {        register_taxonomy_for_object_type('category', 'attachment');     }      Adds a "Category" input field to the media manager and attachments editor. I'd like to know if its possible to alter this function to capture a "link destination" URL instead. The URL would be executed when the image is clicked. Also need to know how to retrieve the value for this new field. UPDATE: Thanks to Thomas Answer below, here is my final solution...               function my_image_attachment_fields_to_edit($form_fields, $post) {           $form_fields["custom1"] = array(               "label" => __("Image Links To"),               "input" => "text",             "value" => get_post_meta($post->ID, "_custom1", true)           );                 return $form_fields;       }            function my_image_attachment_fields_to_save($post, $attachment) {             if( isset($attachment['custom1']) ){               update_post_meta($post['ID'], '_custom1', $attachment['custom1']);           }           return $post;       }            add_filter("attachment_fields_to_edit", "my_image_attachment_fields_to_edit", null, 2);      add_filter("attachment_fields_to_save", "my_image_attachment_fields_to_save", null, 2);


What is a good wordpress 3.0+ plugin that supports automatic publishing to Twitter/Facebook?

I've tried Socialite and a couple others but they all appear to be reported as broken. When I tried them out, they were in fact broken. Can anyone suggest some that automatically publish to these services and work on WP 3.0+? This is not for a wordpress.com blog, but an installed instance of wordpress. Thanks.


How to create Parent-Child relation for custom fields?

I am new in here. Hope that you guys can help me. Few days ago, I posted the same question on Wordpress.org support forum, however till now no one answer me, not even 1 reply. Maybe my issues is too complex, or too stupid. So be gentle. Here is my questions: For the custom fields, can we defined Parent and Child value option? The child value options are depend on the Parent input. For example when we adding an address: Country : [US, CN] If the user choose US then the next custom field is State and the value options would be The states in US . Country -> [us] State : [Alabama,Alaska,American Samoa,Arizona,Arkansas...etc] However if user choose CN, then the next custom field would be Province and the value options would be the provinces in China Country -> [CN] State : [Anhui,Beijing,Chongqing,Guangdong,Shang Hai...etc] Hope you guys know what I tried to express.. The plugin that I use for create the dropdown custom fields is Custom Content Type Manager. I wonder if I able to hook jquery to custom fields area to make it happens? If it is possible to do so, how? Any guides to help me solve this would be appreciated.


saving the widgets position after drag and drop

I have created a web application in which I have 3 columns, or i would say left sidebar, right sidebar and a middle widget area, I have few widgets in the left sidebar, few in the right sidebar and few in the middle widget area to give it a look of igoogle. Each user will have his widgets and then will also be able to drag and drop those widgets.I have added the drag and drop functionality of the widgets. What I want now is to save the dropped widgets position in the database and retrieve it for the user when he/she logs in again. Any sugestions as to how this can be done?


How to add some custom HTML to the edit posts page

On the wordpress admin edit posts page, I want to display some custom content and script, underneath the meta box. I want to hand code this as the various plugins I could use (advanced custom fields for instance) take too much control away, and I don't need an actual field to be saved. So for example, I want to add this to the edit posts page:

      That's pretty much it. Nothing fancy or that contains any editable content. What hook or function do I need to use to achieve this? Any help greatly appreciated


wp-editor is empty on first submit

I'm using wp-editor in a simple plugin, but I'm having an issue where the first time I hit the submit button the content from it is blank in the database.               <?php      $editor_id = 'mycontent';            wp_editor($content, $editor_id );                    ?>      So I tried alerting the content using this:               if (j(".wp-content-wrap").hasClass("tmce-active")){        alert( tinyMCE.activeEditor.getContent());     }else{        alert( j('#mycontent').val());     }      and the first submit comes up empty. If I switch to the text version before I submit, it works. What am I doing wrong here that prevents the submit from working? Edit: Interestingly, if I do this:               wp_editor('test', $editor_id );      It works. If I do this:               wp_editor('', $editor_id );      It doesn't work again. How do I get it to work if the `$content` is initially blank?


WP_UnitTestCase missing?

I was looking at tests for wordpress and some, if not all the classes have WP_UnitTestCase but I cannot find the class, why do I care? I have downloaded The most up to date version of this from github which is the same set of tests. Why does this matter so much? Because when ever I run one of the tests via phpunit filename.php I get the error from php unit stating that its missing WP_UnitTestCase. So my question is: Where is this class, why is it missing if it works for the WordPress developers?


How to insert category list into post creation page, and retrieve chosen categories?

I would like to display the full list of categories on the Page creation page, so that the user can pick using checkboxes which category posts should appear on that page. ![where I would like to display it](http://s9.postimage.org/biwlbzvrj/box.jpg) I then need to retrieve the chosen categories for that specific page in my custom page templates, so that I can modify my loop to filter for only those chosen categories.


Attribution when using other plugin's code

What's the proper way to show attribution when using code taken from another open source WordPress plugin? I'd like to know both in the case of just a particular function, and even for a whole file containing many functions.


Append custom parameter to taxonomy/term URI

I have a **Custom Post Type** named " **Cars** " and **2 Custom Taxonomies** " **Ferrari** " and " **Lamborghini** ". Each taxonomy has **2 Terms** : " **New** " and " **Used** ". These URIs work as expected:               http://myhost/ferrari/new     http://myhost/ferrari/used      The problem is, of course, when I append the car ID at the end I get a **404** :               http://myhost/ferrari/new/123      I've been playing a lot with **add_rewrite_rule/add_rewrite_tag** and read many discussions here on **StackExchange** but I couldn't find a solution. I also tried WP Router and it actually works, but it almost entirely overrides the default routing so that it feels like a hack. **Question:** All I need is being able to route the URI with the appended ID to the same template as it would without, so from there I can make a custom query using the ID segment. Thank you!


Delete/replace img tags in post content for auto published posts

In my blog I have set up auto-publish for posts and I get 5 thousands new posts every day, in this moment I have more than 150 thousand posts. I need a script, or a plugin, or a function to connect to my database and strip out all `img` tags from post content. I know the regular expression to match the img tags, but I can't find a script for using this regular expression               <img[^>]+\>        to replace imgs in already published posts and to prevent new posts to contain image tags. I found this class and I think that it will achieve my goal but I am not sure how to edit this               $wpdb->query(       "UPDATE $wpdb->posts SET post_parent = 7       WHERE ID = 15       AND post_status = 'static'"     );      to fit my needs. **please note:** my site is using some auto publish posts feature Any ideas!


Getting Post details when post is published

I would like to collect main info about post like Title etc. **in moment when post was written and it's going to be published** and perform some actions on this data. What's the hook for that? Thanks!


System audit plugin?

Is there a plugin that tracks wordpress admin settings and actions? eg when plugins are activated/deactivated, plugin settings are changed, user settings and permissions changed?


Searching with Multiple (Parallel) Criteria on Custom Fields?

I'm just an basic Wordpress user. I need to make search box with **multiple criteria** inputs (multiple conditions) to search **inside various Custom Fields**. For example including following **Custom Fields** : Color: **___ ___ _**   Size: **___ ___ _**   Price: **___ __ _**   Condition: **___ ___**   Discount %: **___ __ _**   Hit Count: **___ ___**   User may input **1 or more** fileds.   **Result should be filtered for multiple input also.**   For example: `Price: ____100___` and `Condition: ____Fair____`   So, how can i handle this multiple conditions in Query? It is **ok for every single inputs**.   But, problem with more then 1.   I'm confusing how to write query **for multiple criteria** (in former way).   A simple sample please.


Any tools for quickly grabbing comments / comment count?

I am working on an aggregator at the moment for an opt-in blog service. Essential a handful of people submit their WP blogs to the aggregator for, well, aggregation. I am currently using a slightly hacked version of http://feedwordpress.radgeek.com/ What I want to be able to do is for each bit of syndicated content shoot off to the post in question and grab the latest comments and comment count. Anyone have any opinions on the best way to do this?


Showing Thumbnail from Previous and Next Posts

Is there a simple way to use the post thumbnail when calling `previous_post_link()` and `next_post_link()`?


How to correctly make admin pages for custom tables which don't show in the menu?

I have to create a custom table to store data for a client because they want a very precise search capability. I already have this working with custom post types and using custom fields, but with 800+ records it now takes 90+ seconds to search. (I know of no way to simplify this answer.) I'm taking the same idea and turning it into a custom table now. So I've got the start of my plugin, the table definitions, and some basic pages by the add_object_page / add_submenu_page functions. However, I need the ability to edit a page so I found a function that lets me create a hidden page.               function add_admin_page($hook) {       global $_registered_pages;            $hookname = get_plugin_page_hookname($hook, 'admin.php');            if(!empty($hookname)) {         add_action($hookname, $hook);         $_registered_pages[$hookname] = true;       }     }      This works like a charm until I look at the header and notice that **there's no page title defined for this callback**. I've looked at `plugin.php` for the `add_menu_item` to see how it defines a title... and see no way for this custom page to display a title correctly. **So I thought about finding a hook and using a switch statement to override the title.** Possible? Bad idea? Another problem I have is that I'd like to use some of the scripts by `wp_enqueue_script` from within my callback, like "post" or "editor", and validate my form too, but **the scripts I'm enqueuing aren't included in the payload.** Should I include them in the footer of my callback?


connect (relate) content of different types in WordPress

I´m just starting with WordPress and looking for an approach to this problem. I have to setup a site which displays:   * library [1]   * exhibitions [2]   * shop [3]   * some static pages like contact … All items of those categories can be related to items of other categories. In detail a book in "library" can be related to several posts in "exhibitions" and to items in "shop", if a user views this book the related items from all other categories should be shown also. Reading Tutorials about related item posts and looking at plugins   * http://wp-types.com/documentation/user-guides/creating-post-type-relationships   * http://wordpress.org/plugins/yet-another-related-posts-plugin/ I still having problems finding a proper solution for this. My Questions:   * Is there a native WordPress of way solving these issues? F.e. the ability to add to every administration form a new input field to choose relations   * If not is there a plugin which could handle this job?    * What would you do? Looking at WordPress code, I think my question is more regarding the backend. If the relation is written to the database I could surely write something to output the related items at frontend page (template) (having PHP knowledge). [1] https://wordpress.org/plugins/weblibrarian/ [2] setup as native wordpress "posts" [3] http://wordpress.org/plugins/wp-e-commerce/


Button Shortcode

I am trying to create a custom button shortcode, with multiple color and size options. However, when I try to use the shortcode in my post it isn't showing up. My Function               function btn($atts, $content = null) {        extract(shortcode_atts(array('link' => '#', 'color' => 'teal' , 'size' => 'large'), $atts));        return '' . do_shortcode($content) . '';     }      How I am using the shortcode               [btn color="blue" size="large"]Button Text[/btn]      My CSS               /* Buttons */     .btn {background:#222 url(img/alert-overlay.png) repeat-x; display:inline-block; padding:5px 10px 6px; color:#fff!important; text-decoration:none; font-weight:bold; line-height:1; -moz-border-radius:5px; -webkit-border-radius:5px; position:relative; cursor:pointer; -moz-box-shadow:0 1px 3px rgba(0,0,0,0.5); -webkit-box-shadow:0 1px 3px rgba(0,0,0,0.5); text-shadow:0 -1px 1px rgba(0,0,0,0.25); border-bottom:1px solid rgba(0,0,0,0.25)}     .btn:active{-webkit-transform:translateY(1px); -moz-transform:translateY(1px)}          /* Sizes ---------- */     .small { font-size: 11px; margin:10px 0 }     .medium { font-size: 13px; margin:10px 0 }     .large { font-size: 14px; padding: 8px 14px 9px; margin:10px 0 }          /* Colors ---------- */     .blue { background-color: #2daebf }     .red { background-color: #e33100 }     .magenta { background-color: #a9014b }     .orange { background-color: #ff5c00 }     .yellow { background-color:#ffb515 }


Cloning the last few posts & comments only

I cloned an entire WP site to a different location a few weeks ago. The new site is being redesigned (but keeping the same content). In the meantime my client posted new posts with comments from her readers. What's the easiest way to clone those last few posts and comments? If the solution involves PhpMyAdmin, which tables will I be working with?


TinyMCE Styles Dropdown not adding html tags other than span

I am trying to add h1,h2 .. in the TinyMCE Styles Dropdown with my other html elements. I have tried the following code, but the problem is it only adds styles if I use `span` as 'block' value. If I use div, h3, h4, the code doesn't add anything I have searched a lot for the solution but haven't found anything helpful. Could you please tell me how to fix this problem? FYI: I am using wordpress 3.5.1               function my_mce_buttons_2( $buttons ) {     array_unshift( $buttons, 'styleselect' );     return $buttons;     }     // Register our callback to the appropriate filter     add_filter('mce_buttons_2', 'my_mce_buttons_2');               // Callback function to filter the MCE settings     function my_mce_before_init_insert_formats( $init_array ) {       // Define the style_formats array     $style_formats = array(           // Each array child is a format with it's own settings         array(               'title' => 'Head',               'block' => 'h4',               'classes' => 'headings',             'wrapper' => true,              ),           array(               'title' => 'Sub Heading',               'block' => 'span',               'classes' => 'subheadlines2',             'wrapper' => true,         ),          );       // Insert the array, JSON ENCODED, into 'style_formats'     $init_array['style_formats'] = json_encode( $style_formats );            return $init_array;             }           // Attach callback to 'tiny_mce_before_init'      add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );


Recent posts in current category?

On my category page (not single.php) I'd like to have the recent posts from that category in the sidebar, it also needs to be dynamic. I'm already doing something similar on single.php, but I can't think how to do it on the category.php page.
                   <?php                   $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );              if( $related ) {              echo '
Related Articles

';              }         if( $related ) foreach( $related as $post ) {         setup_postdata($post); ?>
                                     <?php the_time('F jS, Y') ?>                                  <?php the_post_thumbnail('sidethumb'); ?>
<a href="<?php the_permalink() ?>"><?php the_title (); ?>

<?php echo excerpt(25); ?>

                   <?php }              wp_reset_postdata(); ?>

        Is it possible to have say the 20 recent posts from on the currently selected category? Uh, so I can't get your code to work.                               <?php         $max_posts = 20;         $cat_ID = get_cat_ID ( single_cat_title( '', false ) );         $args = array(             'category' => $cat_ID,             'numberposts' => $max_posts,         );         $myposts = get_posts( $args );         foreach( $myposts as $post ) {             setup_postdata( $post );             // display your posts with the_title(), the_excerpt(), etc           <php the_title (); ?>               }     ?>      If I put the `<php the_title (); ?>` etc in where you've written display your posts with title etc, it gives me a blank page. My category.php looks like this               <?php get_header(); ?>               <?php get_sidebar('catbar'); ?>

                       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                      <article <?php post_class('item') ?> id="post-<?php the_ID(); ?>">

By <a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author_meta('display_name'); ?>

                                                                            <?php comments_popup_link ('0', '1', '%'); ?>

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

                             <?php the_time('F jS, Y') ?>
                                              <?php                         if(has_post_thumbnail()) :?>
                                  <?php the_post_thumbnail(''); ?>                             <?php if( !empty( get_post( get_post_thumbnail_id() )->post_excerpt ) ) { ?>
                                     <?php echo get_post( get_post_thumbnail_id() )->post_excerpt ?>
                             <?php } ?>
                      <?php else :?>                     <?php endif;?>
                         <?php the_content('Read Full Article'); ?>

                            Share this Article:                      <input type="text" value="<?php the_permalink (); ?>">                          Show Sharing Options

                         <a  class="social-email" rel="nofollow" title="Email this page" href="mailto:?Subject=<?php the_title(); ?>&body=<?php the_permalink(); ?>">

                         <a class="social-twitter" rel="nofollow" href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Share page via Twitter" target="_blank">

                     <a class="social-facebook" title="Share page via Facebook" rel="nofollow" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="blank">

                         <a class="social-goo" title="Share page via Google+"  href="http://plus.google.com/share?url=<?php the_permalink (); ?>" rel="nofollow" target="_blank">

                         <a class="social-linked" title="Share page via LinkedIn" rel="nofollow" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink (); ?>" target="_blank">

                             <?php endwhile; ?>                       <?php endif; ?>

                          <?php if(function_exists('wp_pagenavi')) { ?>                          <?php wp_pagenavi(); ?>                          <?php } else { ?>
<?php next_posts_link(__('Load More Articles')) ?>

<?php previous_posts_link(__('Newer posts')) ?>
                          <?php } ?>

                          <?php get_footer(); ?>


Custom template support for custom post type?

I know I can use `single-{posttype}.php` but can I use something like `single-{custom-post-type-slug}.php` to target a specific custom post type post? Or is there another way like a custom template which I can select from the admin? It doesn't seem to work on custom post type edit sreen.


Dropdown: Display terms from B only if has relationship with a term A selected

I've googling for a solution for this issue and found nothing: I have some posts from a Custom Post Type (Restaurants) and its taxonomies ('city' and 'cuisine'). Whenever I create a restaurant post, I can set many 'cuisine' terms as I want, but 'city' is single selected. I've also made a custom search using a html dropdown which I can search from 'restaurants' posts by filtering from its taxonomy terms. The search works well but what I really want is populate the second taxonomy (cuisine) only with terms that has some relationship based on the first taxonomy chosen (city). In the first dropdown, if someone choose the city 'New York' the second dropdown must display only cuisine terms that has relationship with 'New York' city term on restaurant posts. If there's not a post with 'brazilian' cuisine and 'New York' city registered, the 'brazilian' term must not appear on second dropdown. Of course, the cuisine dropdown doesn't have to display duplicated terms. Is that possible? Thanks in advance!


Expanding / Collapsing Modules in Wordpress Panel

I'm using WordPress 3.3.2. version. I can't able to expand / collapse modules in wordpress panel. I have deactivated all plugins and checked. But no result. If i disable Java Script, it is working well. Can any one please give me a solution?


How to add multiple chat rooms in a WordPress website

I am building a sports chat website and I cannot seem to find a good method to add multiple chat rooms. What I mean, for example - I want to create a chat room for each NFL team, but each chat room should be on its own page.


Transferring data to the end of a transaction with the Shopp Plugin

I'm using the Shopp Plugin, and basically, I need to send an email to a unique email address field that I've created on the front end. The transaction has to complete fully before sending it. I mean, money has to have been transferred successfully, etc. I've attached the fields to a particular set of products, and I can move the data between pages (via $_POST of course), ie; Product -> Cart -> Checkout... It's after this that's the problem. Landing on the Thank you page or whatever, I don't have access to the finalized list of items that were bought, via the $_POST method. Could someone point me in the right direction? Thanks


How to get the custom post type from an archive page?

In my website I have three custom post types: scripts, scenes and plugins. When visiting the archive page of a single post type (i.e. by going to mysite.com/plugins) you correctly see all the posts of that type. **In archive.php, how can I find out which custom post type the user is looking at right now?** I tried the following:               <?php          global $post;          $postTypeLabels = get_post_type_labels(get_post_type_object($post));          echo var_export($postTypeLabels);      ?>      But I'm getting the this:               Post name is stdClass::__set_state(       array( 'name' => 'Posts',          'singular_name' => 'Post',          'add_new' => 'Add New',          'add_new_item' => 'Add New Post',          'edit_item' => 'Edit Post',          'new_item' => 'New Post',          'view_item' => 'View Post',          'search_items' => 'Search Posts',          'not_found' => 'No posts found.',          'not_found_in_trash' => 'No posts found in Trash.',          'parent_item_colon' => NULL,          'all_items' => 'All Posts',          'menu_name' => 'Posts',          'name_admin_bar' => NULL,        )     )      I'm guessing that, since I am in an archive page, the $post is not correct. P.S. I know that I can create archive-plugins.php for the plugins archive. Unfortunately, I have installed a theme that, as far as I know, kinda prevents that. So this is not an option.


site_url and $current_user producing undesired results

I am trying to make the link like this: `site.com/forums/user/userid` using the code below. I think I messed it up though because it keeps producing an error on this line. `$buttons['Edit My Profile'] = site_url('/forums/user/')$current_user->user_login;` Here is more of the surrounding code:                   <?php              if ( is_user_logged_in() ) {                  global $current_user;             get_currentuserinfo();             $buttons    = array();                  if ( $sl_options['show_dashboard'] )                 $buttons['Dashboard']   = admin_url();                  if ( $sl_options['show_profile'] )                 $buttons['Edit My Profile'] =  site_url('/forums/user/')$current_user->user_login;                   $buttons['Log Out'] = ( $sl_options['redirect_logout'] == 'custom' && $sl_options['redirect_logout_url'] != '' ) ? wp_logout_url( $sl_options['redirect_logout_url'] ) : wp_logout_url( $this->current_url() );                           ?>       Can somebody please take a look and let me know where I went wrong on that line?


Get post type from taxonomy or category page

This might be somewhat backward, but how can one get the post type being displayed on an archive page? Alternatively, how can one get the post type associated with a given taxonomy?


Alternating post layout

I am trying to create a layout with two different divs alternating vertically. For example the even has to be: picture + content; and the odd has to be: content + picture. Here is my code, at the moment it prints every post doubled, once per div:
     <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : the_post(); ?>
         <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/>

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

          <?php else : ?>
         <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/>

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

          <?php endif; endwhile; endif; ?>
      Any hint on how can I fix it? Thank you in advance.


Using get_terms for custom taxonomy in functions.php

I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel.               function retrieve_my_terms() {              global $terms;              $terms = get_terms('taxonomy');              foreach ($terms as $term) {             $option = $term->name;             return $option;         }     }      The function is added after the functions which created the custom post type and taxonomy. From what I've found out, it seems that the `init` action occurs after the theme's functions.php file has been included, so if I'm looking for terms directly in the functions file, I`m doing so before they've actually been registered. In other words, init action doesn't fire until after the theme functions file is included, therefore any term retrieval must occur after init. My problem is that I don`t know how to retrieve the terms after the init. Any answer will be much appreciated! Thank you! Madalin


Plugin to display weekly schedule that can be edited via admin panel

I am working on a simple wordpress site for a fitness club. They require a simple wordpress plugin that displays a static weekly schedule for their theater. They need to be able to specify what plays on what day of the week and what time. A full blown calender/event scheduler plugin is probably overkill for this as it just needs to display Day of Week, Event Title, Event time. Any ideas on what plugin I can use for this?


How to give "author" user role appropriate capabilities to add PollDaddy polls? WordPress multisite

At the moment, users with role "Author" can only view but not add or edit polls. "Editor" and "Administrator" (site administrator) can add and edit polls however. This is despite the fact that I have explicitly assigned "manage_polls" capability to "Author". I've tried both Advanced Access Manager 1.6.8 and User Role Editor 3.8.1 plugins which claim that they support WordPress multisite. Still, "Author" can't add or edit polls. I'm using WordPress 3.3.1 multisite. I strongly believe this has to do with multisite because "edit_users" capability does not work as it appears - How to enable a site administrator to edit users in a WordPress network/ multisite setup? Is this a PollDaddy's plugin bug or WordPress multisite's bug or is there any way I can enable "Author" to add/ edit polls with PollDaddy plugin?


Issues with Wordpress permalinks

I am new to wordpress but have experience in Drupal. I am developing wordpress site which I access as `localhost/site1`. I created another copy of it to experiment a few things. I can access another site as `localhost/site2`. The strange thing I see now is whenever I click on a post from `localhost/site2` it takes me to `localhost/site1`. For example I am taken to `localhost/site1/my-post` from site2 when expected is `localhost/site2/my- post`. Then I checked the database and saw the links were stored in posts table in guid column. I was expecting only relative URLs to be saved in tables(as in drupal) but here the full URL is saved in database. How can I make all URLs as `localhost/site2/my-post`? Also how can I make this work when I move it online to a particular domain ?


How to resize images in wordpress without adding any compression or changing the color profile of the images, possible?

As you can guess from the title, Im looking for a solution that allows me to alter the way Wordpress processes/saves its newly created images according to the media settings in the dashboard. This is very important since I primarily use Wordpress as a way to present portfolio images so they need to maintain the same color profile, etc. as they had when they were first uploaded. The problem is, once an image is resized by wordpress it tends to become desaturated because it changes the color profile, this needs to be altered somehow so that it stays the same as the original and only the pixel dimensions are changed. The easiest solution to this is to prepare your images to the exact size to be used prior to upload and then use the images actual size setting in wordpress' dialog while placing an image into a post, however this is not very convenient, nor is it exactly a very nice solution for clients that dont understand how to do such a thing before uploading.... Ultimately, Id like to avoid the use of a plugin and just alter the existing script that wordpress uses to process its photos/images, or possibly create a special function for the functions.php template if thats possible.... Thanks for the help in advance.


Wordpress get_categories & listing recent post thumbnail

I'm trying to get a page to list all the child categories and then display their name and a thumbnail from the most recent post in that category. This is the following code I've got, it appears to be fetching some thumbnails from other posts that aren't in the category and also repeating the categories. Any help would greatly be appreciated.               <?php get_header(); ?>
                  <?php     $args = array(       'orderby' => 'name',       'order' => 'ASC',       'child_of' => '3592'       );     $categories = get_categories($args);       foreach($categories as $category) {             query_posts( $category->name . 'posts_per_page=1' );             while ( have_posts() ) : the_post();         echo '
';         echo '
'; the_post_thumbnail('interview-thumb'); echo '
';              echo '
term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'
 ';         echo '
';         endwhile;         wp_reset_query();         }     ?>

          <?php get_footer(); ?>


Have WP Theme update from Git Repository

I have a client's theme currently hosted on github. Instead of doing a git deploy or using a service like Beanstalk's deployments. I will be pushing the same theme across many sites (79 to be exact) and want them to be able to update themselves just like a WP repo hosted theme. A good example is how the Genesis framework has it's updates work. I've seen things where you have another plugin installed to do this, but i'm looking for a more minimalist solution (if there is anyway to keep this functionality within the theme itself)?


How can I find all internal links that are pointing to post/page?

I have deleted a page and now I want to find all internal links that are pointing to this deleted page. So I need to know which posts/pages have a link to the deleted page. Is there a faster way to do this than just manually checking all your pages and posts? Please advise me.


Orderby comment_count ignored if multiple orderby values

I'm trying to order my archive page by comment_count then title.               add_action( 'pre_get_posts', 'my_change_sort_order');     function my_change_sort_order($query)     {         if (is_archive()) {            $query->set( 'orderby', 'comment_count title' );         }     }      However, comment_count is ignored and I just get my posts in descending order of title. It works fine if I just order by comment_count alone:               add_action( 'pre_get_posts', 'my_change_sort_order');     function my_change_sort_order($query)     {         if (is_archive()) {            $query->set( 'orderby', 'comment_count' );         }     }      Any ideas what I'm doing wrong? Or have I found a bug?


Cforms II conditional processing

I have a form with 2 email fields. When the form is submitted I need to check whether the emails entered in the form already exist in the database, if any one of the emails entered on the form exist I need to stop the form processing and send an error message back to the user. I am using `my_custom_filter` function inside my-functions.php but don't know how to stop further processing of the form Having read the code, I see a variable called `$all_valid` being used to check if the validation of the form fields passed. Can that variable be used inside `my_custom_filter` method?               function my_cforms_filter($POSTdata) {         ### triggers on your 2nd form         if ( isset($POSTdata['sendbutton2']) ) {             //query to check if the emails entered in the form already exist in the database             /* if emails_exist                    //may be set $all_valid to false so that further processing doesn't happen                else                    return $POSTdata;         }         /* return $POSTdata; */     }      Help is appreciated, thanks.


Custom Menu not functioning properly

I register 2 menus in my functions.php file:               register_nav_menus(array(         'main_menu' => 'Main Menu',         'bottom_menu' => 'Bottom Menu'     ));      I populate a menu in the admin and assign the theme location: ![Assigning menu location](http://i.stack.imgur.com/4bloQ.jpg) I call the menu in my theme:               <?php         wp_nav_menu('menu', 'main_menu');     ?>      After doing all this, `bottom_menu` is the menu showing up in my theme instead. Can anyone tell me what I'm doing wrong? Either I'm missing something really silly here or Wordpress is giving me the finger.


Recent posts widget

I use the normal 'recent posts' widget on a website. But it is also including my custom post type, I don't want this. I only want to show the posts from the real posts post type. I think it has something to do with my cpt code, just don't know what part. Does anyone know how to exclude my cpt from the recent posts widget ? **EDIT:** I did adjust my functions.php a few days ago so that my CPT would be shown also on archives.php, could this has something to do with it ? I do want to keep my CPT in archives


How to get current post id of a custom post type in a loop using template singel-{custom type}.php?

I have a custom post type template where am looping through all post. what i am trying is when i go to my custom post page i want to get the current post id in the loop. So i tried to check if the permalink is same for the post inside the loop if it is same i'll get the post id of the current post in the loop. Here is the code i tried First trying to get the permalink in outside to check it inside the loop               $permalink = get_permalink();      Now i got the current post permalink now i want to get the current post id               if($query->have_posts()) : while ($query->have_posts()) : $query->the_post();          if(the_permalink()==$permalink)                            {                              echo get_the_ID();                            }else                             {                              echo "not found";                               }                  endwhile;                       wp_reset_postdata();                   endif;      I tried this things in `single-{custom-post-name}.php` am getting `not found`. can anyone give me a way to get the current post id in this template?


Comments - Ensure the correct field is highlighted for nested replies

I've got my comments working great, well.... Just about Great!!!! I'm a passionate UX guy doing my blog. I've got the comments form to beautifully reposition its self under neath a comment so that it does nested comments. But I have one annoyance! When someone hits the reply button the comment field is highlighted / focussed. From a user's point of view this is wrong as it should be the first field that should be highlighted or none at all! Do you guys have any thoughts on how one could fix it so that when a user does reply that the comment field isn't the one that gets highlighted?   * Solution 1 would be just show the form - Don't highlight / focus on any fields   * Solution 2 would be highlight the first field in the form Would love to know your thoughts, on how I can achieve either.


How can I show my post under a certain content name?

I want to know how can I show my detail post under that post name. When I post something under a category it shows up with the description of that post in the category, there is no problem with it, when I posted my second post it shows up also with the description of my second post but I have to scroll down to my page to see the posts i made because both of the post shows up with their descriptions. I want to know how can I hyperlink my post name so that visitors can see my posts name sequentially as hyper-linked and my all descriptions and post content which is under the post name will appear after clicking my post name. **As example:** Suppose I made three post which titled are "A", "B" and "C", in my page I want to show only the title sequentially as "A", "B" and "C" and after clicking on any of the title name it will show its description. I hope you will understand what I am trying to say.


Custom Field select list is truncated

The site I'm working on has many custom fields being used in it's pages. For some reason though, the list of custom fields that you can pick from the dropdown only displays the first 30 field names. If I want to use an existing custom field that isn't, alphabetically, in the first 30, I have to manually type it in each time. Any idea why?


add_post_meta Adds post meta but the value is blank

My plugin uses a metabox to save post meta. I have three option in the metabox. Everything is saving/updating/deleting correctly except for this:               add_post_meta( $post_id, $meta_key_duration, $new_meta_value_duration, true );      If I echo out the values right before this call:               echo $post_id.' '.$meta_key_duration.' '.$new_meta_value_duration;      I get:               52 expDuration 10      this is correct since I chose "10" as the value to be saved. The database is showing the post_id and meta_id correctly but the value isn't being saved.


Saving Plugin settings to the database

1. I'm not a complete novice with php or wordpress but am wanting to approach this problem the most efficient way so believe asking here will help.   2. I've got a plugin that randomly generates a quote - I've got to the point where I need to save the quote to the mysql DB.   3. I want to know the best way to save the data whether its using the settings api or simply saving it to an array.    4. I'm also wanting to implement the option of deleting a quote.   5. Using the input text field, I want to know how I can add new quotes in the textbox and pass the data to the array holding the quotes. My code far (The quotes are stored in an array at the moment)               <?php          /*idea to develop further would be, add a text box that the user can input the quote in     this then gets added to the DB and passed to the $quotes array. From here the results get     output the same way*/     /*     Plugin Name: Random Quotes     Plugin URI: xxx      Description: This Plugin randomly generates Quotes input by the user.     Version: 0.0.1     Author: xxx     Author URI: xxx     License: GPL2     */          add_action('admin_menu', 'dw_quotes_create_menu');          function dw_quotes_create_menu() {         //create custom top-level menu         add_menu_page('Quotes Settings', 'Quotes Styling', 'manage_options', __FILE__, 'dw_styling_quotes_settings');     }          function dw_styling_quotes_settings() { ?>
             <?php screen_icon( 'plugins' ); ?>
Quotes Page

                 Input Quotes in the textbox	                     <input type="textarea" name="random_quote" value="" />

     <?php }           // add quotes to this list     $quotes = array(                 "one" => "The weak can never forgive. Forgiveness is the attribute of the strong",                 "two" => "Be strong when you are weak, Be brave when you are scared, Be humble when you are victorious",                 "three" => "Our success is achieved by uniting our strength, not by gathering our weaknesses",                 "four" => "One of the most common causes of failure is the habit of of quitting when one is overtaken by temporary defeat",                 "five" => "The struggles make you stronger and the changes make you wise! Happiness has its own way of taking its sweet time"                 );          // uses array_rand to randomly pick a quote     $rand_quotes = array_rand( $quotes);          // pass's the result of $array_rand to $result_quotes     $result_quote = $quotes[$rand_quotes];          // outputs the result     //echo $result_quote;          ?>


Check if custom thumnail size image has been cropped to the correct dimensions

I'm looking for a way to check if an image has properly created a custom thumbnail size that has been hard cropped.               add_image_size( 'homepage-thumb', 1676, 828, true );          $size = "homepage-thumb";      echo wp_get_attachment_image( $attachment_id, $size );      This works well if the uploaded image is large enough but if it's smaller than the dimensions defined in add_image_size the aspect will be out which invariably breaks a layout. Is there a way to check the thumbnail before echoing the image?


Pagination with custom query (not using posts)

I've been looking at this problem for a few weeks now, constantly running into the same problem. It's a bit of a complicated setup: I've got a **category** called "dossiers". I've also got a **custom taxonomy** "dossiers" which is used to group posts that are about the same news event or story. When someone creates a post, they can assign the post to certain dossier and then put it in the category for "dossiers". That way, all dossier- posts are filed under the same category while still having a way to separate stories from each other. I need the **category page** for the category "dossiers" to display all the **custom taxonomy terms** in the taxonomy "dossiers". These, in turn, link to their own listing of that particular dossier. I created the category- dossiers.php file which replaces the default category page, so that's not a problem anymore. Using other forum posts, particular this one, I have gotten the bulk of the problem figured out. The category-page shows all taxonomy terms, with links and everything, and can split them up into pages. (This is a bit hacky because WordPress normally doesn't use terms as the main content blocks, but posts). My only problem right now is to get the second, third, etc. page working. Beyond the first page it just displays the default index.php file of my theme. Here is the full template page. Can anyone figure out what's wrong with it? I've tried and tried but just can't seem to find the problem.               <?php get_header(); ?>          <?php get_sidebar (); ?>

<?php single_cat_title();?>
                      <?php                      if ( get_query_var( 'paged' ) ) {                     $paged = get_query_var('paged');                     }                 else if ( get_query_var( 'page' ) ) {                     $paged = get_query_var( 'page' );                     }                 else {                     $paged = 1;                     }                      $per_page    = 9;                 $number_of_terms = count( get_terms( "dossiers") );                 $offset      = $per_page * ( $paged - 1) ;                      // Setup the arguments to pass in                 $args = array(                     'order'     => 'ASC',                     'orderby'      => 'menu_order',                     'offset'    => $offset,                     'paged'    => $per_page                 );                      // Gather the terms                 $terms = get_terms("dossiers", $args);                      $count = count($terms);                 if ( $count > 0 ){                     echo "
";                     foreach ( $terms as $term ) {?>
                             <a href="<?php echo get_term_link( $term ); ?>">                                 <?                                     if ( get_field('banner', $term->taxonomy._.$term->term_id) ) { // check if the post has a Banner Image assigned to it.                                         $image = get_field('banner', $term->taxonomy._.$term->term_id);                                         echo '';                                     }                                     else {                                         echo '';                                     }                                 ?>
                                     <div class="caption" data-category="<?php $category = get_the_category(); echo $category[0]->slug; ?>"><?php echo $term->name; ?>

                      <?}                      echo "
";                  }             ?>
                        <?php                       if($terms) {                              $big = 999999999; // need an unlikely integer                         echo paginate_links( array(                             'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),                             'format'  => '/page/%#%',                             'current' => $paged,                             'total'   => ceil( $number_of_terms / $per_page ), // 9 items per page                             'type' => 'list',                             'mid_size' => 5                         ) );                      }     ?>                   <?php get_footer(); ?>


How to change the menu like this?

Here is my `wp_nav_menu`:               wp_nav_menu( array(                 'link_before' => '',                 'link_after'  => ''             ) );      I got `a` tag like this:               LINK      But I actually need this:               LINKTITLE      Is it possible to write a filter?


Hook for post permalink update

I would like to know what hook should I used when the permalink/url of a post is modified. My goal is to get the old permalink and new permalink so I can used it for my plugin. Thanks. [EDIT] Just want to clarify the question. I would like to get the old and new url in a scenario for example, when a user select one its post in the admin area, and edit the current permalink/url(/helloworld) into a new permalink/url(/helloworld_new) of the selected post. I would like to get the complete url the post being edited.


How to find the number of Tags a post has?

Is is possible to find how how many tags (and categories) a post has and to display it? something like this: when a post has three Tags and two categories, at the end of the post show that number inside brackets, like so: TAGS (3) | CATEGORIES (2) I would like to have it so, because i would like that the tag/category list is hidden until the user clicks or hovers it. Right now i am making the Tags into an unordered list like this:               the_tags('

','

','

');      thanks!


Hiding taxonomies with no children WP_Query & tax_query

I have this code which has taken over 7 hours to put together through research but the last hours or so I have hit a brick wall! I require the taxonomy title to be hidden if there are no posts associated with it. Here is the page: http://cb.dannycheeseman.me/wine-menu/usa/california/ Here is my code:               /**********************************************/     //  CUSTOM WINE MENU SHORTCODE     /**********************************************/               add_shortcode( 'wine_list_per_cat', 'wine_list_per_cat' );          function wine_list_per_cat($atts){              global $woocommerce_loop;              extract(shortcode_atts(array(             'cat' => '',    // list of categories in the format 0,1,2,3,4             'tax' => 'product_cat', // taxonomy use             'per_cat' => '3',   // max featured items to display per category             'columns' => '3',   // columns size         ), $atts));     ?>
              <?php                    $wine_type_terms = get_terms( 'wine-type' );                  foreach ( $wine_type_terms as $wine_type_term ) {                      $args = array(                     'post_type' => 'product',                     'showposts' => -1,                     'tax_query' => array(                         'relation' => 'IN',                         array(                             'taxonomy' => 'wine-type',                                 'field' => 'slug',                                 'terms' => array( $wine_type_term->slug ),                             ),                             array(                                 'taxonomy' => 'product_cat',                                 'field' => 'slug',                                 'terms' => $cat                             )                         ));                      $wine_type_query = new WP_Query($args);?>

<?php echo $wine_type_term->name; ?>

                     <?php  while ( $wine_type_query->have_posts() ) : $wine_type_query->the_post();global $product ?>

<?php the_title(); ?>
                             Size: <?php echo get_post_meta( get_the_ID(),'wine_bottle_size', true );?>
                             Percentage: <?php echo get_post_meta( get_the_ID(), 'wine_percentage', true );?>
                             Year: <?php echo get_post_meta( get_the_ID(), 'wine_year', true );?>
                             Price: <?php echo $product->get_price_html(); ?>

<?php echo get_post_meta( get_the_ID(), 'wine_menu_content', true );?>
                             <?php woocommerce_template_loop_add_to_cart( $wine_type_query->post, $product ); ?>
                               <?php endwhile;?>                     <?php wp_reset_postdata(); ?>

                            <?php } ?>                  <?php wp_reset_query(); ?>
     <?php }       **UPDATE! OK!!! Woooohooo! Found out what it was.. I should have been calling if have posts before the call for $tax->name; Here is my final, and working code! :)**               /**********************************************/     //  CUSTOM WINE MENU SHORTCODE     /**********************************************/               add_shortcode( 'wine_list_per_cat', 'wine_list_per_cat' );          function wine_list_per_cat($atts){              global $woocommerce_loop;              extract(shortcode_atts(array(             'cat' => '',    // list of categories in the format 0,1,2,3,4             'tax' => 'product_cat', // taxonomy use             'per_cat' => '3',   // max featured items to display per category             'columns' => '3',   // columns size         ), $atts));     ?>
              <?php                    $taxonomy = get_terms( 'wine-type', array('hide_empty' => true, 'pad_counts' => true));                  foreach ( $taxonomy as $tax ) {                      $args = array(                     'post_type' => 'product',                     'orderby' => 'title',                     'showposts' => -1,                     'tax_query' => array(                         'relation' => 'AND',                         array(                             'taxonomy' => 'product_cat',                             'field' => 'slug',                             'terms' => $cat,                             'operator' => 'IN'                         ),                         array(                             'taxonomy' => 'wine-type',                             'field' => 'slug',                             'terms' => array( $tax->slug ),                             'operator' => 'IN'                         ),                          ));                      $wine_type_query = null;                      $wine_type_query = new WP_Query($args);                      if( $wine_type_query->have_posts() ) : ?>

<?php echo $tax->name; ?>

                             <?php while ( $wine_type_query->have_posts() ) : $wine_type_query->the_post();global $product ?>

<?php the_title(); ?>
                                 Size: <?php echo get_post_meta( get_the_ID(),'wine_bottle_size', true );?>
                                 Percentage: <?php echo get_post_meta( get_the_ID(), 'wine_percentage', true );?>
                                 Year: <?php echo get_post_meta( get_the_ID(), 'wine_year', true );?>
                                 Price: <?php echo $product->get_price_html(); ?>

<?php echo get_post_meta( get_the_ID(), 'wine_menu_content', true );?>
                                 <?php woocommerce_template_loop_add_to_cart( $wine_type_query->post, $product ); ?>
                             <?php endwhile;?>

                  <?php endif; wp_reset_query(); ?>              <?php } ?>
     <?php }


Allow multiple selection of user roles

By deafult we are only allowed to select one roles per user. Due to my website requirement, I have to enable multiple selection of user roles. I have searched but cannot find any answers on this. I also have tried plugins for creating custom fields but no luck at all. Does anyone ever tried this or have any plugin suggestion or code.


Get a list of posts by specific category

I'm trying to build a search query in PHP in WordPress and I need to get all posts by a specific author in a specific category including drafts. For example, is it possible to do something like, "status=draft and author=12 and category=7"? Also, I haven't been able to find the page that shows how to build WordPress query. Note: I'm using the JSON-API plug-in and using it's get_search_results method. It's not clear if it's a full WP_Query like search since "cat=1" and "author=1" does not return results but "demo" and other common keywords return posts.


Change get_post_thumb responsively?

How can I responsively change the get_post_thumb when reaching a certain breakpoint with PHP code? I use the following code to print my posts thumb at the moment:               <?php      echo '
';      the_post_thumbnail('featured-cat',array('title' => ''));      echo '
';     ?>      Which are specified in my `functions.php` file:               add_image_size( 'featured-cat', 248, 110, true ); //featured-cat      What I then want to do is to instead use the following code when reaching 320px in screen size. I want to use               add_image_size( '**featured-cat-mobile**', 200, 80, true ); //featured-cat mobile


Exclude Categories from wp_list_categories()

in before: I already searched for this answer her but couldn't find a thing that worked for me. I have a Lot of Categories and Child Categories. I use them to give a Location, Country, Type of Employment, etc to different posts and to later sort them in my sidebar. My code looks like this.                       $country_filter = array(                         "show_count" => 0, // no count behind each Category                         "hide_empty" => 1, // no empty categories                         "exclude" => "24", // THE ONE to exclude                         "child_of" => 55, // category ID                         "title_li" => "");  // leaves the title empty so we can use the headline above                  wp_list_categories($country_filter);      The Thing is: Every post has a Category 55 (it's the Country Category) but can also have 24 - which is a category that should never show up on search, sidebar, etc. this one is only displayed on a specific page. My question is: How can I remove posts in category 24 from the list? The above snippet doesn't work. Thanks!


Wp set post terms not work

My code is not working, it does not add the taxonomy               add_action('init', 'post_test', 10);     function post_test() {         $empty = get_page_by_title('Produto teste', OBJECT, 'produtos');         if(empty($empty)) {             $insert_post = array(                 'post_status' => 'publish',                 'post_type' => 'produtos',                 'post_title' => 'Produto teste',             );             $post_id = wp_insert_post($insert_post);             if ($post_id) {                 wp_set_post_terms($post_id, array('metais'), 'categoria-produtos'); // tag metais id is 108             }             add_post_meta($post_id, 'fornecedores', '5948'); // id do fornecedor             add_post_meta($post_id, '_fornecedores', 'field_52377232eb265');         }     }      why not work?


Remove settings if theme is deleted?

Is it possible to perform an action only if the theme is deleted (not deactivated) from the theme directory ? For example, I want to remove the theme settings from database after the theme is removed. So I want to run this when the theme is deleted:               delete_option( 'mysettings' );


how to remove the default title of Categories widget

hi i'm using the Categories widget show hierarchy. I leave the space for title because I don't need to show any title. but it then displays on the website as "Categories". how can I remove that?


How to enable/disable a hook with theme options

I am trying to use this function to add maintenance mode feature by adding this in my theme's functions.php and I am trying to use my theme options to enable/disable it. I realized when i check/uncheck this via theme options page, it doesnt work. My guess is, once the action is added, it cannot be disabled. I tried to add elseif condition with remove_action for the same hook, but that didn't work either..                       function mytheme_under_construction(){                      // if user is logged in, don't show the construction page                 if ( is_user_logged_in() ) {                     return;                 }                 $protocol = $_SERVER["SERVER_PROTOCOL"];                 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )                     $protocol = 'HTTP/1.0';                 // 503 is recommended :  http://bit.ly/YdGkXl                 header( "$protocol 503 Service Unavailable", true, 503 );                 // or header( "$protocol 200 Ok", true, 200 );                 header( 'Content-Type: text/html; charset=utf-8' );                 // adjust the Retry-After value (in seconds)                 header( 'Retry-After: 3600' );                  ?>             <?php get_template_part('maintanance'); ?>             <?php                      die();                   }          global $mytheme;     if(!empty($mytheme['offline_id'])){     add_action( 'template_redirect', 'amytheme_under_construction' );     }      The onyl way it works is when I direclty add/remove the ! from this line:               if(!empty($mytheme['offline_id'])){      Can anyone help me with the issue? Thanks


Metabox nonce not allowing update

I'm having a problem correcting saving metabox data on a custom post type. I thought I fixed it by applying the advice on this post: Metabox nonce PHP notice which does get rid of the warning but leaves me unable to update the metaboxes. Here is the code in question :               function save_goal_info_meta( $post_id ) {         global $goal_info_meta_fields;              // verify nonce         if ( ! isset( $_POST['product_noncename'] ) || ! wp_verify_nonce( $_POST['goal_info_meta_box_nonce'], basename( __file__ ) ) ) {             return $post_id;         }              // check autosave         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {             return $post_id;         }              // check permissions         if ( 'page' == $_POST['post_type'] ) {             if ( ! current_user_can( 'edit_page', $post_id ) )                 return $post_id;         } elseif ( ! current_user_can( 'edit_post', $post_id ) ) {             return $post_id;         }              // loop through fields and save the data         foreach ( $goal_info_meta_fields as $field ) {             if ( $field['type'] == 'tax_select' )                 continue;                  $old = get_post_meta( $post_id, $field['id'], true );             $new = $_POST[$field['id']];                  if ( isset( $new ) && ! empty( $new ) && ( $new != $old ) ) {                 update_post_meta( $post_id, $field['id'], $new );             } elseif ( '' == $new && $old ) {                 delete_post_meta( $post_id, $field['id'], $old );             }         }     }          add_action( 'save_post', 'save_goal_info_meta' );      I understand more or less why it isn't updating but I can't seem to fix it without having an "Undefined Index".               $goal_info_meta_fields = array(             array(         'label' => 'Home Goals by:',         'desc' => 'Add and select home scorers',         'id' => $prefix.'home-scorers',         'type' => 'home_player_list'        ),        array(         'label' => 'Away Goals by:',         'desc' => 'Add and select away scorers',         'id' => $prefix.'away-scorers',         'type' => 'away_player_list'        )     );      Here is the output :               function show_goal_info_meta_box($field, $meta, $items = null) {         global $goal_info_meta_fields, $post;     // Use nonce for verification          echo '<input type="hidden" name="goal_info_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';          // Begin the field table and loop     echo '
';     foreach ($goal_info_meta_fields as $field) {         // get value of this field if it exists for this post         $meta = get_post_meta($post->ID, $field['id'], true);         // begin a table row with         echo '
                 '.$field['label'].'	                 ';         switch($field['type']) {                       // home_player_list         case 'home_player_list':             echo '+ '.$field['desc'].'
';             $post_id = get_the_ID();             $team_id = get_post_meta( $post_id, 'report_home-select');                  $items = get_users( array (                     'meta_key' => 'team-meta',                     'meta_value' => $team_id                 ));             $i = 0;                  if ($meta) {                 foreach($meta as $row) {                          echo '
|||';                     echo '<select name="'.$field['id'].'['.$i.']" style="width:200px;" id="report_home-scorers">                     <option value="">Select One</option>'; // Select One                     foreach($items as $item) {                         echo '<option value="'.$item->ID.'"',$row == $item->ID ? ' selected="selected"' : '','>'.$item->display_name.'</option>';                     }                     echo '</select>-
';                          $i++;                 }             } else {                 echo '
|||';                 echo '<select name="report_home-scorers[0]" style="width:200px;" id="'.$field['id'].'">                 <option value="NULL">Select One</option>'; // Select One                      foreach ($items as $item) {                     echo '<option value="" selected="selected">'.$item->display_name.'</option>';                 }                      echo '</select>-
';                  }             echo '
';             break;                  // away_player_list         case 'away_player_list':             echo '+ '.$field['desc'].'
';             $postid = get_the_ID();             $team_id = get_post_meta( $postid, 'report_away-select');                  $items = get_users( array (                     'meta_key' => 'team-meta',                     'meta_value' => $team_id                 ));                       $i = 0;             if ($meta) {                 foreach($meta as $row) {                     echo '
|||';                     echo '<select name="'.$field['id'].'['.$i.']" class="chzn-select" style="width:200px;" id="'.$field['id'].'" value="'.$row.'">                     <option value="">Select One</option>'; // Select One                     foreach($items as $item) {                         echo '<option value="'.$item->ID.'"',$row == $item->ID ? ' selected="selected"' : '','>'.$item->display_name.'</option>';                     }                     echo '</select>-
';                          $i++;                 }             } else {                 echo '
|||';                 echo '<select name="'.$field['id'].'['.$i.']" class="chzn-select" style="width:200px;" id="'.$field['id'].'">                 <option value="">Select One</option>'; // Select One                      foreach ($items as $item) {                     echo '<option value="" selected="selected">'.$item->display_name.'</option>';                 }                      echo '</select>-
';                  }             echo '
';             break;              } //end switch         echo '
';     } // end foreach     echo '
'; // end table     }


different image size in home

I have the home page in two columns and images of 312×100. The problem is that, when you go the category page, you see the list of posts but the images appear with sizes like the home, with 312×100. I need the images in home with 312×100 and in category with 980×200. This is how I have configured each column in the home:               <div class="left">          <?php if ( have_posts() ) : ?>          <?php while ( have_posts() ) : the_post(); ?>          <?php get_template_part( 'content', get_post_format() );?>          <?php endwhile; ?>          <?php endif; ?>          </div>      I don´t find anything to solve my problem, I put your code but the image is doubled.


Using Advanced Custom Fields with Associative Arrays

So, I've got this conversion chart I'm working with, and have stored its values in a simple array, wherein it lists both UK and US sizes:                $conversion = array(         "2.5" => "1",         "2.75" => "2",         "3.25" => "3",         "3.5" => "4",         "3.75" => "5",         "4" => "6"     );      I'm using Advanced Custom Fields on my WordPress site and am successfully retrieving the UK size via a Select Field. Now that's exactly what I want, except I also want to retrieve its US value from the `$conversion` array, so both values are displayed. I'm using a Repeater field with two child Select Fields (`min` and `max`) and a True/False Field (`to`). My code currently looks something like this:               <?php if( have_rows('repeater') ): ?>     <?php while( have_rows('repeater') ): the_row();          $min = get_sub_field('min');     $max = get_sub_field('max');          foreach($conversion as $uk => $us) {         if( get_sub_field('to') == true ) { // if ticked             if( $min == $uk ) {                 echo $uk . ' ' . $us;             }         }              else {             if( $min == $uk ) {                 echo $uk . ' ' . $us;             }         }     }          ?>     <?php endwhile; ?>     <?php endif; ?>      Now I need a way when checking my True/False Field for the page to echo both the UK values (`$min` and `$max`) and the US values (`$min` and `$max`). Right now it's only echoing the `$min` value for the UK and the US. I'd appreciate any help on how to achieve this. Thanks in advance!